/* Play screen: HUD, status, grid, tiles, result. */

.screen { display: none; width: 100%; max-width: 720px; margin: 0 auto; text-align: center; animation: fadeIn .35s ease both; }
.screen.is-active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.hud {
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 10px 14px; margin: 0 auto 14px; max-width: 640px;
}
.hud-cell { padding: 6px 4px; border-right: 1px solid rgba(255,255,255,0.06); }
.hud-cell:last-child { border-right: none; }
.hud-label { font-size: 10px; letter-spacing: 0.25em; color: var(--text-dim); text-transform: uppercase; }
.hud-value {
  font-family: var(--font-display); font-weight: 900;
  font-size: 22px; color: var(--cyan);
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.55);
  transition: transform .15s ease;
}
.hud-value.bump { animation: bump .35s ease; }
@keyframes bump { 0% { transform: scale(1);} 50% { transform: scale(1.25);} 100% { transform: scale(1);} }

.status-banner {
  font-family: var(--font-display); font-weight: 700;
  letter-spacing: 0.2em; text-transform: uppercase;
  font-size: 13px; color: var(--text-dim);
  margin: 4px 0 14px; min-height: 20px;
}
.status-banner.good { color: var(--good); text-shadow: 0 0 10px rgba(109, 255, 176, 0.6); }
.status-banner.bad { color: var(--bad); text-shadow: 0 0 10px rgba(255, 85, 119, 0.6); }
.status-banner.watch { color: var(--cyan); text-shadow: var(--glow-cyan); }
.status-banner.turn { color: var(--magenta); text-shadow: var(--glow-magenta); }

.game-grid {
  --n: 4;
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  gap: 8px;
  width: min(86vmin, 560px);
  aspect-ratio: 1 / 1;
  margin: 0 auto 18px;
  padding: 12px;
  background: rgba(8, 10, 22, 0.55);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-panel);
}
.tile {
  /* --cr/--cg/--cb: base RGB channels for the tile's bilinear-blended color.
     --cbr/--cbg/--cbb: pre-lifted bright variant for borders/highlights/halos.
     See paletteFor() in js/game.js and docs/plans/v3-bleed-modes-audio.md. */
  --cr: 128; --cg: 128; --cb: 128;
  --cbr: 198; --cbg: 198; --cbb: 198;
  border: 2px solid rgb(var(--cbr) var(--cbg) var(--cbb) / 0.9);
  background:
    radial-gradient(120% 120% at 50% 0%, rgb(var(--cbr) var(--cbg) var(--cbb) / 0.45), transparent 65%),
    rgb(var(--cr) var(--cg) var(--cb) / 0.45);
  border-radius: 10px;
  cursor: pointer; position: relative;
  transition: transform .08s ease, box-shadow .1s ease, background .1s ease, filter .08s ease;
  outline: none;
  box-shadow:
    inset 0 0 0 1px rgb(var(--cbr) var(--cbg) var(--cbb) / 0.35),
    0 0 8px rgb(var(--cr) var(--cg) var(--cb) / 0.45);
}
.tile:hover { filter: brightness(1.25); box-shadow: 0 0 14px rgb(var(--cbr) var(--cbg) var(--cbb) / 0.7); }
.tile:focus-visible { box-shadow: 0 0 0 2px var(--cyan), 0 0 16px rgb(var(--cbr) var(--cbg) var(--cbb) / 0.7); }
/* Active state: every tile flashes in its OWN blended color — brightened, scaled,
   with an inner highlight + outer glow in the tile's RGB. AI/human modifier
   classes layer a cyan/magenta halo ring on top without hiding the color. */
