:root { --bg:#101214; --fg:#f2f3f5; --muted:#9aa3ad; --card:#1b1f24; --accent:#ffd21f; --line:#2c333b; --field:#0d0f11; --bad:#ff8585; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--fg);
  font: 17px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
body { touch-action: manipulation; overscroll-behavior: none; }

.screen { display: none; min-height: 100vh; min-height: 100dvh;
  padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.screen.on { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.card { width: 100%; max-width: 640px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 24px; }
.brandline { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 12px; }
h2 { font-size: 20px; line-height: 1.25; margin: 0 0 10px; }
p { margin: 0 0 12px; }
a { color: var(--accent); }
.muted { color: var(--muted); } .small { font-size: 14px; }
.prize { background: rgba(255, 210, 31, .1); border: 1px solid rgba(255, 210, 31, .35); border-radius: 10px; padding: 10px 14px; margin: 0 0 14px; }
ol.steps { padding-left: 22px; margin: 0 0 12px; } ol.steps li { margin-bottom: 6px; }

fieldset.q { border: 0; padding: 0; margin: 18px 0 0; min-width: 0; }
fieldset.q legend { font-weight: 600; padding: 0; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { position: relative; cursor: pointer; }
.chips input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.chips span { display: block; padding: 10px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--field); font-size: 16px; user-select: none; }
.chips input:checked + span { background: var(--accent); border-color: var(--accent); color: #111; font-weight: 600; }
.chips input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

label.check { display: flex; gap: 10px; align-items: flex-start; margin: 18px 0 0; cursor: pointer; }
label.check input { width: 22px; height: 22px; margin: 2px 0 0; flex: none; accent-color: var(--accent); }
label.lbl { display: block; margin: 14px 0 6px; font-weight: 600; }
input[type=text] { width: 100%; padding: 12px; font-size: 17px; border-radius: 9px; border: 1px solid var(--line); background: var(--field); color: var(--fg); }
input[type=text]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

button { font: inherit; font-weight: 600; padding: 13px 18px; border-radius: 9px; border: 0; cursor: pointer; min-height: 48px; }
button:disabled { opacity: .55; cursor: default; }
.primary { background: var(--accent); color: #111; }
.ghost { background: #2a3038; color: var(--fg); }
button.link { background: none; color: var(--accent); text-decoration: underline; padding: 8px 0; min-height: 0; font-weight: 500; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; } .row button { flex: 1 1 200px; }
.err { color: var(--bad); min-height: 22px; font-size: 15px; margin-top: 8px; }
.hint { margin: 2px 0 0; }

/* the answer card: one row, so a phone held sideways still shows it above the keyboard */
.answerRow { display: flex; gap: 10px; flex-wrap: wrap; }
.answerRow input { flex: 1 1 100%; }
.answerRow button { flex: 1 1 160px; }

/* the picture */
#stage { position: fixed; inset: 0; z-index: 20; background: #000; display: none; align-items: center; justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
#stage.on { display: flex; }
#frameWrap { position: relative; line-height: 0; flex: none; }
#frame { display: block; visibility: hidden; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; pointer-events: none; }
#marks { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
#count { position: fixed; top: max(8px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); color: #8a929b; font-size: 13px; z-index: 5; }

#rotate { position: fixed; inset: 0; z-index: 40; background: var(--bg); display: none; align-items: center; justify-content: center; padding: 20px; text-align: center; }
#rotate.on { display: flex; }
#rotate .card { max-width: 420px; }
.rotateIcon { margin-bottom: 8px; }

#errbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; display: none; background: #5a1f1f; color: #fff; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); font-size: 15px; text-align: center; }
#errbar.on { display: block; }

/* a phone held sideways: short and wide */
@media (orientation: landscape) and (max-height: 520px) {
  html, body { font-size: 16px; }
  .screen { padding-top: max(10px, env(safe-area-inset-top)); padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .screen.on { justify-content: flex-start; }
  .card { max-width: 760px; padding: 16px 18px; }
  h1 { font-size: 22px; margin-bottom: 8px; } h2 { font-size: 18px; margin-bottom: 8px; }
  .card.answer h2 { font-size: 16px; }
  .card.answer .err { min-height: 0; margin-top: 4px; } .card.answer .hint { font-size: 13px; }
  .answerRow { flex-wrap: nowrap; }
  .answerRow input { flex: 1 1 auto; min-width: 0; }
  .answerRow button { flex: 0 0 auto; white-space: nowrap; padding: 10px 14px; }
  .row { margin-top: 10px; }
  #count { top: auto; bottom: max(8px, env(safe-area-inset-bottom)); }
}
