/* Oʻyin Lab game UI kit, v2 (game style, themed per brand).
   Same class names as v1. Each brand sets the theme through CSS variables (applyBrand in oyin-ui.js).
   Language: chunky bevelled buttons, heavy wide type, framed panels, a coupon-style reward, a 3-star result,
   medal ranks. Still: no emoji, no text under 13px, 48px+ targets, real contrast. */

@import url("https://fonts.googleapis.com/css2?family=Mona+Sans:wdth,wght@75..125,400..900&family=Geist+Mono:wght@500..700&display=swap");

:root {
  /* theme (overwritten per brand) */
  --brand: #d9472b; --brand-dark: #9e2f19; --brand-ink: #ffffff;
  --accent2: #ffc83d; --accent2-ink: #2a1a00;
  --panel: #17141f; --panel-2: #221e2d; --panel-ink: #ffffff; --panel-muted: rgba(255, 255, 255, .64); --panel-line: rgba(255, 255, 255, .12);
  --hud: rgba(16, 14, 22, .86); --hud-ink: #ffffff; --hud-line: rgba(255, 255, 255, .14);
  --good: #19b36b; --bad: #e5352b;
  /* studio */
  --o-ink: #0a0a0a; --o-putty: #dedad3; --o-teal: #256f82;
  --f-display: "Mona Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "Geist Mono", ui-monospace, Menlo, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1); --ease-enter: cubic-bezier(.22, 1, .36, 1);
  --safe-t: max(12px, env(safe-area-inset-top)); --safe-b: max(12px, env(safe-area-inset-bottom));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; color: var(--panel-ink); font-family: var(--f-display);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-font-smoothing: antialiased; }
canvas#c { position: fixed; inset: 0; display: block; width: 100%; height: 100%; }
.hide { display: none !important; }
.num { font-variant-numeric: tabular-nums; font-weight: 800; font-stretch: 110%; letter-spacing: -.02em; }
.mono { font-family: var(--f-mono); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent2); outline-offset: 3px; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- studio mark ---------- */
.o-mark { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; }
.o-mark svg { width: 28px; height: 28px; }
.o-sign { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 500; color: var(--panel-muted); }
.o-sign svg { width: 16px; height: 16px; }

/* ---------- loading ---------- */
#loading { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; justify-content: space-between; padding: calc(var(--safe-t) + 10px) 24px calc(var(--safe-b) + 10px);
  background: radial-gradient(120% 70% at 50% 35%, var(--panel-2) 0%, var(--panel) 70%); color: var(--panel-ink); transition: opacity .45s var(--ease); }
