/* =========================================================
   מוח חד: עיצוב
   שפת עיצוב בהשראת Material 3 Expressive:
   משטחים טונאליים, צורות מעוגלות גדולות, תנועה קפיצית.
   ========================================================= */

:root {
  --font-display: 'Fredoka', 'Assistant', system-ui, sans-serif;
  --font-text: 'Assistant', 'Fredoka', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;

  --r-xl: 32px;
  --r-lg: 24px;
  --r-md: 18px;
  --r-sm: 12px;
  --r-full: 999px;

  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --emph: cubic-bezier(.2, 0, 0, 1);
  --emph-out: cubic-bezier(.3, 0, .8, .15);
}

/* ---------- Light (ברירת מחדל) ---------- */
[data-theme="light"] {
  color-scheme: light;
  --surface: #F4F8F5;
  --c-lowest: #FFFFFF;
  --c-low: #EDF3EF;
  --c: #E6EEE9;
  --c-high: #DCE6E0;
  --ink: #131C17;
  --ink-2: #404A44;
  --ink-3: #6B766F;
  --outline: #707B74;
  --outline-v: #C5D0C9;
  --grid-dot: rgba(19, 28, 23, .09);

  --primary: #00704A;
  --on-primary: #FFFFFF;
  --primary-c: #A3F5CB;
  --on-primary-c: #002113;

  --sky: #00609F;
  --sky-c: #D3E4FF;
  --on-sky-c: #001C38;

  --berry: #9B2E6B;
  --on-berry: #FFFFFF;
  --berry-c: #FFD8E9;
  --on-berry-c: #3D0026;

  --shadow-1: 0 1px 2px rgba(19, 28, 23, .08), 0 1px 3px 1px rgba(19, 28, 23, .05);
  --shadow-2: 0 2px 6px rgba(19, 28, 23, .08), 0 8px 24px rgba(19, 28, 23, .07);
  --card-edge: #C9D6CE;
}

/* ---------- Dark ---------- */
[data-theme="dark"] {
  color-scheme: dark;
  --surface: #0E1411;
  --c-lowest: #161D19;
  --c-low: #1F2823;
  --c: #252F29;
  --c-high: #2E3933;
  --ink: #DEE5E0;
  --ink-2: #BFC9C2;
  --ink-3: #8D9891;
  --outline: #89938C;
  --outline-v: #3F4943;
  --grid-dot: rgba(222, 229, 224, .07);

  --primary: #83DBAE;
  --on-primary: #00391F;
  --primary-c: #005235;
  --on-primary-c: #A3F5CB;

  --sky: #A2C9FF;
  --sky-c: #00497A;
  --on-sky-c: #D3E4FF;

  --berry: #FFAFD3;
  --on-berry: #5E1140;
  --berry-c: #7D1652;
  --on-berry-c: #FFD8E9;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4), 0 1px 3px 1px rgba(0, 0, 0, .25);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, .35), 0 10px 30px rgba(0, 0, 0, .35);
  --card-edge: #0A0F0C;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-text);
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--surface);
  /* נייר משבצות של מחברת חידות */
  background-image: radial-gradient(var(--grid-dot) 1.2px, transparent 1.3px);
  background-size: 22px 22px;
  min-height: 100vh;
  transition: background-color .4s var(--emph), color .4s var(--emph);
  overflow-x: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; border-radius: 10px; }


