/* AR Carnival — Powered by Trickavu */
:root {
  --navy: #1f2a44; --navy2: #141b2e; --coral: #e86d63; --red: #d8272f;
  --gold: #f2b632; --cream: #fff6e9; --teal: #2bb3a3; --ink: #1b1b1f;
  --font: "Trebuchet MS", "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--navy2); color: var(--cream); font-family: var(--font); }
body { overscroll-behavior: none; touch-action: none; user-select: none; -webkit-user-select: none; }
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

#app { position: fixed; inset: 0; }
.screen { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; padding: max(24px, env(safe-area-inset-top)) 20px 70px; overflow-y: auto; touch-action: pan-y; }
.screen.active { display: flex; }
#home, #pick, #end {
  background:
    radial-gradient(ellipse at 50% -10%, rgba(242,182,50,.25), transparent 60%),
    repeating-linear-gradient(90deg, #1f2a44 0 46px, #19233a 46px 92px);
}

/* ---------- marquee sign ---------- */
.sign { position: relative; margin: 4vh auto 26px; padding: 26px 30px 22px; text-align: center; background: var(--coral); border-radius: 22px; box-shadow: 0 10px 0 #b8473f, 0 24px 40px rgba(0,0,0,.35); max-width: 460px; width: 100%; }
.bulbs { position: absolute; inset: 8px; border-radius: 16px; pointer-events: none;
  background:
    radial-gradient(circle, #fff7c2 0 4px, transparent 5px) 0 0 / 26px 26px repeat-x,
    radial-gradient(circle, #fff7c2 0 4px, transparent 5px) 13px 100% / 26px 26px repeat-x;
  animation: blink 1.2s steps(2) infinite; }
@keyframes blink { 50% { filter: brightness(.55); } }
.eyebrow { margin: 10px 0 0; letter-spacing: .25em; text-transform: uppercase; font-size: 12px; font-weight: 700; opacity: .9; }
.logo { margin: 4px 0 6px; font-size: clamp(42px, 13vw, 66px); line-height: .95; font-weight: 900; letter-spacing: .02em; text-shadow: 0 4px 0 #b8473f; }
.logo .ar { display: inline-block; background: var(--gold); color: var(--navy); border-radius: 12px; padding: 0 10px; margin-right: 10px; text-shadow: none; transform: rotate(-4deg); }
.tag { margin: 0 0 6px; font-size: 15px; opacity: .95; }

.panel { width: 100%; max-width: 420px; background: var(--cream); color: var(--ink); border-radius: 18px; padding: 22px; box-shadow: 0 16px 30px rgba(0,0,0,.3); }
.panel label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 14px; color: var(--navy); }
.panel .opt { font-weight: 400; opacity: .6; }
.panel input { display: block; width: 100%; margin-top: 6px; padding: 14px 14px; font-size: 18px; font-family: inherit; border: 2px solid #e3d6c0; border-radius: 12px; background: #fff; color: var(--ink); user-select: text; -webkit-user-select: text; }
.panel input:focus { outline: none; border-color: var(--coral); }

.btn { display: inline-block; border: 0; border-radius: 14px; padding: 14px 22px; font-size: 17px; font-weight: 800; color: #fff; background: var(--coral); box-shadow: 0 5px 0 #b8473f; transition: transform .08s; }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #b8473f; }
.btn.big { width: 100%; font-size: 20px; padding: 16px; letter-spacing: .02em; }
.btn.ghost { background: transparent; color: var(--navy); box-shadow: inset 0 0 0 2px var(--navy); }
.link { background: none; border: 0; color: var(--cream); opacity: .7; text-decoration: underline; margin-top: 14px; font-size: 14px; }

/* ---------- pick ---------- */
.pick-title { font-size: 24px; margin: 3vh 0 16px; text-align: center; }
.pick-title span { color: var(--gold); }
.cards { width: 100%; max-width: 520px; display: grid; gap: 14px; }
.card { display: flex; align-items: center; gap: 14px; text-align: left; border: 0; border-radius: 18px; padding: 14px; background: var(--cream); color: var(--ink); box-shadow: 0 6px 0 #d9c9ab; transition: transform .08s; }
.card:active { transform: translateY(4px); box-shadow: 0 2px 0 #d9c9ab; }
.card .art { flex: 0 0 104px; height: 74px; background: #f3e6cf; border-radius: 12px; display: grid; place-items: center; }
.card .art svg { width: 96px; height: 64px; }
.card h3 { margin: 0 0 4px; font-size: 20px; color: var(--navy); }
.card p { margin: 0 0 8px; font-size: 13px; line-height: 1.35; color: #4a4a55; }
.chip { display: inline-block; font-size: 12px; font-weight: 700; color: #fff; background: var(--teal); padding: 3px 9px; border-radius: 99px; }
.mode { margin-top: 20px; display: flex; background: rgba(0,0,0,.25); border-radius: 99px; padding: 4px; }
.mode button { border: 0; background: transparent; color: var(--cream); padding: 10px 16px; border-radius: 99px; font-weight: 700; font-size: 14px; }
.mode button.on { background: var(--gold); color: var(--navy); }
.mode-note { font-size: 13px; opacity: .75; text-align: center; max-width: 360px; margin: 10px 0 0; }

/* ---------- play ---------- */
#play { padding: 0; overflow: hidden; touch-action: none; }
body.mode-screen #play { background: radial-gradient(ellipse at 50% 0%, #3b4a74, #141b2e 70%); }
#viewport { position: absolute; inset: 0; overflow: hidden; }
#viewport .camvideo { position: absolute; object-fit: fill; }
#viewport .gl { position: absolute; }
#touch { position: absolute; inset: 0; z-index: 5; touch-action: none; }
.hud-top { position: absolute; z-index: 6; top: max(12px, env(safe-area-inset-top)); left: 12px; right: 12px; display: flex; gap: 8px; align-items: center; pointer-events: none; }
.pill { background: rgba(20,27,46,.82); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border-radius: 99px; padding: 9px 15px; font-weight: 800; font-size: 15px; }
.pill.score { margin-left: auto; background: var(--gold); color: var(--navy); font-size: 22px; padding: 5px 16px; }
.pill.score small { font-size: 12px; margin-left: 4px; }
.pill.score.bump { animation: bump .45s; }
@keyframes bump { 30% { transform: scale(1.25); } }
.quit { pointer-events: auto; width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(20,27,46,.82); color: #fff; font-size: 18px; }
.throws { position: absolute; z-index: 6; top: calc(max(12px, env(safe-area-inset-top)) + 52px); left: 0; right: 0; display: flex; justify-content: center; gap: 6px; pointer-events: none; }
.tok { width: 26px; height: 26px; filter: drop-shadow(0 2px 2px rgba(0,0,0,.5)); transition: opacity .3s, transform .3s; }
.tok svg { width: 100%; height: 100%; }
.tok.used { opacity: .2; transform: scale(.8); }
.hand { position: absolute; z-index: 6; left: 50%; bottom: calc(46px + env(safe-area-inset-bottom)); width: 96px; height: 96px; transform: translateX(-50%); pointer-events: none; filter: drop-shadow(0 8px 10px rgba(0,0,0,.5)); transition: transform .25s cubic-bezier(.3,1.6,.5,1), opacity .2s; animation: bob 1.6s ease-in-out infinite; }
.hand.held { transition: none; animation: none; }
.hand svg { width: 100%; height: 100%; }
.hand.item-ball { width: 70px; height: 70px; }
.hand.item-dart { width: 84px; height: 84px; }
@keyframes bob { 50% { margin-bottom: 8px; } }
.hint { position: absolute; z-index: 6; left: 50%; bottom: calc(160px + env(safe-area-inset-bottom)); transform: translate(-50%, 10px); background: rgba(20,27,46,.88); padding: 10px 16px; border-radius: 12px; font-weight: 700; font-size: 15px; text-align: center; width: max-content; max-width: 86vw; opacity: 0; transition: opacity .3s, transform .3s; pointer-events: none; }
.hint.on { opacity: 1; transform: translate(-50%, 0); }
.find { position: absolute; z-index: 7; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none; padding: 20px; }
.find-frame { width: 46vmin; height: 46vmin; max-width: 260px; max-height: 260px; border: 3px dashed rgba(255,255,255,.9); border-radius: 18px; display: grid; place-items: center; animation: pulse 1.4s ease-in-out infinite; }
.find-frame img { width: 46%; opacity: .55; border-radius: 6px; }
@keyframes pulse { 50% { transform: scale(1.05); border-color: var(--gold); } }
.find p { font-weight: 800; font-size: 18px; margin: 16px 0 4px; text-shadow: 0 2px 6px rgba(0,0,0,.8); }
.find small { opacity: .9; text-shadow: 0 2px 6px rgba(0,0,0,.8); max-width: 300px; }
.loading { position: absolute; z-index: 8; inset: 0; background: var(--navy2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; padding: 30px; }
.loading p { max-width: 340px; line-height: 1.4; }
.loading .btn { margin: 6px; }
.loading .btn.ghost { color: var(--cream); box-shadow: inset 0 0 0 2px var(--cream); }
.spinner { width: 54px; height: 54px; border-radius: 50%; border: 6px solid rgba(255,255,255,.15); border-top-color: var(--gold); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#pops { position: absolute; inset: 0; z-index: 6; pointer-events: none; overflow: hidden; }
.pop { position: absolute; transform: translate(-50%, -50%); text-align: center; animation: popup 1.5s ease-out forwards; text-shadow: 0 3px 0 rgba(0,0,0,.35); }
.pop b { display: block; font-size: 34px; color: var(--gold); font-weight: 900; -webkit-text-stroke: 1.5px var(--navy); }
.pop span { display: block; font-size: 15px; font-weight: 900; color: #fff; letter-spacing: .06em; }
.pop.big b { font-size: 46px; }
.pop.miss b { font-size: 18px; color: #fff; opacity: .8; -webkit-text-stroke: 0; }
@keyframes popup { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); } 15% { opacity: 1; transform: translate(-50%, -60%) scale(1.1); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -160%) scale(1); } }

/* ---------- end ticket ---------- */
#end { justify-content: center; }
.ticket { position: relative; width: 100%; max-width: 400px; background: var(--cream); color: var(--ink); border-radius: 14px; padding: 0 22px 22px; text-align: center; box-shadow: 0 16px 30px rgba(0,0,0,.35);
  -webkit-mask: radial-gradient(circle 14px at 0 120px, transparent 13px, #000 14px) left / 51% 100% no-repeat, radial-gradient(circle 14px at 100% 120px, transparent 13px, #000 14px) right / 51% 100% no-repeat;
          mask: radial-gradient(circle 14px at 0 120px, transparent 13px, #000 14px) left / 51% 100% no-repeat, radial-gradient(circle 14px at 100% 120px, transparent 13px, #000 14px) right / 51% 100% no-repeat; }
.ticket-head { display: flex; justify-content: space-between; margin: 0 -22px 14px; padding: 12px 22px; background: var(--coral); color: #fff; font-weight: 800; font-size: 12px; letter-spacing: .18em; border-radius: 14px 14px 0 0; }
.ticket h2 { margin: 6px 0 0; color: var(--navy); font-size: 26px; }
.who { margin: 4px 0 0; color: #666; font-size: 14px; }
.big-score { margin: 14px 0 6px; padding-top: 14px; border-top: 2px dashed #e0d1b6; }
.big-score span { display: block; font-size: 76px; font-weight: 900; color: var(--navy); line-height: 1; }
.big-score small { font-size: 14px; color: #777; letter-spacing: .2em; text-transform: uppercase; }
.prize { display: inline-block; margin: 8px 0; padding: 8px 18px; border-radius: 99px; font-weight: 900; font-size: 20px; color: #fff; }
.prize.gold { background: linear-gradient(135deg, #f7d26a, #d89b12); color: var(--navy); }
.prize.silver { background: linear-gradient(135deg, #e6e9ee, #9aa3ae); color: var(--navy); }
.prize.bronze { background: linear-gradient(135deg, #e3a777, #a8622c); }
.prize.none { background: var(--teal); }
.rank { min-height: 20px; margin: 6px 0; font-weight: 700; color: var(--navy); }
.claim { font-size: 13px; color: #666; margin: 0 0 16px; }
.end-actions { display: grid; gap: 12px; }
.station-note { margin: 12px 0 0; font-size: 13px; color: #777; }

.powered { position: fixed; z-index: 9; left: 0; right: 0; bottom: calc(10px + env(safe-area-inset-bottom)); text-align: center; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: rgba(255,246,233,.75); pointer-events: none; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.powered b { color: var(--gold); }
