/* BrainBox — shared styles for TV, phone and landing page */
:root {
  --bg: #120b2e;
  --bg2: #1f1150;
  --panel: rgba(255, 255, 255, 0.07);
  --panel2: rgba(255, 255, 255, 0.12);
  --line: rgba(255, 255, 255, 0.16);
  --text: #fff8ef;
  --muted: #b9b2d8;
  --pink: #ff5d8f;
  --blue: #4cc9f0;
  --green: #5ee6a0;
  --yellow: #ffd166;
  --purple: #b388ff;
  --orange: #ff9f43;
  --red: #ff5a5a;
  --ok: #45e08a;
  --bad: #ff5a6e;
  --radius: 22px;
  --font-head: 'Fredoka', 'Baloo 2', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --emoji: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
  color-scheme: dark;
}
[dir='rtl'] { --font-head: 'Vazirmatn', 'Noto Naskh Arabic', 'Fredoka', sans-serif; --font-body: 'Vazirmatn', 'Noto Naskh Arabic', 'Nunito', sans-serif; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 700px at 15% -10%, #3a1a8a 0%, transparent 60%), radial-gradient(900px 600px at 110% 110%, #0d4f6e 0%, transparent 55%), var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  overflow-x: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, select { font: inherit; color: inherit; }
.h { font-family: var(--font-head); font-weight: 600; letter-spacing: 0.01em; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 12px; }
.col { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1; }
.center { display: flex; align-items: center; justify-content: center; text-align: center; }
.emo { font-family: var(--emoji); line-height: 1; }

/* ---------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 16px 26px; border-radius: 999px; font-family: var(--font-head); font-weight: 600; font-size: 20px;
  background: linear-gradient(180deg, #ff7aa5, var(--pink)); color: #2b0a1a; box-shadow: 0 6px 0 #b8355f, 0 12px 30px rgba(255, 93, 143, 0.35);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.2s; user-select: none;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #b8355f; }
.btn:disabled { filter: grayscale(1) brightness(0.7); cursor: default; }
.btn.blue { background: linear-gradient(180deg, #7ddcf6, var(--blue)); color: #062433; box-shadow: 0 6px 0 #2a8cab, 0 12px 30px rgba(76, 201, 240, 0.3); }
.btn.green { background: linear-gradient(180deg, #8ff2bf, var(--green)); color: #06301a; box-shadow: 0 6px 0 #2a9d63, 0 12px 30px rgba(94, 230, 160, 0.3); }
.btn.yellow { background: linear-gradient(180deg, #ffe29a, var(--yellow)); color: #3a2800; box-shadow: 0 6px 0 #c49a2c; }
.btn.ghost { background: var(--panel2); color: var(--text); box-shadow: inset 0 0 0 2px var(--line); }
.btn.small { padding: 10px 16px; font-size: 16px; }
.btn.block { width: 100%; }
:focus-visible { outline: 4px solid var(--yellow); outline-offset: 4px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; backdrop-filter: blur(8px); }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; background: var(--panel2); font-weight: 700; font-size: 15px; }

/* ---------- avatars */
.av { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; font-family: var(--emoji); flex: none; position: relative; }
.av.off { opacity: 0.35; filter: grayscale(1); }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 999px; background: var(--panel2); font-weight: 800; }
.chip .av { width: 34px; height: 34px; font-size: 20px; }