/* ---------- צורות רקע (Material shapes) עם פרלקסה ---------- */
.app { position: relative; z-index: 1; }
.bg-shapes { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.bs { position: absolute; opacity: .55; transition: transform 1.2s cubic-bezier(.2, 0, 0, 1); }
.bs1 { width: 340px; top: -110px; left: -120px; fill: var(--primary-c); transform: translate(calc(var(--px, 0) * 26px), calc(var(--py, 0) * 20px)) rotate(calc(var(--px, 0) * 8deg)); }
.bs2 { width: 300px; bottom: 6%; left: -150px; fill: var(--sky-c); transform: translate(calc(var(--px, 0) * -18px), calc(var(--py, 0) * 14px)) rotate(-28deg); }
.bs3 { width: 220px; top: 38%; right: -90px; fill: var(--berry-c); transform: translate(calc(var(--px, 0) * 20px), calc(var(--py, 0) * -16px)) rotate(calc(18deg + var(--px, 0) * -10deg)); }
.bs4 { width: 160px; bottom: -50px; right: 12%; fill: var(--primary-c); opacity: .4; transform: translate(calc(var(--px, 0) * -12px), calc(var(--py, 0) * -10px)); }
[data-theme="dark"] .bs { opacity: .28; }
@media (max-width: 640px) { .bs1 { width: 220px; top: -90px; left: -100px; } .bs2, .bs4 { display: none; } .bs3 { width: 150px; right: -80px; } }

/* הטיה תלת ממדית של הכרטיס לפי מיקום העכבר */
.tilt { transform-style: preserve-3d; transition: transform .5s cubic-bezier(.2, 0, 0, 1); }

#fx { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 60; }

.app { max-width: 860px; margin: 0 auto; padding: 22px 18px 64px; }
.screen { display: none; }
.screen.active { display: block; }

/* ---------- Material Symbols ---------- */
.msr {
  font-family: 'Material Symbols Rounded';
  font-weight: 500;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  width: 1em; height: 1em;
  overflow: hidden;
  display: inline-block;
  flex: 0 0 auto;
  letter-spacing: normal;
  text-transform: none;
  white-space: nowrap;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  font-feature-settings: 'liga';
  font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
.msr.fill { font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24; }
.msr.flip { transform: scaleX(-1); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 22px; border-radius: var(--r-full);
  font-family: var(--font-display); font-weight: 500; font-size: 1rem;
  transition: background-color .2s, box-shadow .2s, transform .25s var(--spring), color .2s;
  position: relative; overflow: hidden; isolation: isolate;
}
.btn:active { transform: scale(.96); }
.btn.filled { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-1); }
.btn.filled:hover { box-shadow: var(--shadow-2); }
.btn.tonal { background: var(--primary-c); color: var(--on-primary-c); }
.btn.outline { border: 1.5px solid var(--outline-v); color: var(--ink-2); }
.btn.outline:hover:not(:disabled) { background: var(--c); }
.btn.text { color: var(--primary); padding: 10px 14px; }
.btn.text:hover { background: color-mix(in srgb, var(--primary) 9%, transparent); }
.btn.text.danger { color: var(--ink-3); }
.btn.text.danger.armed { color: var(--on-berry); background: var(--berry); }
.btn:disabled { cursor: default; }

.icon-btn {
  width: 48px; height: 48px; border-radius: var(--r-full);
  display: grid; place-items: center; color: var(--ink-2);
  transition: background-color .2s, transform .25s var(--spring);
}
.icon-btn:hover { background: var(--c); }
.icon-btn:active { transform: scale(.9); }

/* Ripple */
.ripple {
  position: absolute; border-radius: 50%; pointer-events: none; z-index: -1;
  background: currentColor; opacity: .16; transform: scale(0);
  animation: ripple .6s var(--emph) forwards;
}
@keyframes ripple { to { transform: scale(1); opacity: 0; } }

/* =========================================================
   HOME
   ========================================================= */
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 26px; }
.brand { display: flex; align-items: center; gap: 16px; }
.mark { width: 72px; height: 72px; flex: 0 0 72px; overflow: visible; filter: drop-shadow(0 6px 14px color-mix(in srgb, var(--primary) 30%, transparent)); }
.mark-shape { fill: var(--primary); transform-origin: 50px 50px; animation: spin 28s linear infinite; }
.mark text { font-family: var(--font-display); font-weight: 700; font-size: 52px; fill: var(--on-primary); }
@keyframes spin { to { transform: rotate(360deg); } }
.brand h1 {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(2.3rem, 7vw, 3.4rem); line-height: 1; letter-spacing: -.5px;
}
.tagline { color: var(--ink-2); margin-top: 8px; font-size: 1.05rem; max-width: 46ch; }
.top-actions { display: flex; gap: 2px; }

