:root {
  --bg: #0d0a09;
  --panel: #2b2523;
  --panel-dark: #1f1a19;
  --card: #2f2927;
  --card-hi: #3d3532;
  --line: #9a8f86;
  --line-dim: #4e4540;
  --text: #f4ede1;
  --text-dim: #a2968d;
  --cost: #ff7b47;
  --cost-poor: #8f5a48;
  --accent: #ff9a3c;
  --accent-dark: #b85f1c;
  --gold: #ffd25a;
  --splinter: #f2b766;
  --ui-unit: 1;
  --panel-w: 340px;
}

/* Notch / cutout insets. Browsers and iOS report them through env(); the Android app (Capacitor, system bars
   hidden) reports them as --safe-area-inset-*. Use whichever is larger. */
:root {
  --safe-top: max(env(safe-area-inset-top, 0px), var(--safe-area-inset-top, 0px), var(--ait-safe-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--safe-area-inset-bottom, 0px), var(--ait-safe-bottom, 0px));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Galmuri11, 'Courier New', monospace;
  font-size: 12px;
  overflow: hidden;
  -webkit-font-smoothing: none;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; cursor: pointer; }
img { image-rendering: pixelated; }
.hidden { display: none !important; }

/* Apps in Toss permits only Toss login, ads and payments. Hide unavailable surfaces instead of showing dead CTAs. */
body.platform-toss [data-tab="social"],
body.platform-toss [data-page="social"],
body.platform-toss #promo-section {
  display: none !important;
}

/* The Toss game navigation capsule (... / close) overlays the WebView and is not included in SafeArea.get(). */
body.platform-toss { --ait-nav-clearance: 48px; }

/* Korean game-rating notice: Apps in Toss shows it for the legally required opening interval.
   It sits below the native navigation/safe area, so neither the mark nor the game HUD is covered. */
.age-rating { display: none; }
body.platform-toss.age-rating-visible .age-rating {
  position: fixed;
  z-index: 40;
  display: block;
  top: calc(var(--safe-top) + var(--ait-nav-clearance) + 8px);
  right: 8px;
  width: 64px;
  height: 64px;
  padding: 4px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}
body.platform-toss.age-rating-visible .age-rating img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ---------- Layout: the play area fills everything the panel does not ---------- */

#app {
  display: flex;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  touch-action: manipulation;
}

.stage {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

#game {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  image-rendering: pixelated;
  cursor: none;
  touch-action: none;
}

/* ---------- HUD (Keep on Mining style counters) ---------- */

