/* Self-hosted fonts (Almarai, Reem Kufi) — woff2 from Google Fonts, SIL OFL */
/* arabic */
@font-face {
  font-family: 'Almarai';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/almarai-400-arabic.woff2") format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC7, U+10EC9-10EEE, U+10EF0-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;
}
/* latin */
@font-face {
  font-family: 'Almarai';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/almarai-400-latin.woff2") format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* arabic */
@font-face {
  font-family: 'Almarai';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/almarai-700-arabic.woff2") format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC7, U+10EC9-10EEE, U+10EF0-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;
}
/* latin */
@font-face {
  font-family: 'Almarai';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/almarai-700-latin.woff2") format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* arabic */
@font-face {
  font-family: 'Almarai';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("fonts/almarai-800-arabic.woff2") format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC7, U+10EC9-10EEE, U+10EF0-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;
}
/* latin */
@font-face {
  font-family: 'Almarai';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("fonts/almarai-800-latin.woff2") format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* arabic */
@font-face {
  font-family: 'Reem Kufi';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/reem-kufi-500-arabic.woff2") format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC7, U+10EC9-10EEE, U+10EF0-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;
}
/* vietnamese */
@font-face {
  font-family: 'Reem Kufi';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/reem-kufi-500-vietnamese.woff2") format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
  font-family: 'Reem Kufi';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/reem-kufi-500-latin-ext.woff2") format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Reem Kufi';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/reem-kufi-500-latin.woff2") format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* arabic */
@font-face {
  font-family: 'Reem Kufi';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/reem-kufi-700-arabic.woff2") format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC7, U+10EC9-10EEE, U+10EF0-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;
}
/* vietnamese */
@font-face {
  font-family: 'Reem Kufi';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/reem-kufi-700-vietnamese.woff2") format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
  font-family: 'Reem Kufi';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/reem-kufi-700-latin-ext.woff2") format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Reem Kufi';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/reem-kufi-700-latin.woff2") format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* =========================================================
   المجلس — Najdi theme v2
   Mud brick (طين), stepped crenellations (شرفات), Sadu weave
   (السدو), painted Najdi door triangles + real photography.
   ========================================================= */

:root {
  --mud: #d6b48a;
  --clay: #8b5a3c;
  --clay-dark: #5e3a24;
  --ink: #2b1b12;
  --cream: #f8eedb;
  --cream-2: #efe0c2;
  --sand: #e8d2ae;
  --gold: #c99a3b;
  --gold-2: #e9bf62;
  --t1: #1d6b70;  --t1-2: #2a8a90;  --t1-d: #11474b;   /* Najdi door teal */
  --t2: #9a2a1f;  --t2-2: #bb4231;  --t2-d: #5f1912;   /* Sadu red */
  --muted: #7a5a44;
  --radius: 16px;
  --topbar-h: 62px;
  --shadow: 0 14px 34px rgba(60, 30, 10, .28), 0 2px 6px rgba(60, 30, 10, .2);
  --font: "Almarai", "Segoe UI", Tahoma, sans-serif;
  --font-deco: "Reem Kufi", "Almarai", sans-serif;

  --noise: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='260' height='260'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .32  0 0 0 0 .2  0 0 0 0 .1  0 0 0 .55 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  --straw: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><g stroke='%237a5233' stroke-opacity='.18' stroke-width='1' stroke-linecap='round'><path d='M8 20l14 3'/><path d='M60 12l11-4'/><path d='M95 40l16 2'/><path d='M30 70l-12 5'/><path d='M70 88l15 4'/><path d='M100 105l-9-6'/><path d='M15 105l10-2'/><path d='M50 45l8 6'/></g></svg>");
  --crenel: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='28' height='16'><path d='M0 16V12H4V8H8V4H11V1H17V4H20V8H24V12H28V16Z' fill='%238b5a3c'/><path d='M12 9l2-3 2 3z' fill='%235e3a24'/></svg>");
  --crenel-dark: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='28' height='16'><path d='M0 16V12H4V8H8V4H11V1H17V4H20V8H24V12H28V16Z' fill='%235e3a24'/></svg>");
  --sadu: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='22'><rect width='40' height='22' fill='%23982a1e'/><rect width='40' height='2.5' fill='%23241510'/><rect y='19.5' width='40' height='2.5' fill='%23241510'/><path d='M0 2.5h40v1.5H0zM0 18h40v1.5H0z' fill='%23f3e6cc'/><polygon points='20,5 28,11 20,17 12,11' fill='%23f3e6cc'/><polygon points='20,8 24,11 20,14 16,11' fill='%23241510'/><polygon points='0,5 6,11 0,17' fill='%23241510'/><polygon points='40,5 34,11 40,17' fill='%23241510'/><rect x='19' y='10' width='2' height='2' fill='%23e0a43a'/><polygon points='3,11 6,8 6,14' fill='%23e0a43a'/><polygon points='37,11 34,8 34,14' fill='%23e0a43a'/></svg>");
  --door: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='14'><polygon points='0,14 8,1 16,14' fill='%231d6b70'/><polygon points='16,14 24,1 32,14' fill='%23c99a3b'/><polygon points='32,14 40,1 48,14' fill='%239a2a1f'/><polygon points='5,14 8,9 11,14' fill='%23f7ecd6'/><polygon points='21,14 24,9 27,14' fill='%23f7ecd6'/><polygon points='37,14 40,9 43,14' fill='%23f7ecd6'/></svg>");
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@supports (overflow: clip) { html, body { overflow-x: clip; } }
button, .tile, .cat-card, a, input { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
body {
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--mud);
  background-image:
    radial-gradient(ellipse at 50% -10%, rgba(255, 240, 210, .55), transparent 60%),
    radial-gradient(ellipse at 50% 120%, rgba(90, 50, 20, .35), transparent 60%),
    var(--straw), var(--noise);
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
img { -webkit-user-drag: none; user-select: none; }
kbd {
  font: 700 .7em var(--font); padding: 2px 7px; border-radius: 6px; opacity: .7;
  background: rgba(0, 0, 0, .12); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .15);
}

/* ---------- Photo backdrop (setup + end screens) ---------- */
.photo-bg {
  --photo: url("img/najdi-architecture-17c4e.jpg"); /* shown before login too (public image); game.js may override */
  position: fixed; inset: 0; z-index: -1; opacity: 0; transition: opacity .6s;
  background:
    linear-gradient(180deg, rgba(43, 27, 18, .25) 0%, rgba(43, 27, 18, .55) 55%, rgba(60, 36, 20, .92) 100%),
    var(--photo) center 40% / cover no-repeat, var(--clay-dark);
}
body[data-screen="setup"] .photo-bg, body[data-screen="end"] .photo-bg { opacity: 1; }

/* ---------- Ornaments ---------- */
.crenel {
  height: 16px; margin-top: -16px; position: relative;
  background: var(--crenel) repeat-x bottom center / 28px 16px;
}
.sadu-band { height: 22px; background: var(--sadu) repeat-x center / 40px 22px; border-radius: 3px; box-shadow: 0 2px 0 rgba(0, 0, 0, .15); }
.sadu-band.thin { height: 14px; background-size: 26px 14px; border-radius: 0 0 12px 12px; flex: none; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px;
  background: linear-gradient(var(--clay-dark), var(--clay));
  color: var(--cream);
  box-shadow: 0 3px 0 var(--gold), 0 6px 18px rgba(0, 0, 0, .3);
}
.topbar::after {
  content: ""; position: absolute; inset: auto 0 -17px 0; height: 14px; pointer-events: none;
  background: var(--door) repeat-x top / 48px 14px; transform: scaleY(-1);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 30px; height: 30px; border-radius: 6px; background: var(--sadu) center / 40px 22px; box-shadow: 0 0 0 2px var(--gold); }
.brand-name { font: 700 1.5rem var(--font-deco); letter-spacing: .5px; }
.topbar-actions { display: flex; gap: 8px; }
.icon-btn {
  min-width: 40px; height: 40px; padding: 0 10px; border-radius: 10px;
  border: 1px solid rgba(255, 235, 200, .35); background: rgba(255, 235, 200, .1); color: var(--cream);
  font: 700 1rem var(--font); cursor: pointer; transition: background .15s, transform .1s;
}
.icon-btn:hover { background: rgba(255, 235, 200, .22); }
.icon-btn:active { transform: scale(.95); }

/* ---------- Layout ---------- */
#app { max-width: 1500px; margin: 0 auto; padding: 36px 24px 40px; }
.screen { animation: rise .45s cubic-bezier(.2, .8, .2, 1); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- Buttons ---------- */
.btn {
  font: 800 1.05rem var(--font); border: none; border-radius: 12px; cursor: pointer; padding: 12px 22px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  transition: transform .12s, box-shadow .15s, background .15s, opacity .15s, filter .15s;
}
.btn:active:not(:disabled) { transform: translateY(2px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-xl { font-size: 1.35rem; padding: 16px 36px; }
.btn-lg { font-size: 1.2rem; padding: 14px 28px; }
.btn-sm { font-size: .95rem; padding: 9px 16px; }
.btn-primary { color: var(--cream); background: linear-gradient(var(--t1-2), var(--t1)); box-shadow: 0 4px 0 var(--t1-d), 0 8px 18px rgba(20, 70, 75, .35); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-gold { color: var(--ink); background: linear-gradient(var(--gold-2), var(--gold)); box-shadow: 0 5px 0 #8a6420, 0 10px 22px rgba(140, 100, 30, .35); }
.btn-gold:hover { filter: brightness(1.06); }
.btn-ghost { color: var(--clay-dark); background: rgba(248, 238, 219, .85); box-shadow: inset 0 0 0 2px var(--clay), 0 3px 0 rgba(94, 58, 36, .35); }
.btn-ghost:hover:not(:disabled) { background: var(--cream); }
html[dir="ltr"] .arrow { display: inline-block; transform: scaleX(-1); }

/* ---------- Shared panel look ---------- */
.hero-frame, .q-card, .end-card, .modal-box, .cat-block, .timer-panel {
  background: linear-gradient(rgba(255, 250, 238, .6), rgba(255, 250, 238, 0) 40%), var(--cream);
  border: 4px solid var(--clay);
  border-radius: 6px 6px var(--radius) var(--radius);
  box-shadow: var(--shadow);
  position: relative;
}

/* ================= 1. Setup ================= */
#screen-setup { min-height: calc(100vh - var(--topbar-h) - 76px); min-height: calc(100dvh - var(--topbar-h) - 76px); display: grid; place-items: center; }
.hero-frame { width: min(880px, 100%); }
.hero-frame::before { content: ""; position: absolute; inset: 10px; pointer-events: none; border: 2px solid rgba(139, 90, 60, .3); border-radius: 4px 4px 10px 10px; }
.hero-inner { padding: 30px 40px 30px; text-align: center; position: relative; }
.hero-kicker { margin: 0; color: var(--muted); font-weight: 700; }
.hero-title {
  margin: 4px 0 14px; font: 700 clamp(3.6rem, 9vw, 6.2rem)/1.1 var(--font-deco); color: var(--clay-dark);
  text-shadow: 0 3px 0 var(--gold-2), 0 6px 0 rgba(94, 58, 36, .25);
}
.hero-inner .sadu-band { max-width: 420px; margin: 0 auto; }
.hero-sub { font-size: 1.15rem; color: var(--muted); margin: 18px 0 30px; }
.teams-input { display: grid; grid-template-columns: 1fr auto 1fr; gap: 18px; align-items: center; margin-bottom: 30px; }
.team-card {
  position: relative; display: flex; flex-direction: column; gap: 10px; text-align: start;
  padding: 22px 18px 18px; border-radius: 12px; background: var(--cream-2);
  border-top: 8px solid var(--tc); box-shadow: inset 0 0 0 2px rgba(139, 90, 60, .25);
}
.team-card.t1 { --tc: var(--t1); }
.team-card.t2 { --tc: var(--t2); }
.team-badge {
  position: absolute; top: -20px; inset-inline-start: 16px; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; background: var(--tc); color: var(--cream); font-weight: 800; box-shadow: 0 0 0 3px var(--cream);
}
.team-label { font-weight: 800; color: var(--tc); }
.team-card input {
  font: 800 1.35rem var(--font); color: var(--ink); padding: 12px 14px; border-radius: 10px; width: 100%;
  border: 2px solid rgba(139, 90, 60, .35); background: #fffaf0; outline: none; transition: border-color .15s, box-shadow .15s;
}
.team-card input:focus { border-color: var(--tc); box-shadow: 0 0 0 4px color-mix(in srgb, var(--tc) 20%, transparent); }
.vs {
  font: 700 1.6rem var(--font-deco); color: var(--gold); width: 58px; height: 58px; display: grid; place-items: center;
  border-radius: 50%; background: var(--clay-dark); box-shadow: 0 0 0 4px var(--gold), 0 6px 14px rgba(0, 0, 0, .25);
}
.hero-stats { display: flex; justify-content: center; gap: 10px; margin-top: 24px; flex-wrap: wrap; }
.hero-stats span { font-weight: 800; font-size: .9rem; color: var(--clay-dark); background: var(--cream-2); padding: 6px 14px; border-radius: 999px; box-shadow: inset 0 0 0 1.5px rgba(139, 90, 60, .35); }

/* ================= 2. Categories ================= */
.section-head { margin-top: 8px; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.section-head h2 { margin: 0; font: 700 2.3rem var(--font-deco); color: var(--clay-dark); text-shadow: 0 2px 0 rgba(255, 240, 210, .6); }
.section-sub { margin: 6px 0 0; color: var(--muted); font-weight: 700; }
.cats-tools { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 40px; }
.group-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.cat-search {
  font: 700 1rem var(--font); padding: 10px 16px; border-radius: 999px; width: min(300px, 100%);
  border: 2px solid rgba(139, 90, 60, .45); background: rgba(255, 250, 240, .85); color: var(--ink); outline: none;
}
.cat-search:focus { border-color: var(--t1); box-shadow: 0 0 0 4px rgba(29, 107, 112, .18); }
.no-results { grid-column: 1 / -1; text-align: center; font-weight: 800; color: var(--muted); font-size: 1.2rem; }
.cat-card .plays {
  position: absolute; z-index: 3; top: -30px; left: 50%; transform: translateX(-50%);
  width: 52px; height: 52px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1;
  background: radial-gradient(circle at 35% 30%, var(--gold-2), var(--gold) 60%, #8a6420);
  color: var(--ink); box-shadow: 0 0 0 3px var(--cream), 0 4px 10px rgba(0, 0, 0, .3);
}
.cat-card .plays { font: 800 1.6rem var(--font); }
.cat-card.last .plays { background: radial-gradient(circle at 35% 30%, #e46b55, var(--t2) 65%); color: #fff; }
.cat-card.locked { cursor: not-allowed; filter: grayscale(1) brightness(.85); opacity: .7; }
.cat-card.locked:hover { transform: none; }
.cat-card.locked .plays { background: #6b5a4c; color: #f3e6cc; }
.group-tab {
  font: 800 1rem var(--font); padding: 9px 18px; border-radius: 999px; border: none; cursor: pointer;
  background: rgba(248, 238, 219, .7); color: var(--clay-dark); box-shadow: inset 0 0 0 2px rgba(139, 90, 60, .45);
  transition: background .15s, color .15s;
}
.group-tab:hover { background: var(--cream); }
.group-tab.active { background: var(--clay-dark); color: var(--gold-2); box-shadow: inset 0 0 0 2px var(--gold); }
.group-tab .n { opacity: .6; font-size: .85em; margin-inline-start: 4px; }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 50px 18px; padding-bottom: 120px; }
.cat-card {
  position: relative; cursor: pointer; padding: 0; text-align: center; font: inherit; color: inherit;
  border-radius: 6px 6px 14px 14px; background: var(--cream); border: 4px solid var(--clay);
  box-shadow: var(--shadow); transition: transform .18s, border-color .18s, box-shadow .18s; overflow: visible;
}
.cat-card::before { content: ""; position: absolute; top: -19px; left: -4px; right: -4px; height: 16px; background: var(--crenel) repeat-x bottom center / 28px 16px; }
.cat-card:hover { transform: translateY(-5px); }
.cat-card .thumb { position: relative; aspect-ratio: 4 / 3; overflow: hidden; background: var(--sand); }
.cat-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s; }
.cat-card:hover .thumb img { transform: scale(1.06); }
.cat-card .thumb::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 55%, rgba(43, 27, 18, .55)); }
.cat-card .cat-emoji {
  position: absolute; z-index: 1; top: -24px; inset-inline-start: 12px; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.45rem; background: var(--cream); box-shadow: 0 0 0 3px var(--gold), 0 3px 8px rgba(0, 0, 0, .25);
}
.cat-card .cat-label { position: relative; padding: 26px 10px 14px; }
.cat-card .cat-name { font-size: 1.15rem; font-weight: 800; color: var(--clay-dark); line-height: 1.3; }
.cat-card .cat-meta { font-size: .8rem; color: var(--muted); margin-top: 4px; font-weight: 700; }
.cat-card .order {
  position: absolute; z-index: 2; top: 8px; inset-inline-end: 8px; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; color: var(--cream); background: var(--t1);
  box-shadow: 0 0 0 3px var(--cream); transform: scale(0); transition: transform .2s cubic-bezier(.2, 1.6, .4, 1);
}
.cat-card.selected { border-color: var(--t1); box-shadow: 0 0 0 4px rgba(29, 107, 112, .35), var(--shadow); transform: translateY(-5px); }
.cat-card.selected .order { transform: scale(1); }
.cat-card.selected::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 10px; background: var(--door) repeat-x bottom / 32px 10px; border-radius: 0 0 10px 10px; }
.cat-card.dim { opacity: .68; filter: saturate(.55); }

.pick-bar {
  position: fixed; z-index: 15; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 16px; padding: 14px 24px;
  background: linear-gradient(var(--clay), var(--clay-dark)); box-shadow: 0 -6px 20px rgba(0, 0, 0, .25);
}
.pick-bar::before { content: ""; position: absolute; left: 0; right: 0; top: -15px; height: 16px; background: var(--crenel-dark) repeat-x bottom / 28px 16px; filter: brightness(1.45); }
.pick-slots { flex: 1; display: flex; gap: 10px; justify-content: center; }
.pick-slot {
  width: 74px; height: 54px; border-radius: 10px; overflow: hidden; position: relative; flex: none;
  background: rgba(255, 235, 200, .1); box-shadow: inset 0 0 0 2px rgba(255, 235, 200, .35);
}
.pick-slot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pick-slot span { position: absolute; inset: auto 0 0 0; font-size: .65rem; font-weight: 800; color: #fff; background: rgba(0, 0, 0, .55); padding: 2px 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.pick-slot.filled { box-shadow: 0 0 0 2px var(--gold-2); cursor: pointer; }
.pick-count { background: rgba(0, 0, 0, .2); padding: 2px 10px; border-radius: 999px; font-size: .9em; }

/* ================= 3. Board ================= */
.scorebar { display: grid; grid-template-columns: 1fr auto 1fr; gap: 18px; align-items: stretch; margin-bottom: 36px; }
.score-plaque {
  position: relative; min-width: 0; display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-radius: 14px;
  background: linear-gradient(var(--tc2), var(--tc)); color: var(--cream);
  box-shadow: 0 5px 0 rgba(0, 0, 0, .25), var(--shadow); transition: transform .2s, box-shadow .2s, opacity .2s; opacity: .75;
}
.score-plaque.t1 { --tc: var(--t1); --tc2: var(--t1-2); }
.score-plaque.t2 { --tc: var(--t2); --tc2: var(--t2-2); flex-direction: row-reverse; }
.score-plaque.active { opacity: 1; transform: scale(1.03); box-shadow: 0 0 0 4px var(--gold-2), 0 5px 0 rgba(0, 0, 0, .25), var(--shadow); }
.score-plaque .team-name { font-weight: 800; font-size: 1.35rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-plaque.t2 .team-name { text-align: end; }
.score-plaque .turn-tag {
  position: absolute; top: -13px; inset-inline-start: 18px; font-size: .8rem; font-weight: 800;
  padding: 3px 12px; border-radius: 999px; background: var(--gold-2); color: var(--ink); box-shadow: 0 2px 0 rgba(0, 0, 0, .2);
}
.score-plaque.t2 .turn-tag { inset-inline-start: auto; inset-inline-end: 18px; }
.score-num { font: 800 2.6rem/1 var(--font); min-width: 3ch; text-align: center; text-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
.score-adj { display: flex; flex-direction: column; gap: 4px; }
.score-adj button { width: 30px; height: 24px; border-radius: 6px; border: none; cursor: pointer; background: rgba(255, 255, 255, .18); color: var(--cream); font-weight: 800; }
.score-adj button:hover { background: rgba(255, 255, 255, .32); }
.score-center { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 6px 18px; border-radius: 14px; background: var(--clay-dark); color: var(--cream); box-shadow: inset 0 0 0 2px var(--gold); min-width: 120px; }
.score-center .lbl { font-size: .8rem; opacity: .8; }
.score-center .val { font: 800 1.5rem var(--font); color: var(--gold-2); }

.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 40px 26px; }
.cat-block { display: grid; grid-template-columns: 1fr 1.35fr 1fr; gap: 10px; padding: 12px; }
.cat-block::before { content: ""; position: absolute; top: -20px; left: -4px; right: -4px; height: 16px; background: var(--crenel) repeat-x bottom center / 28px 16px; }
.tiles { display: flex; flex-direction: column; gap: 8px; }
.tile {
  flex: 1; min-height: 56px; font: 800 1.5rem var(--font); border: none; border-radius: 10px; cursor: pointer; color: var(--cream);
  background: linear-gradient(var(--lv2), var(--lv)); box-shadow: 0 4px 0 var(--lv3), inset 0 0 0 2px rgba(255, 255, 255, .15);
  transition: transform .12s, filter .12s, box-shadow .12s; position: relative; overflow: hidden;
}
.tile::after { content: ""; position: absolute; inset: auto 0 0 0; height: 6px; background: var(--door) repeat-x bottom / 24px 7px; opacity: .55; }
.tile:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.12); }
.tile:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--lv3); }
.tile.d200 { --lv: #b08a52; --lv2: #c9a36a; --lv3: #7c5c31; }
.tile.d400 { --lv: #8b5a3c; --lv2: #a46e4c; --lv3: #5e3a24; }
.tile.d600 { --lv: #4a2c1b; --lv2: #6a412a; --lv3: #2b1a10; }
.tile:disabled { cursor: default; color: transparent; filter: none; background: repeating-linear-gradient(45deg, rgba(139, 90, 60, .12) 0 6px, rgba(139, 90, 60, .05) 6px 12px), var(--cream-2); box-shadow: inset 0 0 0 2px rgba(139, 90, 60, .2); }
.tile:disabled::after { display: none; }
.tile .won { position: absolute; inset: 0; display: grid; place-items: center; font: 800 .85rem var(--font); color: var(--cream); padding: 0 4px; line-height: 1.15; }
.tile .won.t1 { background: rgba(29, 107, 112, .8); background: color-mix(in srgb, var(--t1) 80%, transparent); }
.tile .won.t2 { background: rgba(154, 42, 31, .8); background: color-mix(in srgb, var(--t2) 80%, transparent); }
.tile .won.none { color: var(--muted); font-size: 1.3rem; }
.cat-face {
  position: relative; border-radius: 10px; overflow: hidden; min-height: 190px;
  background: var(--sand) center / cover no-repeat; box-shadow: inset 0 0 0 3px var(--gold), 0 3px 8px rgba(0, 0, 0, .15);
  display: flex; flex-direction: column; justify-content: flex-end;
}
.cat-face::before { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 35%, rgba(43, 27, 18, .88)); }
.cat-face .cat-emoji { position: absolute; top: 8px; inset-inline-start: 8px; font-size: 1.3rem; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: rgba(248, 238, 219, .92); box-shadow: 0 0 0 2px var(--gold); }
.cat-face .cat-name { position: relative; color: #fff; font-weight: 800; font-size: 1.15rem; line-height: 1.25; padding: 10px 8px 12px; text-align: center; text-shadow: 0 2px 6px rgba(0, 0, 0, .6); }
.cat-block.done .cat-face { filter: grayscale(.7) brightness(.85); }
.board-footer { display: flex; justify-content: center; gap: 12px; margin-top: 36px; flex-wrap: wrap; }

/* ================= 4. Question (fills the viewport) ================= */
body[data-screen="question"] #app { max-width: none; padding: 26px 24px 18px; }
#screen-question {
  height: calc(100vh - var(--topbar-h) - 44px); height: calc(100dvh - var(--topbar-h) - 44px); min-height: 560px;
  display: flex; flex-direction: column; gap: 22px;
}
.q-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: none; }
.q-chips { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.chip { font-weight: 800; font-size: 1.15rem; padding: 8px 20px; border-radius: 999px; background: var(--cream); color: var(--clay-dark); box-shadow: inset 0 0 0 2px var(--clay); display: inline-flex; gap: .4em; align-items: center; }
.chip-points { background: var(--clay-dark); color: var(--gold-2); box-shadow: inset 0 0 0 2px var(--gold); }
.chip-points.d600 { background: linear-gradient(#6a412a, #2b1a10); }

.q-main { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr clamp(230px, 18vw, 300px); gap: 22px; }
.q-card { display: flex; flex-direction: column; min-height: 0; }
.q-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 1.15fr 1fr; }
.q-body.pic { grid-template-columns: 1.7fr 1fr; }
.media {
  position: relative; margin: 16px; margin-inline-end: 0; border-radius: 12px; overflow: hidden; min-height: 0;
  background: #2b1b12; box-shadow: inset 0 0 0 3px var(--gold), 0 6px 18px rgba(0, 0, 0, .25);
}
.media-bg { position: absolute; inset: -30px; background: center / cover no-repeat; filter: blur(26px) brightness(.55) saturate(1.2); transition: background-image .3s; }
.media img { position: absolute; inset: 10px; width: calc(100% - 20px); height: calc(100% - 20px); object-fit: contain; filter: drop-shadow(0 8px 20px rgba(0, 0, 0, .45)); animation: imgin .5s ease; }
.media img.swap { animation: imgin .5s ease; }
@keyframes imgin { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
.media::after { content: ""; position: absolute; inset: 0; border-radius: 12px; box-shadow: inset 0 0 0 3px var(--gold); pointer-events: none; }
.media-icon { position: absolute; inset: 0; display: grid; place-items: center; font-size: 7rem; }
.q-textwrap { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 26px; padding: 26px 34px; text-align: center; min-height: 0; overflow: auto; }
.q-text { font: 800 clamp(1.9rem, 1.9vw + 1.5vh, 3.8rem)/1.5 var(--font); color: var(--ink); }
.q-body.pic .q-text { font-size: clamp(1.7rem, 1.5vw + 1.3vh, 3.1rem); }
.answer { width: 100%; padding: 20px 22px; border-radius: 14px; background: linear-gradient(#fff6df, #f3dca9); box-shadow: inset 0 0 0 3px var(--gold), 0 8px 20px rgba(140, 100, 30, .2); animation: pop .5s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes pop { from { transform: scale(.8); opacity: 0; } to { transform: none; opacity: 1; } }
.answer-label { font-weight: 800; color: var(--muted); font-size: 1rem; margin-bottom: 6px; }
.answer-text { font: 800 clamp(2rem, 1.9vw + 1.6vh, 3.6rem)/1.35 var(--font); color: var(--t1); }

.timer-panel { display: flex; flex-direction: column; align-items: center; justify-content: space-evenly; gap: 10px; padding: 18px 14px; --tc: var(--t1); min-height: 0; }
.timer-panel > .crenel { position: absolute; top: 0; left: -4px; right: -4px; }
.timer-who { font-weight: 800; font-size: 1.3rem; color: var(--cream); background: var(--tc); padding: 8px 18px; border-radius: 999px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: background .3s; }
.timer-panel > * { flex: none; }
.timer-ring { position: relative; width: min(100%, 24vh, 230px); aspect-ratio: 1; }
.timer-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: var(--cream-2); stroke: rgba(139, 90, 60, .2); stroke-width: 10; }
.ring-fg { fill: none; stroke: var(--tc); stroke-width: 10; stroke-linecap: round; stroke-dasharray: 326.73; stroke-dashoffset: 0; transition: stroke-dashoffset .25s linear, stroke .3s; }
.timer-num { position: absolute; inset: 0; display: grid; place-items: center; font: 800 clamp(2.6rem, 6vh, 4.4rem) var(--font); color: var(--tc); }
.timer-panel.urgent .timer-num { color: #c0392b; animation: beat 1s infinite; }
.timer-panel.urgent .ring-fg { stroke: #c0392b; }
.timer-panel.over .timer-num { font-size: 3.4rem; color: var(--muted); animation: none; text-align: center; padding: 0 20px; }
.timer-panel.paused .timer-num { opacity: .4; }
@keyframes beat { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.timer-phase { font-weight: 800; color: var(--muted); text-align: center; min-height: 1.3em; }
.timer-controls { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.mini-scores { width: 100%; display: grid; gap: 6px; }
.mini-scores div { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 7px 12px; border-radius: 10px; color: var(--cream); font-weight: 800; }
.mini-scores div span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-scores .t1 { background: var(--t1); }
.mini-scores .t2 { background: var(--t2); }

.q-bottom { flex: none; height: 84px; display: flex; align-items: center; justify-content: center; }
.q-actions .btn-xl { min-width: 340px; height: 72px; font-size: 1.55rem; }
.judge { width: 100%; height: 100%; display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 16px; align-items: center; animation: rise .35s ease; }
.judge-title { font: 700 1.7rem var(--font-deco); color: var(--clay-dark); padding: 0 6px; }
.judge-btn { height: 100%; font-size: 1.5rem; color: var(--cream); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.judge-btn.t1 { background: linear-gradient(var(--t1-2), var(--t1)); box-shadow: 0 5px 0 var(--t1-d); }
.judge-btn.t2 { background: linear-gradient(var(--t2-2), var(--t2)); box-shadow: 0 5px 0 var(--t2-d); }
.judge-btn.none { background: var(--cream); color: var(--clay-dark); box-shadow: inset 0 0 0 2px var(--clay), 0 5px 0 rgba(94, 58, 36, .4); padding: 0 30px; }
.judge-btn:hover { filter: brightness(1.08); }
.judge-btn kbd { margin-inline-start: 8px; }

/* ================= 5. End ================= */
#screen-end { display: grid; place-items: center; min-height: calc(100vh - var(--topbar-h) - 80px); min-height: calc(100dvh - var(--topbar-h) - 80px); }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 30; }
.end-card { width: min(720px, 100%); }
.end-inner { padding: 36px 30px 34px; text-align: center; }
.end-kicker { font-weight: 800; color: var(--muted); letter-spacing: 1px; }
.end-title { font: 700 clamp(2.4rem, 6vw, 3.8rem) var(--font-deco); margin: 6px 0 16px; color: var(--clay-dark); text-shadow: 0 3px 0 var(--gold-2); }
.end-inner .sadu-band { max-width: 380px; margin: 0 auto 26px; }
.end-scores { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 28px; }
.end-score { padding: 18px; border-radius: 12px; color: var(--cream); }
.end-score.t1 { background: linear-gradient(var(--t1-2), var(--t1)); }
.end-score.t2 { background: linear-gradient(var(--t2-2), var(--t2)); }
.end-score .n { font-weight: 800; font-size: 1.2rem; }
.end-score .s { font: 800 3rem/1.2 var(--font); }
.end-score.winner { box-shadow: 0 0 0 4px var(--gold-2), 0 8px 20px rgba(0, 0, 0, .25); }
.end-score.winner .n::before { content: "👑 "; }
.end-btns { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(43, 27, 18, .55); padding: 16px; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.modal-box { width: min(440px, 100%); }
.modal-inner { padding: 26px; text-align: center; }
.modal-inner p { font-size: 1.25rem; font-weight: 800; margin: 0 0 20px; line-height: 1.6; }
.modal-btns { display: flex; justify-content: center; gap: 12px; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .board { grid-template-columns: repeat(2, 1fr); }
  .q-body, .q-body.pic { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1.2fr) auto; }
  .media { margin: 14px 14px 0; }
}
@media (max-width: 900px) {
  #screen-question { height: auto; min-height: 0; }
  .q-main { grid-template-columns: 1fr; }
  .q-body, .q-body.pic { grid-template-rows: auto auto; }
  .media { height: 38vh; }
  .timer-panel { flex-direction: row; flex-wrap: wrap; padding: 22px 14px 14px; }
  .timer-ring { width: 120px; }
  .q-bottom { height: auto; }
  .judge { grid-template-columns: 1fr 1fr; }
  .judge-title { grid-column: 1 / -1; text-align: center; }
  .judge-btn { height: 64px; }
  .judge-btn.none { grid-column: 1 / -1; grid-row: 3; }
  .pick-slots { display: none; }
  .pick-bar { justify-content: space-between; }
}
@media (max-width: 640px) {
  #app { padding: 28px 16px 30px; }
  .topbar { padding: 0 16px; }
  .hero-inner { padding: 24px 18px 26px; }
  .teams-input { grid-template-columns: 1fr; gap: 26px; }
  .vs { margin: -6px auto; }
  .cat-grid { grid-template-columns: repeat(2, 1fr); gap: 28px 12px; }
  .board { grid-template-columns: 1fr; }
  .scorebar { grid-template-columns: 1fr 1fr; }
  .score-center { grid-column: 1 / -1; grid-row: 1; flex-direction: row; gap: 10px; }
  .score-plaque { padding: 10px 12px; gap: 8px; }
  .score-plaque .team-name { font-size: 1rem; }
  .score-num { font-size: 1.9rem; }
  .end-scores { grid-template-columns: 1fr; }
  .q-top { flex-wrap: wrap; }
  .q-actions .btn-xl { min-width: 0; width: 100%; }
  .q-textwrap { padding: 20px 16px; }
  .pick-bar { padding: 12px 16px; }
}

/* ---------- Access codes ---------- */
body[data-screen="code"] .photo-bg { opacity: 1; }
#screen-code { min-height: calc(100vh - var(--topbar-h) - 76px); min-height: calc(100dvh - var(--topbar-h) - 76px); display: grid; place-items: center; }
.code-frame { width: min(620px, 100%); }
.code-input {
  width: 100%; font: 800 1.35rem monospace; letter-spacing: 1px; text-align: center; text-transform: uppercase;
  padding: 14px; border-radius: 12px; border: 2px solid rgba(139, 90, 60, .45); background: #fffaf0; outline: none; margin-bottom: 10px;
}
.code-input:focus { border-color: var(--t1); box-shadow: 0 0 0 4px rgba(29, 107, 112, .2); }
.code-err { min-height: 1.5em; color: var(--t2); font-weight: 800; margin-bottom: 14px; }
.ticket { display: inline-flex; align-items: center; gap: 6px; padding: 0 14px; height: 40px; border-radius: 10px;
  background: var(--gold-2); color: var(--ink); font-weight: 800; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .15); white-space: nowrap; }
.ticket.empty { background: var(--t2); color: #fff; }
a.icon-btn { display: inline-grid; place-items: center; text-decoration: none; }
.pick-bar .no-games { color: var(--gold-2); font-weight: 800; }
@media (max-width: 640px) { .ticket { padding: 0 8px; font-size: .85rem; } }

/* ---------- About section (first screen only) ---------- */
.about { display: none; max-width: 980px; margin: 30px auto 10px; gap: 40px; }
body:not([data-screen]) .about, body[data-screen="code"] .about { display: grid; }
.about-card {
  position: relative; padding: 26px 30px 22px; line-height: 1.85; color: var(--ink);
  background: linear-gradient(rgba(255, 250, 238, .6), rgba(255, 250, 238, 0) 40%), var(--cream);
  border: 4px solid var(--clay); border-radius: 6px 6px var(--radius) var(--radius); box-shadow: var(--shadow);
}
.about-card .crenel { position: absolute; top: 0; left: -4px; right: -4px; }
.about-card h2 { margin: 0 0 10px; font: 800 1.55rem/1.5 var(--font); color: var(--clay-dark); }
.about-card h3 { margin: 22px 0 8px; font: 800 1.2rem/1.5 var(--font); color: var(--clay); }
.about-card p { margin: 0 0 12px; font-size: 1.05rem; }
.about-card ol, .about-card ul { margin: 0; padding-inline-start: 1.4em; }
.about-facts { list-style: none; padding: 0 !important; display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; }
.about-facts li { background: var(--cream-2); border-radius: 10px; padding: 8px 12px; box-shadow: inset 0 0 0 1.5px rgba(139, 90, 60, .3); font-weight: 700; }
.about-cats { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 6px 22px; }
.about-cats h4 { margin: 10px 0 2px; color: var(--t1); font-size: 1rem; }
.about-cats p { margin: 0; font-size: .95rem; color: var(--muted); }
.about-faq dt { font-weight: 800; margin-top: 10px; color: var(--clay-dark); }
.about-faq dd { margin: 2px 0 0; }
@media (max-width: 640px) { .about-card { padding: 22px 16px 18px; } .about-card h2 { font-size: 1.4rem; } }

/* ---------- Phones / tablets / touch ---------- */
@media (max-width: 480px) {           /* iPhone portrait: keep the whole top bar on screen */
  .code-input { font-size: 1.05rem; letter-spacing: 0; padding: 14px 8px; } /* >=16px: no iOS zoom; fits MJLS-XXXX-XXXX-XXXX-XXXX */
  .topbar { padding: 0 10px; }
  .brand-name { display: none; }
  .topbar-actions { gap: 5px; }
  .icon-btn { min-width: 36px; height: 38px; padding: 0 6px; font-size: .95rem; }
  .ticket { height: 38px; }
}
@media (max-width: 360px) {           /* small phones (iPhone SE 1st gen, mini zoomed) */
  .topbar-actions { gap: 4px; }
  .icon-btn { min-width: 33px; padding: 0 4px; font-size: .9rem; }
  .ticket { padding: 0 6px; font-size: .78rem; }
}
@media (pointer: coarse) {            /* fingers, not a mouse */
  .score-adj { gap: 6px; }
  .score-adj button { width: 40px; height: 34px; font-size: 1.05rem; }
  kbd { display: none; }              /* keyboard hints mean nothing on a phone/iPad */
}
@media (hover: none) {                /* no sticky hover effects after a tap */
  body { background-attachment: scroll; }
  .cat-card:hover:not(.selected) { transform: none; }
  .cat-card:hover .thumb img { transform: none; }
  .tile:hover:not(:disabled) { transform: none; filter: none; }
}

/* ---------- Text questions: no image until the answer is revealed ---------- */
.q-body.noimg { grid-template-columns: 1fr; }
.q-body.noimg .media { display: none; }
.q-body.noimg .q-textwrap { padding: 30px 8%; }
.q-body.noimg .q-text { font-size: clamp(2.2rem, 2.4vw + 2vh, 4.6rem); }
.q-body:not(.noimg) .media { animation: mediain .55s cubic-bezier(.2, .9, .3, 1); }
@keyframes mediain { from { opacity: 0; transform: translateX(var(--slide, 30px)); } to { opacity: 1; transform: none; } }
html[dir="rtl"] .q-body { --slide: 30px; }
html[dir="ltr"] .q-body { --slide: -30px; }

/* link to the code shop (code screen) */
.buy-link { display: block; width: fit-content; margin: 16px auto 0; color: var(--clay-dark); font-weight: 700; text-decoration: none;
  border-bottom: 2px solid var(--gold); padding-bottom: 2px; }
.buy-link:hover, .buy-link:focus-visible { color: var(--t2); border-color: var(--t2); }
