/*
 * Web-only map menu layout.
 * This file is copied into web/dist by scripts/sync-from-common.mjs.
 */

.action-bar.map-mode {
  min-height: clamp(208px, 28dvh, 260px);
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(52px, 1fr));
  grid-auto-rows: 0;
  gap: 10px;
  align-content: stretch;
}

.action-bar.map-mode #homeBtn {
  grid-column: 1;
  grid-row: 1;
}

.action-bar.map-mode #deckConfigBtn {
  grid-column: 2;
  grid-row: 1;
}

.action-bar.map-mode #bagBtn {
  grid-column: 3;
  grid-row: 1;
}

.action-bar.map-mode #questBtn {
  grid-column: 1;
  grid-row: 2;
}

.action-bar.map-mode #saveBtn {
  grid-column: 3;
  grid-row: 2;
}

.action-bar.map-mode #potionBtn {
  grid-column: 1;
  grid-row: 3;
}

.action-bar.map-mode #desertPotionBtn {
  grid-column: 3;
  grid-row: 3;
}

.action-bar.map-mode .secondary {
  height: auto;
  min-height: 64px;
  padding: 10px 14px;
  display: grid;
  place-items: center;
  overflow: visible;
  font-size: 18px;
  line-height: 1.15;
  text-align: center;
}

.action-bar.map-mode .potion-action {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr auto;
  justify-content: center;
  place-items: center;
  gap: 0;
  padding: 6px 8px;
}

.action-bar.map-mode .potion-action-icon {
  width: 54px;
  height: 54px;
}

.action-bar.map-mode .potion-action-count {
  top: 8px;
  left: auto;
  right: 10px;
  min-width: 24px;
  height: 24px;
  font-size: 14px;
}

.action-bar.map-mode .potion-action-size {
  right: 12px;
  bottom: 8px;
  min-width: 24px;
  height: 22px;
  font-size: 13px;
}

.action-bar.map-mode .potion-action-label {
  position: static;
  width: auto;
  height: auto;
  min-width: 0;
  clip: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
}

/*
 * Web-only battle potion buttons.
 * Common owns potion behavior; this only hides the heal amount badge in battle.
 */

.action-bar.battle-mode .potion-action-size {
  display: none;
}

/*
 * Web-only battle command layout.
 * Move potion and End Turn above the card hand while keeping Home/Save/Flee
 * separated below the cards. iOS keeps the common action bar layout.
 */

.game-shell.battle-shell,
.game-shell:has(#battleScreen:not(.hidden)) {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: auto minmax(324px, 1fr) auto 62px 235px 58px;
  row-gap: 6px;
}