/* Hero: progress ring + KPIs */
.hero {
  display: grid; grid-template-columns: auto 1fr; gap: 28px; align-items: center;
  background: var(--c-lowest); border-radius: var(--r-xl); padding: 24px 28px;
  box-shadow: var(--shadow-1); margin-bottom: 18px;
}
.ring-wrap { position: relative; width: 168px; height: 168px; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg) scaleY(-1); }
.ring circle { fill: none; stroke-width: 11; stroke-linecap: round; transition: stroke-dasharray 1.1s var(--emph), stroke-dashoffset 1.1s var(--emph); }
.ring-track { stroke: var(--c-high); }
.ring-easy { stroke: var(--primary); }
.ring-med { stroke: var(--sky); }
.ring-hard { stroke: var(--berry); }
.ring-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-label strong { font-family: var(--font-display); font-size: 3rem; font-weight: 600; line-height: 1; }
.ring-label span { color: var(--ink-3); font-size: .92rem; }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.kpi { display: flex; align-items: center; gap: 10px; background: var(--c-low); border-radius: var(--r-md); padding: 12px 14px; }
.kpi .msr { color: var(--primary); font-size: 26px; }
.kpi:nth-child(2) .msr { color: var(--berry); }
.kpi:nth-child(3) .msr { color: var(--sky); }
.kpi strong { display: block; font-family: var(--font-display); font-size: 1.55rem; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi span:not(.msr) { color: var(--ink-3); font-size: .85rem; }
.legend-row { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 16px; color: var(--ink-2); font-size: .94rem; }
.lg { display: inline-flex; align-items: center; gap: 7px; }
.lg i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.lg.easy i { background: var(--primary); } .lg.med i { background: var(--sky); } .lg.hard i { background: var(--berry); }
.lg b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.rank-line { margin-top: 12px; color: var(--ink-2); font-size: .95rem; }
.rank-line:empty { display: none; }
.rank-line b { color: var(--primary); font-family: var(--font-display); font-weight: 600; }

/* Segmented + FAB */
.play-row { display: grid; gap: 14px; margin-bottom: 22px; }
.segmented {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border: 1.5px solid var(--outline-v); border-radius: var(--r-full); padding: 4px; background: var(--c-lowest);
}
.seg {
  min-height: 44px; border-radius: var(--r-full); font-family: var(--font-display); font-weight: 500;
  color: var(--ink-2); transition: background-color .3s var(--emph), color .3s;
}
.seg:hover { color: var(--ink); }
.seg.active { background: var(--c-high); color: var(--ink); }
.seg[data-f="קל"].active { background: var(--primary-c); color: var(--on-primary-c); }
.seg[data-f="בינוני"].active { background: var(--sky-c); color: var(--on-sky-c); }
.seg[data-f="קשה"].active { background: var(--berry-c); color: var(--on-berry-c); }

.fab {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  min-height: 72px; border-radius: var(--r-lg);
  background: var(--primary-c); color: var(--on-primary-c);
  font-family: var(--font-display); font-weight: 600; font-size: 1.3rem;
  box-shadow: var(--shadow-2);
  transition: transform .3s var(--spring), border-radius .4s var(--spring), box-shadow .2s;
  position: relative; overflow: hidden; isolation: isolate;
}
.fab .msr { font-size: 32px; }
.fab:hover { border-radius: var(--r-xl); transform: translateY(-2px); }
.fab:active { transform: scale(.97); border-radius: var(--r-md); }
.done-note { display: none; text-align: center; color: var(--primary); font-weight: 600; }
.done-note.show { display: block; }

/* Sheet with tabs */
.sheet { background: var(--c-lowest); border-radius: var(--r-xl); box-shadow: var(--shadow-1); padding: 8px 20px 22px; }
.tabs { position: relative; display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--outline-v); margin: 0 -20px 18px; padding: 0 12px; }
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 12px 4px 10px; color: var(--ink-3); font-family: var(--font-display); font-weight: 500; font-size: .95rem;
  transition: color .25s;
}
.tab .msr { transition: transform .35s var(--spring); }
.tab.active { color: var(--primary); }
.tab.active .msr { font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24; transform: translateY(-1px) scale(1.08); }
.tab b { font-weight: 500; font-size: .8rem; color: var(--ink-3); }
.tab-ind {
  position: absolute; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--primary);
  transition: left .45s var(--spring), width .45s var(--spring);
}
.tab-body { display: none; }
.tab-body.active { display: block; animation: tabIn .35s var(--emph) both; }
@keyframes tabIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.note { color: var(--ink-2); text-align: center; padding: 8px 6px 14px; line-height: 1.6; }