/* ---------- answer tiles (A B C D) */
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.opt {
  position: relative; display: flex; align-items: center; gap: 14px; padding: 18px 20px; border-radius: 20px; text-align: start;
  font-family: var(--font-head); font-weight: 600; font-size: 22px; color: #1a0f2e; min-height: 74px; overflow-wrap: break-word; word-break: normal; hyphens: auto;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.25); transition: transform 0.1s, opacity 0.3s, filter 0.3s;
}
.opt .sym { font-size: 0.9em; opacity: 0.75; flex: none; width: 1.3em; text-align: center; }
.opt:nth-child(1) { background: #ff7096; } .opt:nth-child(2) { background: #5fd3f5; }
.opt:nth-child(3) { background: #ffd166; } .opt:nth-child(4) { background: #7ef0b0; }
.opt:nth-child(5) { background: #c3a2ff; } .opt:nth-child(6) { background: #ffb26b; }
.opt:active { transform: translateY(3px); }
.opt.sel { outline: 5px solid #fff; outline-offset: 3px; }
.opt.dim { opacity: 0.25; filter: grayscale(0.7); }
.opt.right { outline: 6px solid var(--ok); outline-offset: 3px; }
.opt.right::after { content: '✓'; position: absolute; right: 14px; font-size: 1.3em; color: #0b4d2a; }
[dir='rtl'] .opt.right::after { right: auto; left: 14px; }
.opt.wrong { outline: 5px dashed var(--bad); outline-offset: 3px; }
.opts.one { grid-template-columns: 1fr; }
@media (max-width: 600px) { .opt { font-size: 19px; padding: 14px 14px; gap: 10px; min-height: 64px; } }

/* ---------- timer */
.timer { position: relative; width: 84px; height: 84px; flex: none; }
.timer svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.timer .num { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--font-head); font-size: 30px; font-weight: 700; }
.timer.low .num { color: var(--bad); animation: pulse 0.6s infinite; }
@keyframes pulse { 50% { transform: scale(1.15); } }

/* ---------- visuals */
.vis { display: flex; align-items: center; justify-content: center; position: relative; }
.vis .big-emo { font-family: var(--emoji); font-size: 160px; line-height: 1; }
.vis .flag { max-height: 220px; max-width: 90%; border-radius: 12px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45); background: #fff; }
.vis .expr { font-family: var(--font-head); font-size: 96px; font-weight: 700; direction: ltr; }
.zoombox { width: 360px; height: 260px; overflow: hidden; border-radius: 24px; background: #fff; display: flex; align-items: center; justify-content: center; box-shadow: inset 0 0 0 6px rgba(0,0,0,0.08); }
.zoombox .big-emo { transition: transform 0.25s linear, filter 0.25s linear; }
.versus { display: flex; align-items: center; gap: 26px; }
.versus .vs { font-family: var(--font-head); font-size: 42px; color: var(--yellow); }
.versus .it { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px 26px; border-radius: 24px; background: var(--panel2); min-width: 200px; }
.versus .it .emo { font-size: 110px; }
.versus .it .lbl { font-family: var(--font-head); font-size: 26px; text-align: center; }
.pattern { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; align-items: center; direction: ltr; }
.pattern .cell { min-width: 96px; height: 96px; padding: 0 10px; border-radius: 20px; background: var(--panel2); display: flex; align-items: center; justify-content: center; font-size: 56px; font-family: var(--emoji); }
.pattern .cell.num { font-family: var(--font-head); font-size: 50px; font-weight: 700; }
.pattern .cell.q { background: var(--yellow); color: #3a2800; font-family: var(--font-head); animation: pulse 1.2s infinite; }
.jar { position: relative; width: 520px; height: 340px; border-radius: 26px; background: linear-gradient(180deg, rgba(255,255,255,0.14), rgba(255,255,255,0.05)); border: 3px solid var(--line); overflow: hidden; }
.jar span { position: absolute; font-family: var(--emoji); font-size: 34px; transform: translate(-50%, -50%); }
.jar .cover { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; background: #2a1a66; font-family: var(--font-head); font-size: 34px; gap: 10px; }
.soundbtn { width: 220px; height: 220px; border-radius: 50%; background: radial-gradient(circle at 30% 30%, #7ddcf6, #2a8cab); display: flex; align-items: center; justify-content: center; font-size: 110px; font-family: var(--emoji); box-shadow: 0 0 0 0 rgba(76, 201, 240, 0.6); }
.soundbtn.playing { animation: ripple 1s infinite; }
@keyframes ripple { 0% { box-shadow: 0 0 0 0 rgba(76, 201, 240, 0.6); } 100% { box-shadow: 0 0 0 40px rgba(76, 201, 240, 0); } }

/* ---------- interactive puzzles */
.clockwrap { display: flex; align-items: center; justify-content: center; gap: 40px; flex-wrap: wrap; direction: ltr; }
.anaclock { width: 300px; height: 300px; touch-action: none; }
.digital { display: flex; align-items: center; gap: 10px; font-family: 'Courier New', monospace; font-weight: 700; }
.digital .bar { display: flex; flex-direction: column; align-items: center; gap: 6px; touch-action: none; }
.digital .val { font-size: 72px; background: #0a0618; color: #7dffb0; border-radius: 16px; padding: 8px 18px; min-width: 2.4ch; text-align: center; text-shadow: 0 0 18px rgba(125, 255, 176, 0.6); box-shadow: inset 0 0 0 3px #26184f; }
.digital .colon { font-size: 64px; color: #7dffb0; }
.digital .arr { width: 74px; height: 50px; border-radius: 14px; background: var(--panel2); font-size: 26px; }
.digital .tag { font-family: var(--font-head); font-size: 22px; color: var(--yellow); margin-inline-start: 8px; }
.ampm { font-family: var(--font-head); font-size: 28px; padding: 6px 16px; border-radius: 12px; background: var(--yellow); color: #3a2800; }
.grid { display: grid; gap: 8px; direction: ltr; }
.grid .g { aspect-ratio: 1; border-radius: 14px; background: var(--panel2); display: flex; align-items: center; justify-content: center; font-family: var(--emoji); position: relative; transition: background 0.15s, transform 0.15s; user-select: none; }
.grid .g.lit { background: var(--yellow); transform: scale(1.05); box-shadow: 0 0 30px rgba(255, 209, 102, 0.7); }
.grid .g.tap { background: var(--blue); }
.grid .g.good::after { content: ''; position: absolute; inset: -4px; border: 5px solid var(--ok); border-radius: 50%; }
.grid .g.bad::after { content: '✕'; position: absolute; color: var(--bad); font-family: var(--font-head); font-size: 1.4em; }
.spot { display: flex; gap: 24px; justify-content: center; align-items: center; flex-wrap: wrap; }
.spot .lab { text-align: center; font-weight: 800; color: var(--muted); margin-bottom: 6px; }
.tiles { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; direction: ltr; }
.tile { width: 64px; height: 72px; border-radius: 14px; background: #fff3d6; color: #2b1a00; font-family: var(--font-head); font-size: 38px; font-weight: 700; display: flex; align-items: center; justify-content: center; box-shadow: 0 5px 0 #c9a96b; }
.tile.used { opacity: 0.2; }
.slot { width: 64px; height: 72px; border-radius: 14px; border: 3px dashed var(--line); display: flex; align-items: center; justify-content: center; font-family: var(--font-head); font-size: 38px; font-weight: 700; }
.slot.filled { border: 0; background: var(--yellow); color: #3a2800; }
.coins { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.coin { width: 78px; height: 78px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: var(--font-head); font-weight: 700; font-size: 22px; color: #3a2a00; background: radial-gradient(circle at 35% 30%, #ffe9a6, #d4a63a); box-shadow: inset 0 0 0 5px rgba(0,0,0,0.12), 0 4px 0 #8a6a1f; }
.coin.copper { background: radial-gradient(circle at 35% 30%, #f6b58a, #b4683a); box-shadow: inset 0 0 0 5px rgba(0,0,0,0.12), 0 4px 0 #6e3a1c; color: #2e1406; }
.coin.silver { background: radial-gradient(circle at 35% 30%, #ffffff, #aab3c0); box-shadow: inset 0 0 0 5px rgba(0,0,0,0.1), 0 4px 0 #6b7480; color: #1d2430; }
.coin.bi { background: radial-gradient(circle at 50% 50%, #e9edf2 0 48%, #e6be55 50%); }
.coin.note { width: 110px; height: 64px; border-radius: 10px; background: linear-gradient(135deg, #7fd3a8, #3b9d6e); color: #062b18; box-shadow: 0 4px 0 #1f5a3e; }
.coin.sm { width: 54px; height: 54px; font-size: 16px; }
.coin.note.sm { width: 76px; height: 46px; }
.tray { min-height: 70px; border-radius: 18px; border: 3px dashed var(--line); padding: 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; }
.sorter { display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.sorter .row2 { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.sitem { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 14px; border-radius: 16px; background: var(--panel2); min-width: 104px; font-weight: 800; font-size: 15px; position: relative; }
.sitem .emo { font-size: 44px; }
.sitem.used { opacity: 0.25; }
.sitem .n { position: absolute; top: -10px; left: -10px; width: 28px; height: 28px; border-radius: 50%; background: var(--yellow); color: #3a2800; font-family: var(--font-head); display: flex; align-items: center; justify-content: center; }
.dpad { display: grid; grid-template-columns: repeat(3, 72px); grid-template-rows: repeat(3, 72px); gap: 8px; justify-content: center; }
.dpad button { border-radius: 18px; background: var(--panel2); font-size: 32px; }
.dpad button:active { background: var(--blue); }
.jig { display: grid; gap: 3px; direction: ltr; touch-action: manipulation; }
.jig .p { aspect-ratio: 1; overflow: hidden; position: relative; border-radius: 6px; }
.jig .p.sel { outline: 5px solid var(--yellow); z-index: 2; }
.jig .pic { position: absolute; display: flex; align-items: center; justify-content: center; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.keypad button { height: 64px; border-radius: 16px; background: var(--panel2); font-family: var(--font-head); font-size: 30px; font-weight: 700; }
.keypad button:active { background: var(--blue); }
.numdisp { font-family: var(--font-head); font-size: 64px; font-weight: 700; text-align: center; min-height: 80px; border-radius: 18px; background: #0a0618; padding: 4px; direction: ltr; }
.balance svg { width: 100%; max-width: 560px; height: auto; }

/* ---------- leaderboard */
.board { display: flex; flex-direction: column; gap: 10px; }
.brow { display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-radius: 18px; background: var(--panel); transition: transform 0.6s cubic-bezier(.2,.8,.2,1); }
.brow .rank { width: 36px; font-family: var(--font-head); font-size: 26px; text-align: center; color: var(--muted); }
.brow .nm { flex: 1; font-weight: 800; font-size: 22px; }
.brow .sc { font-family: var(--font-head); font-size: 28px; font-weight: 700; }
.brow .dl { font-family: var(--font-head); color: var(--ok); font-size: 20px; min-width: 70px; text-align: end; }
.brow.top { background: linear-gradient(90deg, rgba(255, 209, 102, 0.25), var(--panel)); }

@keyframes pop { 0% { transform: scale(0.6); opacity: 0; } 70% { transform: scale(1.06); } 100% { transform: scale(1); opacity: 1; } }
@keyframes rise { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.pop { animation: pop 0.45s cubic-bezier(.2,.9,.3,1.3) both; }
.rise { animation: rise 0.5s ease both; }
.shake { animation: shake 0.4s; }

/* ---------- drawing */
.canvaswrap { background: #fff; border-radius: 18px; overflow: hidden; touch-action: none; position: relative; }
.canvaswrap canvas { display: block; width: 100%; height: 100%; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.swatches button { width: 40px; height: 40px; border-radius: 50%; box-shadow: inset 0 0 0 3px rgba(0,0,0,0.2); }
.swatches button.sel { outline: 4px solid #fff; outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* typed answers */
.typedhint { text-align: center; font-family: var(--font-head); font-size: 40px; color: var(--yellow); padding: 18px 0 26px; }
.typedin { font-size: 24px; text-align: center; padding: 16px; }
.typedwas { text-align: center; font-weight: 800; color: var(--muted); margin: 0 0 12px; font-size: 18px; }

/* game thumbnails (TV picker): 352x198, YouTube clickbait style */
.thumb { position: relative; width: 352px; height: 198px; border-radius: 18px; overflow: hidden; color: #fff; text-align: start; isolation: isolate; }
.thumb::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(0,0,0,.55)); z-index: 1; pointer-events: none; }
.th-art { position: absolute; inset: 0; }
.th-e { position: absolute; font-family: var(--emoji); line-height: 1; filter: drop-shadow(0 4px 6px rgba(0,0,0,.35)); }
.th-flag { position: absolute; border-radius: 6px; box-shadow: 0 6px 14px rgba(0,0,0,.45); border: 3px solid #fff; }
.th-title { position: absolute; left: 12px; right: 12px; bottom: 8px; z-index: 2; font: 700 31px/1 var(--font-head); text-transform: uppercase; letter-spacing: .01em; color: #fff;
  -webkit-text-stroke: 7px #111; paint-order: stroke fill; text-shadow: 0 4px 0 #111; }
.th-tag { position: absolute; top: 8px; right: 8px; z-index: 2; background: #ff1f3d; color: #fff; font: 800 15px/1 var(--font-body); padding: 6px 10px; border-radius: 8px; transform: rotate(3deg); box-shadow: 0 3px 0 #8a0016, 0 6px 12px rgba(0,0,0,.35); text-transform: uppercase; }
.th-big, .th-vs, .th-waves, .th-chalk, .th-sign, .th-digital, .th-bubble, .th-arrow { position: absolute; }
.th-big { font: 700 60px/1 var(--font-head); color: #ffd166; -webkit-text-stroke: 6px #111; paint-order: stroke fill; }
.th-vs { font: 700 46px/1 var(--font-head); color: #fff; -webkit-text-stroke: 7px #111; paint-order: stroke fill; transform: rotate(-8deg); }
.th-waves { font: 700 70px/1 var(--font-head); color: #fff; letter-spacing: -8px; opacity: .9; }
.th-chalk { font: 700 54px/1 'Comic Sans MS', var(--font-head); color: #f8fafc; text-shadow: 0 0 2px #fff; transform: rotate(-3deg); }
.th-sign { background: #fff; color: #111; font: 700 28px/1 var(--font-head); padding: 8px 12px; border-radius: 10px; transform: rotate(6deg); box-shadow: 0 5px 0 #0003; }
.th-digital { background: #111; color: #4ade80; font: 700 44px/1 ui-monospace, monospace; padding: 8px 12px; border-radius: 10px; border: 3px solid #333; }
.th-bubble { background: #fff; color: #111; font: 800 24px/1.1 var(--font-body); padding: 12px 16px; border-radius: 22px; max-width: 250px; }
.th-arrow { font: 900 54px/1 var(--font-body); color: #ff1f3d; -webkit-text-stroke: 3px #fff; paint-order: stroke fill; }
.th-circle { position: absolute; border: 6px solid #ff1f3d; border-radius: 50%; box-shadow: 0 0 0 3px #fff, 0 0 16px rgba(255,31,61,.6); }
.th-tile { display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; color: #3a2800; font: 700 1em/1 var(--font-head); box-shadow: 0 5px 0 #c49a2c; }
.th-maze { position: absolute; width: 200px; height: 130px; border-radius: 10px; background:
  repeating-linear-gradient(90deg, transparent 0 28px, #14532d 28px 36px), repeating-linear-gradient(0deg, rgba(255,255,255,.9) 0 26px, transparent 26px 34px); opacity: .9; }
.th-scribble { position: absolute; left: 18px; top: 8px; font: 700 76px/1 'Comic Sans MS', cursive; color: #ef4444; transform: rotate(-8deg); }

.thumbwrap { position: relative; border-radius: 14px; overflow: hidden; flex: none; }
.th-spot { position: absolute; left: 120px; top: -40px; width: 200px; height: 260px; background: radial-gradient(ellipse at 50% 30%, rgba(255,240,180,.45), transparent 65%); }
.th-card { position: absolute; width: 66px; height: 92px; border-radius: 9px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; box-shadow: 0 6px 14px rgba(0,0,0,.5); color: #111; border: 3px solid #111; }
.th-card span { font-family: var(--emoji); font-size: 34px; line-height: 1; }
.th-card b { font: 700 16px/1 var(--font-head); color: #b91c1c; }
.th-ring { position: absolute; left: 70px; top: 6px; width: 210px; height: 140px; border-radius: 50%; border: 7px solid #fde68a; box-shadow: inset 0 0 30px rgba(0,0,0,.45), 0 0 20px rgba(253,230,138,.6); background: rgba(0,0,0,.25); }
.th-ball { position: absolute; width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: var(--emoji); font-size: 26px; border: 4px solid #fff; box-shadow: 0 5px 10px rgba(0,0,0,.45); }
.th-peg { position: absolute; width: 9px; height: 9px; border-radius: 50%; background: #c7d2fe; box-shadow: 0 0 6px #a5b4fc; }
.th-marble { position: absolute; width: 30px; height: 30px; border-radius: 50%; box-shadow: 0 4px 8px rgba(0,0,0,.5); }

.suggest { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.suggest .sugg { text-align: start; padding: 12px 16px; border-radius: 14px; background: var(--panel2); color: var(--text); font-weight: 800; font-size: 18px; border: 2px solid var(--line); }
.suggest .sugg:active { background: var(--yellow); color: #3a2800; }
.tunebtn { background: radial-gradient(circle at 30% 30%, #f9a8d4, #be185d); }

.av.photo { overflow: hidden; }
