:root {
  color-scheme: light;
  --ink: #1e252a;
  --muted: #5e6765;
  --paper: #f8f5ef;
  --paper-dark: #ece5d8;
  --accent: #d54b42;
  --accent-dark: #ad302a;
  --teal: #176c67;
  --line: #d7cfc1;
  --success-dark: #0e8a46;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: radial-gradient(circle at 80% 0%, #f1d8b8 0, transparent 30%), var(--paper);
  color: var(--ink);
}

button, input, label { font: inherit; }
button { cursor: pointer; }

.icon-svg { width: 1em; height: 1em; display: inline-block; vertical-align: -0.15em; stroke: currentColor; }
.icon-button { display: grid; width: 34px; height: 34px; place-items: center; border: 0; border-radius: 50%; background: var(--paper-dark); color: var(--ink); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }

.app-shell { width: min(100%, 610px); min-height: 100vh; margin: 0 auto; padding: max(24px, env(safe-area-inset-top)) 20px max(28px, env(safe-area-inset-bottom)); }
.screen { min-height: calc(100vh - 52px); display: flex; flex-direction: column; }
.is-hidden { display: none !important; }

.welcome-screen { justify-content: center; align-items: center; text-align: center; padding-bottom: 6vh; }
.logo { display: inline-flex; align-items: center; gap: 10px; margin: 0 0 14px; }
.logo-mark { width: 36px; height: 36px; flex-shrink: 0; }
.logo-word { font-family: Georgia, "Times New Roman", serif; font-weight: 800; font-size: 1.35rem; letter-spacing: -.02em; color: var(--ink); }
.eyebrow { margin: 0 0 10px; color: var(--teal); font-size: .78rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1, h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; line-height: 1; letter-spacing: -.035em; }
h1 { font-size: clamp(2.9rem, 12vw, 4.6rem); max-width: 9ch; }
h2 { font-size: 2.25rem; }
.intro { max-width: 33rem; margin: 26px 0 22px; color: var(--muted); font-size: 1.12rem; line-height: 1.5; }
.test-mode-note { color: var(--muted); font-size: .84rem; line-height: 1.45; }
.button { min-height: 54px; border: 0; border-radius: 11px; padding: 14px 20px; font-weight: 800; text-align: center; text-decoration: none; }
.button-primary { background: var(--accent); color: white; box-shadow: 0 5px 0 var(--accent-dark); }
.button-primary:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--accent-dark); }
.button-primary:disabled { background: var(--paper-dark); color: var(--muted); box-shadow: 0 5px 0 var(--line); cursor: not-allowed; }
.button-primary:disabled:active { transform: none; box-shadow: 0 5px 0 var(--line); }
.welcome-screen .button { width: 100%; margin-top: 13px; }

.field { width: 100%; margin-top: 22px; text-align: left; }
.text-input { display: block; width: 100%; min-height: 54px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 11px; background: white; color: var(--ink); text-align: center; }
.text-input:focus { outline: 2px solid var(--teal); outline-offset: 1px; }

.qr-block { display: flex; justify-content: center; margin-top: 26px; }
.qr-code { width: 148px; height: 148px; padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: white; }

.game-header { display: flex; align-items: flex-end; padding: 5px 0 17px; }
.game-header h1 { font-size: 3rem; }
.game-header .eyebrow { margin-bottom: 5px; }
.game-instruction { margin: 0 0 19px; color: var(--muted); }
.bingo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.tile { position: relative; aspect-ratio: 1; overflow: hidden; border-radius: 12px; background: #222; box-shadow: 0 2px 0 rgba(30, 37, 42, .17); }
.tile img { width: 100%; height: 100%; object-fit: cover; transition: transform .18s ease; }
.tile:hover img, .tile:focus-visible img { transform: scale(1.05); }
.tile.is-approved { border: 12px solid var(--success-dark); }
.tile.is-approved::after { content: ""; position: absolute; inset: 0; background: rgba(14, 138, 70, .38); pointer-events: none; }
.approved-check { display: none; position: absolute; z-index: 3; inset: 0; margin: auto; width: 88%; height: 88%; }
.tile.is-approved .approved-check { display: block; }
.tile.is-approved .hint-icon { display: none; }
.hint-icon { position: absolute; z-index: 2; top: 6px; right: 6px; display: grid; width: 26px; height: 26px; place-items: center; border: 0; border-radius: 12px; background: rgba(255,255,255,.92); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.25); opacity: .5; }
.hint-icon .icon-svg { width: 15px; height: 15px; }
.tile.is-checking::after { content: ""; position: absolute; inset: 0; background: rgba(30, 37, 42, .4); pointer-events: none; }
.tile.is-checking .hint-icon { display: none; }
.checking-spinner { display: none; position: absolute; z-index: 3; inset: 0; margin: auto; width: 34%; height: 34%; border: 4px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.tile.is-checking .checking-spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }
.test-mode-note { margin: auto 0 0; padding-top: 20px; }

.complete-screen { align-items: center; justify-content: center; text-align: center; }
.complete-screen h1 { max-width: 8ch; font-size: clamp(3rem, 13vw, 4.5rem); }
.complete-screen p:not(.eyebrow) { max-width: 25rem; color: var(--muted); font-size: 1.1rem; line-height: 1.45; }
.complete-screen .button { width: 100%; max-width: 330px; margin-top: 16px; }
.celebration-mark { color: var(--accent); font-size: 5rem; line-height: 1; }
.complete-screen p.results-label { margin-top: 76px; margin-bottom: 4px; max-width: none; color: var(--ink); font-size: 1rem; font-weight: 800; }
.results-list { list-style: none; margin: 0; padding: 0; width: 100%; max-width: 330px; display: grid; gap: 8px; text-align: left; }
.result-item { display: flex; align-items: center; gap: 12px; padding: 7px; border-radius: 10px; background: var(--paper-dark); }
.result-item img { width: 46px; height: 46px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.result-item span { font-weight: 700; font-size: .92rem; color: var(--ink); }

.hint-popup { position: absolute; z-index: 30; max-width: min(480px, 90vw); padding: 28px 32px; border-radius: 20px; background: var(--paper); color: var(--ink); border: 1px solid var(--line); box-shadow: 0 12px 40px rgba(0,0,0,.28); }
.hint-popup p { margin: 0; padding-right: 30px; font-size: 1.3rem; line-height: 1.45; }
.hint-popup-close { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; }
.hint-popup-close .icon-svg { width: 16px; height: 16px; }

.toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40; max-width: min(420px, 90vw); padding: 14px 18px; border-radius: 12px; background: var(--ink); color: white; box-shadow: 0 12px 30px rgba(0,0,0,.3); text-align: center; }
.toast p { margin: 0; font-weight: 700; font-size: .94rem; line-height: 1.4; }
.toast.tone-warning { background: #92400e; }
.toast.tone-error { background: var(--accent-dark); }

@media (min-width: 500px) { .app-shell { padding-inline: 28px; } .bingo-grid { gap: 13px; } }