/* Leaderboard */
.lb { list-style: none; display: grid; gap: 8px; }
.lb li {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto auto; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: var(--r-md); background: var(--c-low);
  animation: rowIn .45s var(--emph) both;
}
@keyframes rowIn { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }
.lb .rk { font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; text-align: center; color: var(--ink-3); }
.lb .podium .rk { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: var(--on-primary); }
.lb .p1 .rk { background: var(--primary); }
.lb .p2 .rk { background: var(--sky); color: #fff; }
.lb .p3 .rk { background: var(--berry); color: #fff; }
[data-theme="dark"] .lb .p2 .rk, [data-theme="dark"] .lb .p3 .rk { color: #10161A; }
.lb .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb .sv { color: var(--ink-3); font-size: .9rem; font-variant-numeric: tabular-nums; }
.lb .sc { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; min-width: 3ch; text-align: left; font-variant-numeric: tabular-nums; }
.lb li.me { background: var(--primary-c); color: var(--on-primary-c); }
.lb li.me .sv, .lb li.me .rk { color: var(--on-primary-c); }
.lb li.me.podium .rk { color: var(--on-primary); }
.me-tag { font-size: .75rem; font-weight: 600; margin-inline-start: 8px; padding: 1px 8px; border-radius: var(--r-full); background: var(--on-primary-c); color: var(--primary-c); }
.lb .gap { background: none; text-align: center; display: block; color: var(--ink-3); padding: 0; letter-spacing: 6px; animation: none; }

.nick { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--outline-v); }
.nick label { display: block; font-size: .9rem; color: var(--ink-2); margin-bottom: 8px; font-weight: 600; }
.nick-row { display: flex; gap: 10px; }
.nick input {
  flex: 1; min-width: 0; min-height: 48px; padding: 10px 16px;
  border-radius: var(--r-sm); border: 1.5px solid var(--outline); background: transparent;
  transition: border-color .2s, box-shadow .2s;
}
.nick input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 1.5px var(--primary); }

/* Achievements */
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.ach { display: flex; gap: 14px; align-items: center; padding: 12px 14px; border-radius: var(--r-md); background: var(--c-low); color: var(--ink-3); }
.ach .badge {
  width: 52px; height: 52px; flex: 0 0 52px; display: grid; place-items: center; font-size: 26px;
  border-radius: 16px; background: var(--c-high); filter: grayscale(1); opacity: .55;
  transition: border-radius .5s var(--spring), transform .5s var(--spring);
}
.ach b { display: block; color: var(--ink-2); font-family: var(--font-display); font-weight: 500; }
.ach small { font-size: .86rem; line-height: 1.4; display: block; }
.ach.on { color: var(--ink-2); }
.ach.on b { color: var(--ink); }
.ach.on .badge { filter: none; opacity: 1; background: var(--primary-c); border-radius: 50%; }
.ach.on:hover .badge { transform: rotate(-12deg) scale(1.08); border-radius: 30%; }

/* My stats */
.me-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 22px; }
.mestat { background: var(--c-low); border-radius: var(--r-md); padding: 14px; text-align: center; }
.mestat strong { display: block; font-family: var(--font-display); font-size: 1.7rem; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.mestat span { color: var(--ink-3); font-size: .88rem; }
.sub { font-family: var(--font-display); font-weight: 500; font-size: 1.02rem; margin-bottom: 12px; }
.cat-row { margin-bottom: 14px; }
.cat-row .lbl { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: .95rem; }
.cat-row .lbl span:last-child { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.bar { height: 10px; border-radius: 10px; background: var(--c-high); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; border-radius: 10px; background: var(--primary); transition: width .9s var(--emph); }

/* Map */
.grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
.tile {
  aspect-ratio: 1; border-radius: 10px; font-family: var(--font-display); font-weight: 500; font-size: .9rem;
  color: var(--ink-3); background: var(--c-low); border: 1.5px solid transparent;
  transition: transform .25s var(--spring), border-radius .3s var(--spring), background-color .2s;
}
.tile:hover { transform: scale(1.12); border-radius: 50%; z-index: 1; }
.tile.easy { border-color: color-mix(in srgb, var(--primary) 40%, transparent); }
.tile.med { border-color: color-mix(in srgb, var(--sky) 40%, transparent); }
.tile.hard { border-color: color-mix(in srgb, var(--berry) 40%, transparent); }
.tile.solved { font-weight: 700; }
.tile.solved.easy { background: var(--primary-c); color: var(--on-primary-c); }
.tile.solved.med { background: var(--sky-c); color: var(--on-sky-c); }
.tile.solved.hard { background: var(--berry-c); color: var(--on-berry-c); }
.tile.hide { display: none; }
.grid-legend { color: var(--ink-3); font-size: .88rem; margin-top: 14px; }

.foot { display: flex; justify-content: center; margin-top: 22px; }

/* =========================================================
   PLAY
   ========================================================= */
.play-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.chips { display: flex; gap: 8px; }
.chip-stat {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  height: 40px; padding: 0 14px 0 16px; border-radius: var(--r-full);
  background: var(--c-lowest); box-shadow: var(--shadow-1);
  font-family: var(--font-display); font-weight: 600; font-variant-numeric: tabular-nums;
}
.chip-stat .msr { color: var(--primary); font-size: 22px; }
.chip-stat.streak .msr { color: var(--berry); }
.chip-stat b { transition: transform .3s var(--spring); display: inline-block; min-width: 2ch; text-align: center; }
.chip-stat.bump b { transform: scale(1.45); }
.chip-stat.hot { background: var(--berry-c); color: var(--on-berry-c); }
.float {
  position: absolute; top: -4px; left: 50%; pointer-events: none; white-space: nowrap;
  font-family: var(--font-display); font-weight: 700; color: var(--primary);
  animation: floatUp 1.2s var(--emph) forwards;
}
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, 6px) scale(.6); } 20% { opacity: 1; transform: translate(-50%, -6px) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -38px) scale(1); } }