.game-shell.battle-shell .top-bar,
.game-shell.battle-shell .arena,
.game-shell.battle-shell .mid-panel,
.game-shell.battle-shell .hand-wrap,
.game-shell:has(#battleScreen:not(.hidden)) .top-bar,
.game-shell:has(#battleScreen:not(.hidden)) .arena,
.game-shell:has(#battleScreen:not(.hidden)) .mid-panel,
.game-shell:has(#battleScreen:not(.hidden)) .hand-wrap {
  grid-column: 1 / -1;
}

.game-shell.battle-shell .action-bar.battle-mode,
.game-shell:has(#battleScreen:not(.hidden)) .action-bar.battle-mode {
  display: contents;
}

.game-shell.battle-shell .action-bar.battle-mode #potionBtn,
.game-shell.battle-shell .action-bar.battle-mode #desertPotionBtn,
.game-shell.battle-shell .action-bar.battle-mode #endTurnBtn,
.game-shell.battle-shell .action-bar.battle-mode #homeBtn,
.game-shell.battle-shell .action-bar.battle-mode #saveBtn,
.game-shell.battle-shell .action-bar.battle-mode #fleeBtn,
.game-shell:has(#battleScreen:not(.hidden)) .action-bar.battle-mode #potionBtn,
.game-shell:has(#battleScreen:not(.hidden)) .action-bar.battle-mode #desertPotionBtn,
.game-shell:has(#battleScreen:not(.hidden)) .action-bar.battle-mode #endTurnBtn,
.game-shell:has(#battleScreen:not(.hidden)) .action-bar.battle-mode #homeBtn,
.game-shell:has(#battleScreen:not(.hidden)) .action-bar.battle-mode #saveBtn,
.game-shell:has(#battleScreen:not(.hidden)) .action-bar.battle-mode #fleeBtn {
  width: 100%;
  min-width: 0;
  height: 100%;
  min-height: 0;
  align-self: stretch;
  justify-self: stretch;
  border-radius: 8px;
}

.game-shell.battle-shell .action-bar.battle-mode #potionBtn,
.game-shell:has(#battleScreen:not(.hidden)) .action-bar.battle-mode #potionBtn {
  grid-row: 4;
  grid-column: 1 / 2;
}

.game-shell.battle-shell .action-bar.battle-mode #desertPotionBtn,
.game-shell:has(#battleScreen:not(.hidden)) .action-bar.battle-mode #desertPotionBtn {
  grid-row: 4;
  grid-column: 2 / 3;
}

.game-shell.battle-shell .action-bar.battle-mode #endTurnBtn,
.game-shell:has(#battleScreen:not(.hidden)) .action-bar.battle-mode #endTurnBtn {
  grid-row: 4;
  grid-column: 4 / 7;
}

.game-shell.battle-shell .hand-wrap,
.game-shell:has(#battleScreen:not(.hidden)) .hand-wrap {
  grid-row: 5;
}

.game-shell.battle-shell .action-bar.battle-mode #homeBtn,
.game-shell:has(#battleScreen:not(.hidden)) .action-bar.battle-mode #homeBtn {
  grid-row: 6;
  grid-column: 1 / 3;
}

.game-shell.battle-shell .action-bar.battle-mode #saveBtn,
.game-shell:has(#battleScreen:not(.hidden)) .action-bar.battle-mode #saveBtn {
  grid-row: 6;
  grid-column: 3 / 5;
}

.game-shell.battle-shell .action-bar.battle-mode #fleeBtn,
.game-shell:has(#battleScreen:not(.hidden)) .action-bar.battle-mode #fleeBtn {
  grid-row: 6;
  grid-column: 5 / 7;
}

@media (max-width: 430px) {
  .game-shell {
    height: min(var(--app-height, 100dvh), 100svh);
    min-height: 0;
    overflow: hidden;
  }

  .action-bar.map-mode {
    min-height: clamp(208px, 28dvh, 246px);
    padding: 8px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: repeat(3, minmax(48px, 1fr));
    grid-auto-rows: 0;
    gap: 8px;
  }

  .action-bar.map-mode .secondary {
    height: auto;
    min-height: 58px;
    padding: 8px 10px;
    font-size: 15px;
  }

  .action-bar.map-mode .potion-action {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 6px 8px;
  }

  .action-bar.map-mode .potion-action-icon {
    width: 48px;
    height: 48px;
  }

  .action-bar.map-mode .potion-action-count {
    top: 6px;
    left: auto;
    right: 8px;
    min-width: 22px;
    height: 22px;
    font-size: 13px;
  }

  .action-bar.map-mode .potion-action-size {
    right: 8px;
    bottom: 6px;
  }

  .action-bar.map-mode .potion-action-label {
    font-size: 13px;
  }

  .game-shell.battle-shell,
  .game-shell:has(#battleScreen:not(.hidden)) {
    height: min(var(--app-height, 100dvh), 100svh);
    min-height: 0;
    grid-template-rows: auto minmax(184px, 1fr) 44px 44px minmax(142px, 0.78fr) 48px;
    row-gap: 3px;
    padding-bottom: max(4px, env(safe-area-inset-bottom));
  }

  .game-shell.battle-shell .action-bar.battle-mode #potionBtn,
  .game-shell.battle-shell .action-bar.battle-mode #desertPotionBtn,
  .game-shell.battle-shell .action-bar.battle-mode #endTurnBtn,
  .game-shell.battle-shell .action-bar.battle-mode #homeBtn,
  .game-shell.battle-shell .action-bar.battle-mode #saveBtn,
  .game-shell.battle-shell .action-bar.battle-mode #fleeBtn,
  .game-shell:has(#battleScreen:not(.hidden)) .action-bar.battle-mode #potionBtn,
  .game-shell:has(#battleScreen:not(.hidden)) .action-bar.battle-mode #desertPotionBtn,
  .game-shell:has(#battleScreen:not(.hidden)) .action-bar.battle-mode #endTurnBtn,
  .game-shell:has(#battleScreen:not(.hidden)) .action-bar.battle-mode #homeBtn,
  .game-shell:has(#battleScreen:not(.hidden)) .action-bar.battle-mode #saveBtn,
  .game-shell:has(#battleScreen:not(.hidden)) .action-bar.battle-mode #fleeBtn {
    border-radius: 8px;
    padding: 4px;
    font-size: 11px;
    line-height: 1.1;
  }

  .game-shell.battle-shell .action-bar.battle-mode #potionBtn,
  .game-shell:has(#battleScreen:not(.hidden)) .action-bar.battle-mode #potionBtn {
    grid-column: 1 / 2;
  }

  .game-shell.battle-shell .action-bar.battle-mode #desertPotionBtn,
  .game-shell:has(#battleScreen:not(.hidden)) .action-bar.battle-mode #desertPotionBtn {
    grid-column: 2 / 3;
  }

  .game-shell.battle-shell .action-bar.battle-mode #endTurnBtn,
  .game-shell:has(#battleScreen:not(.hidden)) .action-bar.battle-mode #endTurnBtn {
    grid-column: 3 / 7;
  }

  .game-shell.battle-shell .arena,
  .game-shell.battle-shell .hand-wrap,
  .game-shell.battle-shell .hand,
  .game-shell:has(#battleScreen:not(.hidden)) .arena,
  .game-shell:has(#battleScreen:not(.hidden)) .hand-wrap,
  .game-shell:has(#battleScreen:not(.hidden)) .hand {
    height: 100%;
    min-height: 0;
  }

  .game-shell.battle-shell .hand,
  .game-shell:has(#battleScreen:not(.hidden)) .hand {
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }

  .game-shell.battle-shell .hand > .card,
  .game-shell.battle-shell .hand-slot,
  .game-shell:has(#battleScreen:not(.hidden)) .hand > .card,
  .game-shell:has(#battleScreen:not(.hidden)) .hand-slot {
    height: 100%;
    min-height: 0;
    max-height: none;
  }
}

@media (max-width: 430px) and (max-height: 760px) {
  .game-shell.battle-shell,
  .game-shell:has(#battleScreen:not(.hidden)) {
    grid-template-rows: auto minmax(164px, 0.95fr) 40px 40px minmax(124px, 0.7fr) 44px;
    row-gap: 2px;
  }

  .game-shell.battle-shell .action-bar.battle-mode #potionBtn,
  .game-shell.battle-shell .action-bar.battle-mode #desertPotionBtn,
  .game-shell.battle-shell .action-bar.battle-mode #endTurnBtn,
  .game-shell.battle-shell .action-bar.battle-mode #homeBtn,
  .game-shell.battle-shell .action-bar.battle-mode #saveBtn,
  .game-shell.battle-shell .action-bar.battle-mode #fleeBtn,
  .game-shell:has(#battleScreen:not(.hidden)) .action-bar.battle-mode #potionBtn,
  .game-shell:has(#battleScreen:not(.hidden)) .action-bar.battle-mode #desertPotionBtn,
  .game-shell:has(#battleScreen:not(.hidden)) .action-bar.battle-mode #endTurnBtn,
  .game-shell:has(#battleScreen:not(.hidden)) .action-bar.battle-mode #homeBtn,
  .game-shell:has(#battleScreen:not(.hidden)) .action-bar.battle-mode #saveBtn,
  .game-shell:has(#battleScreen:not(.hidden)) .action-bar.battle-mode #fleeBtn {
    font-size: 10px;
  }
}

/*
 * Web-only map NPC labels.
 * Common owns NPC placement and click behavior; this only prevents long browser labels
 * from sitting on top of character art.
 */

.korean-traveler,
.kpop-girl-group,
.cv25-store,
.manchu-gatekeeper,
.manchu-shaman,
.skilled-person {
  overflow: visible;
}

.korean-traveler > strong,
.kpop-girl-group > strong,
.cv25-store > strong,
.manchu-gatekeeper > strong,
.manchu-shaman > strong,
.skilled-person > strong {
  position: absolute;
  left: 50%;
  bottom: -18px;
  z-index: 2;
  width: max-content;
  max-width: 220px;
  transform: translateX(-50%);
  text-align: center;
  white-space: nowrap;
}

/*
 * Web-only encounter popup polish.
 * Common owns the encounter behavior; this file only changes the browser visual layer.
 */

.overlay.is-encounter {
  place-items: center;
  padding: max(22px, env(safe-area-inset-top)) 18px max(22px, env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, rgba(6, 9, 15, 0.62), rgba(6, 8, 12, 0.88)),
    rgba(4, 6, 10, 0.78);
}

.overlay.is-encounter .reward-panel {
  width: min(92vw, 480px);
  max-height: min(78svh, 620px);
  padding: 22px;
  gap: 14px;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid rgba(244, 204, 103, 0.58);
  background:
    linear-gradient(180deg, rgba(63, 47, 35, 0.98), rgba(22, 25, 34, 0.98) 54%, rgba(14, 17, 24, 0.99)),
    #202532;
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.54),
    0 0 0 1px rgba(255, 255, 255, 0.07) inset,
    0 12px 28px rgba(214, 121, 42, 0.14);
}

.overlay.is-encounter .reward-panel::before {
  height: 5px;
  background: linear-gradient(90deg, #f7d267 0%, #ee8b39 52%, #f7d267 100%);
  box-shadow: 0 0 18px rgba(247, 210, 103, 0.34);
}

.overlay.is-encounter .overline {
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(247, 210, 103, 0.16);
  border: 1px solid rgba(247, 210, 103, 0.34);
  color: #ffdf78;
  font-size: 12px;
}

.overlay.is-encounter h2 {
  margin: 0;
  color: #fff5d0;
  font-size: 26px;
  line-height: 1.18;
}

.overlay.is-encounter .overlay-body {
  padding: 14px 16px;
  border-radius: 8px;
  background: rgba(5, 7, 11, 0.34);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #eadfc9;
  font-size: 16px;
  line-height: 1.45;
}

.overlay.is-encounter .encounter-actions {
  width: 100%;
  gap: 10px;
}

.overlay.is-encounter #skipRewardBtn,
.overlay.is-encounter .encounter-actions button {
  min-height: 50px;
  border-radius: 10px;
  font-size: 16px;
  line-height: 1.15;
  box-shadow:
    0 10px 20px rgba(0, 0, 0, 0.25),
    0 1px 0 rgba(255, 255, 255, 0.14) inset;
}

.overlay.is-encounter #skipRewardBtn {
  background: linear-gradient(180deg, #f8cf61, #dd8b32);
  border-color: rgba(255, 235, 169, 0.44);
  color: #21150f;
}

.overlay.is-encounter #skipRewardBtn:hover {
  filter: brightness(1.05);
}

.overlay.is-encounter .encounter-actions button {
  background: linear-gradient(180deg, rgba(47, 54, 70, 0.96), rgba(33, 38, 51, 0.96));
  border-color: rgba(255, 255, 255, 0.18);
  color: #f1e7d2;
}

.overlay.is-encounter .encounter-actions button:hover {
  border-color: rgba(247, 210, 103, 0.36);
  background: linear-gradient(180deg, rgba(58, 65, 82, 0.98), rgba(39, 45, 60, 0.98));
}

@media (min-width: 560px) {
  .overlay.is-encounter .reward-panel {
    grid-template-columns: 1fr 1fr;
  }

  .overlay.is-encounter .overline,
  .overlay.is-encounter h2,
  .overlay.is-encounter .overlay-body {
    grid-column: 1 / -1;
  }

  .overlay.is-encounter .encounter-actions,
  .overlay.is-encounter #skipRewardBtn {
    order: 4;
  }

  .overlay.is-encounter .encounter-actions {
    grid-column: 1;
  }

  .overlay.is-encounter #skipRewardBtn {
    grid-column: 2;
  }
}

@media (max-width: 430px) {
  .overlay.is-encounter {
    place-items: center;
    padding: max(18px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
  }

  .overlay.is-encounter .reward-panel {
    width: min(92vw, 360px);
    padding: 18px;
    gap: 11px;
    border-radius: 12px;
  }

  .overlay.is-encounter h2 {
    font-size: 21px;
  }

  .overlay.is-encounter .overlay-body {
    padding: 12px 13px;
    font-size: 14px;
  }

  .overlay.is-encounter #skipRewardBtn,
  .overlay.is-encounter .encounter-actions button {
    min-height: 46px;
    border-radius: 9px;
    font-size: 15px;
  }
}

@media (max-width: 430px) {
  .game-shell:has(#mapScreen:not(.hidden)) {
    width: 100%;
    max-width: 520px;
    min-width: 0;
    overflow: hidden;
  }

  .game-shell:has(#mapScreen:not(.hidden)) .top-bar,
  .game-shell:has(#mapScreen:not(.hidden)) .map-screen,
  .game-shell:has(#mapScreen:not(.hidden)) .action-bar.map-mode {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .game-shell:has(#mapScreen:not(.hidden)) .top-bar {
    grid-template-columns: minmax(62px, 76px) minmax(0, 1fr);
  }

  .game-shell:has(#mapScreen:not(.hidden)) .brand,
  .game-shell:has(#mapScreen:not(.hidden)) .top-actions,
  .game-shell:has(#mapScreen:not(.hidden)) .top-settings,
  .game-shell:has(#mapScreen:not(.hidden)) .stat-row,
  .game-shell:has(#mapScreen:not(.hidden)) .stat,
  .game-shell:has(#mapScreen:not(.hidden)) .action-bar.map-mode > * {
    min-width: 0;
  }

  .game-shell:has(#mapScreen:not(.hidden)) .stat-row {
    width: 100%;
  }

  .game-shell:has(#mapScreen:not(.hidden)) .action-bar.map-mode {
    margin-left: 0;
    margin-right: 0;
  }

  .game-shell:has(#mapScreen:not(.hidden)) .action-bar.map-mode .secondary,
  .game-shell:has(#mapScreen:not(.hidden)) .action-bar.map-mode .potion-action {
    max-width: 100%;
    overflow: hidden;
  }
}

@media (max-width: 430px) {
  .game-shell:has(#mapScreen:not(.hidden)) .top-bar {
    grid-template-columns: minmax(58px, 72px) minmax(92px, 124px) minmax(58px, 1fr) max-content;
    align-items: stretch;
    gap: 5px;
  }

  .game-shell:has(#mapScreen:not(.hidden)) .top-actions {
    display: contents;
  }

  .game-shell:has(#mapScreen:not(.hidden)) .top-settings {
    grid-column: 4;
    width: 95px;
    justify-content: end;
  }

  .game-shell:has(#mapScreen:not(.hidden)) .stat-row {
    display: contents;
  }

  .game-shell:has(#mapScreen:not(.hidden)) .stat.hp {
    grid-column: 2;
    width: 100%;
    max-width: 124px;
  }

  .game-shell:has(#mapScreen:not(.hidden)) .stat.gold {
    grid-column: 3;
    width: 100%;
  }

  .game-shell:has(#mapScreen:not(.hidden)) .stat.deck {
    display: none;
  }
}

@media (max-width: 380px) {
  .game-shell:has(#mapScreen:not(.hidden)) .top-bar {
    grid-template-columns: minmax(54px, 64px) minmax(82px, 108px) minmax(48px, 1fr) max-content;
    gap: 4px;
  }

  .game-shell:has(#mapScreen:not(.hidden)) .top-settings {
    width: 87px;
  }

  .game-shell:has(#mapScreen:not(.hidden)) .stat.hp {
    max-width: 108px;
  }
}
