/* Reaction trainer. Dark, high-contrast so the red dot is the only thing that matters. Older-Android friendly: no inset, no gap, no custom properties for layout. */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #0b1020; color: #fff; font-family: "Trebuchet MS","Arial Rounded MT Bold","Segoe UI",Arial,sans-serif; font-weight: 900;
  overscroll-behavior: none; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; cursor: default;
}
#app { position: fixed; top: 0; right: 0; bottom: 0; left: 0; overflow: hidden; }
#bg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, #1a2547 0%, #0e1530 55%, #070b18 100%); }
#bg::after { content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: .35;
  background-image: linear-gradient(rgba(120,150,255,.10) 1px, transparent 1px), linear-gradient(90deg, rgba(120,150,255,.10) 1px, transparent 1px); background-size: 6vh 6vh; }
#world, #field, #halves, #wins, #pops { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
#world, #halves, #wins, #pops, .hud, #title, #big, #diag { pointer-events: none; }
#field { touch-action: none; }
body:not([data-state="PLAYING"]) #field { pointer-events: none; }

/* ---------- title + HUD ---------- */
#title { position: absolute; top: 5vh; left: 0; right: 0; text-align: center; transition: opacity .4s; }
#title h1 { margin: 0; font-size: 13vh; line-height: 1.05; letter-spacing: .12em; color: #fff; text-shadow: 0 0 4vh rgba(255,40,40,.9), 0 0 1vh rgba(255,255,255,.6); }
#title p { margin: 1vh 0 0; font-size: 3.4vh; letter-spacing: .35em; color: #ff5a5a; text-shadow: 0 0 2vh rgba(255,40,40,.8); }
body:not([data-state="ATTRACT"]) #title { opacity: 0; }
.hud { position: absolute; opacity: 0; transition: opacity .3s; text-align: center; }
body[data-state="PLAYING"] .hud, body[data-state="VICTORY"] .pbox { opacity: 1; }
.pbox { top: 1.5vh; min-width: 17vw; padding: .6vh 1vw .8vh; border: .5vh solid #38d6ff; border-radius: 2vh; background: rgba(8,14,34,.82); box-shadow: 0 0 2.4vh rgba(56,214,255,.45); }
#p1 { left: .8vw; } #p2 { display: none; right: 6vw; border-color: #ffd24a; box-shadow: 0 0 2.4vh rgba(255,210,74,.45); }
body[data-mode="2"] #p2 { display: block; }
.pbox .lbl { display: block; font-size: 2.2vh; letter-spacing: .25em; color: #8fe6ff; }
#p2 .lbl { color: #ffe08a; }
.pbox .num { display: block; font-size: 8vh; line-height: 1; color: #fff; text-shadow: 0 0 1.6vh #38d6ff; }
#p2 .num { text-shadow: 0 0 1.6vh #ffd24a; }
.pbox .num.bump { animation: bump .2s ease-out; }
@keyframes bump { 0% { transform: scale(1.3); } 100% { transform: scale(1); } }
.pbox .num.hurt { animation: hurt .4s ease-out; }
@keyframes hurt { 0% { transform: translateX(-.8vh); color: #ff4a4a; } 25% { transform: translateX(.8vh); } 50% { transform: translateX(-.5vh); color: #ff4a4a; } 100% { transform: none; } }
.pbox .last { display: block; min-height: 3vh; font-size: 2.6vh; letter-spacing: .08em; color: #cfe3ff; }
#timer { left: 50%; top: 1.5vh; margin-left: -6vw; width: 12vw; padding: .4vh 1vw; border: .5vh solid #fff; border-radius: 2vh; background: rgba(8,14,34,.82); box-shadow: 0 0 2.4vh rgba(255,255,255,.35); font-size: 9vh; line-height: 1.1; color: #fff; }
#timer.low { color: #ff5a5a; border-color: #ff5a5a; animation: pulse .45s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.1); } }

/* ---------- two-player split ---------- */
#halves { display: none; }
body[data-mode="2"][data-state="COUNTDOWN"] #halves, body[data-mode="2"][data-state="PLAYING"] #halves { display: block; }
#halves i { position: absolute; top: 0; height: 100%; display: block; }
#half1 { left: 0; width: 50%; background: linear-gradient(90deg, rgba(56,214,255,.10), rgba(56,214,255,.02)); }
#half2 { left: 50%; width: 50%; background: linear-gradient(270deg, rgba(255,210,74,.10), rgba(255,210,74,.02)); }
#divider { left: 50%; width: .6vh; transform: translateX(-50%); background: linear-gradient(#38d6ff, #fff, #ffd24a); box-shadow: 0 0 3vh #fff; opacity: .8; }

/* ---------- countdown + end screen ---------- */
#big { position: absolute; z-index: 10; left: 50%; top: 52%; transform: translate(-50%,-50%); display: none; max-width: 96vw; text-align: center; white-space: nowrap; }
body[data-state="COUNTDOWN"] #big, body[data-state="VICTORY"] #big { display: block; }
body[data-state="VICTORY"] #big { padding: 2.6vh 4vw 3vh; border: .7vh solid #38d6ff; border-radius: 4vh; background: rgba(6,10,26,.93); box-shadow: 0 0 5vh rgba(56,214,255,.5); }
#big div { display: block; line-height: 1.15; }
#big div:empty { display: none; }
#bigMain { font-size: 26vh; color: #fff; text-shadow: 0 0 5vh rgba(255,40,40,.95), 0 0 1.5vh #fff; }
#bigMain.pop { animation: bigPop .6s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes bigPop { 0% { transform: scale(.2); opacity: 0; } 55% { transform: scale(1.18); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
body[data-state="VICTORY"] #bigMain { font-size: 13vh; color: #ffd24a; text-shadow: 0 0 4vh rgba(255,210,74,.9); }
#bigSub { margin-top: 1.4vh; font-size: 5.6vh; letter-spacing: .06em; color: #8fe6ff; text-shadow: 0 0 2vh rgba(56,214,255,.8); }
#bigScore { margin-top: 2.2vh; font-size: 7.6vh; color: #fff; text-shadow: 0 0 2vh #38d6ff; }
#bigTier { margin-top: 1vh; font-size: 4.6vh; letter-spacing: .14em; color: #ffd24a; text-shadow: 0 0 1.6vh #ff9a00; }
#bigNew { margin-top: 1.6vh; font-size: 5vh; color: #ffd24a; text-shadow: 0 0 2vh #ff3b1c; animation: pulse .5s ease-in-out infinite alternate; }

/* ---------- start screen ---------- */
#menu { position: absolute; left: 0; right: 0; top: 30vh; bottom: 3vh; display: none; flex-direction: column; justify-content: space-evenly; align-items: center; pointer-events: none; }
body[data-state="ATTRACT"] #menu { display: flex; }
#boards { display: flex; justify-content: center; align-items: flex-start; width: 100%; min-height: 0; }
.board { width: 38vw; margin: 0 1vw; padding: .8vh 1.6vw 1vh; border: .5vh solid #38d6ff; border-radius: 2.4vh; background: rgba(8,14,34,.86); box-shadow: 0 0 2.6vh rgba(56,214,255,.4); overflow: hidden; }
.board.bd2 { border-color: #ffd24a; box-shadow: 0 0 2.6vh rgba(255,210,74,.4); }
.board h2 { margin: 0 0 .4vh; text-align: center; font-size: 3.2vh; letter-spacing: .14em; color: #8fe6ff; }
.board.bd2 h2 { color: #ffe08a; }
.board ol { list-style: none; margin: 0; padding: 0; }
.board li { display: flex; justify-content: space-between; align-items: baseline; font-size: 3.1vh; line-height: 1.25; color: #fff; }
.board .rk { width: 4vh; color: #7f93c4; }
.board .in { flex: 1; letter-spacing: .25em; text-align: center; }
.board .sc { min-width: 9vh; text-align: right; color: #ffd24a; }
.board li.first .in, .board li.first .sc { color: #ffd24a; text-shadow: 0 0 1.4vh #ff9a00; }
.board li.me { animation: pulse .45s ease-in-out infinite alternate; text-shadow: 0 0 2vh #38d6ff; }
.board .empty { display: block; text-align: center; color: #7f93c4; font-size: 2.8vh; line-height: 1.5; }
#modes { width: 94vw; text-align: center; white-space: nowrap; pointer-events: none; }
#start, #start2 { display: inline-block; vertical-align: middle; width: 42vw; height: 17vh; margin: 0 1.2vw; padding: 0; border: .9vh solid #38d6ff; border-radius: 4vh; font: inherit; color: #fff; cursor: pointer; touch-action: none; pointer-events: auto;
  background: linear-gradient(#16264f, #0a1230 70%); box-shadow: 0 0 5vh 1vh rgba(56,214,255,.6), inset 0 0 3vh rgba(56,214,255,.3); text-shadow: 0 0 2.4vh #38d6ff; animation: startPulse 1.1s ease-in-out infinite; }
#start2 { border-color: #ffd24a; box-shadow: 0 0 5vh 1vh rgba(255,210,74,.6), inset 0 0 3vh rgba(255,210,74,.3); text-shadow: 0 0 2.4vh #ffd24a; animation-delay: -.55s; }
#start span, #start2 span { display: block; font-size: 8vh; line-height: 1.05; letter-spacing: .05em; }
#start small, #start2 small { display: block; margin-top: .4vh; font-size: 3.2vh; letter-spacing: .3em; color: #ff7a7a; }
@keyframes startPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.04); } }
#start:active, #start2:active { filter: brightness(1.3); }

/* ---------- initials entry ---------- */
#entry { position: absolute; left: 0; right: 0; top: 5vh; text-align: center; display: none; }
body[data-state="ENTRY"] #entry { display: block; }
body[data-state="ENTRY"] #title, body[data-state="ENTRY"] .hud { opacity: 0; }
#entry h2 { margin: 0; font-size: 7.4vh; line-height: 1.15; color: #ffd24a; text-shadow: 0 0 3vh #ff7a2b; }
#entryScore { margin: .6vh 0 0; font-size: 6vh; color: #fff; text-shadow: 0 0 2vh #38d6ff; }
#entrySlots { margin-top: 2vh; }
#entrySlots span { display: inline-block; width: 11vh; height: 13vh; margin: 0 1vw; border: .6vh solid #38d6ff; border-radius: 2vh; background: rgba(8,14,34,.92); font-size: 10vh; line-height: 12vh; color: #fff; text-shadow: 0 0 2vh #38d6ff; box-shadow: 0 0 2vh rgba(56,214,255,.5); }
#entrySlots span.cur { border-color: #ffd24a; box-shadow: 0 0 3vh #ffd24a; }
#entryHint { margin: 1.4vh 0 1vh; font-size: 3.6vh; letter-spacing: .15em; color: #8fe6ff; }
#kbd .row { margin-bottom: 1.2vh; }
#kbd button { display: inline-block; width: 6.4vw; height: 8.6vh; margin: 0 .35vw; padding: 0; font: inherit; font-size: 5vh; color: #fff; background: #16264f; border: .4vh solid #38d6ff; border-radius: 1.4vh; cursor: pointer; touch-action: none; }
#kbd button:active { background: #2a4aa0; }
#kbd button.wide { width: 11vw; }
#kbd button.ok { background: #1f7a2e; border-color: #7dff9a; }

/* ---------- popups + winner effects ---------- */
#pops { overflow: hidden; }
.wpop { position: absolute; font-size: 6vh; color: #fff; text-shadow: 0 0 1.6vh #38d6ff; white-space: nowrap; animation: popUp .8s ease-out forwards; }
.wpop.bad { color: #ff4a4a; text-shadow: 0 0 1.8vh #ff0000; font-size: 6.4vh; }
.wpop small { display: block; font-size: 3.2vh; color: #cfe3ff; text-align: center; }
@keyframes popUp { 0% { transform: translate(-50%,-30%) scale(.5); opacity: 1; } 30% { transform: translate(-50%,-90%) scale(1.15); } 100% { transform: translate(-50%,-190%) scale(1); opacity: 0; } }
#wins { display: none; }
body[data-state="VICTORY"][data-winner] #wins { display: block; }
#wins > div { position: absolute; top: 0; width: 50%; height: 100%; overflow: hidden; display: none; text-align: center; }
#w0 { left: 0; } #w1 { right: 0; }
body[data-winner="0"] #w0, body[data-winner="1"] #w1, body[data-winner="tie"] #w0, body[data-winner="tie"] #w1 { display: block; background: radial-gradient(ellipse at 50% 38%, rgba(255,246,190,.55), rgba(255,200,80,.28) 48%, rgba(255,150,0,.06) 80%); box-shadow: inset 0 0 9vh 2.5vh rgba(255,225,120,.85); animation: winPulse .7s ease-in-out infinite alternate; }
@keyframes winPulse { from { filter: brightness(1); } to { filter: brightness(1.35); } }
#wins > div::before { content: ""; position: absolute; left: 50%; top: 38%; width: 190vh; height: 190vh; margin: -95vh 0 0 -95vh; border-radius: 50%;
  background: repeating-conic-gradient(rgba(255,250,210,.5) 0deg 7deg, rgba(255,250,210,0) 7deg 22deg);
  -webkit-mask-image: radial-gradient(circle, #000 12%, transparent 66%); mask-image: radial-gradient(circle, #000 12%, transparent 66%); animation: raySpin 7s linear infinite; }
@keyframes raySpin { to { transform: rotate(360deg); } }
#wins b { position: absolute; left: 0; right: 0; bottom: 4vh; font-size: 12vh; line-height: 1; color: #fff7c8; -webkit-text-stroke: .8vh #8a4a00; paint-order: stroke fill; text-shadow: 0 0 4vh #ffd34d, 0 0 9vh #ff9a00; animation: winBounce .5s ease-in-out infinite alternate; }
body[data-winner="tie"] #wins b { display: none; }
@keyframes winBounce { from { transform: scale(1); } to { transform: scale(1.1); } }
body[data-winner="0"] #w1, body[data-winner="1"] #w0 { display: block; background: rgba(2,4,14,.65); }
body[data-winner="0"] #w1::before, body[data-winner="1"] #w0::before, body[data-winner="0"] #w1 b, body[data-winner="1"] #w0 b { display: none; }
#diag { position: absolute; left: 1vw; bottom: 1vh; margin: 0; padding: 1vh 1.2vw; font: 700 2vh/1.4 monospace; background: rgba(0,0,0,.7); color: #7dff9e; border-radius: 1vh; z-index: 20; }
#diag[hidden] { display: none; }

/* a miss or a wrong-colour tap briefly locks that player: flash their area so it is clear why */
#field.lock0, #field.lock1 { background: rgba(255,40,40,.12); }
body[data-mode="2"] #field.lock0 { background: linear-gradient(90deg, rgba(255,40,40,.2) 50%, rgba(255,40,40,0) 50%); }
body[data-mode="2"] #field.lock1 { background: linear-gradient(270deg, rgba(255,40,40,.2) 50%, rgba(255,40,40,0) 50%); }

/* Booth-operator full-screen control: unlabeled box, top-right corner. Hidden once full screen. */
#fs { position: absolute; top: 1vh; right: 1vw; width: 4.5vh; height: 4.5vh; padding: 0; margin: 0; background: #8a3fe0; border: .3vh solid #c9a0ff; border-radius: .8vh; opacity: .75; cursor: pointer; touch-action: none; z-index: 6; }
body.is-fs #fs, body.no-fs #fs { display: none; }