/* 3D stage */
.stage { perspective: 1500px; perspective-origin: 50% 40%; }
.card {
  position: relative;
  background: var(--c-lowest);
  border-radius: var(--r-xl);
  padding: 28px 28px 24px;
  /* עובי של אריח: שכבת "צד" מתחת לכרטיס */
  box-shadow: 0 6px 0 var(--card-edge), var(--shadow-2);
  transform-style: preserve-3d;
  backface-visibility: hidden;
  will-change: transform;
}
.card.shake { animation: wobble .55s var(--emph); }
@keyframes wobble {
  0%, 100% { transform: rotateY(0); }
  20% { transform: rotateY(9deg); }
  40% { transform: rotateY(-7deg); }
  60% { transform: rotateY(4deg); }
  80% { transform: rotateY(-2deg); }
}
.card.pop { animation: pop .5s var(--spring); }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.025) translateZ(20px); } 100% { transform: scale(1); } }

.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 18px; }
.diff, .cat, .num, .pts {
  display: inline-flex; align-items: center; height: 32px; padding: 0 14px; border-radius: 10px;
  font-family: var(--font-display); font-weight: 500; font-size: .9rem;
}
.diff.easy { background: var(--primary-c); color: var(--on-primary-c); }
.diff.med { background: var(--sky-c); color: var(--on-sky-c); }
.diff.hard { background: var(--berry-c); color: var(--on-berry-c); }
.cat { border: 1.5px solid var(--outline-v); color: var(--ink-2); }
.num { color: var(--ink-3); padding: 0 6px; }
.pts { margin-inline-start: auto; color: var(--primary); background: color-mix(in srgb, var(--primary) 9%, transparent); }
.pts.practice { color: var(--ink-3); background: var(--c-low); }

