/* ── ChronQuest WEB — 1:1 with ESP32 device ─────────────── */

.play-body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  padding-top: 60px;
}

.play-main {
  max-width: 920px;
  margin: 0 auto;
  padding: 2.5rem 1rem 4rem;
}

.play-header {
  text-align: center;
  margin-bottom: 2rem;
}
.play-header h1 {
  font-family: var(--font-head);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}
.play-header h1 .gold { color: var(--gold); }
.play-header p {
  color: var(--text-sub);
  font-size: 0.95rem;
}

/* ── Device frame ────────────────────────────────────────── */
.device-wrap {
  display: flex; flex-direction: column;
  align-items: center; gap: 1rem;
}
.device-bezel {
  background: linear-gradient(180deg, #1a1d24 0%, #0d0f14 100%);
  padding: 18px;
  border-radius: 22px;
  border: 1px solid #2a2e38;
  box-shadow:
    0 30px 80px rgba(0,0,0,0.5),
    0 0 0 1px rgba(255,255,255,0.04) inset;
}

/* The 480x320 screen — no anti-aliasing on text or images */
.device-screen {
  position: relative;
  width: 480px;
  height: 320px;
  background: #090909;
  overflow: hidden;
  font-family: 'Share Tech Mono', 'Consolas', monospace;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  cursor: default;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: auto;
  font-smooth: never;
  text-rendering: optimizeSpeed;
  image-rendering: pixelated;
}
.device-screen * {
  -webkit-font-smoothing: none;
  font-smooth: never;
}

.device-caption {
  color: var(--text-mute);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
}

/* ── Responsive scaling — JS sets transform + negative margins ── */
.device-bezel {
  /* size is natural — wraps the screen after margin collapse */
  display: inline-flex;
}
.device-screen {
  transform-origin: top left;
  /* transform and negative margins set by applyScale() in JS */
}

/* ── Rotate prompt ───────────────────────────────────────── */
.rotate-prompt {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem;
  text-align: center;
}
.rotate-icon {
  font-size: 3rem;
  color: var(--gold);
  animation: rotate-spin 2s linear infinite;
}
@keyframes rotate-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.rotate-msg {
  color: var(--text-sub);
  font-size: 1rem;
  max-width: 280px;
}
.rotate-skip {
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--gold);
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 0.5rem 1.2rem;
  cursor: pointer;
  letter-spacing: 0.05em;
}
.rotate-skip:hover { background: rgba(201,168,76,0.1); }

/* Rotate prompt visibility is controlled entirely by JS — not CSS media queries */
.rotate-prompt          { display: none; }
.rotate-prompt.visible  { display: flex; }
#deviceWrap.hidden      { display: none; }

/* ── Splash (TFT-style, no fancy fonts) ──────────────────── */
.splash {
  position: absolute; inset: 0;
  background: #090909;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  cursor: pointer;
}
.splash-crown {
  font-family: 'Share Tech Mono', monospace;
  font-size: 38px;
  font-weight: 700;
  color: #c9a84c;
  letter-spacing: 0.18em;
}
.splash-sub {
  margin-top: 6px;
  color: #7a6030;
  font-size: 11px;
  letter-spacing: 0.3em;
}
.splash-tap {
  position: absolute; bottom: 32px; left: 0; right: 0;
  text-align: center;
  color: #c9a84c;
  font-size: 11px;
  letter-spacing: 0.3em;
  animation: pulse 1.6s steps(2, end) infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.25; }
  50%      { opacity: 1; }
}
.splash-wifi {
  position: absolute; bottom: 10px; left: 0; right: 0;
  text-align: center;
  color: #3a4050;
  font-size: 9px;
  letter-spacing: 0.15em;
}

