/*
 * Each game's world, on the big screen and the phones. The page sets
 * body[data-game="<game id>"] (src/client/screen.ts, controller.ts); this file
 * re-colours the shared variables, sets the game's display font, and draws its
 * backdrop: CSS gradients and inline SVG only, no image files, so it stays light
 * on a TV browser. Decorations sit in body::before / ::after at z-index -1,
 * behind everything, and never take clicks.
 *
 *   coming-soon, trailer   a cinema: velvet curtains, marquee bulbs, film grain
 *   clue-hai               a detective's desk at night: dark wood, lamp glow, typewriter
 *   tukka, andaaz          a game-show casino: green felt, gold, chips
 *   genzee                 Y2K stickers: neon blobs on deep purple
 *   zindagi (Life)         a board game on a table: tiles, rounded type
 *   guessplore             a road trip: map contours, highway-sign green
 *   tap-race               an arcade: neon grid floor, scanlines, pixel type
 *   sarrey-gamma           a Bollywood stage: spotlights, magenta and gold
 *   twenty-questions       a chalkboard: green slate, chalk dust, scribbled question marks
 *   fast-and-furious       a town at night: asphalt, lane stripes, tail-light red and amber
 */

:root {
  /* Film grain / paper noise, tinted by each theme's opacity. */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n' color-interpolation-filters='sRGB'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --font-display: inherit;
  --frame: rgb(255 255 255 / 0.08);
  --glow: transparent;
}

/* ------------------------------------------------ shared: what makes a screen feel like a game */

body[data-game] { background-attachment: fixed; }
body[data-game]::before,
body[data-game]::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

/* Display type for the big moments. */
body[data-game] h1,
body[data-game] .huge,
body[data-game] .eyebrow,
body[data-game] .tr-title,
body[data-game] .bar-value,
body[data-game] .tr-n {
  font-family: var(--font-display);
}
body[data-game] h1 { text-shadow: 0 3px 0 rgb(0 0 0 / 0.35), 0 0 28px var(--glow); letter-spacing: 0.01em; }
body[data-game] .huge { text-shadow: 0 6px 0 rgb(0 0 0 / 0.35), 0 0 40px var(--glow); }

/* Panels: a frame, a lit top edge and a shadow, like pieces on a board. */
body[data-game] .panel,
body[data-game] details.rules,
body[data-game] .players li,
body[data-game] .player-grid li,
body[data-game] .tr-players li,
body[data-game] .tr-guess,
body[data-game] .cs-guess,
body[data-game] .gz-performer,
body[data-game] .zg-card,
body[data-game] .gp-board li,
body[data-game] .gp-scores li,
body[data-game] .sg-card,
body[data-game] .aa-card,
body[data-game] .sentences li {
  border: 1px solid var(--frame);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.08), 0 6px 18px rgb(0 0 0 / 0.35);
  backdrop-filter: blur(2px);
}

/* Buttons on the phones: chunky, with a pressed state. */
body[data-game].controller button.primary {
  font-family: var(--font-display);
  letter-spacing: 0.02em;
  box-shadow: 0 5px 0 rgb(0 0 0 / 0.35), 0 0 22px var(--glow);
  transition: transform 0.06s, box-shadow 0.06s;
}
body[data-game].controller button.primary:active { transform: translateY(4px); box-shadow: 0 1px 0 rgb(0 0 0 / 0.35); }

@media (prefers-reduced-motion: reduce) {
  body[data-game]::before, body[data-game]::after { animation: none !important; }
}

/* ------------------------------------------------ the cinema: Coming Soon…, Trailer */