.question {
  font-family: var(--font-text); font-weight: 600;
  font-size: clamp(1.18rem, 2.8vw, 1.4rem); line-height: 1.75;
  white-space: pre-line; margin-bottom: 18px; max-width: 62ch;
}

.hint-area { margin-bottom: 18px; }
.hint-btn small { font-family: var(--font-text); font-weight: 400; opacity: .7; font-size: .85rem; }
.hint-btn small:empty { display: none; }
.hint-btn.used { border-color: transparent; background: var(--c-low); }
.reveal { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .55s var(--emph), opacity .4s, margin .4s; opacity: 0; }
.reveal.open { grid-template-rows: 1fr; opacity: 1; }
.reveal > div { overflow: hidden; min-height: 0; }
#hintWrap.open { margin-top: 12px; }
.hint-box {
  background: var(--sky-c); color: var(--on-sky-c); border-radius: var(--r-md);
  padding: 14px 18px; font-size: 1.02rem; clip-path: inset(0 0 0 0 round 18px);
}

.options { display: grid; gap: 10px; }
.opt {
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: right;
  min-height: 64px; padding: 12px 16px; border-radius: var(--r-md);
  background: var(--c-low); border: 2px solid transparent;
  font-size: 1.05rem; line-height: 1.5;
  transition: background-color .25s, border-color .25s, transform .3s var(--spring), opacity .35s, border-radius .4s var(--spring);
  animation: optIn .5s var(--emph) both;
}
@keyframes optIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.opt:hover:not(:disabled) { background: var(--c); border-color: var(--outline-v); transform: translateX(-4px); }
.opt:active:not(:disabled) { transform: scale(.98); }
.opt:disabled { cursor: default; }
.opt .key {
  flex: 0 0 38px; height: 38px; display: grid; place-items: center; border-radius: 12px;
  background: var(--c-lowest); font-family: var(--font-display); font-weight: 600; color: var(--ink-2);
  transition: border-radius .4s var(--spring), background-color .25s, color .25s;
}
.opt .mark2 { margin-inline-start: auto; font-size: 26px; opacity: 0; transform: scale(.3); transition: opacity .3s, transform .45s var(--spring); }
.opt.correct { background: var(--primary-c); color: var(--on-primary-c); border-color: var(--primary); border-radius: var(--r-lg); }
.opt.correct .key { background: var(--primary); color: var(--on-primary); border-radius: 50%; }
.opt.correct .mark2 { opacity: 1; transform: scale(1); color: var(--primary); }
.opt.wrong { background: var(--berry-c); color: var(--on-berry-c); border-color: var(--berry); }
.opt.wrong .key { background: var(--berry); color: var(--on-berry); }
.opt.wrong .mark2 { opacity: 1; transform: scale(1); color: var(--berry); }
.opt.dim { opacity: .4; }