#loading.out { opacity: 0; pointer-events: none; }
#loading .ld-brand { margin: auto 0; text-align: center; }
#loading .ld-name { display: inline-block; font-size: 40px; font-weight: 900; font-stretch: 118%; letter-spacing: -.035em; line-height: 1; padding: 10px 18px 12px; border-radius: 16px; background: var(--brand); color: var(--brand-ink); box-shadow: 0 6px 0 var(--brand-dark); }
#loading .ld-game { font-size: 18px; font-weight: 700; margin-top: 18px; }
#loading .ld-bar { width: min(260px, 64vw); height: 12px; border-radius: 999px; background: var(--panel-line); margin: 22px auto 8px; overflow: hidden; padding: 2px; }
#loading .ld-bar i { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--accent2); transition: width .2s var(--ease); }
#loading .ld-pct { font-size: 13px; color: var(--panel-muted); font-weight: 600; }
#loading .ld-foot { display: flex; justify-content: center; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; color: var(--hud-ink); }
.hud-top { position: absolute; left: 10px; right: 10px; top: var(--safe-t); display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 8px; }
.chip { background: var(--hud); border: 2px solid var(--hud-line); border-radius: 16px; padding: 6px 12px; box-shadow: 0 4px 0 rgba(0, 0, 0, .28); }
.hud-brand { justify-self: start; display: flex; align-items: center; gap: 8px; min-height: 48px; padding-left: 6px; }
.hud-brand .sw { width: 30px; height: 30px; border-radius: 10px; background: var(--brand); box-shadow: inset 0 -3px 0 var(--brand-dark); display: grid; place-items: center; color: var(--brand-ink); }
.hud-brand .sw svg.i { width: 18px; height: 18px; }
.hud-brand b { font-weight: 800; font-size: 15px; font-stretch: 110%; letter-spacing: -.01em; max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-time { justify-self: center; position: relative; width: 64px; height: 64px; padding: 0; border-radius: 50%; display: grid; place-items: center; }
.hud-time .num { position: relative; font-size: 24px; line-height: 1; }
.hud-time .bar { position: absolute; inset: 3px; border-radius: 50%; background: conic-gradient(var(--accent2) calc(var(--t, 1) * 360deg), rgba(255, 255, 255, .12) 0);
  -webkit-mask: radial-gradient(circle, transparent 23px, #000 24px); mask: radial-gradient(circle, transparent 23px, #000 24px); }
.hud-time .bar i { display: none; }
.hud-time.low .bar { background: conic-gradient(var(--bad) calc(var(--t, 1) * 360deg), rgba(255, 255, 255, .12) 0); }
.hud-time.low .num { color: #ff9a8f; animation: tick 1s steps(1) infinite; }
@keyframes tick { 50% { opacity: .55; } }
.hud-score { justify-self: end; display: flex; align-items: center; gap: 8px; min-height: 48px; padding-right: 14px; }
.hud-score::before { content: ""; width: 26px; height: 26px; border-radius: 50%; flex: none; background: var(--accent2);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2.5l2.9 6 6.6.9-4.8 4.6 1.2 6.5L12 17.4l-5.9 3.1 1.2-6.5L2.5 9.4l6.6-.9z'/%3E%3C/svg%3E") center/22px no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2.5l2.9 6 6.6.9-4.8 4.6 1.2 6.5L12 17.4l-5.9 3.1 1.2-6.5L2.5 9.4l6.6-.9z'/%3E%3C/svg%3E") center/22px no-repeat; }
.hud-score .num { display: block; font-size: 26px; line-height: 1; }
.hud-score .lab { display: none; }
#combo { position: absolute; top: calc(var(--safe-t) + 76px); left: 50%; transform: translateX(-50%); font-size: 16px; font-weight: 800; font-stretch: 110%; padding: 7px 14px; border-radius: 12px;
  background: var(--accent2); color: var(--accent2-ink); box-shadow: 0 4px 0 rgba(0, 0, 0, .25); white-space: nowrap; transition: opacity 150ms var(--ease), transform 200ms var(--ease-enter); }
#combo.off { opacity: 0; transform: translateX(-50%) translateY(-6px); }
#toast { position: absolute; top: 28%; left: 50%; transform: translate(-50%, 8px) scale(.96); display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-radius: 16px; background: var(--hud); border: 2px solid var(--hud-line);
  font-size: 19px; font-weight: 800; font-stretch: 108%; white-space: nowrap; opacity: 0; box-shadow: 0 5px 0 rgba(0, 0, 0, .3); transition: opacity 160ms var(--ease), transform 260ms var(--ease-enter); }
#toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
#toast.good { background: var(--brand); color: var(--brand-ink); border-color: rgba(255, 255, 255, .25); box-shadow: 0 5px 0 var(--brand-dark); }
#toast.bad { background: var(--bad); color: #fff; border-color: rgba(255, 255, 255, .25); box-shadow: 0 5px 0 #8f1a12; }
#pops { position: absolute; inset: 0; overflow: hidden; }
.pop { position: absolute; left: 0; top: 0; font-weight: 900; font-stretch: 112%; font-size: 22px; color: #fff; -webkit-text-stroke: 4px rgba(0, 0, 0, .55); paint-order: stroke fill; will-change: transform, opacity; }
#vig { position: absolute; inset: 0; box-shadow: inset 0 0 0 0 rgba(229, 53, 43, 0); transition: box-shadow 150ms var(--ease); }
#vig.hit { box-shadow: inset 0 0 120px 10px rgba(229, 53, 43, .55); }

/* round action buttons */
.act { position: absolute; right: 12px; pointer-events: auto; width: 78px; height: 78px; border-radius: 50%; border: 0; padding: 0; cursor: pointer; display: grid; place-items: center;
  background: conic-gradient(var(--accent2) calc(var(--n, 0) * 360deg), rgba(255, 255, 255, .16) 0); box-shadow: 0 5px 0 rgba(0, 0, 0, .35); transition: transform 120ms var(--ease); }
.act::before { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--hud); }
.act > * { position: relative; }
.act .ac-in { display: flex; flex-direction: column; align-items: center; gap: 1px; color: rgba(255, 255, 255, .55); }
.act .ac-in svg.i { width: 26px; height: 26px; }
.act .ac-in small { font-size: 13px; font-weight: 800; }
.act.ready::before { background: var(--brand); box-shadow: inset 0 -4px 0 var(--brand-dark); }
.act.ready .ac-in, .act.active .ac-in { color: var(--brand-ink); }
.act.active::before { background: var(--brand-dark); }
.act.ready { animation: pulse 1.1s var(--ease) infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }
.act:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0, 0, 0, .35); }
#mute { position: absolute; left: 12px; bottom: var(--safe-b); pointer-events: auto; width: 48px; height: 48px; border: 2px solid var(--hud-line); border-radius: 14px; background: var(--hud); color: var(--hud-ink); display: grid; place-items: center; cursor: pointer; box-shadow: 0 4px 0 rgba(0, 0, 0, .28); }
#count { position: fixed; inset: 0; z-index: 6; pointer-events: none; display: grid; place-items: center; }
#count span { font-weight: 900; font-stretch: 125%; font-size: 120px; line-height: 1; color: var(--accent2); -webkit-text-stroke: 8px var(--panel); paint-order: stroke fill; animation: cnt .9s var(--ease-enter) forwards; }
@keyframes cnt { 0% { opacity: 0; transform: scale(1.6); } 25% { opacity: 1; transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: scale(.9); } }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; z-index: 8; display: flex; align-items: flex-end; justify-content: center; padding: 12px 12px var(--safe-b); }
.screen::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0, 0, 0, 0) 30%, rgba(0, 0, 0, .5) 100%); pointer-events: none; }
@media (min-aspect-ratio: 1/1) { .screen { align-items: center; justify-content: flex-start; padding-left: max(5vw, 24px); }
  .screen::before { background: linear-gradient(90deg, rgba(0, 0, 0, .45) 0%, rgba(0, 0, 0, 0) 60%); } }
