:root {
  --cream: #f6ecd6;
  --gold: #f5c542;
  --go: #34c759;
  --panel-dark: rgba(30, 34, 45, 0.92);
  --p-color: #2f8fff;
  --a-color: #ff3b3b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  background: radial-gradient(circle at 50% 40%, #3a4a63 0%, #232b3a 70%, #1a2030 100%);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: #fff;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

.game-root {
  position: relative;
  width: 100%;
  height: 100dvh;
  height: 100svh;
  overflow: hidden;
}

.game-interaction-layer { touch-action: manipulation; }

/* Board */
#board-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#board {
  position: relative;
}
#board-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 18px;
  border: 5px solid #1a140a;
  box-shadow: 0 0 0 3px #e0be55, 0 18px 50px rgba(0,0,0,0.55), inset 0 0 0 2px rgba(255,240,190,0.25);
}
#board-calm {
  position: absolute;
  inset: 8%;
  border-radius: 8px;
  background: rgba(246,236,214,0.0);
  pointer-events: none;
}
#tiles, #pawns { position: absolute; inset: 0; pointer-events: none; }

.tile {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
}
.tile img {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 100%; height: 100%;
  object-fit: contain;
  /* Cel-shade: crisp dark outline around each tile piece. */
  filter:
    drop-shadow(1.5px 0 0 #1a140a) drop-shadow(-1.5px 0 0 #1a140a)
    drop-shadow(0 1.5px 0 #1a140a) drop-shadow(0 -1.5px 0 #1a140a)
    drop-shadow(0 4px 4px rgba(0,0,0,0.35));
}
.tile .price {
  position: absolute;
  left: 50%;
  top: -18%;
  transform: translateX(-50%);
  color: #1a140a;
  font-weight: 900;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffe27a, #e0be55);
  border: 2px solid #1a140a;
  box-shadow: 0 2px 0 #1a140a;
  white-space: nowrap;
}
.tile .own-strip {
  position: absolute;
  left: 50%;
  bottom: 4%;
  transform: translateX(-50%);
  width: 78%;
  height: 6px;
  border-radius: 3px;
  background: transparent;
  transition: background 0.2s;
}

.pawn {
  position: absolute;
  transform: translate(-50%, -60%);
  width: 8%;
  pointer-events: none;
  z-index: 5;
  transition: left 0.15s cubic-bezier(.34,1.56,.64,1), top 0.15s cubic-bezier(.34,1.56,.64,1);
  filter: drop-shadow(0 4px 5px rgba(0,0,0,0.4));
}
.pawn img { width: 100%; display: block; }

/* HUD */
.hud {
  position: absolute;
  padding: 10px 14px;
  border-radius: 14px;
  min-width: 108px;
  backdrop-filter: blur(4px);
  z-index: 20;
  border: 3px solid rgba(255,255,255,0.5);
  box-shadow: 0 4px 0 rgba(0,0,0,0.45), inset 0 2px 0 rgba(255,255,255,0.15);
  transition: box-shadow 0.2s;
}
.hud-tl { top: max(64px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); }
.hud-tr { top: max(64px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); text-align: right; }
.hud-bl { bottom: max(120px, calc(env(safe-area-inset-bottom) + 116px)); left: max(12px, env(safe-area-inset-left)); }
.hud-br { bottom: max(120px, calc(env(safe-area-inset-bottom) + 116px)); right: max(12px, env(safe-area-inset-right)); text-align: right; }
.hud-lm { top: 50%; left: max(12px, env(safe-area-inset-left)); transform: translateY(-50%); }
.hud-rm { top: 50%; right: max(12px, env(safe-area-inset-right)); transform: translateY(-50%); text-align: right; }
.hud.active-turn { box-shadow: 0 0 0 3px var(--gold), 0 0 18px rgba(245,197,66,0.6); }
.hud.eliminated { opacity: 0.4; filter: grayscale(0.8); }
.hud.eliminated .hud-name::after { content: " ☠"; }
.hud-name { font-weight: 800; font-size: 14px; letter-spacing: 1px; }
.hud-row { font-size: 20px; font-weight: 800; margin: 2px 0; }
.hud-coin { color: var(--gold); margin-right: 4px; }
.hud-props { font-size: 12px; opacity: 0.85; }

/* Center UI */
#center-ui {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 15;
  pointer-events: none;
}
#countdown {
  font-size: 56px;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 3px 0 #000, 0 0 8px rgba(0,0,0,0.6);
  margin-bottom: 4px;
  line-height: 1;
}
#dice-box { position: relative; width: 64px; height: 64px; }
#dice { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.4)); }
#dice.rolling { animation: shake 0.12s linear infinite; }
@keyframes shake {
  0%,100% { transform: rotate(-8deg) translateY(0); }
  50% { transform: rotate(8deg) translateY(-3px); }
}
#dice-value {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  font-weight: 900;
  color: #1a1a1a;
}
#roll-btn {
  margin-top: 12px;
  pointer-events: auto;
  border: 4px solid #10250f;
  background: linear-gradient(180deg, #6bf08a 0%, #2fb84f 100%);
  color: #fff;
  font-weight: 900;
  font-size: 20px;
  letter-spacing: 1.5px;
  padding: 13px 38px;
  border-radius: 30px;
  text-shadow: 0 2px 0 #10250f;
  box-shadow: 0 6px 0 #1f8f3b, 0 10px 16px rgba(0,0,0,0.4), inset 0 2px 0 rgba(255,255,255,0.4);
  cursor: pointer;
  min-width: 130px;
  min-height: 50px;
  transition: transform 0.08s, box-shadow 0.08s, filter 0.2s;
}
#roll-btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 #1f8f3b, 0 4px 8px rgba(0,0,0,0.35); }
#roll-btn:disabled { filter: grayscale(0.7) brightness(0.7); cursor: default; }