#fbWrap.open { margin-top: 20px; }
.feedback { border-radius: var(--r-lg); padding: 20px; background: var(--c-low); }
.feedback.ok { background: color-mix(in srgb, var(--primary-c) 55%, var(--c-lowest)); }
.feedback.bad { background: color-mix(in srgb, var(--berry-c) 45%, var(--c-lowest)); }
.fb-head { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.fb-icon {
  width: 52px; height: 52px; font-size: 30px; display: grid; place-items: center; border-radius: 50%;
  background: var(--primary); color: var(--on-primary);
}
.feedback.bad .fb-icon { background: var(--berry); color: var(--on-berry); border-radius: 16px; }
.feedback.open .fb-icon { animation: iconIn .6s var(--spring) both .1s; }
@keyframes iconIn { from { transform: scale(0) rotate(-120deg); } to { transform: none; } }
.fb-head h3 { font-family: var(--font-display); font-weight: 600; font-size: 1.3rem; line-height: 1.3; }
.fb-head p { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.fb-chip { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 8px; font-size: .85rem; font-weight: 600; background: color-mix(in srgb, var(--c-lowest) 70%, transparent); color: var(--ink-2); }
.feedback.ok .fb-chip:first-child { background: var(--primary); color: var(--on-primary); }
.feedback h4 { font-family: var(--font-display); font-weight: 500; color: var(--ink-2); margin-bottom: 6px; }
.exp { white-space: pre-line; line-height: 1.85; max-width: 68ch; }
.next-btn { width: 100%; min-height: 56px; margin-top: 18px; font-size: 1.1rem; border-radius: var(--r-md); }

.play-bottom { display: flex; justify-content: center; margin-top: 18px; }
.kbd { text-align: center; color: var(--ink-3); font-size: .82rem; margin-top: 6px; }

/* Snackbar */
.snackbar {
  position: fixed; bottom: 24px; left: 50%; z-index: 70; width: max-content; max-width: min(92vw, 520px); text-align: center;
  transform: translate(-50%, 140%); opacity: 0;
  background: var(--ink); color: var(--surface);
  border-radius: var(--r-sm); padding: 14px 20px; box-shadow: var(--shadow-2);
  font-weight: 600; transition: transform .45s var(--spring), opacity .3s;
}
.snackbar.show { transform: translate(-50%, 0); opacity: 1; }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 640px) {
  body { font-size: 16px; }
  .app { padding: 16px 12px 48px; }
  .mark { width: 56px; height: 56px; flex-basis: 56px; }
  .top { margin-bottom: 18px; }
  .tagline { font-size: .95rem; }
  .top-actions { flex-direction: column; margin-top: -6px; }
  .icon-btn { width: 44px; height: 44px; }
  .hero { grid-template-columns: 1fr; justify-items: center; padding: 20px 16px; gap: 18px; }
  .hero-side { width: 100%; }
  .ring-wrap { width: 150px; height: 150px; }
  .kpis { gap: 8px; }
  .kpi { flex-direction: column; text-align: center; padding: 10px 6px; gap: 4px; }
  .legend-row { justify-content: center; }
  .rank-line { text-align: center; }
  .sheet { padding: 4px 12px 18px; }
  .tabs { margin: 0 -12px 16px; padding: 0 4px; }
  .tab { font-size: .82rem; }
  .me-grid { grid-template-columns: repeat(2, 1fr); }
  .ach-grid { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(8, 1fr); gap: 5px; }
  .lb li { gap: 8px; padding: 10px; grid-template-columns: 34px minmax(0, 1fr) auto auto; }
  .card { padding: 20px 16px 18px; border-radius: var(--r-lg); }
  .opt { min-height: 58px; padding: 10px 12px; gap: 10px; font-size: 1rem; }
  .opt .key { flex-basis: 34px; height: 34px; }
  .kbd { display: none; }
  .fab { min-height: 64px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
