:root {
  color-scheme: dark;
  font-family: "Trebuchet MS", system-ui, sans-serif;
  color: #f7eaff;
  background: #210631;
  --u: min(calc(100vw / 390), calc(100svh / 844), 1.1px);
}
* { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(ellipse at 50% 30%, #67238a, #210631 70%); }
button { font: inherit; }
main { width: calc(390 * var(--u)); margin: 0 auto; }
a { color: #ffef78; }
#pg-scene {
  position: relative;
  width: 100%;
  height: calc(844 * var(--u));
  background: url('../assets/play/pulsegrid/backdrop.webp') center / 100% 100% no-repeat;
  isolation: isolate;
  box-shadow: 0 0 80px #17022499;
}
.back { position: absolute; top: calc(14 * var(--u)); left: calc(16 * var(--u)); font-size: calc(11 * var(--u)); text-decoration: none; }
.eyebrow { position: absolute; right: calc(14 * var(--u)); top: calc(17 * var(--u)); font-size: calc(8 * var(--u)); text-transform: uppercase; letter-spacing: 1px; color: #f1cfff; }
h1 { position: absolute; margin: 0; top: calc(35 * var(--u)); left: calc(12 * var(--u)); width: calc(366 * var(--u)); line-height: 0; }
h1 img { display: block; width: 100%; height: auto; filter: drop-shadow(0 7px 5px #21043199); }
#pg-stage { position: absolute; left: calc(12 * var(--u)); top: calc(108 * var(--u)); width: calc(366 * var(--u)); height: calc(712 * var(--u)); touch-action: none; }
.stats { display: grid; grid-template-columns: 1fr 1.3fr 1fr; gap: calc(4 * var(--u)); height: calc(55 * var(--u)); }
.chip { display: flex; align-items: center; justify-content: center; gap: calc(4 * var(--u)); background: url('../assets/play/pulsegrid/display.webp') center / 100% 100% no-repeat; border-radius: calc(13 * var(--u)); padding: calc(5 * var(--u)); text-align: center; font-size: calc(10.5 * var(--u)); text-transform: uppercase; font-weight: bold; color: #f1d2ff; }
.chip strong { color: #fff16c; font-size: calc(23 * var(--u)); line-height: 1; font-variant-numeric: tabular-nums; text-shadow: 0 0 8px #ffe51955; }
.chip.you { color: #87fff1; }
.chip.computer { color: #ffce81; }
.clock { position: absolute; top: calc(65 * var(--u)); left: 0; width: 100%; height: calc(46 * var(--u)); background: url('../assets/play/pulsegrid/clock.webp') center / 100% 100% no-repeat; border-radius: calc(15 * var(--u)); }
#pg-clock-label { position: absolute; top: calc(51 * var(--u)); left: 0; right: 0; text-align: center; color: #f8e8ff; font-size: calc(10 * var(--u)); text-shadow: 0 1px 3px #260234; }
#pg-time { position: absolute; top: calc(8 * var(--u)); left: calc(37 * var(--u)); font-family: ui-monospace, Consolas, monospace; font-size: calc(23 * var(--u)); color: #fff230; letter-spacing: -1px; text-shadow: 0 0 9px #ffee2266; }
.track { position: absolute; top: calc(79 * var(--u)); left: calc(130 * var(--u)); right: calc(34 * var(--u)); height: calc(18 * var(--u)); background: #260533; border-radius: 5px; padding: 1px; box-shadow: inset 0 1px 4px #100019, 0 0 6px #ffe72f55; overflow: hidden; }
#pg-bar { width: 100%; height: 100%; background: repeating-linear-gradient(105deg, #fff24a 0 10px, #ffe700 10px 13px, #4d2053 13px 15px); border-radius: 3px; }
.clock.urgent { border-color: #ffbd70; }
.clock.urgent #pg-time { color: #ffbf7f; }
#pg-status { position: absolute; left: calc(9 * var(--u)); right: calc(9 * var(--u)); top: calc(135 * var(--u)); height: calc(49 * var(--u)); margin: 0; padding: calc(6 * var(--u)) calc(15 * var(--u)); display: flex; align-items: center; justify-content: center; text-align: center; color: #fff6a1; font-size: calc(13 * var(--u)); font-weight: 700; line-height: 1.4; border: calc(2 * var(--u)) solid #ba61e7; border-radius: calc(20 * var(--u)); background: linear-gradient(#3d0d54, #260636); box-shadow: 0 4px 0 #3b0b4d, 0 0 0 calc(5 * var(--u)) #7c259d, inset 0 2px 3px #14001f; }
[data-phase="computer"] #pg-status { color: #ffd39a; }
.board-wrap { position: absolute; top: calc(192 * var(--u)); width: 100%; height: calc(412 * var(--u)); border-radius: calc(22 * var(--u)); background: url('../assets/play/pulsegrid/console.webp') center / 100% 100% no-repeat; filter: drop-shadow(0 8px 8px #240132aa); }
#pg-board { position: absolute; top: 8.9%; left: 10.55%; width: 82.8%; height: 82.15%; display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); grid-template-rows: repeat(6,minmax(0,1fr)); gap: calc(2 * var(--u)); touch-action: none; }
.cell { position: relative; min-width: 0; min-height: 0; border: 0; border-radius: calc(8 * var(--u)); background: url('../assets/play/pulsegrid/tile-empty.webp') center / 100% 100% no-repeat; padding: 0; color: #fff; cursor: pointer; touch-action: none; }
.cell.relay { background-image: url('../assets/play/pulsegrid/tile-relay.webp'); }
.cell.you { background-image: url('../assets/play/pulsegrid/tile-you.webp'); }
.cell.computer { background-image: url('../assets/play/pulsegrid/tile-computer.webp'); }
.owner { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding-bottom: calc(4 * var(--u)); font-weight: 900; font-size: calc(27 * var(--u)); text-shadow: 0 2px 1px #260d3255, 0 3px 1px #260d3233; pointer-events: none; }
.cell small { position: absolute; right: calc(4 * var(--u)); bottom: calc(3 * var(--u)); font-size: calc(9 * var(--u)); line-height: 1; font-weight: 800; color: white; text-shadow: 0 1px 2px #341338; pointer-events: none; }
.cell.home .owner { padding-bottom: calc(11 * var(--u)); }
.cell.home small { left: 0; right: 0; bottom: calc(4 * var(--u)); font-size: calc(18 * var(--u)); }
.cell.legal { outline: calc(2 * var(--u)) solid #29f5d5; outline-offset: calc(-2 * var(--u)); box-shadow: 0 0 calc(7 * var(--u)) #11f4cf; }
.cell.hint { outline: calc(3 * var(--u)) solid #fff126; outline-offset: calc(-3 * var(--u)); box-shadow: 0 0 calc(12 * var(--u)) #ffee00; }
.cell.last::after { content: ''; position: absolute; left: calc(5 * var(--u)); top: calc(5 * var(--u)); width: calc(4 * var(--u)); height: calc(4 * var(--u)); border-radius: 50%; background: #fff; box-shadow: 0 0 3px #fff; pointer-events: none; }
.cell:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid #fff76b; outline-offset: 2px; z-index: 1; }
.legend { position: absolute; top: calc(609 * var(--u)); left: calc(12 * var(--u)); right: calc(12 * var(--u)); min-height: calc(33 * var(--u)); padding: calc(3 * var(--u)) calc(5 * var(--u)); border: 1px solid #ab51c7; border-radius: calc(16 * var(--u)); background: #350c47ed; display: flex; justify-content: center; gap: calc(2 * var(--u)) calc(14 * var(--u)); flex-wrap: wrap; font-size: calc(11 * var(--u)); color: #ffedb2; text-shadow: 0 1px 3px #22002e; }
.legend span:first-child { flex-basis: 100%; text-align: center; font-weight: bold; }
.legend b { color: #64ffe3; }
.controls { position: absolute; top: calc(647 * var(--u)); width: 100%; display: grid; grid-template-columns: 1.28fr 1.15fr 1fr; gap: calc(5 * var(--u)); }
.controls button, #pg-again { height: calc(63 * var(--u)); border: 0; border-radius: calc(20 * var(--u)); padding: calc(4 * var(--u)) calc(6 * var(--u)) calc(9 * var(--u)); color: #fff0ff; background: url('../assets/play/pulsegrid/button-violet.webp') center / 100% 100% no-repeat; text-transform: uppercase; font-family: "Arial Black", system-ui, sans-serif; font-size: calc(14 * var(--u)); font-weight: 900; text-shadow: 0 2px 2px #45055a; cursor: pointer; }
#pg-go, #pg-again { color: #410862; background-image: url('../assets/play/pulsegrid/button-yellow.webp'); text-shadow: 0 1px #fff587; font-size: calc(21 * var(--u)); }
#pg-sound { font-size: calc(10 * var(--u)); }
button:disabled { cursor: default; filter: saturate(.45) brightness(.75); }
#pg-over { position: absolute; inset: 9% 7% 9% 10.5%; display: flex; align-items: center; justify-content: center; padding: calc(22 * var(--u)); border-radius: calc(15 * var(--u)); background: #260a3aee; text-align: center; border: 2px solid #d998fc; box-shadow: inset 0 0 35px #7d29a366; }
#pg-over[hidden] { display: none; }
#pg-over h2 { margin: 0 0 12px; font-size: calc(28 * var(--u)); color: #f3d4ff; }
#pg-over p { font-size: calc(14 * var(--u)); line-height: 1.6; }
#pg-again { width: calc(185 * var(--u)); margin-top: 8px; font-size: calc(17 * var(--u)); }
[data-outcome="win"] #pg-over { border-color: #6cffe1; }
[data-outcome="win"] #pg-result { color: #6cffe1; }
[data-outcome="loss"] #pg-over { border-color: #ffd18b; }
[data-outcome="loss"] #pg-result { color: #ffd18b; }
.guide, .rules { background: #250d33; padding: 18px 22px; }
.subtitle { font-size: 14px; color: #f5e3ff; line-height: 1.6; margin: 0 0 12px; }
.keys, .foot { font-size: 11px; color: #d3b4e0; line-height: 1.7; margin: 0; }
.rules { border-top: 1px solid #67407c; padding-top: 4px; padding-bottom: 28px; }
.rules h2 { font-size: 19px; color: #fff08b; }
.rules ul { padding-left: 18px; font-size: 13px; line-height: 1.7; color: #ead6f3; }
.rules li { margin: 10px 0; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; } }