/* Bottom status */
#status-area {
  position: absolute;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  text-align: center;
  z-index: 20;
  width: 90%;
  max-width: 440px;
}
#turn-label {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 1px;
  color: var(--p-color);
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}
#turn-label.ai { color: var(--a-color); }
#status-label {
  margin-top: 3px;
  font-size: 14px;
  opacity: 0.92;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
  min-height: 18px;
}

/* Modals */
.hidden { display: none !important; }

/* ---- Intro cinematic overlay ---- */
#intro-blocker {
  position: absolute;
  inset: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
}
#intro-blocker.hidden { display: none !important; }
#intro-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
#intro-skip-btn {
  position: absolute;
  right: 18px;
  bottom: 18px;
  padding: 10px 20px;
  font: 700 15px/1 system-ui, sans-serif;
  letter-spacing: 0.08em;
  color: #fff;
  background: rgba(8,10,16,0.55);
  border: 2px solid rgba(255,255,255,0.7);
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background 0.15s, transform 0.1s;
}
#intro-skip-btn:hover { background: rgba(8,10,16,0.8); }
#intro-skip-btn:active { transform: scale(0.95); }
#intro-unmute-btn {
  position: absolute;
  left: 18px;
  bottom: 18px;
  padding: 10px 18px;
  font: 700 14px/1 system-ui, sans-serif;
  letter-spacing: 0.04em;
  color: #fff;
  background: rgba(8,10,16,0.55);
  border: 2px solid rgba(255,255,255,0.7);
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
#intro-unmute-btn:active { transform: scale(0.95); }
#intro-play-btn {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 18px 40px;
  font: 800 22px/1 system-ui, sans-serif;
  letter-spacing: 0.1em;
  color: #fff;
  background: rgba(30,140,70,0.92);
  border: 3px solid rgba(255,255,255,0.85);
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
}
#intro-play-btn:active { transform: translate(-50%, -50%) scale(0.95); }
#buy-blocker, #start-blocker, #end-blocker,
#menu-blocker, #difficulty-blocker, #slots-blocker, #pause-blocker {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(18,14,8,0.55), rgba(10,8,4,0.78)),
    url("art/menu-war-bg.jpg") center/cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 20px;
}
#pause-blocker { background: rgba(8,10,16,0.82); }
#pause-blocker, #slots-blocker, #difficulty-blocker { z-index: 46; }
#buy-dialog, #start-dialog, #end-dialog,
#menu-dialog, #difficulty-dialog, #slots-dialog, #pause-dialog {
  background: linear-gradient(180deg, #4a4326 0%, #35301c 100%);
  border: 3px solid #caa53f;
  border-radius: 14px;
  padding: 22px 24px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 0 0 3px #1c1810, 0 18px 40px rgba(0,0,0,0.7), inset 0 2px 0 rgba(255,235,170,0.25);
}
#menu-dialog {
  max-width: 400px;
  background: linear-gradient(180deg, #5a4d29 0%, #3a3319 100%);
  border: 3px solid #e0be55;
}
#menu-dialog h1 {
  font-size: 34px; margin-bottom: 6px;
  color: #ffe27a;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-shadow: 3px 3px 0 #1c1408, 0 0 18px rgba(255,190,60,0.5);
  transform: rotate(-1.5deg);
}
#difficulty-dialog, #slots-dialog { max-width: 380px; }
#difficulty-dialog h1, #slots-dialog h1, #pause-dialog h1,
#buy-dialog h2, #end-dialog h1, #start-dialog h1 {
  font-size: 24px; margin-bottom: 6px;
  color: #ffe27a;
  text-transform: uppercase; letter-spacing: 0.5px;
  text-shadow: 2px 2px 0 #1c1408;
}
#buy-name { color: #cfd6e6; font-size: 16px; margin-bottom: 14px; font-weight: 700; }
.buy-stats { display: flex; gap: 12px; justify-content: center; margin-bottom: 18px; }
.buy-stat {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 10px;
}
.buy-stat span { display: block; font-size: 11px; opacity: 0.7; letter-spacing: 1px; }
.buy-stat b { font-size: 20px; color: var(--gold); }
.buy-actions { display: flex; gap: 12px; }
.btn-buy, .btn-skip {
  flex: 1;
  border: 3px solid #10131c;
  border-radius: 12px;
  padding: 13px;
  font-weight: 900;
  font-size: 16px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  cursor: pointer;
  min-height: 48px;
}
.btn-buy { background: linear-gradient(180deg, #6bf08a, #3f8f28); color: #fff; box-shadow: 0 5px 0 #1c3d0e, inset 0 2px 0 rgba(255,255,255,0.35); text-shadow: 1px 1px 0 #1c3d0e; }
.btn-buy:active { transform: translateY(3px); box-shadow: 0 2px 0 #1c3d0e; }
.btn-buy:disabled { filter: grayscale(0.6) brightness(0.7); }
.btn-skip { background: linear-gradient(180deg, #d95a41, #8a3220); color: #ffe3d7; box-shadow: 0 5px 0 #40160c, inset 0 2px 0 rgba(255,255,255,0.25); text-shadow: 1px 1px 0 #40160c; }
.btn-skip:active { transform: translateY(3px); box-shadow: 0 2px 0 #40160c; }

/* Start dialog / color grid */
.start-sub { color: #e6d9a8; font-size: 14px; margin-bottom: 16px; }
#color-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.color-swatch {
  background: rgba(255,255,255,0.05);
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 8px 4px 6px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.color-swatch img { width: 54px; height: 54px; object-fit: contain; }
.color-swatch span { display: block; font-size: 11px; margin-top: 2px; opacity: 0.85; }
.color-swatch:active { transform: scale(0.95); }
.color-swatch.selected { border-color: #fff; background: rgba(255,255,255,0.16); }
.color-swatch.taken { opacity: 0.35; pointer-events: none; }
.ai-picked { font-size: 14px; color: #ffb0b0; margin-bottom: 14px; font-weight: 700; }
#end-sub { color: #cfd6e6; margin: 8px 0 18px; }
#end-title.lose { color: var(--a-color); }
#end-title.win { color: var(--go); }

@media (max-height: 520px) {
  .hud { padding: 6px 10px; min-width: 88px; }
  .hud-row { font-size: 16px; }
  #turn-label { font-size: 16px; }
  #status-area { bottom: max(6px, env(safe-area-inset-bottom)); }
  #status-label { font-size: 12px; }
  #center-ui { top: 44%; }
}

/* ---- Troop rail + buy troop ---- */
#troop-rail {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(64px, calc(env(safe-area-inset-bottom) + 58px));
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  max-width: 92vw;
  z-index: 22;
}
.troop-chip {
  position: relative;
  width: 42px; height: 42px;
  background: rgba(20,24,34,0.7);
  border: 2px solid rgba(255,255,255,0.35);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
.troop-chip img { width: 32px; height: 32px; object-fit: contain; }
.troop-count {
  position: absolute;
  top: -8px; right: -8px;
  min-width: 22px; height: 22px;
  padding: 0 5px;
  background: var(--gold);
  color: #1a1a1a;
  font-weight: 900; font-size: 13px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
}
#buy-troop-btn {
  border: 3px solid #6a3c00;
  background: linear-gradient(180deg, #ffca4a, #f0a92f);
  color: #3a2500;
  font-weight: 900; font-size: 13px;
  padding: 10px 14px;
  border-radius: 20px;
  box-shadow: 0 5px 0 #c9861f, inset 0 2px 0 rgba(255,255,255,0.4);
  cursor: pointer;
  min-height: 44px;
}
#buy-troop-btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 #c9861f; }
#buy-troop-btn:disabled { filter: grayscale(0.6) brightness(0.75); }
#troop-tech-btn {
  border: 3px solid #3a1a70;
  background: linear-gradient(180deg, #b98bff, #8a4ff0);
  color: #fff;
  font-weight: 900; font-size: 13px;
  padding: 10px 14px;
  border-radius: 20px;
  box-shadow: 0 5px 0 #6a2fd0, inset 0 2px 0 rgba(255,255,255,0.35);
  cursor: pointer;
  min-height: 44px;
}
#troop-tech-btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 #6a2fd0; }
#troop-tech-btn:disabled { filter: grayscale(0.6) brightness(0.75); }

/* ---- Battle / defense modals ---- */
#attack-choice-blocker, #defense-blocker, #battle-blocker {
  position: absolute;
  inset: 0;
  background: rgba(8,10,16,0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 45;
  padding: 16px;
}
#attack-choice-dialog, #defense-dialog, #battle-dialog {
  background: linear-gradient(180deg, #2b3040 0%, #222634 100%);
  border: 2px solid #46536e;
  border-radius: 18px;
  padding: 18px 18px 16px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
#attack-choice-dialog h2, #defense-dialog h2 { font-size: 20px; margin-bottom: 6px; }
#attack-choice-name { color: var(--a-color); font-weight: 800; font-size: 16px; margin-bottom: 8px; }
.choice-info { color: #cfd6e6; font-size: 13px; margin-bottom: 14px; line-height: 1.5; }
.def-hint { color: #aeb8cc; font-size: 12px; margin: 8px 0 12px; line-height: 1.4; }
.canvas-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 56vh;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 8px;
}
#defense-canvas, #battle-canvas {
  background: #3f7d3a;
  border-radius: 12px;
  border: 2px solid rgba(255,255,255,0.15);
  touch-action: manipulation;
  cursor: pointer;
}
#battle-status { font-size: 14px; font-weight: 700; margin-bottom: 8px; color: #e8eefc; }
.battle-speed {
  display: flex; align-items: center; gap: 6px;
  margin: 8px 0 2px; flex-wrap: wrap;
}
.battle-speed .speed-label { font-size: 12px; color: #9fb0c8; font-weight: 700; margin-right: 2px; }
.speed-btn {
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.06);
  color: #e8eefc;
  font-weight: 800; font-size: 13px;
  border-radius: 9px; padding: 6px 10px;
  min-width: 40px; min-height: 34px; cursor: pointer;
}
.speed-btn.selected {
  background: linear-gradient(180deg, #45d968, #2fb84f);
  border-color: #2fb84f; color: #06210f;
}
.speed-btn:active { transform: translateY(1px); }
.battle-controls {
  display: flex; align-items: center; justify-content: flex-start;
  gap: 8px; margin-top: 6px; flex-wrap: wrap;
}
#battle-deploy { font-size: 13px; color: #cfd6e6; font-weight: 700; flex: 1 0 100%; }
.deploy-btn { flex: 1 1 auto; padding: 11px 10px; min-height: 44px; font-size: 14px; }
.deploy-btn:disabled { filter: grayscale(0.6) brightness(0.7); }
#battle-result {
  position: absolute;
  inset: 0;
  background: rgba(10,12,18,0.9);
  border-radius: 18px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px; padding: 20px;
}
#battle-result h2 { font-size: 24px; }
#battle-result-sub { color: #cfd6e6; font-size: 14px; text-align: center; }
#battle-dialog { position: relative; }

/* ---- Menu system: main menu, difficulty, slots, pause ---- */
.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 4px;
}
.menu-actions .btn-buy, .menu-actions .btn-skip { flex: none; width: 100%; }

/* Difficulty cards */
#difficulty-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0;
}
.difficulty-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  text-align: left;
  background: linear-gradient(180deg, rgba(90,77,41,0.6), rgba(50,44,25,0.6));
  border: 2px solid rgba(0,0,0,0.4);
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  min-height: 60px;
  color: #fff;
  box-shadow: inset 0 2px 0 rgba(255,235,170,0.15);
}
.difficulty-card:active { transform: translateY(1px); }
.difficulty-card.selected { border-color: var(--gold); background: linear-gradient(180deg, rgba(245,197,66,0.28), rgba(180,140,40,0.22)); box-shadow: 0 0 12px rgba(245,197,66,0.5); }
.diff-name { font-size: 18px; font-weight: 800; text-shadow: 1px 1px 0 #1c1408; }
.diff-blurb { font-size: 12.5px; color: #e6d9a8; }

/* Save slots */
#slots-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 14px 0;
}
.slot-card {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 8px;
}
.slot-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  text-align: left;
  background: rgba(255,255,255,0.05);
  border: 2px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  min-height: 56px;
  color: #fff;
}
.slot-main:active { transform: translateY(1px); }
.slot-main:disabled { opacity: 0.5; cursor: default; }
.slot-title { font-size: 15px; font-weight: 800; }
.slot-detail { font-size: 12px; color: #b9c2d6; }
.slot-date { font-size: 11px; color: #8b95ac; }
.slot-del {
  flex: 0 0 44px;
  border: none;
  border-radius: 12px;
  background: rgba(200,70,70,0.25);
  color: #ffd7d7;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  min-height: 44px;
}
.slot-del:active { transform: translateY(1px); }

/* Settings gear */
#top-controls {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 48;
}
#settings-btn, #music-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid #10131c;
  background: linear-gradient(180deg, #2b3348, #1b2130);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 0 #10131c, inset 0 2px 0 rgba(255,255,255,0.18);
}
#settings-btn:active, #music-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #10131c; }
#music-btn.playing {
  background: linear-gradient(180deg, #6bbf3f, #3f8f28);
  border-color: #1c3d0e;
  animation: music-pulse 1.6s ease-in-out infinite;
}
@keyframes music-pulse { 0%,100% { box-shadow: 0 4px 0 #1c3d0e, 0 0 0 0 rgba(107,191,63,0.55); } 50% { box-shadow: 0 4px 0 #1c3d0e, 0 0 0 7px rgba(107,191,63,0); } }
@media (max-height: 520px) {
  #settings-btn, #music-btn { width: 38px; height: 38px; font-size: 18px; }
}

#music-blocker {
  position: absolute;
  inset: 0;
  background: rgba(8,10,16,0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 47;
  padding: 20px;
}
#music-blocker.hidden { display: none !important; }
#music-dialog {
  background: linear-gradient(180deg, #4a4326 0%, #35301c 100%);
  border: 3px solid #caa53f;
  border-radius: 14px;
  padding: 20px;
  width: 100%;
  max-width: 420px;
  max-height: 88vh;
  overflow-y: auto;
  text-align: center;
  box-shadow: 0 0 0 3px #1c1810, 0 18px 40px rgba(0,0,0,0.7), inset 0 2px 0 rgba(255,235,170,0.25);
}
#music-dialog h2 {
  font-size: 24px; margin-bottom: 12px;
  color: #ffe27a;
  text-transform: uppercase; letter-spacing: 0.5px;
  text-shadow: 2px 2px 0 #1c1408;
}
.music-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.music-tab {
  flex: 1; padding: 9px 0;
  font: 700 14px/1 system-ui, sans-serif; letter-spacing: 0.04em;
  color: #e9dcae; background: rgba(0,0,0,0.28);
  border: 2px solid #7a6a34; border-radius: 9px; cursor: pointer;
}
.music-tab.selected { color: #1c1408; background: linear-gradient(180deg, #ffe27a, #d9b243); border-color: #ffe27a; }
.music-pane { text-align: left; }
.music-pane.hidden { display: none !important; }
.music-hint { font-size: 12px; line-height: 1.4; color: #d8cfa8; margin-bottom: 10px; }
.music-row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
#spotify-url {
  flex: 1 1 180px; min-width: 0; padding: 9px 10px;
  font-size: 13px; color: #fff;
  background: rgba(0,0,0,0.35); border: 2px solid #7a6a34; border-radius: 8px;
}
#spotify-url:focus { outline: none; border-color: #ffe27a; }
.music-mini { flex: 0 0 auto; padding: 9px 14px; font-size: 13px; border-radius: 8px; }
.music-file-label { display: inline-flex; align-items: center; cursor: pointer; }
.music-err { font-size: 12px; color: #ff9c86; margin-bottom: 8px; }
.music-err.hidden { display: none; }
#spotify-embed { margin-bottom: 10px; border-radius: 12px; overflow: hidden; }
#spotify-embed iframe { display: block; width: 100%; border: 0; border-radius: 12px; }
.music-np {
  font-size: 13px; color: #ffe27a; font-weight: 700;
  padding: 8px 10px; background: rgba(0,0,0,0.28); border-radius: 8px;
  margin-bottom: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.music-controls { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.music-controls button {
  width: 42px; height: 42px; border-radius: 50%;
  font-size: 18px; color: #1c1408;
  background: linear-gradient(180deg, #ffe27a, #d9b243);
  border: 2px solid #fff2c0; cursor: pointer;
}
.music-controls button:active { transform: translateY(1px); }
#local-vol { flex: 1; accent-color: #d9b243; }
.music-list { list-style: none; margin: 0; padding: 0; max-height: 34vh; overflow-y: auto; }
.music-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; margin-bottom: 6px;
  font-size: 13px; color: #efe6bf;
  background: rgba(0,0,0,0.24); border: 1px solid #6a5c2e; border-radius: 8px;
  cursor: pointer;
}
.music-list li.active { background: rgba(217,178,67,0.28); border-color: #ffe27a; color: #fff; }
.music-list li .track-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.music-list li .track-del {
  flex: 0 0 auto; width: 24px; height: 24px; border-radius: 6px;
  border: none; background: rgba(183,71,47,0.8); color: #fff; cursor: pointer; font-size: 14px;
}
#music-close { width: 100%; margin-top: 12px; }

/* Hide game chrome while a pre-game menu is showing */
body.in-menu #hud-container,
body.in-menu #status-area,
body.in-menu #center-ui,
body.in-menu #troop-rail,
body.in-menu #board-wrap { opacity: 0; pointer-events: none; }

/* ---- Jail / wheel / cards (mechanics expansion) ---- */
#jail-blocker, #wheel-blocker {
  position: absolute;
  inset: 0;
  background: rgba(8,10,16,0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 44;
  padding: 20px;
}
#go-blocker {
  position: absolute;
  inset: 0;
  background: rgba(8,10,16,0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 44;
  padding: 20px;
}
#jail-dialog, #wheel-dialog, #go-dialog {
  background: linear-gradient(180deg, #2b3040 0%, #222634 100%);
  border: 2px solid #46536e;
  border-radius: 18px;
  padding: 22px 24px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
#jail-dialog h2, #wheel-dialog h2, #go-dialog h2 { font-size: 22px; margin-bottom: 8px; }
.go-die {
  font-size: 34px;
  font-weight: 900;
  color: var(--gold);
  margin: 2px 0 8px;
}
.jail-roll {
  font-size: 40px;
  font-weight: 900;
  color: var(--gold);
  margin: 6px 0 14px;
}
.jail-actions { margin-bottom: 10px; }
.jail-free-btn, .instant-win-btn {
  width: 100%;
  margin-top: 4px;
  background: linear-gradient(180deg, #a35bff, #7d3fe0);
  box-shadow: 0 4px 0 #5c2bb0;
}
.jail-free-btn:active, .instant-win-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #5c2bb0; }

/* Prize wheel */
.wheel-wrap {
  position: relative;
  width: 100%;
  max-width: 300px;
  margin: 6px auto 14px;
  aspect-ratio: 1 / 1;
}
#wheel-canvas, #go-canvas { width: 100%; height: 100%; display: block; }
#wheel-pointer, #go-pointer {
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 13px solid transparent;
  border-right: 13px solid transparent;
  border-top: 22px solid var(--gold);
  z-index: 2;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.5));
}
#wheel-result, #go-result { min-height: 20px; margin-bottom: 12px; font-weight: 700; }
#wheel-spin-btn, #wheel-ok-btn, #go-spin-btn, #go-ok-btn { width: 100%; }

/* HUD card/voucher badges */
.hud-cards {
  font-size: 10.5px;
  line-height: 1.35;
  opacity: 0.92;
  margin-top: 2px;
  color: #e8edf7;
}
.hud-cards:empty { display: none; }

@media (max-height: 520px) {
  #wheel-dialog, #go-dialog { max-width: 300px; padding: 16px; }
  .wheel-wrap { max-width: 220px; }
}

/* ---- Player-count selector (color-select screen) ---- */
.player-count-row {
  display: flex; align-items: center; justify-content: center;
  flex-wrap: wrap; gap: 7px; margin: 4px 0 14px;
}
.player-count-row .pc-label { font-size: 13px; color: #9fb0c8; font-weight: 700; margin-right: 4px; width: 100%; }
.pc-btn {
  border: 2px solid #10131c;
  background: rgba(255,255,255,0.08);
  color: #e8eefc; font-weight: 800; font-size: 15px;
  border-radius: 10px; min-width: 44px; min-height: 44px; cursor: pointer;
  box-shadow: 0 3px 0 #10131c;
}
.pc-btn.selected {
  background: linear-gradient(180deg, #6bf08a, #2fb84f);
  border-color: #10250f; color: #06210f;
}
.pc-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #10131c; }

/* ---- Base building-tier badge on owned tiles ---- */
.tier-badge {
  position: absolute;
  top: 2px; left: 50%; transform: translateX(-50%);
  font-size: 12px; line-height: 1;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  pointer-events: none; z-index: 3;
  white-space: nowrap;
}

/* ---- Damaged lot ---- */
.tile.damaged img { filter: grayscale(0.9) brightness(0.55); }
.damaged-badge {
  position: absolute;
  bottom: 2px; left: 50%; transform: translateX(-50%);
  font-size: 11px; font-weight: 800; color: #ffd27a;
  background: rgba(0,0,0,0.6); border-radius: 6px; padding: 0 4px;
  pointer-events: none; z-index: 3;
}

/* ---- Battle takeover choice ---- */
#battle-takeover { width: 100%; margin-bottom: 8px; }
#battle-takeover .btn-buy, #battle-takeover .btn-skip { flex: 1 1 auto; }

/* ---- Random-pick highlight outline on tiles ---- */
.tile.tile-pick::after, .tile.tile-bomb::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 118%; height: 118%;
  transform: translate(-50%, -50%);
  border-radius: 12px;
  pointer-events: none;
  z-index: 5;
}
.tile.tile-pick::after {
  border: 3px solid #ffe066;
  box-shadow: 0 0 14px 4px rgba(255,224,102,0.9), inset 0 0 8px rgba(255,224,102,0.7);
  animation: pickPulse 0.5s ease-in-out infinite alternate;
}
.tile.tile-bomb::after {
  border: 3px solid #ff5b5b;
  box-shadow: 0 0 16px 5px rgba(255,91,91,0.95), inset 0 0 8px rgba(255,91,91,0.7);
  animation: pickPulse 0.35s ease-in-out infinite alternate;
}
@keyframes pickPulse {
  from { transform: translate(-50%, -50%) scale(1); opacity: 0.85; }
  to   { transform: translate(-50%, -50%) scale(1.08); opacity: 1; }
}

/* ---- Music box (settings) ---- */
#music-box {
  background: rgba(20,17,9,0.55);
  border: 2px solid #8a7430;
  border-radius: 12px;
  padding: 12px;
  margin: 4px 0 14px;
  text-align: left;
}
.mb-head { font-weight: 800; font-size: 13px; letter-spacing: 1px; color: #ffe27a; margin-bottom: 8px; }
.mb-track { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.mb-nav {
  flex: none; width: 40px; height: 40px;
  border: 2px solid rgba(0,0,0,0.5); border-radius: 10px;
  background: linear-gradient(180deg, #6bbf3f, #3f8f28); color: #fff;
  font-size: 15px; font-weight: 800; cursor: pointer;
  box-shadow: 0 3px 0 #276016;
}
.mb-nav:active { transform: translateY(2px); box-shadow: 0 1px 0 #276016; }
.mb-now { flex: 1; text-align: center; min-width: 0; }
#mb-name { font-weight: 800; font-size: 15px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#mb-genre { font-size: 11px; color: #e6d9a8; }
#mb-select {
  width: 100%; padding: 8px; border-radius: 8px; margin-bottom: 8px;
  background: #2c2716; color: #fff; border: 1px solid #8a7430; font-size: 13px;
}
.mb-toggles { display: flex; gap: 14px; margin-bottom: 8px; }
.mb-toggle { font-size: 13px; color: #e6d9a8; display: flex; align-items: center; gap: 6px; cursor: pointer; }
.mb-toggle input { width: 18px; height: 18px; accent-color: #6bbf3f; }
.mb-vol { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.mb-vol span { font-size: 12px; color: #e6d9a8; }
.mb-vol input[type=range] { flex: 1; accent-color: #ffca4a; }
.mb-spotify { display: flex; gap: 6px; }
.mb-spotify input {
  flex: 1; min-width: 0; padding: 8px; border-radius: 8px;
  background: #2c2716; color: #fff; border: 1px solid #8a7430; font-size: 12px;
}
#mb-spotify-open {
  flex: none; padding: 8px 12px; border-radius: 8px; cursor: pointer;
  background: #1DB954; color: #fff; border: none; font-weight: 800; font-size: 12px;
}
#mb-spotify-open:active { transform: translateY(1px); }