body[data-game="coming-soon"],
body[data-game="trailer"] {
  --bg: #14040a;
  --surface: rgb(46 10 20 / 0.82);
  --surface-2: rgb(84 22 36 / 0.9);
  --text: #fbf1e3;
  --muted: #d6b9a5;
  --accent: #f6c445;
  --accent-ink: #2a1600;
  --frame: rgb(246 196 69 / 0.28);
  --glow: rgb(246 196 69 / 0.35);
  --font-display: "Limelight", Georgia, serif;
  background:
    radial-gradient(ellipse 70% 55% at 50% -8%, rgb(255 214 150 / 0.1), transparent 70%),
    radial-gradient(ellipse 120% 80% at 50% 120%, rgb(0 0 0 / 0.7), transparent 60%),
    #14040a;
}
/* The curtains, drawn back to each side, and the film grain over them. */
body[data-game="coming-soon"]::before,
body[data-game="trailer"]::before {
  background:
    var(--grain),
    linear-gradient(180deg, rgb(0 0 0 / 0.2), transparent 25%, transparent 80%, rgb(0 0 0 / 0.45)),
    linear-gradient(90deg, rgb(0 0 0 / 0.65) 0, transparent 2vw) 5.4vw 0 / 3vw 100% no-repeat,
    linear-gradient(270deg, rgb(0 0 0 / 0.65) 0, transparent 2vw) calc(100% - 5.4vw) 0 / 3vw 100% no-repeat,
    repeating-linear-gradient(90deg, #4a0716 0, #9a1530 0.7vw, #d8344f 1.1vw, #9a1530 1.5vw, #4a0716 2.2vw) left / 6.5vw 100% no-repeat,
    repeating-linear-gradient(90deg, #4a0716 0, #9a1530 0.7vw, #d8344f 1.1vw, #9a1530 1.5vw, #4a0716 2.2vw) right / 6.5vw 100% no-repeat;
}
/* Marquee bulbs along the top, twinkling. */
body[data-game="coming-soon"]::after,
body[data-game="trailer"]::after {
  inset: 0 0 auto 0;
  height: 18px;
  background:
    radial-gradient(circle at 50% 50%, #fff6d0 0 3px, #f6c445 4px, rgb(246 196 69 / 0.25) 6px, transparent 8px) 0 0 / 28px 18px repeat-x,
    linear-gradient(#3a0912, #24050b);
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.6);
  animation: marquee-twinkle 1.6s steps(2) infinite;
}
@keyframes marquee-twinkle { 50% { filter: brightness(0.7) saturate(0.8); } }
body[data-game="coming-soon"].screen .view,
body[data-game="trailer"].screen .view { padding-left: 6vw; padding-right: 6vw; }

/* The card backs and faces get a gilt edge. */
body[data-game="trailer"] .tr-face,
body[data-game="trailer"] .tr-back { box-shadow: 0 0 0 2px rgb(246 196 69 / 0.35), 0 10px 24px rgb(0 0 0 / 0.5); }

/* ------------------------------------------------ the detective's desk: Kya Clue Hai! */

body[data-game="clue-hai"] {
  --bg: #1a120b;
  --surface: rgb(38 27 17 / 0.86);
  --surface-2: rgb(64 45 27 / 0.92);
  --text: #f5ead6;
  --muted: #c4ae8c;
  --accent: #ff9933;
  --accent-ink: #2a1300;
  --frame: rgb(255 214 160 / 0.18);
  --glow: rgb(255 153 51 / 0.3);
  --font-display: "Special Elite", "Courier New", monospace;
  background:
    radial-gradient(ellipse 55% 45% at 18% 8%, rgb(255 196 110 / 0.22), transparent 70%),
    radial-gradient(ellipse 100% 70% at 50% 110%, rgb(0 0 0 / 0.65), transparent 60%),
    #1a120b;
}
/* A desk of dark planks: a seam every plank, soft grain streaks along them, the lamp's pool of light. */
body[data-game="clue-hai"]::before {
  background:
    radial-gradient(ellipse 60% 50% at 20% 10%, rgb(255 190 100 / 0.18), transparent 70%),
    repeating-linear-gradient(0deg, rgb(0 0 0 / 0.55) 0 2px, transparent 2px 140px),
    repeating-linear-gradient(0deg, transparent 0 17px, rgb(255 220 170 / 0.035) 17px 19px, transparent 19px 41px, rgb(0 0 0 / 0.08) 41px 43px, transparent 43px 70px),
    linear-gradient(90deg, #3b2414, #4a2e18 20%, #3a2313 45%, #4d3019 70%, #3b2414);
}
/* The lamp's edge: the far corners fall into shadow. */
body[data-game="clue-hai"]::after {
  background: radial-gradient(ellipse 110% 90% at 30% 20%, transparent 55%, rgb(0 0 0 / 0.55));
}

/* ------------------------------------------------ the game-show casino: Tukka! */

body[data-game="tukka"],
body[data-game="andaaz"] {
  --bg: #062416;
  --surface: rgb(5 40 24 / 0.84);
  --surface-2: rgb(12 66 40 / 0.92);
  --text: #f3fbf1;
  --muted: #a6d2b5;
  --accent: #ffd34d;
  --accent-ink: #2a1e00;
  --frame: rgb(255 211 77 / 0.3);
  --glow: rgb(255 211 77 / 0.35);
  --font-display: "Bungee", Impact, sans-serif;
  background:
    radial-gradient(ellipse 70% 60% at 50% 40%, #11603a, #073b23 60%, #031a0f),
    #062416;
}
/* The felt, and the table's padded rail around the edge. */
body[data-game="tukka"]::before,
body[data-game="andaaz"]::before {
  background: var(--grain);
  opacity: 0.35;
  box-shadow: inset 0 0 0 10px #3b1d0c, inset 0 0 0 13px #c9a34a, inset 0 0 60px 20px rgb(0 0 0 / 0.55);
}
/* Chips stacked in two corners. */
body[data-game="tukka"]::after,
body[data-game="andaaz"]::after {
  background:
    radial-gradient(circle, #fff 0 4px, #d62c2c 5px 15px, #fff 16px 18px, #d62c2c 19px 24px, transparent 25px) calc(100% - 30px) calc(100% - 30px) / 50px 50px no-repeat,
    radial-gradient(circle, #fff 0 4px, #1f5fd6 5px 15px, #fff 16px 18px, #1f5fd6 19px 24px, transparent 25px) calc(100% - 70px) calc(100% - 22px) / 50px 50px no-repeat,
    radial-gradient(circle, #fff 0 4px, #111 5px 15px, #ffd34d 16px 18px, #111 19px 24px, transparent 25px) 26px calc(100% - 26px) / 50px 50px no-repeat;
}

/* ------------------------------------------------ Y2K stickers: GenZee */

body[data-game="genzee"] {
  --bg: #170828;
  --surface: rgb(38 14 66 / 0.82);
  --surface-2: rgb(70 26 112 / 0.9);
  --text: #fdf4ff;
  --muted: #d3b5ef;
  --accent: #ff4fd8;
  --accent-ink: #2b0024;
  --frame: rgb(255 255 255 / 0.22);
  --glow: rgb(255 79 216 / 0.45);
  --font-display: "Luckiest Guy", "Arial Black", sans-serif;
  background: #170828;
}
body[data-game="genzee"]::before {
  background:
    radial-gradient(circle at 12% 18%, rgb(255 79 216 / 0.55), transparent 22%),
    radial-gradient(circle at 88% 22%, rgb(56 230 255 / 0.45), transparent 24%),
    radial-gradient(circle at 78% 88%, rgb(255 214 10 / 0.35), transparent 22%),
    radial-gradient(circle at 18% 86%, rgb(120 255 160 / 0.3), transparent 20%);
  filter: blur(30px);
  animation: blobs 18s ease-in-out infinite alternate;
}
/* A dotted halftone over it, like a sticker sheet. */
body[data-game="genzee"]::after {
  background: radial-gradient(rgb(255 255 255 / 0.09) 1.5px, transparent 2px) 0 0 / 22px 22px;
}
@keyframes blobs { to { transform: translate(2vw, -2vh) scale(1.06) rotate(3deg); } }
body[data-game="genzee"] h1 { -webkit-text-stroke: 2px rgb(0 0 0 / 0.35); }

/* ------------------------------------------------ the board game: Life */

body[data-game="zindagi"] {
  --bg: #10303a;
  --surface: rgb(16 50 60 / 0.86);
  --surface-2: rgb(28 78 92 / 0.92);
  --text: #f4fbfc;
  --muted: #a9cdd4;
  --accent: #a3e635;
  --accent-ink: #172500;
  --frame: rgb(255 255 255 / 0.16);
  --glow: rgb(163 230 53 / 0.3);
  --font-display: "Fredoka", "Trebuchet MS", sans-serif;
  background: radial-gradient(ellipse 80% 70% at 50% 45%, #1a4b58, #0b2129);
}
/* The board's track of coloured squares round the edge of the table. */
body[data-game="zindagi"]::before {
  --sq: 34px;
  background:
    repeating-linear-gradient(90deg, #ef4444 0 var(--sq), #f59e0b 0 calc(var(--sq) * 2), #22c55e 0 calc(var(--sq) * 3), #3b82f6 0 calc(var(--sq) * 4), #a855f7 0 calc(var(--sq) * 5)) top / 100% 12px no-repeat,
    repeating-linear-gradient(90deg, #3b82f6 0 var(--sq), #a855f7 0 calc(var(--sq) * 2), #ef4444 0 calc(var(--sq) * 3), #f59e0b 0 calc(var(--sq) * 4), #22c55e 0 calc(var(--sq) * 5)) bottom / 100% 12px no-repeat;
  opacity: 0.85;
}
body[data-game="zindagi"]::after { background: var(--grain); opacity: 0.18; }

/* ------------------------------------------------ the road trip: Guessplore */

body[data-game="guessplore"] {
  --bg: #0d1c17;
  --surface: rgb(14 36 29 / 0.86);
  --surface-2: rgb(24 60 47 / 0.92);
  --text: #f1f8f3;
  --muted: #a8c7b6;
  --accent: #ffd60a;
  --accent-ink: #221c00;
  --frame: rgb(255 255 255 / 0.2);
  --glow: rgb(255 214 10 / 0.25);
  --font-display: "Oswald", "Arial Narrow", sans-serif;
  background: radial-gradient(ellipse 90% 80% at 40% 30%, #16332a, #08130f);
}
/* Contour lines, as on a relief map. */
body[data-game="guessplore"]::before {
  background:
    repeating-radial-gradient(circle at 20% 30%, transparent 0 22px, rgb(160 220 180 / 0.07) 23px 24px),
    repeating-radial-gradient(circle at 80% 75%, transparent 0 28px, rgb(160 220 180 / 0.06) 29px 30px);
}
/* A highway centre line along the bottom. */
body[data-game="guessplore"]::after {
  inset: auto 0 0 0;
  height: 10px;
  background: repeating-linear-gradient(90deg, #ffd60a 0 46px, transparent 46px 80px), #2a2f2c;
}
body[data-game="guessplore"] h1, body[data-game="guessplore"] .eyebrow { text-transform: uppercase; }

/* ------------------------------------------------ the arcade: Tap Race */

body[data-game="tap-race"] {
  --bg: #07021a;
  --surface: rgb(20 8 48 / 0.84);
  --surface-2: rgb(40 16 88 / 0.9);
  --text: #f5f0ff;
  --muted: #b8a8ee;
  --accent: #f472b6;
  --accent-ink: #2a0016;
  --frame: rgb(244 114 182 / 0.45);
  --glow: rgb(244 114 182 / 0.55);
  --font-display: "Press Start 2P", "Courier New", monospace;
  background: linear-gradient(#07021a 55%, #2a0a4a);
}
/* A neon grid floor running to the horizon. */
body[data-game="tap-race"]::before {
  inset: 55% -50% -10% -50%;
  background:
    linear-gradient(rgb(56 230 255 / 0.55) 2px, transparent 2px) 0 0 / 100% 40px,
    linear-gradient(90deg, rgb(244 114 182 / 0.55) 2px, transparent 2px) 0 0 / 60px 100%;
  transform: perspective(300px) rotateX(60deg);
  transform-origin: top;
  animation: grid-run 1.2s linear infinite;
}
@keyframes grid-run { to { background-position: 0 40px, 0 0; } }
/* Scanlines over everything. */
body[data-game="tap-race"]::after {
  background: repeating-linear-gradient(rgb(0 0 0 / 0.18) 0 1px, transparent 1px 3px);
  z-index: 50;
}
body[data-game="tap-race"] h1 { font-size: clamp(1.6rem, 4vw, 3.4rem); line-height: 1.3; }

/* ------------------------------------------------ the Bollywood stage: Sarrey Gamma */

body[data-game="sarrey-gamma"] {
  --bg: #1a0620;
  --surface: rgb(48 10 52 / 0.84);
  --surface-2: rgb(84 18 86 / 0.9);
  --text: #fff3fb;
  --muted: #e0b4d8;
  --accent: #ffc23d;
  --accent-ink: #2a1600;
  --frame: rgb(255 61 139 / 0.35);
  --glow: rgb(255 61 139 / 0.45);
  --font-display: "Righteous", "Trebuchet MS", sans-serif;
  background: radial-gradient(ellipse 90% 70% at 50% 100%, #4a0d4e, #1a0620 70%);
}
/* Two spotlights sweeping the stage. */
body[data-game="sarrey-gamma"]::before {
  background:
    conic-gradient(from 160deg at 15% -5%, transparent 0deg, rgb(255 220 150 / 0.18) 12deg, transparent 26deg),
    conic-gradient(from 175deg at 85% -5%, transparent 0deg, rgb(255 120 200 / 0.18) 12deg, transparent 26deg);
  animation: spot-sweep 7s ease-in-out infinite alternate;
}
@keyframes spot-sweep { to { transform: skewX(6deg); } }
body[data-game="sarrey-gamma"]::after { background: radial-gradient(rgb(255 194 61 / 0.18) 1px, transparent 1.5px) 0 0 / 30px 30px; }

/* ------------------------------------------------ the chalkboard: 21 Questions */

body[data-game="twenty-questions"] {
  --bg: #0f2a22;
  --surface: rgb(12 40 32 / 0.86);
  --surface-2: rgb(24 64 50 / 0.92);
  --text: #f4f7ef;
  --muted: #b9d0c2;
  --accent: #ffe066;
  --accent-ink: #2a2200;
  --frame: rgb(255 255 255 / 0.22);
  --glow: rgb(255 224 102 / 0.3);
  --font-display: "Patrick Hand", "Comic Sans MS", cursive;
  background: radial-gradient(ellipse 120% 90% at 50% 40%, #1f4a3b, #0f2a22 75%);
}
/* Chalk question marks scribbled across the board, smudged by the eraser. */
body[data-game="twenty-questions"]::before {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='420' height='300'%3E%3Cg fill='none' stroke='%23fff' stroke-opacity='.09' stroke-width='5' stroke-linecap='round'%3E%3Cpath d='M40 70q0-30 30-30t30 30q0 20-30 30v20'/%3E%3Cpath d='M300 200q0-24 24-24t24 24q0 16-24 24v16'/%3E%3Cpath d='M230 40q0-18 18-18t18 18q0 12-18 18v12' stroke-opacity='.06'/%3E%3C/g%3E%3Cg fill='%23fff' fill-opacity='.09'%3E%3Ccircle cx='70' cy='140' r='4'/%3E%3Ccircle cx='324' cy='258' r='3.5'/%3E%3Ccircle cx='248' cy='86' r='3' fill-opacity='.06'/%3E%3C/g%3E%3C/svg%3E") 0 0 / 420px 300px,
    linear-gradient(100deg, transparent 20%, rgb(255 255 255 / 0.04) 30%, transparent 45%),
    var(--grain);
}
/* A wooden frame around the board. */
body[data-game="twenty-questions"]::after { box-shadow: inset 0 0 0 14px #5a3a1e, inset 0 0 0 18px rgb(0 0 0 / 0.35), inset 0 0 120px rgb(0 0 0 / 0.5); }

/* ------------------------------------------------ phones: the same worlds, quieter */

body.controller[data-game]::before { opacity: 0.6; }
body.controller[data-game="coming-soon"]::before,
body.controller[data-game="trailer"]::before { background: var(--grain); opacity: 0.25; }
body.controller[data-game="tukka"]::after,
body.controller[data-game="andaaz"]::after,
body.controller[data-game="clue-hai"]::after { display: none; }
body.controller[data-game="tap-race"]::after { opacity: 0.5; }
body.controller[data-game="twenty-questions"]::after { box-shadow: inset 0 0 0 6px #5a3a1e; }

/* ------------------------------------------------ Fast and Curious: a town at night */
body[data-game="fast-and-furious"] {
  --bg: #11131a;
  --surface: rgb(26 30 40 / 0.9);
  --surface-2: rgb(40 46 60 / 0.94);
  --text: #f4f6fb;
  --muted: #a3abbd;
  --accent: #ffd60a;
  --accent-ink: #1a1500;
  --frame: rgb(255 214 10 / 0.25);
  --glow: rgb(255 59 59 / 0.35);
  --font-display: "Arial Black", "Helvetica Neue", system-ui, sans-serif;
  background: radial-gradient(ellipse 120% 90% at 50% 30%, #1d2230, #0b0d12 75%);
}
/* Lane stripes running across the asphalt. */
body[data-game="fast-and-furious"]::before {
  background:
    repeating-linear-gradient(90deg, rgb(255 214 10 / 0.07) 0 60px, transparent 60px 120px) 0 30% / 100% 6px no-repeat,
    repeating-linear-gradient(90deg, rgb(255 255 255 / 0.05) 0 60px, transparent 60px 120px) 0 70% / 100% 6px no-repeat,
    var(--grain);
}
body[data-game="fast-and-furious"]::after {
  background: radial-gradient(circle at 8% 100%, rgb(255 59 59 / 0.18), transparent 35%), radial-gradient(circle at 92% 0%, rgb(255 214 10 / 0.12), transparent 35%);
}