.hud {
  position: absolute;
  left: 12px;
  top: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  pointer-events: none;
  z-index: 2;
}
.hud-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 14px 4px 6px;
  border-radius: 8px;
  background: rgba(18, 12, 10, 0.72);
  border: 2px solid rgba(154, 143, 134, 0.35);
  line-height: 1;
  transform-origin: 20% 50%;
}
.hud-bar span {
  text-shadow: 2px 2px 0 #120c0a, -1px -1px 0 #120c0a, 1px -1px 0 #120c0a, -1px 1px 0 #120c0a;
}
.hud-bar.coin { font-size: 36px; color: var(--gold); min-width: 180px; }
.hud-bar.coin img { width: 36px; height: 36px; filter: drop-shadow(2px 2px 0 #120c0a); }
.hud-bar.spl { font-size: 24px; color: var(--splinter); }
.hud-bar.spl img { width: 24px; height: 24px; filter: drop-shadow(2px 2px 0 #120c0a); }
.hud-bar.bump { animation: bump 0.12s ease-out; }
/* Visitor counter: online now · today · all time. Quiet, so it never competes with the coins. */
.hud-visitors {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(18, 12, 10, 0.6);
  color: #cfc3b8;
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
}
.hud-visitors i { width: 6px; height: 6px; border-radius: 50%; background: #6ee07a; box-shadow: 0 0 4px #6ee07a; }
@keyframes bump { 40% { transform: scale(1.1); } }

.hud-stage {
  position: absolute;
  right: 10px;
  top: 10px;
  width: 190px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(18, 12, 10, 0.72);
  border: 2px solid rgba(154, 143, 134, 0.35);
  pointer-events: none;
  z-index: 2;
}
.hud-stage-top { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.hud-stage-name { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.dispatch-dock {
  position: absolute;
  z-index: 7;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  align-items: stretch;
  gap: 8px;
}
.dispatch-btn {
  position: relative;
  min-width: 210px;
  min-height: 64px;
  padding: 7px 18px;
  display: grid;
  grid-template-columns: 34px 1fr;
  grid-template-rows: auto auto 7px;
  align-items: center;
  column-gap: 8px;
  border: 3px solid #fff0a6;
  border-radius: 12px;
  color: #2a1608;
  background: linear-gradient(180deg, #ffd56d 0%, #ff9a3c 62%, #cf6420 100%);
  box-shadow: inset 0 3px 0 rgba(255,255,255,0.55), inset 0 -5px 0 #a64a16, 0 5px 0 #24170f, 0 8px 18px rgba(0,0,0,0.45);
  text-shadow: 1px 1px 0 rgba(255,255,255,0.35);
  touch-action: manipulation;
}
.dispatch-btn:hover { filter: brightness(1.08); }
.dispatch-btn:active { transform: translateY(3px); box-shadow: inset 0 2px 0 rgba(255,255,255,0.4), inset 0 -3px 0 #a64a16, 0 2px 0 #24170f; }
.dispatch-btn.charging { border-color: #fff8ca; }
.dispatch-btn.tut-focus { position: relative; outline-color: var(--gold); outline-offset: 3px; }
.dispatch-icon { grid-row: 1 / 4; width: 30px; height: 30px; filter: drop-shadow(1px 2px 0 rgba(0,0,0,0.25)); }
.dispatch-label { font-size: 15px; font-weight: bold; white-space: nowrap; }
.dispatch-state { min-height: 12px; font-size: 10px; opacity: 0.72; }
.dispatch-charge { grid-column: 2; position: relative; height: 6px; overflow: hidden; border: 1px solid rgba(42,22,8,0.65); border-radius: 4px; background: rgba(42,22,8,0.28); box-shadow: inset 0 1px 1px rgba(0,0,0,0.25); }
.dispatch-btn.auto .dispatch-charge i { transition: none; }
.dispatch-charge i { display: block; width: 0; height: 100%; border-radius: 3px; background: linear-gradient(90deg, #fff3a1, #fffce5); box-shadow: 0 0 5px rgba(255,255,210,0.9); transition: width 0.11s ease-out; }

/* Gnome upgrade beside SEND: same chunky card look as the shop, with the price always in view. */
.gnome-upg {
  position: relative;
  min-width: 118px;
  padding: 6px 9px 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  border: 3px solid #4e4540;
  border-radius: 12px;
  color: #a2968d;
  background: #262120;
  box-shadow: 0 5px 0 #24170f, 0 8px 18px rgba(0,0,0,0.45);
  text-align: left;
  touch-action: manipulation;
}
.gnome-upg-title { font-size: 12px; font-weight: bold; white-space: nowrap; }
.gnome-upg-next { font-size: 10px; line-height: 1.25; white-space: nowrap; }
.gnome-upg-pips { display: flex; gap: 3px; }
.gnome-upg-pips i { width: 9px; height: 5px; border-radius: 2px; background: rgba(0,0,0,0.35); border: 1px solid currentColor; opacity: 0.8; }
.gnome-upg-pips i.on { background: currentColor; }
.gnome-upg-cost { position: absolute; right: 8px; bottom: 4px; display: flex; align-items: center; gap: 2px; font-size: 12px; line-height: 1; color: var(--cost-poor); }
.gnome-upg-cost img { width: 9px; height: 9px; opacity: 0.6; }
.gnome-upg.can {
  color: #2a1608;
  background: linear-gradient(180deg, #ffe48a 0%, #ffd25a 45%, #f0b23a 100%);
  border-color: #fff3c4 #c98a22 #8a5a12 #e8b54a;
  box-shadow: inset 0 2px 0 #fff6d0, inset 0 -4px 0 #c98a22, 0 5px 0 #24170f, 0 8px 18px rgba(0,0,0,0.45);
  cursor: pointer;
}
.gnome-upg.can:hover { filter: brightness(1.06); }
.gnome-upg.can:active { transform: translateY(3px); }
.gnome-upg.can .gnome-upg-cost { color: #7a2408; }
.gnome-upg.can .gnome-upg-cost img { opacity: 1; filter: brightness(0.45); }
.gnome-upg.max .gnome-upg-cost { display: none; }
.gnome-upg.max { padding-bottom: 6px; }

/* ---------- Panel (PC: right sidebar) ---------- */

.panel {
  width: var(--panel-w);
  flex: 0 0 var(--panel-w);
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--panel);
  border-left: 3px solid #4e4540;
  box-shadow: inset 2px 0 0 #1a1514;
  transition: width 0.18s ease, flex-basis 0.18s ease, height 0.18s ease;
}

.panel-toggle {
  position: relative;
  min-height: 44px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 6px 9px;
  border: 2px solid var(--accent);
  border-radius: 7px;
  color: var(--accent);
  background: var(--panel-dark);
}
.panel-toggle img { width: 20px; height: 20px; }
.panel-toggle:hover { background: var(--card-hi); }
.panel-toggle.can { border-color: #9be26a; color: #dfffc8; box-shadow: 0 0 0 2px rgba(155,226,106,0.18); }
.panel-ready { position: absolute; right: -5px; top: -7px; min-width: 18px; height: 18px; line-height: 18px; border-radius: 9px; color: #15200d; background: #9be26a; font-style: normal; animation: blink 0.8s steps(2) infinite; }

body.pc .panel:not(.open) { width: 56px; flex-basis: 56px; padding: 6px; }
body.pc .panel:not(.open) > :not(.panel-toggle) { display: none; }
body.pc .panel:not(.open) .panel-toggle { width: 41px; height: 52px; padding: 4px; }
body.pc .panel:not(.open) .panel-toggle span { display: none; }

.stage-box {
  padding: 8px;
  border-radius: 6px;
  background: var(--panel-dark);
  border: 2px solid var(--line-dim);
}
.stage-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.stage-badge {
  min-width: 24px;
  padding: 3px 5px;
  text-align: center;
  background: var(--accent);
  color: #2a1608;
  border-radius: 3px;
  box-shadow: inset 0 -2px 0 var(--accent-dark);
  white-space: nowrap;
}
.stage-name { font-size: 12px; }
.bar {
  position: relative;
  height: 16px;
  border-radius: 3px;
  background: #1a1514;
  border: 2px solid var(--line-dim);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(180deg, #ffb45e 0%, var(--accent) 50%, #d9731f 100%);
  transition: width 0.15s;
}
.bar-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
  text-shadow: 1px 1px 0 #120c0a;
}

.tree-btn {
  position: relative;
  padding: 10px;
  border-radius: 6px;
  border: 2px solid var(--line);
  background: var(--panel-dark);
  letter-spacing: 1px;
  box-shadow: inset 0 -2px 0 #1a1514;
}
.tree-btn:hover { background: var(--card-hi); }
.side-btns { display: flex; gap: 6px; }
.side-btns .tree-btn { flex: 1; }
.tree-btn.can {
  background: linear-gradient(180deg, #ffe48a 0%, #ffd25a 45%, #f0b23a 100%);
  border-color: #fff3c4 #c98a22 #8a5a12 #e8b54a;
  box-shadow: inset 0 2px 0 #fff6d0, inset 0 -4px 0 #c98a22, 0 3px 0 #4a300c;
  color: #2a1608;
}
.badge {
  position: absolute;
  right: 8px;
  top: -8px;
  padding: 1px 4px;
  font-size: 12px;
  color: #2a1608;
  background: #9be26a;
  border-radius: 3px;
  animation: blink 0.8s steps(2) infinite;
}
@keyframes blink { 50% { transform: translateY(-2px); } }

.tabs { display: flex; gap: 6px; justify-content: center; }
.tab {
  position: relative;
  width: 44px;
  height: 38px;
  border-radius: 6px;
  border: 2px solid var(--line-dim);
  background: var(--panel-dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.tab span { display: none; }
.tab img { width: 18px; height: 18px; opacity: 0.6; }
.tab.active { border-color: var(--accent); background: var(--card-hi); }
.tab.active img { opacity: 1; }
.tab-tree { display: none; }
.dot { position: absolute; top: 4px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: #9be26a; }

.vol-row { display: grid; grid-template-columns: 5.5em 1fr 3em; align-items: center; gap: 8px; padding: 6px 8px; border: 2px solid var(--border, #4e4540); border-radius: 7px; background: var(--panel-dark); }
.vol-row input { width: 100%; accent-color: var(--gold); }
.vol-row b { font-weight: normal; text-align: right; color: var(--text-dim); }
.more-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 6px; }
.more-action {
  min-height: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 2px solid var(--line-dim);
  border-radius: 6px;
  background: var(--card);
}
.more-action:hover { border-color: var(--accent); background: var(--card-hi); }
.more-action img { width: 22px; height: 22px; image-rendering: pixelated; }

.tab-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: 6px;
  background: var(--panel-dark);
  border: 2px solid var(--line-dim);
  padding: 6px;
}
.page-title {
  position: relative;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  padding: 2px 0 6px;
  border-bottom: 2px solid var(--line-dim);
  margin-bottom: 6px;
  letter-spacing: 1px;
}
.buy-mode {
  display: none;
  position: absolute;
  right: 0;
  top: -3px;
  padding: 2px 8px;
  border-radius: 4px;
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--text);
}
.buy-mode.on { border-color: var(--accent); color: var(--accent); }
.hint { margin-top: 6px; text-align: center; color: var(--text-dim); font-size: 12px; }

.cards {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 2px;
}
.cards::-webkit-scrollbar { width: 6px; }
.cards::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 3px; }

.card {
  position: relative;
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 8px;
  align-items: center;
  min-height: 54px;
  padding: 6px 8px 6px 6px;
  border-radius: 6px;
  background: var(--card);
  border: 2px solid var(--line);
  cursor: pointer;
  box-shadow: inset 0 -2px 0 #1d1817;
}
.card:hover { background: var(--card-hi); }
.card:active { transform: translateY(1px); }
.card.bought { animation: pop 0.18s steps(3); }
@keyframes pop { 50% { transform: scale(1.03); } }
.card-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: #1d1817;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-icon img { width: 18px; height: 18px; }
.card-title { font-size: 12px; line-height: 1.3; word-break: keep-all; }
.card-sub { font-size: 12px; color: var(--text-dim); line-height: 1.3; }
.card-cost {
  position: absolute;
  right: 8px;
  bottom: 4px;
  display: flex;
  align-items: center;
  gap: 2px;
  color: var(--cost);
  font-size: 12px;
  line-height: 1;
}
.card-cost img { width: 9px; height: 9px; }
/* Affordable: chunky yellow button that pops out of the list. */
.card.can {
  background: linear-gradient(180deg, #ffe48a 0%, #ffd25a 45%, #f0b23a 100%);
  border-color: #fff3c4 #c98a22 #8a5a12 #e8b54a;
  box-shadow: inset 0 2px 0 #fff6d0, inset 0 -4px 0 #c98a22, 0 3px 0 #4a300c;
  color: #2a1608;
  transform: translateY(-1px);
}
.card.can:hover { background: linear-gradient(180deg, #fff0b0 0%, #ffdc70 45%, #f6bd48 100%); }
.card.can:active { transform: translateY(2px); box-shadow: inset 0 2px 0 #fff6d0, inset 0 -2px 0 #c98a22, 0 1px 0 #4a300c; }
.card.can .card-icon { background: #3a2210; border-color: #8a5a12; }
.card.can .card-sub { color: #6b4515; }
.card.can .card-cost { color: #7a2408; }
.card.can .card-cost img { filter: brightness(0.45); }

/* Not affordable yet: flat and muted. */
.card.poor { cursor: default; background: #262120; border-color: #4e4540; box-shadow: none; }
.card.poor .card-icon { opacity: 0.55; }
.card.poor .card-title { color: #a2968d; }
.card.poor .card-cost { color: var(--cost-poor); }
.card.poor .card-cost img { opacity: 0.5; }
.card.poor:hover { background: #262120; }
.card.max { cursor: default; opacity: 0.65; }
.card.max .card-cost { color: var(--text-dim); }
.card.max .card-cost img { display: none; }
.card-new {
  display: none;
  position: absolute;
  right: 6px;
  top: -7px;
  padding: 1px 4px;
  font-size: 12px;
  line-height: 1.2;
  color: #2a1608;
  background: #9be26a;
  border-radius: 3px;
}
.card.fresh .card-new { display: block; animation: blink 0.8s steps(2) infinite; }
.card.fresh { border-color: #9be26a; }

.stats { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.stat-row { display: flex; justify-content: space-between; font-size: 12px; padding: 2px 4px; }
.stat-row span:last-child { color: var(--accent); }
.stat-sep { height: 2px; background: var(--line-dim); margin: 4px 0; }

.settings { display: flex; flex-direction: column; gap: 8px; }
.wide-btn {
  padding: 10px;
  border-radius: 6px;
  border: 2px solid var(--line);
  background: var(--card);
  box-shadow: inset 0 -2px 0 #1d1817;
}
.wide-btn:hover { background: var(--card-hi); }
.wide-btn.danger { border-color: #b04a3c; color: #ff9c8a; }

/* ---------- Skill tree overlay ---------- */

.overlay {
  position: absolute;
  inset: 10px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  background: #050404;
  border: 3px solid var(--text);
  border-radius: 4px;
  line-height: 1.2;
  box-shadow: 0 0 0 3px #050404;
}
.overlay-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 2px solid #2a2523;
}
.overlay-title { font-size: 12px; letter-spacing: 2px; }
.overlay-currency { display: flex; align-items: center; gap: 4px; color: var(--splinter); font-size: 12px; }
.overlay-currency img { width: 18px; height: 18px; }
.overlay-count { color: var(--text-dim); font-size: 12px; }
.overlay-hint { color: #5e544e; font-size: 12px; margin-left: auto; }
.close-btn {
  width: 28px;
  height: 28px;
  border: 2px solid var(--text);
  background: transparent;
  font-size: 16px;
  line-height: 1;
}
.close-btn:hover { background: #222; }

.tree {
  position: relative;
  flex: 1;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  background:
    radial-gradient(circle, #1a1513 1px, transparent 1px) 0 0 / 16px 16px;
}
.tree:active { cursor: grabbing; }
.tree-board { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.tree-links { position: absolute; left: 0; top: 0; overflow: visible; }
.tree-links line { stroke: #3a3330; stroke-width: 2; }
.tree-links line.open { stroke: #8a7f76; }
.tree-links line.lit { stroke: var(--text); }
.tree-links line.hidden { display: none; }

.branch-label {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 1;
  padding: 1px 3px;
  color: #a2968d;
  background: #050404;
  border: 1px solid #3a3330;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
}

.node {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  padding: 0;
  border: 2px solid #8a7f76;
  background: #050404;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
}
.node.root { width: 52px; height: 52px; border-width: 3px; }
.node.unique { border-radius: 50%; }
.node img { width: 24px; height: 24px; pointer-events: none; }
.node.root img { width: 32px; height: 32px; }
.node-lvl {
  position: absolute;
  right: -9px;
  bottom: -9px;
  padding: 1px 2px;
  font-size: 12px;
  color: var(--text-dim);
  background: #050404;
  white-space: nowrap;
  line-height: 1;
  pointer-events: none;
}
.node[data-lvl-x="left"] .node-lvl { left: -9px; right: auto; }
.node[data-lvl-y="top"] .node-lvl { top: -9px; bottom: auto; }
.node-lvl:empty { display: none; }
.node:hover { background: #1d1817; }
.node.v-hidden { display: none; }
.node.v-hint { border-color: #2a2523; border-style: dashed; }
.node.v-stage { border-color: #4a3a5a; border-style: dashed; }
.node.v-owned { border-color: var(--accent); box-shadow: 0 0 0 2px #050404, 0 0 0 4px #5a2f10; }
.node.v-owned .node-lvl { color: var(--accent); }
.node.maxed { background: #2a1608; }
.node.affordable { border-color: var(--text); animation: glow 0.9s steps(2) infinite; }
.node.v-owned.affordable { border-color: #ffd28a; }
.node.bought { animation: pop 0.2s steps(3); }
@keyframes glow { 50% { box-shadow: 0 0 0 2px #050404, 0 0 0 4px #9be26a; } }

.tooltip {
  position: absolute;
  z-index: 5;
  width: 230px;
  padding: 8px 10px;
  background: #050404;
  border: 2px solid var(--text);
  pointer-events: none;
  font-size: 12px;
  line-height: 1.4;
}
.tip-head { display: flex; justify-content: space-between; margin-bottom: 4px; }
.tip-name { color: var(--text); }
.tip-lvl { color: var(--text-dim); }
.tip-desc { color: #d6ccbe; }
.tip-per { color: var(--text-dim); }
.tip-branch { color: #6d625c; margin-bottom: 4px; }
.tip-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; padding-top: 6px; border-top: 1px solid #2a2523; }
.tip-cost { display: flex; align-items: center; gap: 3px; color: var(--splinter); }
.tip-cost img { width: 9px; height: 9px; }
.tip-cost.poor { color: #8f5a48; }
.tip-act { color: #c88cff; }
.tip-max { color: var(--accent); }
.tip-lock { color: #8f5a48; }

/* ---------- Compact PC (short landscape screens, e.g. phones held sideways) ---------- */

body.compact { --panel-w: 270px; }
body.compact .hud-bar.coin { font-size: 24px; min-width: 120px; }
body.compact .hud-bar.coin img { width: 24px; height: 24px; }
body.compact .hud-bar.spl { font-size: 12px; }
body.compact .hud-bar.spl img { width: 12px; height: 12px; }
/* A phone browser leaves very little CSS height in landscape. Keep the permanent
   sidebar useful by moving stage progress back onto the playfield and reserving
   most of the column for the independently scrollable upgrade cards. */
body.pc.compact .panel { gap: 4px; padding: 5px; }
body.pc.compact .panel.open .panel-toggle { min-height: 32px; padding: 3px 7px; }
body.pc.compact .panel.open .panel-toggle img { width: 16px; height: 16px; }
body.pc.compact .stage-box { display: none; }
body.pc.compact.panel-open .hud-stage { display: block; }
body.compact .tree-btn { min-height: 32px; padding: 4px; }
body.pc.compact .tabs { gap: 4px; }
body.pc.compact .tab { width: 38px; height: 30px; }
body.pc.compact .tab img { width: 15px; height: 15px; }
body.pc.compact .tab-page { padding: 4px; }
body.pc.compact .page-title { margin-bottom: 4px; padding: 1px 0 4px; }
body.pc.compact .hint { display: none; }
body.compact .card { min-height: 44px; }

/* ---------- PC only ---------- */

body.pc .hud-stage { display: block; }
body.pc.panel-open .hud-stage { display: none; }

/* ---------- Mobile: play area on top, panel below with a bottom tab bar ---------- */

body.mobile #app { display: block; }
body.mobile .stage { width: 100%; height: 100%; }
body.mobile .panel {
  position: fixed;
  z-index: 9;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: calc(64px + var(--safe-bottom));
  flex: none;
  min-height: 0;
  padding: 5px 6px var(--safe-bottom);
  gap: 4px;
  border-left: 0;
  border-top: 3px solid #4e4540;
  box-shadow: inset 0 2px 0 #1a1514;
  overflow: hidden;
}
body.mobile .panel.open { height: min(62dvh, 560px); padding: 5px 6px calc(4px + var(--safe-bottom)); }
body.mobile .panel:not(.open) > :not(.panel-toggle) { display: none; }
body.mobile .panel-toggle { width: min(230px, 64vw); margin: 0 auto; min-height: 50px; }
.panel-close { display: none; }
body.mobile .panel.open .panel-close {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 7px;
  right: 8px;
  z-index: 2;
  width: 46px;
  height: 46px;
  padding: 0 0 3px;
  border: 2px solid #9a8f86;
  border-radius: 8px;
  color: var(--text);
  background: var(--panel-dark);
  font-size: 30px;
  line-height: 1;
}
body.mobile .panel.open .panel-close:active { transform: translateY(2px); }
body.mobile.panel-open .dispatch-dock { bottom: calc(min(62dvh, 560px) + 10px); }
body.mobile .dispatch-dock { bottom: calc(76px + var(--safe-bottom)); gap: 6px; max-width: calc(100vw - 16px); }
body.mobile .dispatch-btn { min-width: min(200px, 56vw); max-width: 60vw; min-height: 66px; padding: 7px 12px; }
body.mobile .dispatch-label { white-space: normal; word-break: keep-all; line-height: 1.1; }
body.mobile .gnome-upg { min-width: min(112px, 30vw); max-width: 36vw; padding: 5px 7px 18px; }
body.mobile .gnome-upg-next { white-space: normal; word-break: keep-all; }
body.mobile .stage-box,
body.mobile .tree-btn,
body.mobile .hint { display: none; }
body.mobile .tabs {
  order: 10;
  margin: 0 -6px;
  padding: 3px 3px calc(3px + var(--safe-bottom));
  gap: 0;
  background: var(--panel-dark);
  border-top: 2px solid var(--line-dim);
}
body.mobile .tab {
  flex: 1;
  width: auto;
  min-width: 0;
  height: 44px;
  border: 0;
  background: transparent;
  border-radius: 6px;
}
body.mobile .tab span { display: block; width: 100%; overflow: hidden; font-size: 10px; color: var(--text-dim); white-space: nowrap; text-overflow: ellipsis; }
body.mobile .tab img { width: 16px; height: 16px; }
body.mobile .tab.active { background: var(--card-hi); }
body.mobile .tab.active span { color: var(--accent); }
body.mobile .tab-tree { display: flex; }
body.mobile .tab-page { border: 0; padding: 0 0 4px; background: transparent; }
body.mobile .page-title { margin-bottom: 4px; padding-bottom: 4px; }
body.mobile .buy-mode { display: block; }
body.mobile .cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  align-content: start;
  gap: 4px;
}
body.mobile .card {
  grid-template-columns: 30px 1fr;
  column-gap: 6px;
  row-gap: 1px;
  min-height: 52px;
  padding: 4px 5px 4px 4px;
}
/* Phones: long (English) effect lines wrap, so the price takes its own row instead of floating over the text. */
body.mobile .card-icon { grid-row: 1 / span 2; align-self: center; }
body.mobile .card-title { font-size: 11px; line-height: 1.25; }
body.mobile .card-cost { position: static; grid-column: 2; justify-self: end; }
body.mobile .card-icon { width: 30px; height: 30px; }
body.mobile .card-icon img { width: 18px; height: 18px; }
body.mobile .card-sub .card-name { display: none; }
body.mobile .card:not(.can):hover { background: var(--card); }
body.mobile .more-grid { flex: 1; align-content: center; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: 2px; }
body.mobile .more-action { min-height: 58px; padding: 4px 2px; font-size: 10px; }
body.mobile .more-action img { width: 20px; height: 20px; }

body.mobile .hud { left: 8px; top: calc(8px + var(--safe-top)); gap: 4px; }
body.mobile .hud-bar { padding: 3px 10px 3px 4px; gap: 6px; }
body.mobile .hud-bar.coin { font-size: 24px; min-width: 110px; }
body.mobile .hud-bar.coin img { width: 24px; height: 24px; }
body.mobile .hud-bar.spl { font-size: 12px; }
body.mobile .hud-bar.spl img { width: 12px; height: 12px; }
body.mobile .hud-visitors { font-size: 10px; padding: 2px 6px; }
/* Grows for longer building names (English, Japanese) but stays clear of the coin counter on the left. */
body.mobile .hud-stage { width: min(210px, calc(100% - 150px)); min-width: 0; right: 8px; top: calc(8px + var(--safe-top)); padding: 4px 6px; }
body.platform-toss.mobile .hud-stage { top: calc(8px + var(--safe-top) + var(--ait-nav-clearance)); }
body.platform-toss.mobile.age-rating-visible .hud-stage { visibility: hidden; }
body.mobile .tutorial { max-width: calc(100vw - 24px); padding: 6px 8px 7px; }
body.mobile .tutorial-head { margin-bottom: 2px; }
body.mobile .tutorial-text { white-space: normal; overflow-wrap: anywhere; }

/* Skill tree takes the whole phone screen; details dock at the bottom with a buy button. */
body.mobile .overlay { position: fixed; inset: 0; z-index: 20; border-width: 0; border-radius: 0; box-shadow: none; }
body.mobile .overlay-head { flex-wrap: wrap; gap: 8px; padding: calc(8px + var(--safe-top)) 10px 8px; }
body.mobile .overlay-hint { display: none; }
body.mobile .overlay-count { order: 5; width: 100%; }
body.mobile #tree-center { margin-left: auto; }
body.mobile .close-btn { width: 36px; height: 36px; }
body.mobile .tooltip {
  left: 8px !important;
  right: 8px;
  top: auto !important;
  bottom: calc(8px + var(--safe-bottom));
  width: auto;
  pointer-events: auto;
  font-size: 12px;
}
/* Landscape phones are intentionally laid out like PC, but have no hover.
   Dock their selected-skill details so the explicit learn button stays reachable. */
@media (hover: none), (pointer: coarse) {
  body.pc .tooltip {
    left: 8px !important;
    right: 8px;
    top: auto !important;
    bottom: calc(8px + var(--safe-bottom));
    width: auto;
    max-height: 42dvh;
    overflow-y: auto;
    pointer-events: auto;
    font-size: 12px;
  }
}
/* ---------- World map ---------- */

.worldmap {
  position: absolute;
  inset: 10px;
  z-index: 12;
  display: flex;
  flex-direction: column;
  background: #050404;
  border: 3px solid var(--text);
  border-radius: 4px;
  line-height: 1.2;
  box-shadow: 0 0 0 3px #050404;
}
.worldmap .overlay-count { margin-left: 4px; }
.worldmap #map-close { margin-left: auto; }
.map-view { position: relative; flex: 1; min-height: 0; overflow: hidden; cursor: grab; touch-action: none; }
.map-view:active { cursor: grabbing; }
#map-canvas { position: absolute; left: 0; top: 0; image-rendering: pixelated; }
.map-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px calc(10px + var(--safe-bottom));
  border-top: 2px solid #2a2523;
  background: #120d0b;
}
.map-info { flex: 1; min-width: 0; }
.map-stage-title { font-size: 24px; color: var(--gold); text-shadow: 2px 2px 0 #120c0a; line-height: 1.1; }
.map-stage-region { color: var(--text); margin: 2px 0 4px; }
.map-stage-desc { color: var(--text-dim); white-space: pre-line; line-height: 1.4; }
/* Between buildings: what carries over, so nobody fears losing their progress. */
.map-keep { margin-top: 6px; padding: 4px 7px; border-left: 3px solid #9be26a; border-radius: 0 4px 4px 0; background: rgba(155, 226, 106, 0.1); color: #cdeeb6; line-height: 1.35; word-break: keep-all; }
.map-start {
  flex: 0 0 auto;
  min-width: 120px;
  padding: 12px 18px;
  font-size: 24px;
  border-radius: 8px;
  border: 3px solid #4e4540;
  background: #262120;
  color: #6d625c;
}
.map-start.ready, .map-start:not(:disabled):not(.ready) { color: #2a1608; }
.map-start:not(:disabled) {
  background: linear-gradient(180deg, #ffe48a 0%, #ffd25a 45%, #f0b23a 100%);
  border-color: #fff3c4 #c98a22 #8a5a12 #e8b54a;
  box-shadow: inset 0 2px 0 #fff6d0, inset 0 -5px 0 #c98a22, 0 4px 0 #4a300c;
}
.map-start:not(:disabled):active { transform: translateY(3px); box-shadow: inset 0 2px 0 #fff6d0, inset 0 -2px 0 #c98a22, 0 1px 0 #4a300c; }
.map-start.ready { animation: startpulse 0.8s ease-in-out infinite; }
@keyframes startpulse { 50% { transform: scale(1.06); filter: brightness(1.1); } }
body.mobile .worldmap { position: fixed; inset: 0; z-index: 20; border-width: 0; border-radius: 0; box-shadow: none; }
body.mobile .worldmap .overlay-head { padding-top: calc(8px + var(--safe-top)); }
body.mobile .map-start { min-width: 100px; font-size: 18px; }
/* The world map button, the floor picture of a town you left, and the region pager. */
.worldmap .map-world { margin-right: 8px; color: var(--text); border-color: #6ac8e2; }
.worldmap .map-world.new { animation: startpulse 0.8s ease-in-out infinite; }
.map-preview { flex: 0 0 auto; width: 104px; max-height: 84px; object-fit: contain; image-rendering: pixelated; border: 2px solid #4e4540; background: #050404; }
.map-region { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 4px; background: rgba(13, 9, 7, 0.8); color: var(--text); white-space: nowrap; }
.map-region button { min-width: 44px; min-height: 36px; }
.map-region button:disabled { opacity: 0.35; }
body.mobile .worldmap .overlay-head { flex-wrap: wrap; row-gap: 4px; }
body.mobile .map-preview { width: 72px; }
body.mobile .tab-map { display: flex; }
.tab-map { display: none; }
body.mobile .side-btns { display: none; }

/* ---------- Two trees, automation toggles, relocation ---------- */

.tree-tabs { display: flex; gap: 4px; }
.tree-tabs button {
  padding: 4px 10px;
  border: 2px solid #4e4540;
  border-radius: 4px;
  background: transparent;
  color: var(--text-dim);
}
.tree-tabs button.active { border-color: var(--text); color: var(--text); background: #1d1817; }
.tree-tabs button[data-tree="license"].active { border-color: #9be26a; color: #9be26a; }
.tree-tabs:not(.hidden) + .tree-title { display: none; }
.overlay-currency.lic { color: #9be26a; }
.head-toggle {
  padding: 4px 10px;
  border-radius: 4px;
  border: 2px solid #4e4540;
  background: #1d1817;
  color: var(--text-dim);
  white-space: nowrap;
}
.head-toggle.on { border-color: #9be26a; color: #9be26a; }
.head-toggle.relocate { border-color: #4e4540; }
.head-toggle.relocate.can, .worldmap .head-toggle.relocate {
  color: #2a1608;
  border-color: #fff3c4 #c98a22 #8a5a12 #e8b54a;
  background: linear-gradient(180deg, #ffe48a 0%, #ffd25a 45%, #f0b23a 100%);
  box-shadow: inset 0 -3px 0 #c98a22;
}
.worldmap .head-toggle.relocate { margin-left: auto; }
.worldmap .head-toggle.relocate:not(.hidden) ~ #map-close { margin-left: 8px; }
.auto-up {
  position: absolute;
  left: 0;
  top: -3px;
  padding: 2px 8px;
  border-radius: 4px;
  border: 2px solid #4e4540;
  background: var(--card);
  color: var(--text-dim);
}
.auto-up.on { border-color: #9be26a; color: #9be26a; }
.node.lic { border-color: #5a7a4a; }
.node.lic.v-owned { border-color: #9be26a; box-shadow: 0 0 0 2px #050404, 0 0 0 4px #2f5a26; }
.node.lic.v-owned .node-lvl { color: #9be26a; }
.node.lic.maxed { background: #13240e; }
.tip-cost.license { color: #9be26a; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(5, 4, 4, 0.75);
}
.modal-box {
  width: 100%;
  max-width: 420px;
  padding: 16px;
  background: #120d0b;
  border: 3px solid var(--gold);
  border-radius: 8px;
  box-shadow: 0 6px 0 #4a300c, 0 12px 30px rgba(0, 0, 0, 0.6);
}
.modal-title { font-size: 24px; color: var(--gold); margin-bottom: 10px; text-shadow: 2px 2px 0 #120c0a; }
.modal-body { line-height: 1.5; }
.rl-gain { display: flex; align-items: center; gap: 8px; font-size: 24px; color: #9be26a; margin-bottom: 6px; }
.rl-gain img { width: 36px; height: 36px; }
.rl-row { margin: 3px 0; }
.rl-row b { color: var(--gold); font-weight: normal; }
.rl-row.dim { color: var(--text-dim); }
.rl-sep { height: 2px; background: #2a2523; margin: 8px 0; }
.modal-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.modal-btns .map-start { min-width: 0; font-size: 18px; padding: 10px 18px; }

/* ---------- 광장 (online) ---------- */

input { font: inherit; color: var(--text); user-select: text; -webkit-user-select: text; }
.social { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.soc-card { padding: 8px; border-radius: 6px; background: var(--card); border: 2px solid #4e4540; }
.soc-card:empty { display: none; }
.soc-title { display: flex; align-items: center; gap: 6px; color: var(--gold); margin-bottom: 4px; }
.soc-name { color: var(--text); }
.soc-tag { padding: 1px 5px; border-radius: 3px; background: #1d1817; color: var(--text-dim); font-size: 12px; }
.soc-tag.ok { background: #1f3315; color: #9be26a; }
.soc-dim { color: var(--text-dim); line-height: 1.45; margin: 4px 0; }
.soc-dim.small, .small { font-size: 12px; }
.soc-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.yb, .gb { padding: 6px 10px; border-radius: 4px; border: 2px solid #4e4540; background: #1d1817; color: var(--text); }
.yb {
  color: #2a1608;
  border-color: #fff3c4 #c98a22 #8a5a12 #e8b54a;
  background: linear-gradient(180deg, #ffe48a 0%, #ffd25a 45%, #f0b23a 100%);
  box-shadow: inset 0 -3px 0 #c98a22;
}
.gb:hover { background: var(--card-hi); }
.cm-big { font-size: 18px; margin: 2px 0 6px; }
.cm-big b { color: var(--gold); font-weight: normal; font-size: 24px; }
.cm-bar { margin: 4px 0; }
.cm-bar.thin { height: 14px; }
.bar-fill.alt { background: linear-gradient(180deg, #b8f08a 0%, #9be26a 50%, #5aa83a 100%); }
.gb-list { list-style: none; margin: 4px 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.gb-list li { display: flex; align-items: center; gap: 6px; line-height: 1.3; }
.gb-list b { color: var(--text); font-weight: normal; }
.gb-list i { margin-left: auto; font-style: normal; color: var(--text-dim); font-size: 12px; white-space: nowrap; }
.gb-nail { width: 6px; height: 6px; flex: 0 0 6px; background: #d5dade; box-shadow: 0 0 0 1px #24170f, 1px 1px 0 1px #6f767e; }
.soc-visit { display: flex; gap: 6px; margin-top: 8px; }
.soc-visit input, .auth-box input:not([type="checkbox"]) {
  flex: 1;
  min-width: 0;
  padding: 7px 8px;
  border-radius: 4px;
  border: 2px solid #4e4540;
  background: #0d0a09;
}
.soc-visit input:focus, .auth-box input:focus { outline: none; border-color: var(--gold); }

.auth-box form { display: flex; flex-direction: column; gap: 8px; }
.auth-box label { display: flex; flex-direction: column; gap: 3px; color: var(--text-dim); }
.auth-box label.check { flex-direction: row; align-items: center; gap: 6px; }
.auth-err { color: #ff8a7a; margin: 4px 0; }
.auth-info { color: #9be26a; margin: 4px 0; }
.auth-warn { color: #ffb45e; margin: 4px 0; }
.auth-links { text-align: center; margin: 10px 0 0; }
.auth-links a { color: var(--gold); }
.save-picks { display: flex; gap: 8px; margin-top: 8px; }
.save-pick {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px;
  text-align: left;
  border-radius: 6px;
  border: 2px solid #4e4540;
  background: var(--card);
  line-height: 1.3;
}
.save-pick b { color: var(--gold); font-weight: normal; font-size: 18px; }
.save-pick:hover { border-color: var(--gold); }
.save-pick.rec { border-color: var(--gold); }
.save-pick em { font-style: normal; color: var(--gold); margin-top: 2px; }
.backup-list { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow-y: auto; }
.backup-list li { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; }
.backup-list li .gb { grid-row: span 2; }
.visit-box { max-width: 460px; max-height: 90vh; overflow-y: auto; }
.visit-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 6px 0; }
.visit-stats div { display: flex; flex-direction: column; align-items: center; padding: 6px 2px; border-radius: 4px; background: var(--card); }
.visit-stats b { color: var(--gold); font-weight: normal; font-size: 18px; white-space: nowrap; }
.visit-stats span { color: var(--text-dim); font-size: 12px; text-align: center; }
.stamps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.stamp { padding: 8px 4px; border-radius: 4px; border: 2px solid #8a5a12; background: #2a1d10; color: var(--gold); }
.stamp:hover { background: #3a2814; }
.stamp:active { transform: translateY(2px); }

/* ---------- Tutorial ---------- */

.tutorial {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 15;
  max-width: min(360px, calc(100vw - 24px));
  padding: 5px 9px 6px;
  background: rgba(26, 18, 16, 0.9);
  border: 2px solid var(--gold);
  border-radius: 6px;
  box-shadow: 0 4px 0 #4a300c, 0 8px 18px rgba(0, 0, 0, 0.5);
  line-height: 1.25;
  white-space: pre-line;
}
.tutorial-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.tutorial-step { color: var(--gold); }
.tutorial-skip { border: 0; background: transparent; color: var(--text-dim); padding: 2px 0 2px 8px; text-decoration: underline; }
.tutorial-text { color: var(--text); word-break: keep-all; overflow-wrap: anywhere; }
.tutorial-arrow {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 15;
  width: 45px;
  height: 55px;
  pointer-events: none;
  object-fit: fill;
  image-rendering: pixelated;
  transform: rotate(180deg);
  filter: drop-shadow(0 4px 0 #4a300c);
  animation: tutorial-arrow-down 0.65s ease-in-out infinite alternate;
}
.tutorial-arrow.up {
  transform: none;
  animation-name: tutorial-arrow-up;
}
@keyframes tutorial-arrow-down {
  from { transform: translateY(0) rotate(180deg); }
  to { transform: translateY(8px) rotate(180deg); }
}
@keyframes tutorial-arrow-up {
  from { transform: translateY(0); }
  to { transform: translateY(-8px); }
}
@media (prefers-reduced-motion: reduce) {
  .tutorial-arrow { animation: none; }
}
.tut-focus { position: relative; z-index: 3; outline: 3px solid var(--gold); outline-offset: 2px; }

.tip-buy {
  padding: 8px 18px;
  border-radius: 4px;
  border: 2px solid #9be26a;
  background: #1f3315;
  color: #9be26a;
}
.tip-buy:disabled { border-color: #4e4540; background: transparent; color: #6d625c; }

/* ---------- Mobile shop and optional reward screens ---------- */

.settings { flex: 1; min-height: 0; overflow-y: auto; padding: 2px 2px 12px; }
.settings-group-title {
  margin: 7px 2px 0;
  padding-bottom: 5px;
  border-bottom: 2px solid #4e4540;
  color: var(--gold);
  letter-spacing: 1px;
}
.policy-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 10px; color: var(--text-dim); font-size: 11px; }
.policy-links a, .policy-btn { color: var(--text-dim); text-decoration: underline; text-underline-offset: 2px; }
.policy-btn { flex-basis: 100%; padding: 0; border: 0; background: none; font: inherit; cursor: pointer; }
.policy-links a:hover, .policy-links a:focus-visible, .policy-btn:hover, .policy-btn:focus-visible { color: var(--text); }

/* Cross promotion (js/promo.js): our other games, from EagleGaze */
.promo-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.promo-card {
  display: block;
  overflow: hidden;
  color: var(--text);
  text-decoration: none;
  border: 2px solid var(--line-dim);
  border-radius: 6px;
  background: var(--card);
  box-shadow: inset 0 -2px 0 #1d1817;
}
.promo-card:hover, .promo-card:focus-visible { background: var(--card-hi); border-color: var(--line); }
.promo-banner { display: block; width: 100%; aspect-ratio: 2 / 1; object-fit: cover; background: var(--panel-dark); }
.promo-row { display: flex; align-items: center; gap: 8px; padding: 7px; }
.promo-icon { width: 44px; height: 44px; flex: none; border-radius: 8px; object-fit: cover; background: var(--panel-dark); }
.promo-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.promo-copy strong { font-weight: normal; color: var(--gold); overflow-wrap: anywhere; }
.promo-copy small { color: var(--text-dim); font-size: 11px; overflow-wrap: anywhere; }
.promo-new { font-style: normal; font-size: 10px; padding: 0 4px; border-radius: 3px; background: #c4321f; color: #fff; vertical-align: 1px; }
.promo-go {
  flex: none;
  padding: 6px 8px;
  border: 2px solid #9be26a;
  border-radius: 5px;
  background: #1f3315;
  color: #9be26a;
  white-space: nowrap;
}
.promo-popup .promo-card { margin-top: 4px; }
.promo-desc { margin: 10px 0 0; line-height: 1.5; color: var(--text-dim); white-space: pre-line; }
.lang-picks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.lang-pick {
  padding: 8px 6px;
  border-radius: 6px;
  border: 2px solid var(--line);
  background: var(--card);
  box-shadow: inset 0 -2px 0 #1d1817;
}
.lang-pick:hover { background: var(--card-hi); }
.lang-pick.on { border-color: var(--gold); color: var(--gold); background: #3a2814; }
.settings-feature {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 66px;
  padding: 8px;
  text-align: left;
  border: 2px solid #a8761f;
  border-radius: 6px;
  background: #3a2814;
  box-shadow: inset 0 2px 0 #5a3d1a, inset 0 -3px 0 #20140c;
}
.settings-feature.secondary { border-color: #5b6449; background: #293020; box-shadow: inset 0 -3px 0 #171c13; }
.settings-feature:hover, .settings-feature:focus-visible { filter: brightness(1.18); }
.settings-feature-icon { flex: 0 0 42px; height: 42px; display: grid; place-items: center; border: 2px solid #bb8429; background: #20150c; border-radius: 5px; }
.settings-feature.secondary .settings-feature-icon { border-color: #6d8257; background: #172011; }
.settings-feature-icon img { width: 25px; height: 25px; }
.settings-feature-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.settings-feature-copy strong { color: var(--gold); font-weight: normal; font-size: 14px; }
.settings-feature.secondary strong { color: #bde999; }
.settings-feature-copy small { color: #d6c2a5; font-size: 11px; line-height: 1.4; }
.settings-feature-arrow { color: var(--gold); font-size: 25px; line-height: 1; }
.settings-feature.secondary .settings-feature-arrow { color: #bde999; }

.bm-modal { z-index: 40; padding: 12px; }
.bm-window {
  width: min(100%, 620px);
  max-height: min(90vh, 760px);
  max-height: min(90dvh, 760px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 3px solid #ffdc87;
  border-radius: 9px;
  background: #120d0b;
  box-shadow: 0 0 0 4px #090706, 0 8px 0 #754616, 0 20px 45px #050404b8;
}
.bm-topline {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 4px 7px 4px 14px;
  border-bottom: 3px solid #5a3a1c;
  background: #2d1e14;
  color: #f2bd71;
  font-size: 11px;
  letter-spacing: 1px;
}
.bm-top-mark { padding: 4px 5px; border: 1px solid #d39a4f; color: var(--gold); letter-spacing: 2px; }
.bm-close { margin-left: auto; width: 31px; height: 31px; border: 2px solid #8b6a48; border-radius: 4px; background: #1b130e; color: #f4ede1; font-size: 21px; line-height: 1; }
.bm-close:hover, .bm-close:focus-visible { border-color: var(--gold); background: #3b2819; }
.bm-content { overflow-y: auto; padding: 17px 19px 22px; scrollbar-color: #8a5a2d #1b130e; }
.bm-title { margin: 0 0 13px; color: var(--gold); font-size: 24px; font-weight: normal; line-height: 1.25; text-shadow: 2px 2px 0 #4c2b12; }
.bm-back { display: block; margin: 0 0 10px; padding: 2px 0; border: 0; background: transparent; color: #c8aa86; font-size: 12px; }
.bm-back:hover, .bm-back:focus-visible { color: var(--gold); text-decoration: underline; }
.bm-hero {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 148px;
  gap: 10px;
  overflow: hidden;
  padding: 18px 20px;
  border: 3px solid #8a5a22;
  border-radius: 5px;
  background: radial-gradient(circle at 83% 35%, #704320, #392417 42%, #241810 75%);
  box-shadow: inset 0 2px 0 #b47c35, inset 0 -4px 0 #1a110c;
}
.bm-hero::after { content: ''; position: absolute; inset: 8px; border: 1px dashed #96662f; pointer-events: none; }
.bm-hero > div:first-child { position: relative; z-index: 1; }
.bm-eyebrow { display: inline-block; padding: 2px 6px; margin-bottom: 7px; background: #1b130d; color: #e7bd70; border: 1px solid #91612b; font-size: 10px; }
.bm-hero strong { display: block; color: #fff1b4; font-size: 25px; font-weight: normal; line-height: 1.18; text-shadow: 2px 3px 0 #21120a; }
.bm-hero p { max-width: 280px; margin: 9px 0 0; color: #ead2b2; line-height: 1.4; }
.bm-hero-art { position: relative; flex: 0 0 100px; height: 95px; display: grid; place-items: center; transform: rotate(-12deg); }
.bm-hero-art::before { content: ''; position: absolute; width: 78px; height: 78px; border: 4px solid #e5a642; border-radius: 50%; box-shadow: 0 0 0 5px #4d2e18; }
.bm-hero-art > span:last-child { position: absolute; right: 1px; top: 3px; color: #ffe48a; font-size: 18px; }
.bm-icon { flex: 0 0 auto; width: 44px; height: 44px; display: grid; place-items: center; border: 2px solid #78512d; border-radius: 4px; background: #20160f; box-shadow: inset 0 -3px 0 #120d0b; }
.bm-icon img { width: 25px; height: 25px; image-rendering: pixelated; }
.bm-icon.large { width: 78px; height: 78px; border-width: 3px; }
.bm-icon.large img { width: 49px; height: 49px; }
.bm-icon.hero { width: 62px; height: 62px; border: 0; background: transparent; box-shadow: none; }
.bm-icon.hero img { width: 61px; height: 61px; filter: drop-shadow(3px 4px 0 #21120a); }
.bm-section-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 17px 0 8px; padding-bottom: 6px; border-bottom: 2px solid #4e3930; color: #f9d995; font-size: 13px; }
.bm-section-head small { color: #a79786; font-size: 11px; }
.bm-products, .bm-rewards { display: flex; flex-direction: column; gap: 7px; }
.bm-product, .bm-reward-card { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px; text-align: left; border: 2px solid #655344; border-radius: 5px; background: #29211d; box-shadow: inset 0 -3px 0 #17110e; }
.bm-product:hover, .bm-product:focus-visible, .bm-reward-card:hover, .bm-reward-card:focus-visible { border-color: #e9b35d; background: #382b21; }
.bm-product-copy, .bm-reward-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.bm-product-copy small, .bm-reward-copy small { color: #a89782; font-size: 10px; }
.bm-product-copy strong, .bm-reward-copy strong { color: #f2e4c8; font-size: 14px; font-weight: normal; }
.bm-product-copy > span, .bm-reward-copy > span { color: #baab9d; font-size: 11px; line-height: 1.35; }
.bm-product-price { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; color: var(--gold); font-size: 14px; white-space: nowrap; }
.bm-product-chevron, .bm-reward-arrow { color: #a89782; font-size: 23px; line-height: 1; }
.bm-footnote { margin-top: 11px; color: #9d8e82; font-size: 11px; line-height: 1.5; }
.bm-text-button { display: block; margin: 10px 0 0 auto; padding: 5px 1px; border: 0; background: transparent; color: #e2b465; font-size: 11px; text-decoration: underline; text-underline-offset: 3px; }
.bm-text-button:hover { color: #ffe48a; }

.bm-detail-hero { display: flex; flex-direction: column; align-items: center; padding: 18px; border: 2px solid #79512f; border-radius: 5px; background: radial-gradient(circle at center 30%, #4f321d, #241913 70%); text-align: center; }
.bm-detail-art { position: relative; min-height: 93px; display: grid; place-items: center; }
.bm-detail-art .bm-icon { transform: rotate(-7deg); border-color: #d59b4e; box-shadow: 0 5px 0 #3a2112; }
.bm-detail-tag { margin-top: 9px; color: #ffce75; letter-spacing: 1px; }
.bm-detail-hero p { margin: 9px 0 0; color: #e3d3bc; font-size: 13px; line-height: 1.5; }
.bm-perks { list-style: none; display: grid; gap: 8px; margin: 0; padding: 0; }
.bm-perks li { position: relative; padding: 7px 9px 7px 28px; border: 1px solid #4b3c31; background: #241d19; color: #d8c9b7; line-height: 1.4; }
.bm-perks li::before { content: '✓'; position: absolute; left: 10px; color: #a9df7b; }
.bm-purchase-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 15px; padding: 12px; border: 2px solid #6c4d2e; border-radius: 5px; background: #2b211a; }
.bm-purchase-bar > div { display: flex; flex-direction: column; gap: 3px; }
.bm-purchase-bar small { color: #a89782; font-size: 10px; }
.bm-purchase-bar strong { color: #ffe08a; font-size: 18px; font-weight: normal; white-space: nowrap; }
.bm-gold-button { flex: 0 1 auto; min-height: 39px; padding: 7px 12px; border: 2px solid #fff3c4; border-radius: 5px; background: linear-gradient(180deg, #ffe48a, #f0b23a); color: #2a1608; box-shadow: inset 0 -3px 0 #c98a22; font-size: 12px; }
.bm-gold-button:disabled { border-color: #635b54; background: #524943; color: #b7aba0; box-shadow: inset 0 -3px 0 #332b27; cursor: not-allowed; }
.bm-reward-intro { display: flex; align-items: center; gap: 15px; padding: 13px; border: 2px solid #6c794b; border-radius: 5px; background: #29301e; }
.bm-reward-stamp { flex: 0 0 auto; display: grid; place-items: center; width: 79px; height: 66px; border: 3px solid #a7d276; color: #d8f3a6; font-size: 21px; transform: rotate(-6deg); box-shadow: inset 0 0 0 3px #29301e, inset 0 0 0 5px #76944f; }
.bm-reward-intro strong { color: #d8f3a6; font-size: 15px; font-weight: normal; }
.bm-reward-intro p { margin: 6px 0 0; color: #c9d3bd; line-height: 1.45; }
.bm-reward-card .bm-icon { border-color: #718451; background: #1d2517; }
.bm-reward-copy small { color: #a9c291; }
.bm-reward-copy strong { color: #d5eac0; }
.bm-reward-arrow { color: #b9db98; }
.bm-note { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; padding: 12px; border-left: 3px solid #a8ce75; background: #24291d; color: #c4d1b6; line-height: 1.5; }
.bm-note strong { color: #d7efa9; font-weight: normal; }
.bm-plus { position: absolute; right: -36px; bottom: 5px; padding: 3px 5px; border: 2px solid #adcf79; background: #233019; color: #d8f3a6; transform: rotate(8deg); }
.bm-restore-art { display: flex; justify-content: center; margin: 18px 0 10px; }
.bm-restore-art .bm-icon { border-color: #d59b4e; }
.bm-restore-copy { max-width: 370px; margin: 0 auto 18px; color: #e0d1bf; line-height: 1.6; text-align: center; }
.bm-restore-status { color: #b6a896; }
.bm-status { margin-top: 9px; padding: 8px 10px; border: 1px solid #6c794b; border-radius: 4px; background: #29301e; color: #d8f3a6; font-size: 12px; }

/* Field-support chip: a rewarded-ad splinter grant, docked under the HUD currency bars (placed by script). */
.support-chip {
  position: fixed;
  z-index: 35;
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 4px 12px 5px 5px;
  border: 2px solid #fff3c4;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffe48a, #f0b23a);
  box-shadow: inset 0 -3px 0 #c98a22, 0 3px 0 #0008;
  color: #2a1608;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.support-chip:hover { filter: brightness(1.06); }
.support-chip:active { transform: translateY(1px); }
.support-chip:disabled { cursor: default; filter: none; transform: none; }
.sc-badge { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #2a1608; color: #ffe48a; font-size: 12px; }
.sc-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sc-copy small { color: #6b4518; font-size: 10px; white-space: nowrap; }
.sc-copy strong { display: flex; align-items: center; gap: 4px; font-size: 15px; font-weight: normal; white-space: nowrap; }
.sc-copy strong img { width: 14px; height: 14px; image-rendering: pixelated; }
.support-chip.hot { animation: chiphot 0.9s ease-in-out infinite; }
.support-chip.hot .sc-copy small { color: #8a2f00; }
@keyframes chiphot { 50% { box-shadow: inset 0 -3px 0 #c98a22, 0 3px 0 #0008, 0 0 0 4px #ffe48a88, 0 0 16px 4px #ffb45e; } }
.support-chip.cooldown { background: linear-gradient(180deg, #b9ab93, #8f8169); border-color: #d6cbb6; box-shadow: inset 0 -3px 0 #6c6150, 0 3px 0 #0008; }
.support-chip.cooldown .sc-copy small { color: #3d3324; }
.support-chip.cooldown .sc-copy strong { font-variant-numeric: tabular-nums; }
.support-chip.cooldown .sc-copy strong img { display: none; }
.support-chip.flash { background: linear-gradient(180deg, #d8f3a6, #9bd36a); border-color: #f1ffd9; box-shadow: inset 0 -3px 0 #6c9a3a, 0 3px 0 #0008; }
body.mobile .support-chip { min-height: 40px; padding: 3px 10px 4px 4px; }
body.mobile .sc-badge { width: 24px; height: 24px; }
body.mobile .sc-copy strong { font-size: 13px; }

/* Product card on top of the upgrade list (only where purchases are live). */
.shop-card { margin-bottom: 6px; padding: 5px 6px 6px; border: 2px solid #c98a22; border-radius: 6px; background: linear-gradient(180deg, #3a2a1a, #2b211a); box-shadow: inset 0 -2px 0 #1d1817; }
.shop-card-head { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; color: var(--gold); font-size: 10px; letter-spacing: 1px; }
.shop-card-head span { flex: 1; }
.shop-card-head button { border: 0; background: none; color: #d6c2a5; font: inherit; cursor: pointer; padding: 2px 4px; }
.shop-card-head button:hover { color: var(--text); }
.shop-card-x { font-size: 14px !important; line-height: 1; }
.shop-card-row { display: flex; align-items: center; gap: 8px; }
.shop-card-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 0; border: 0; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.shop-card-icon { flex: 0 0 auto; display: grid; place-items: center; width: 36px; height: 36px; border: 2px solid #c98a22; border-radius: 50%; background: #241d19; }
.shop-card-icon img { width: 22px; height: 22px; image-rendering: pixelated; }
.shop-card-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.shop-card-copy strong { color: #ffe08a; font-size: 13px; font-weight: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shop-card-copy span { color: #d6c2a5; font-size: 11px; line-height: 1.3; }
.shop-card.status .shop-card-copy span { color: #d8f3a6; }
.shop-card .shop-card-buy { flex: 0 0 auto; min-height: 36px; white-space: nowrap; }

/* Xsolla PayStation, framed with our own close button (players must always be able to leave it). */
.paystation { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 12px; background: #000b; }
.paystation-box { position: relative; width: min(100%, 760px); height: min(100%, 720px); border: 2px solid var(--line); border-radius: 6px; background: #fff; overflow: hidden; }
.paystation-box iframe { width: 100%; height: 100%; border: 0; }
.paystation-close { position: absolute; top: 6px; right: 6px; z-index: 1; }

@media (max-width: 520px) {
  .bm-modal { padding: 7px; align-items: center; }
  .bm-window { max-height: calc(100dvh - 14px - var(--safe-top) - var(--safe-bottom)); }
  .bm-content { padding: 13px 12px 17px; }
  .bm-hero { min-height: 132px; padding: 14px; }
  .bm-hero strong { font-size: 21px; }
  .bm-hero-art { flex-basis: 74px; }
  .bm-hero-art::before { width: 63px; height: 63px; }
  .bm-product-price { font-size: 12px; }
  .bm-product-copy > span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
  .bm-purchase-bar { flex-wrap: wrap; }
  .bm-gold-button { flex: 1 1 100%; }
}

@media (max-width: 360px) {
  .bm-hero-art { display: none; }
  .bm-product, .bm-reward-card { gap: 7px; padding: 7px; }
  .bm-icon { width: 38px; height: 38px; }
  .bm-icon img { width: 22px; height: 22px; }
  .bm-product-copy > span { display: none; }
}

/* ---------- 광장 building (plaza overlay) ---------- */

.plaza {
  position: absolute;
  inset: 10px;
  z-index: 13;
  display: flex;
  flex-direction: column;
  background: #050404;
  border: 3px solid var(--text);
  border-radius: 4px;
  line-height: 1.2;
  box-shadow: 0 0 0 3px #050404;
}
.pz-ch { display: flex; align-items: center; gap: 6px; color: var(--gold); }
.pz-ch .close-btn { width: 24px; height: 24px; border-color: #4e4540; }
.pz-ch .close-btn:disabled { opacity: 0.3; cursor: default; }
.plaza #pz-join { margin-left: auto; border-color: #9be26a; color: #9be26a; }
.plaza #pz-close { margin-left: auto; }
.plaza #pz-join:not(.hidden) ~ #pz-close { margin-left: 8px; }
.pz-body { flex: 1; min-height: 0; display: flex; }
.pz-view { position: relative; flex: 1; min-width: 0; overflow: hidden; touch-action: none; cursor: pointer; }
#pz-canvas { position: absolute; left: 0; top: 0; image-rendering: pixelated; }
.pz-side {
  flex: 0 0 240px;
  width: 240px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  border-left: 2px solid #2a2523;
  background: #120d0b;
}
.pz-card { padding: 8px; border-radius: 6px; background: var(--card); border: 2px solid #4e4540; }
.pz-board { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.pz-board li { display: flex; align-items: center; gap: 6px; padding: 3px 4px; border-radius: 3px; cursor: pointer; }
.pz-board li:hover { background: var(--card); }
.pz-board li.me { background: #3a2a10; color: var(--gold); }
.pz-board li.sel { box-shadow: inset 0 0 0 2px var(--text); }
.pz-board li.gap { justify-content: center; color: var(--text-dim); cursor: default; }
.pz-board li.gap:hover { background: none; }
.pz-board b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: normal; }
.pz-rank { width: 20px; text-align: right; color: var(--text-dim); }
.pz-rank.r1 { color: #ffd25a; }
.pz-rank.r2 { color: #d5dade; }
.pz-rank.r3 { color: #d08a4a; }
.pz-dot { width: 8px; height: 8px; flex: 0 0 8px; border-radius: 4px 4px 1px 1px; box-shadow: 0 0 0 1px #24170f; }
.pz-tiles { color: var(--accent); font-size: 12px; }
.pz-medal { display: inline-block; width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 0 1px #24170f; }
.pz-helmets { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.pz-helmet { width: 24px; height: 18px; padding: 0; border-radius: 10px 10px 2px 2px; border: 2px solid #24170f; }
.pz-helmet.on { outline: 2px solid var(--text); outline-offset: 1px; }
body.mobile .plaza { position: fixed; inset: 0; z-index: 20; border-width: 0; border-radius: 0; box-shadow: none; }
body.mobile .plaza .overlay-head { flex-wrap: wrap; padding-top: calc(8px + var(--safe-top)); }
body.mobile .plaza .overlay-count { order: 0; width: auto; }
body.mobile .pz-body { flex-direction: column; }
body.mobile .pz-side {
  flex: 0 0 auto;
  width: auto;
  max-height: 42%;
  border-left: 0;
  border-top: 2px solid #2a2523;
  padding-bottom: calc(10px + var(--safe-bottom));
}

/* Full-screen game views also need to start below Toss's persistent navigation capsule.
   This covers skill/license trees, the world map (including relocation), and the plaza. */
body.platform-toss.mobile .overlay-head,
body.platform-toss.mobile .worldmap .overlay-head,
body.platform-toss.mobile .plaza .overlay-head {
  padding-top: calc(8px + var(--safe-top) + var(--ait-nav-clearance));
}

.pz-thumb-btn {
  position: relative;
  display: block;
  width: 100%;
  height: 120px;
  margin: 2px 0 6px;
  padding: 0;
  overflow: hidden;
  border: 2px solid #4e4540;
  border-radius: 4px;
  background: #0d0a09;
}
.pz-thumb-btn:hover { border-color: var(--gold); }
.pz-thumb-btn canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.pz-thumb-btn span { position: absolute; right: 4px; bottom: 4px; padding: 1px 5px; border-radius: 3px; background: rgba(13, 10, 9, 0.8); color: var(--gold); font-size: 12px; }

/* ---------- visiting: the host's floor running live ---------- */

.visit-box { max-width: 560px; }
.visit-live { position: relative; aspect-ratio: 16 / 10; overflow: hidden; border: 2px solid #4e4540; border-radius: 4px; background: #0d0a09; }
.visit-live iframe { display: block; width: 100%; height: 100%; border: 0; }
.visit-live-tag { position: absolute; left: 6px; top: 6px; padding: 1px 6px; border-radius: 3px; background: #c8463c; color: #fff; font-size: 12px; pointer-events: none; }

body.spectate .panel, body.spectate .tutorial, body.spectate .tutorial-arrow { display: none !important; }
body.spectate .stage { flex: 1 1 auto; }
body.spectate #game { pointer-events: none; }
.spectate-tag {
  position: absolute;
  left: 50%;
  bottom: 8px;
  z-index: 5;
  transform: translateX(-50%);
  padding: 3px 8px;
  border: 2px solid var(--line-dim);
  border-radius: 4px;
  background: rgba(13, 10, 9, 0.8);
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
}