.panel { position: relative; width: min(420px, 100%); background: var(--panel); color: var(--panel-ink); border-radius: 26px; padding: 0 18px 16px;
  border: 2px solid var(--panel-line); box-shadow: 0 8px 0 rgba(0, 0, 0, .35), 0 24px 60px rgba(0, 0, 0, .35); animation: enter .5s var(--ease-enter) both; overflow: hidden; }
@keyframes enter { from { opacity: 0; transform: translateY(24px) scale(.98); } to { opacity: 1; transform: none; } }
/* brand ribbon across the top of every panel */
.p-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 -18px; padding: 12px 14px 12px 16px; background: var(--brand); color: var(--brand-ink); box-shadow: inset 0 -4px 0 var(--brand-dark); }
.c-word { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-stretch: 112%; letter-spacing: -.01em; font-size: 16px; min-width: 0; }
.c-word .sw { width: 10px; height: 10px; border-radius: 3px; background: var(--accent2); flex: none; }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: rgba(0, 0, 0, .22); }
.seg button { border: 0; background: none; font-size: 13px; font-weight: 800; color: inherit; opacity: .75; min-width: 42px; height: 34px; border-radius: 9px; cursor: pointer; }
.seg button.on { background: var(--brand-ink); color: var(--brand); opacity: 1; }
.p-title { font-size: 36px; line-height: .98; font-weight: 900; font-stretch: 118%; letter-spacing: -.035em; margin: 18px 0 10px; text-wrap: balance; }
.p-lead { font-size: 16px; line-height: 1.45; margin: 0; color: var(--panel-muted); font-weight: 500; }
.p-lead b { color: var(--panel-ink); }
.ctrls { list-style: none; margin: 14px 0 2px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ctrls li { display: grid; grid-template-columns: 34px 1fr; grid-template-rows: auto auto; column-gap: 8px; align-items: center; padding: 8px; border-radius: 14px; background: var(--panel-2); font-size: 14px; font-weight: 700; line-height: 1.2; }
.ctrls li svg.i { grid-row: 1 / 3; width: 34px; height: 34px; padding: 7px; border-radius: 10px; background: var(--accent2); color: var(--accent2-ink); stroke-width: 2.4; }
.ctrls li .k { font-size: 13px; font-weight: 500; color: var(--panel-muted); }
.btn-row { display: flex; gap: 10px; margin-top: 16px; }
.btn { flex: 1; position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px; height: 60px; padding: 0 14px; border-radius: 18px; border: 0; white-space: nowrap; min-width: 0; cursor: pointer;
  font-size: 19px; font-weight: 900; font-stretch: 115%; letter-spacing: -.01em; transition: transform 90ms var(--ease), box-shadow 90ms var(--ease), filter 150ms var(--ease); }
.btn--primary { background: var(--brand); color: var(--brand-ink); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .28), inset 0 -4px 0 rgba(0, 0, 0, .18), 0 6px 0 var(--brand-dark), 0 12px 22px rgba(0, 0, 0, .25); margin-bottom: 6px; }
.btn--secondary { background: var(--panel-2); color: var(--panel-ink); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .08), 0 6px 0 rgba(0, 0, 0, .35); margin-bottom: 6px; font-size: 16px; font-weight: 800; }
@media (hover: hover) and (pointer: fine) { .btn:hover { filter: brightness(1.06); } }
.btn:active { transform: translateY(5px); }
.btn--primary:active { box-shadow: inset 0 2px 0 rgba(255, 255, 255, .2), inset 0 -2px 0 rgba(0, 0, 0, .18), 0 1px 0 var(--brand-dark); }
.btn--secondary:active { box-shadow: 0 1px 0 rgba(0, 0, 0, .35); }
.btn svg.i { width: 22px; height: 22px; stroke-width: 2.6; }
.btn--icon { flex: 0 0 60px; width: 60px; padding: 0; }
.btn--icon svg.i { width: 26px; height: 26px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.btn--primary svg.i { fill: currentColor; stroke-width: 1.5; }
.p-legal { font-size: 13px; line-height: 1.4; color: var(--panel-muted); margin: 10px 0 0; }
.p-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--panel-line); }