.tile.is-active {
  transform: scale(1.1);
  z-index: 2;
  filter: brightness(1.35) saturate(1.4);
  background:
    radial-gradient(120% 120% at 50% 0%, rgb(255 255 255 / 0.85) 0%, rgb(var(--cbr) var(--cbg) var(--cbb)) 35%, rgb(var(--cr) var(--cg) var(--cb)) 75%),
    rgb(var(--cr) var(--cg) var(--cb));
  border-color: rgb(var(--cbr) var(--cbg) var(--cbb));
  box-shadow:
    inset 0 0 22px rgb(var(--cbr) var(--cbg) var(--cbb) / 0.85),
    0 0 22px rgb(var(--cbr) var(--cbg) var(--cbb) / 0.85),
    0 0 60px rgb(var(--cr) var(--cg) var(--cb) / 0.55);
}
.tile.is-bad { animation: shake .42s ease; box-shadow: 0 0 18px var(--bad), inset 0 0 14px rgba(255, 85, 119, 0.5); }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* During sequence playback: dim non-active tiles hard */
.game-grid.is-showing .tile { filter: brightness(0.25) saturate(0.6); opacity: 0.55; cursor: default; }
.game-grid.is-showing .tile.is-active { filter: brightness(1.7) saturate(1.3); opacity: 1; }

/* AI showing the puzzle — add a CYAN halo ring around the tile, but keep the
   tile's own color visible. Tile fill stays from .tile.is-active above. */
.tile.is-active.is-ai {
  box-shadow:
    inset 0 0 22px rgb(var(--cbr) var(--cbg) var(--cbb) / 0.85),
    0 0 0 3px rgba(174, 246, 255, 0.9),
    0 0 22px rgb(var(--cbr) var(--cbg) var(--cbb) / 0.85),
    0 0 38px var(--cyan),
    0 0 70px rgba(0, 240, 255, 0.45);
}
/* Human input — MAGENTA halo ring, tile color unchanged. */
.tile.is-active.is-human {
  box-shadow:
    inset 0 0 22px rgb(var(--cbr) var(--cbg) var(--cbb) / 0.85),
    0 0 0 3px rgba(255, 208, 243, 0.9),
    0 0 22px rgb(var(--cbr) var(--cbg) var(--cbb) / 0.85),
    0 0 38px var(--magenta),
    0 0 70px rgba(255, 43, 214, 0.45);
}

.result-title {
  font-family: var(--font-display); font-weight: 900;
  font-size: clamp(28px, 5vw, 44px);
  letter-spacing: 0.12em; margin: 8px 0 18px;
  background: linear-gradient(90deg, var(--cyan), var(--magenta));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 12px rgba(0, 240, 255, 0.45));
}
.result-stats { display: grid; grid-template-columns: repeat(2, 1fr); padding: 18px; max-width: 480px; margin: 0 auto 14px; }
.result-stats > div {
  padding: 10px; display: grid; gap: 4px;
  border-right: 1px solid rgba(255,255,255,0.06);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.result-stats > div:nth-child(2n) { border-right: none; }
.result-stats > div:nth-last-child(-n+2) { border-bottom: none; }
.result-stats span { font-size: 10px; letter-spacing: 0.25em; text-transform: uppercase; color: var(--text-dim); }
.result-stats strong {
  font-family: var(--font-display); font-weight: 900; font-size: 22px; color: var(--cyan);
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}
.new-best {
  font-family: var(--font-display); font-weight: 700; letter-spacing: 0.25em;
  text-transform: uppercase; color: var(--magenta);
  text-shadow: var(--glow-magenta); animation: bump .6s ease;
}
.res-cloud { min-height: 1.2em; margin: 6px 0 10px; font-size: 13px; color: var(--text-dim); letter-spacing: 0.06em; }
.res-cloud.ok { color: var(--cyan); text-shadow: 0 0 6px rgba(0,240,255,0.4); }
.res-cloud.err { color: var(--magenta); }
.primary-actions { margin: 14px 0 10px; }
.secondary-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }
.play-actions { margin-top: 6px; }

@media (max-width: 540px) {
  .hud { grid-template-columns: repeat(5, 1fr); }
  .hud-value { font-size: 16px; }
  .game-grid { gap: 6px; padding: 8px; }
}