/* ── Game Select ─────────────────────────────────────────── */
.gselect {
  position: absolute; inset: 0;
  padding: 14px;
  display: flex; flex-direction: column;
}
.gselect-title {
  font-size: 12px;
  color: #c9a84c;
  text-align: center;
  letter-spacing: 0.3em;
  margin-bottom: 12px;
  font-weight: 700;
}
.gselect-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  flex: 1;
}
.game-card {
  background: #0a0a0f;
  border: 1px solid #181a1e;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 10px;
  cursor: pointer;
}
.game-card:hover     { background: #131826; border-color: #2a3040; }
.game-card:active    { background: #1a2030; }
.game-card.locked    { opacity: 0.35; cursor: not-allowed; }
.game-card-name {
  font-size: 13px;
  color: #c9a84c;
  letter-spacing: 0.12em;
  font-weight: 700;
  text-align: center;
}
.game-card-sub {
  font-size: 9px;
  color: #7a8090;
  margin-top: 4px;
  text-align: center;
  letter-spacing: 0.1em;
}

/* ── Setup wizard ────────────────────────────────────────── */
.setup {
  position: absolute; inset: 0;
  padding: 12px;
  display: flex; flex-direction: column;
}
.setup-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px;
}
.setup-back {
  width: 34px; height: 34px;
  background: #0a0a0f; border: 1px solid #181a1e;
  color: #c9a84c; font-size: 22px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.setup-back:hover { background: #131826; }
.setup-title {
  flex: 1; text-align: center;
  font-size: 12px;
  color: #c9a84c;
  letter-spacing: 0.25em;
  font-weight: 700;
}
.setup-body {
  flex: 1;
  display: flex; flex-direction: column;
  justify-content: center;
}
.setup-grid {
  display: grid; gap: 4px;
}
.setup-btn {
  background: #0a0a0f;
  border: 1px solid #181a1e;
  color: #ffffff;
  font-family: inherit;
  font-size: 28px;
  font-weight: 700;
  padding: 14px;
  cursor: pointer;
  text-align: center;
}
.setup-btn:hover  { background: #131826; border-color: #44aaff; color: #44aaff; }
.setup-btn:active { background: #1a2030; }
.setup-btn.small  { font-size: 13px; padding: 10px; letter-spacing: 0.1em; }

.name-row {
  display: flex; align-items: center;
  gap: 6px; margin-bottom: 4px;
}
.name-row-label {
  width: 36px;
  color: #c9a84c;
  font-size: 11px;
  letter-spacing: 0.1em;
  font-weight: 700;
}
.name-row input {
  flex: 1;
  background: #0a0a0f;
  border: 1px solid #181a1e;
  color: #ffffff;
  font-family: inherit;
  font-size: 13px;
  padding: 6px 8px;
  outline: none;
  letter-spacing: 0.05em;
}
.name-row input:focus { border-color: #44aaff; }
.name-row input.cmd { width: 130px; flex: 0 0 130px; font-size: 11px; }

.setup-foot {
  display: flex; gap: 4px;
  margin-top: 8px;
}
.setup-foot .setup-btn { flex: 1; font-size: 13px; padding: 10px; letter-spacing: 0.2em; }
.setup-btn.primary {
  background: #0a1820;
  border-color: #44aaff;
  color: #44aaff;
}
.setup-btn.primary:hover { background: #122838; }

/* ── Main game ───────────────────────────────────────────── */
.game {
  position: absolute; inset: 0;
  background: #090909;
}
.tile {
  position: absolute;
  background: #0d1018;
  border: 1px solid #181a1e;
  overflow: hidden;
}

/* Name bar */
.tile-namebar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 20px;
  background: rgba(0,0,0,0.4);
  padding: 0 6px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.tile-name {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 65%;
}
.tile-cmdname {
  font-size: 9px;
  color: #7a8090;
  max-width: 50%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  letter-spacing: 0.06em;
}

/* CMD damage row (only visible if any damage) */
.tile-cmdrow {
  position: absolute;
  left: 0; right: 0;
  top: 20px;
  height: 26px;
  display: flex; gap: 2px;
  padding: 2px 4px;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.cmd-badge {
  position: relative;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.18);
  min-width: 26px;
  height: 22px;
  padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
}
.cmd-badge.lethal { color: #ff6060; border-color: #ff6060; }
.cmd-badge-dot {
  position: absolute; top: 1px; left: 1px;
  width: 4px; height: 4px;
}

/* Life number area + side +/- buttons */
.tile-lifearea {
  position: absolute;
  left: 0; right: 0;
  display: flex;
}
.life-btn {
  width: 44px;
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: rgba(255,255,255,0.35);
  font-size: 28px;
  font-weight: 400;
  font-family: inherit;
  border: none;
}
.life-btn:hover  { background: rgba(255,255,255,0.04); color: rgba(255,255,255,0.7); }
.life-btn:active { background: rgba(68,170,255,0.12); color: #44aaff; }

.tile-life {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.tile-life-num {
  font-family: inherit;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: 0;
}

.tile.eliminated .tile-life-num { display: none; }
.tile.eliminated .life-btn      { opacity: 0; pointer-events: none; }
.tile.eliminated::after {
  content: 'ELIM';
  position: absolute;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  color: #ff6060;
  font-size: 22px;
  letter-spacing: 0.3em;
  font-weight: 700;
  pointer-events: none;
  font-family: inherit;
}
.tile.eliminated { opacity: 0.45; }

/* Counter row (TAX | PSN — text labels, not icons) */
.tile-counters {
  position: absolute;
  left: 0; right: 0;
  bottom: 0;
  height: 26px;
  display: flex;
  background: #0a0a0f;
  border-top: 1px solid rgba(255,255,255,0.04);
}
.ctr-half {
  flex: 1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 6px;
  cursor: pointer;
  border-right: 1px solid rgba(255,255,255,0.04);
}
.ctr-half:last-child { border-right: none; }
.ctr-half:hover { background: rgba(255,255,255,0.03); }
.ctr-half:active { background: rgba(68,170,255,0.08); }
.ctr-label {
  font-size: 10px;
  color: #404850;
  letter-spacing: 0.15em;
  font-weight: 700;
}
.ctr-val {
  font-size: 14px;
  font-weight: 700;
  color: #303840;
  font-family: inherit;
}
.ctr-half.active .ctr-val   { color: #ffffff; }
.ctr-half.gold .ctr-val     { color: #c9a84c; }
.ctr-half.gold .ctr-label   { color: #404850; }
.ctr-half.lethal .ctr-val   { color: #ff6060; }
.ctr-half.lethal            { background: rgba(60,8,8,0.5); }

/* Monarch border (4 nested colored rects, matches firmware) */
.tile.monarch {
  box-shadow:
    inset 0 0 0 1px #c9a84c,
    inset 0 0 0 2px rgba(201,168,76,0.75),
    inset 0 0 0 3px rgba(201,168,76,0.5),
    inset 0 0 0 4px rgba(201,168,76,0.25);
  animation: monarch-pulse 7s steps(40, end) infinite;
}
@keyframes monarch-pulse {
  0%, 100% {
    box-shadow:
      inset 0 0 0 1px rgba(201,168,76,0.45),
      inset 0 0 0 2px rgba(201,168,76,0.33),
      inset 0 0 0 3px rgba(201,168,76,0.22),
      inset 0 0 0 4px rgba(201,168,76,0.11);
  }
  50% {
    box-shadow:
      inset 0 0 0 1px #c9a84c,
      inset 0 0 0 2px rgba(201,168,76,0.75),
      inset 0 0 0 3px rgba(201,168,76,0.5),
      inset 0 0 0 4px rgba(201,168,76,0.25);
  }
}

/* Center pip (40x40 disc with gear glyph) */
.center-pip {
  position: absolute;
  left: 220px; top: 140px;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: #0a0a0f;
  border: 1px solid #2a3040;
  display: flex; align-items: center; justify-content: center;
  color: #c9a84c;
  font-size: 20px;
  cursor: pointer;
  z-index: 20;
  font-family: inherit;
}
.center-pip:hover  { background: #131826; }
.center-pip:active { background: #1a2030; }

/* ── Detail screen ───────────────────────────────────────── */
.detail {
  position: absolute; inset: 0;
  background: #090909;
  padding: 10px;
  overflow-y: auto;
  display: flex; flex-direction: column;
}
.detail-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
}
.detail-back {
  width: 30px; height: 30px;
  background: #0a0a0f; border: 1px solid #181a1e;
  color: #c9a84c; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; line-height: 1;
}
.detail-name {
  flex: 1;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.1em;
}
.detail-cmdname {
  font-size: 10px;
  color: #7a8090;
  letter-spacing: 0.06em;
}
.detail-section { margin-bottom: 6px; }
.detail-label {
  font-size: 9px;
  color: #404850;
  letter-spacing: 0.2em;
  margin-bottom: 4px;
  font-weight: 700;
}
.cmd-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
}
.cmd-row {
  display: flex; align-items: center;
  background: #0a0a0f; border: 1px solid #181a1e;
  padding: 3px 5px;
  gap: 5px;
  font-size: 11px;
}
.cmd-row.lethal { border-color: #ff6060; background: rgba(40,8,8,0.7); }
.cmd-row-dot { width: 7px; height: 7px; flex-shrink: 0; }
.cmd-row-name {
  flex: 1;
  font-size: 11px;
  color: #d8dde8;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: 0.04em;
}
.cmd-row-val {
  font-size: 14px; font-weight: 700;
  min-width: 22px; text-align: center;
}
.cmd-row-btn {
  width: 20px; height: 20px;
  background: #181a1e; border: 1px solid #2a3040;
  color: #ffffff; cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  padding: 0; line-height: 1;
}
.cmd-row-btn:active { background: #2a3040; }

.detail-counters {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
}
.dctr-card {
  background: #0a0a0f;
  border: 1px solid #181a1e;
  padding: 6px 8px;
  display: flex; align-items: center; gap: 6px;
}
.dctr-label { flex: 1; font-size: 11px; color: #7a8090; letter-spacing: 0.1em; font-weight: 700; }
.dctr-val { font-size: 16px; font-weight: 700; min-width: 26px; text-align: center; font-family: inherit; }
.dctr-btn {
  width: 22px; height: 22px;
  background: #181a1e; border: 1px solid #2a3040;
  color: white; cursor: pointer; font-size: 14px;
  font-family: inherit;
}
.dctr-btn:active { background: #2a3040; }

.detail-actions {
  display: flex; gap: 4px; margin-top: 6px;
}
.dact {
  flex: 1;
  background: #0a0a0f; border: 1px solid #181a1e;
  color: #c9a84c;
  font-family: inherit;
  font-size: 11px; letter-spacing: 0.15em; font-weight: 700;
  padding: 8px;
  cursor: pointer;
}
.dact.active { background: #2a200a; border-color: #c9a84c; }
.dact:hover { background: #131826; }

/* ── Settings overlay ────────────────────────────────────── */
.settings {
  position: absolute; inset: 0;
  background: rgba(9,9,9,0.96);
  padding: 16px;
  display: flex; flex-direction: column;
  z-index: 30;
}
.settings-title {
  font-size: 13px;
  color: #c9a84c;
  text-align: center;
  letter-spacing: 0.3em;
  margin-bottom: 14px;
  font-weight: 700;
}
.settings-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
}
.s-btn {
  background: #0a0a0f;
  border: 1px solid #181a1e;
  color: #ffffff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 14px;
  cursor: pointer;
  letter-spacing: 0.15em;
}
.s-btn:hover { background: #131826; }
.s-btn.warn  { color: #c9a84c; border-color: #c9a84c; }
.s-btn.danger{ color: #ff6060; border-color: #ff6060; }
.s-btn.full  { grid-column: span 2; }
.s-btn[disabled] { opacity: 0.3; cursor: not-allowed; }

/* Confirm */
.confirm {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 40;
}
.confirm-box {
  background: #0a0a0f;
  width: 320px;
  border: 1px solid #181a1e;
}
.confirm-strip { height: 4px; background: #c9a84c; }
.confirm-strip.danger { background: #ff6060; }
.confirm-body { padding: 14px; }
.confirm-msg {
  font-size: 12px; color: #d8dde8;
  margin-bottom: 12px; line-height: 1.4;
  letter-spacing: 0.04em;
}
.confirm-actions { display: flex; gap: 6px; }
.confirm-btn {
  flex: 1;
  background: #181a1e; border: 1px solid #2a3040;
  color: white; padding: 9px;
  font-family: inherit;
  font-size: 11px; letter-spacing: 0.2em; font-weight: 700;
  cursor: pointer;
}
.confirm-btn.go.danger { background: #2a0808; border-color: #ff6060; color: #ff6060; }
.confirm-btn.go.warn   { background: #2a200a; border-color: #c9a84c; color: #c9a84c; }