/* ---------- end screen ---------- */
.stars { display: flex; justify-content: center; gap: 6px; margin: 16px 0 2px; }
.stars svg { width: 46px; height: 46px; }
.stars svg:nth-child(2) { width: 58px; height: 58px; margin-top: -10px; }
.stars .on path { fill: var(--accent2); stroke: rgba(0, 0, 0, .35); }
.stars .off path { fill: var(--panel-2); stroke: var(--panel-line); }
.stars .on { animation: star .45s var(--ease-enter) both; } .stars .on:nth-child(2) { animation-delay: .12s; } .stars .on:nth-child(3) { animation-delay: .24s; }
@keyframes star { from { transform: scale(.3); opacity: 0; } to { transform: none; opacity: 1; } }
.e-label { font-size: 14px; font-weight: 700; color: var(--panel-muted); margin: 6px 0 0; text-align: center; }
.e-score { font-variant-numeric: tabular-nums; font-size: 60px; line-height: 1; font-weight: 900; font-stretch: 118%; letter-spacing: -.035em; text-align: center; }
.e-best { font-size: 14px; font-weight: 600; color: var(--panel-muted); margin-top: 6px; text-align: center; }
.e-best .badge { display: inline-block; font-size: 14px; font-weight: 900; padding: 5px 10px; border-radius: 9px; background: var(--accent2); color: var(--accent2-ink); box-shadow: 0 3px 0 rgba(0, 0, 0, .3); }
.rows { margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rows div { display: flex; flex-direction: column-reverse; align-items: center; padding: 10px 6px; border-radius: 14px; background: var(--panel-2); text-align: center; }
.rows dt { font-size: 13px; font-weight: 600; color: var(--panel-muted); line-height: 1.2; }
.rows dd { margin: 0 0 2px; font-size: 22px; font-weight: 900; font-stretch: 112%; font-variant-numeric: tabular-nums; }
/* reward: a coupon */
.reward { position: relative; margin-top: 12px; border-radius: 16px; background: var(--accent2); color: var(--accent2-ink); padding: 14px 18px;
  -webkit-mask: radial-gradient(circle 10px at 0 62%, transparent 9.5px, #000 10px) left / 51% 100% no-repeat, radial-gradient(circle 10px at 100% 62%, transparent 9.5px, #000 10px) right / 51% 100% no-repeat;
          mask: radial-gradient(circle 10px at 0 62%, transparent 9.5px, #000 10px) left / 51% 100% no-repeat, radial-gradient(circle 10px at 100% 62%, transparent 9.5px, #000 10px) right / 51% 100% no-repeat; }
.reward .r-t { font-size: 15px; font-weight: 700; line-height: 1.35; padding-bottom: 12px; border-bottom: 2px dashed rgba(0, 0, 0, .22); }
.reward .r-code { margin-top: 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.reward .r-code .num { font-family: var(--f-mono); font-size: 24px; font-weight: 700; letter-spacing: .04em; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.reward .r-copy { white-space: nowrap; flex: none; width: 52px; height: 48px; padding: 0; justify-content: center; border-radius: 14px; border: 0; background: var(--accent2-ink); color: var(--accent2); font-size: 15px; font-weight: 800; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; box-shadow: 0 4px 0 rgba(0, 0, 0, .3); }
.reward .r-copy:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, .3); }
.reward.locked { background: var(--panel-2); color: var(--panel-ink); -webkit-mask: none; mask: none; }
.reward.locked .r-t { border-bottom: 0; padding-bottom: 0; color: var(--panel-ink); }
.reward .r-prog { height: 12px; border-radius: 999px; background: rgba(0, 0, 0, .25); margin-top: 10px; overflow: hidden; padding: 2px; }
.reward .r-prog i { display: block; height: 100%; border-radius: 999px; background: var(--accent2); }
.lb { margin-top: 12px; }
.lb h3 { font-size: 13px; font-weight: 700; color: var(--panel-muted); margin: 0 0 6px; }
.lb ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.lb li { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 10px; padding: 6px 12px 6px 6px; font-size: 15px; font-weight: 700; border-radius: 12px; background: var(--panel-2); }
.lb li .rk { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 14px; color: #2a1a00; background: #c9ccd3; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .2); }
.lb li:nth-child(1) .rk { background: #f5c542; } .lb li:nth-child(3) .rk { background: #d79a63; }
.lb li .sc { font-variant-numeric: tabular-nums; font-weight: 900; }
.lb li.me { outline: 2px solid var(--accent2); outline-offset: -2px; }

@media (max-height: 760px) and (max-aspect-ratio: 1/1) {
  .p-title { font-size: 30px; margin-top: 14px; } .e-score { font-size: 48px; } .stars svg { width: 36px; height: 36px; } .stars svg:nth-child(2) { width: 46px; height: 46px; }
  .lb { display: none; } .ctrls li { padding: 6px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
