/* ===== WordQuest — design tokens ===== */
:root {
  --bg: #FFF7EC;
  --bg-2: #FFEFD9;
  --surface: #FFFFFF;
  --surface-2: #F6F2FF;
  --ink: #1E1B3A;
  --muted: #625F80;
  --line: rgba(30, 27, 58, .10);
  --primary: #5B3DF5;
  --primary-deep: #3F24C9;
  --primary-soft: #ECE7FF;
  --on-primary: #FFFFFF;
  --sun: #FFB020;
  --sun-deep: #D48700;
  --good: #138A4E;
  --good-deep: #0B6A3A;
  --good-soft: #DDF6E8;
  --hard: #F08A00;
  --hard-deep: #B86500;
  --bad: #D93A40;
  --bad-deep: #A9252B;
  --bad-soft: #FFE3E4;
  --flame: #FF6B2C;
  --shadow: 0 1px 2px rgba(30,27,58,.06), 0 8px 24px rgba(30,27,58,.08);
  --shadow-lg: 0 2px 4px rgba(30,27,58,.06), 0 20px 48px rgba(30,27,58,.14);
  --radius: 20px;
  --radius-lg: 28px;
  --font: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --nav-h: 68px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #13112A;
    --bg-2: #1A1736;
    --surface: #1F1C3D;
    --surface-2: #292550;
    --ink: #F4F2FF;
    --muted: #ABA8CC;
    --line: rgba(255,255,255,.10);
    --primary: #7C63FF;
    --primary-deep: #5B3DF5;
    --primary-soft: #2D2760;
    --good: #1FA862;
    --good-deep: #137A45;
    --good-soft: #163B2A;
    --bad: #E5484D;
    --bad-deep: #B3262B;
    --bad-soft: #43202A;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.3);
    --shadow-lg: 0 2px 4px rgba(0,0,0,.3), 0 20px 48px rgba(0,0,0,.45);
    color-scheme: dark;
  }
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; border-radius: 12px; }
h1, h2, h3 { margin: 0; line-height: 1.15; letter-spacing: -0.01em; font-weight: 900; }
p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; position: relative; }

.view {
  padding: calc(var(--safe-t) + 16px) 16px calc(var(--nav-h) + var(--safe-b) + 24px);
  animation: viewIn .35s cubic-bezier(.2,.8,.2,1);
}
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } }

/* ===== Buttons ===== */
.btn {
  --c: var(--primary); --c-deep: var(--primary-deep); --c-ink: var(--on-primary);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 0 22px;
  border-radius: 18px;
  background: var(--c); color: var(--c-ink);
  font-weight: 900; font-size: 1.05rem; letter-spacing: .01em;
  box-shadow: 0 4px 0 var(--c-deep);
  transform: translateY(0);
  transition: transform 90ms ease-out, box-shadow 90ms ease-out, filter .2s;
  user-select: none;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--c-deep); }
.btn.block { width: 100%; }
.btn.good { --c: var(--good); --c-deep: var(--good-deep); }
.btn.bad { --c: var(--bad); --c-deep: var(--bad-deep); }
.btn.hard { --c: var(--sun); --c-deep: var(--sun-deep); --c-ink: #2A1A00; }
.btn.ghost { --c: var(--surface); --c-deep: var(--line); --c-ink: var(--ink); box-shadow: 0 4px 0 var(--line), inset 0 0 0 2px var(--line); }
.btn.ghost:active { box-shadow: 0 1px 0 var(--line), inset 0 0 0 2px var(--line); }
.btn small { display: block; font-size: .78rem; font-weight: 700; opacity: .85; }
.btn .stack { display: flex; flex-direction: column; line-height: 1.1; align-items: center; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 14px;
  display: grid; place-items: center;
  color: var(--muted);
  transition: background .15s, transform 90ms;
}
.icon-btn:active { transform: scale(.92); background: var(--line); }
.icon-btn svg { width: 24px; height: 24px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 12px;
  border-radius: 999px; background: var(--surface); box-shadow: var(--shadow);
  font-weight: 900; font-size: .95rem;
}
.chip .em { font-size: 1.1rem; }

/* ===== Header ===== */
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.topbar .who { display: flex; align-items: center; gap: 10px; min-height: 44px; border-radius: 16px; padding-right: 8px; }
.topbar .who:active { background: var(--line); }
.avatar {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.6rem;
  background: var(--av, var(--primary-soft));
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.08);
  flex: none;
}
.topbar .name { font-size: 1.15rem; font-weight: 900; }
.topbar .lvl { font-size: .8rem; color: var(--muted); font-weight: 800; line-height: 1; }
.spacer { flex: 1; }

/* ===== Hero / daily ===== */
.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(145deg, var(--primary) 0%, #7B5CFF 60%, #9C7BFF 100%);
  color: #fff; border-radius: var(--radius-lg);
  padding: 20px; box-shadow: var(--shadow-lg);
}
.hero::after {
  content: ""; position: absolute; inset: auto -40px -60px auto; width: 180px; height: 180px;
  border-radius: 50%; background: rgba(255,255,255,.08);
}
.hero-row { display: flex; align-items: center; gap: 16px; }
.ring { position: relative; width: 104px; height: 104px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; stroke-linecap: round; }
.ring .track { stroke: rgba(255,255,255,.22); }
.ring .fill { stroke: var(--sun); transition: stroke-dashoffset 1s cubic-bezier(.2,.8,.2,1); }
.ring .label { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; line-height: 1.05; }
.ring .label b { font-size: 1.5rem; font-weight: 900; display: block; }
.ring .label span { font-size: .72rem; opacity: .9; }
.hero h2 { font-size: 1.35rem; margin-bottom: 4px; }
.hero p { opacity: .92; font-size: .95rem; }
.xpbar { margin-top: 16px; }
.xpbar .meta { display: flex; justify-content: space-between; font-size: .8rem; opacity: .95; margin-bottom: 6px; }
.bar { height: 12px; border-radius: 999px; background: rgba(255,255,255,.22); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--sun), #FFD36B); transition: width .8s cubic-bezier(.2,.8,.2,1); }
.hero .btn { margin-top: 18px; --c: #fff; --c-deep: rgba(0,0,0,.18); --c-ink: var(--primary-deep); }
.hero .btn .stack small { color: var(--muted); opacity: 1; }

/* ===== Stats ===== */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0 24px; }
.stat { background: var(--surface); border-radius: var(--radius); padding: 14px 10px; text-align: center; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 1.5rem; font-weight: 900; line-height: 1.1; }
.stat span { font-size: .78rem; color: var(--muted); }
.stat .em { font-size: 1.2rem; }

.section-title { font-size: 1.15rem; margin: 8px 4px 12px; display: flex; align-items: baseline; justify-content: space-between; }
.section-title small { font-size: .85rem; color: var(--muted); font-weight: 800; }

/* ===== Worlds path ===== */
.worlds { display: flex; flex-direction: column; gap: 12px; }
.world {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow);
}
.world.locked { opacity: .55; }
.world.current { box-shadow: 0 0 0 3px var(--primary), var(--shadow); }
.world .badge {
  width: 56px; height: 56px; border-radius: 18px; flex: none;
  display: grid; place-items: center; font-size: 1.8rem;
  background: var(--surface-2);
}
.world.done .badge { background: linear-gradient(145deg, #FFD36B, var(--sun)); }
.world .info { flex: 1; min-width: 0; }
.world .info b { display: block; font-size: 1rem; }
.world .info span { font-size: .8rem; color: var(--muted); }
.world .mini { height: 8px; border-radius: 99px; background: var(--line); margin-top: 8px; overflow: hidden; }
.world .mini span { display: block; height: 100%; background: var(--primary); border-radius: inherit; }
.world .mini span.m { background: var(--good); }

/* ===== Bottom nav (translucent material) ===== */
.nav {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 100%; max-width: 560px;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px calc(6px + var(--safe-b));
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid var(--line);
  z-index: 10;
}
.nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 56px; border-radius: 16px;
  color: var(--muted); text-decoration: none; font-size: .75rem; font-weight: 800;
  transition: color .15s, transform 90ms;
}
.nav a:active { transform: scale(.94); }
.nav a svg { width: 26px; height: 26px; }
.nav a[aria-current="page"] { color: var(--primary); }
.nav a[aria-current="page"] svg { filter: drop-shadow(0 2px 6px color-mix(in srgb, var(--primary) 40%, transparent)); }
@media (prefers-reduced-transparency: reduce) { .nav { background: var(--surface); backdrop-filter: none; } }

/* ===== Session ===== */
.session {
  min-height: 100dvh; display: flex; flex-direction: column;
  padding: calc(var(--safe-t) + 10px) 16px calc(var(--safe-b) + 16px);
  background: radial-gradient(120% 60% at 50% 0%, var(--bg-2), var(--bg));
}
.s-top { display: flex; align-items: center; gap: 10px; min-height: 52px; }
.progress { flex: 1; height: 16px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--good), #3DDC84); transition: width .5s cubic-bezier(.2,.8,.2,1); position: relative; }
.progress span::after { content: ""; position: absolute; left: 8px; right: 8px; top: 3px; height: 4px; border-radius: 99px; background: rgba(255,255,255,.35); }
.combo { min-width: 56px; text-align: center; font-weight: 900; color: var(--muted); transition: transform .2s; }
.combo.on { color: var(--flame); }
.combo.pop { animation: pop .35s cubic-bezier(.3,1.6,.5,1); }
@keyframes pop { 50% { transform: scale(1.35); } }

.s-body { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 18px; padding: 12px 0; position: relative; }
.s-actions { display: grid; gap: 10px; min-height: 64px; }
.s-actions.three { grid-template-columns: repeat(3, 1fr); }
.s-actions.two { grid-template-columns: 1fr 1.4fr; }
.s-actions .btn { padding: 0 10px; min-height: 64px; }
.linkish { color: var(--muted); font-weight: 800; min-height: 44px; text-decoration: underline; text-underline-offset: 3px; }

.tag {
  align-self: center; display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 999px; font-size: .8rem; font-weight: 900;
  background: var(--primary-soft); color: var(--primary);
}
.tag.new { background: #FFF1CC; color: #8A5A00; }
@media (prefers-color-scheme: dark) { .tag.new { background: #4A3A10; color: #FFD36B; } }

/* flip card */
.flip { perspective: 1200px; height: min(56dvh, 420px); touch-action: pan-y; position: relative; outline: none; }
.flip-inner {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform .55s cubic-bezier(.2,.9,.25,1.15);
}
.flip.is-flipped .flip-inner { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg), inset 0 -6px 0 var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 24px; text-align: center;
}
.face.back { transform: rotateY(180deg); background: linear-gradient(160deg, var(--surface), var(--surface-2)); }
.flip:focus-visible .face { box-shadow: 0 0 0 3px var(--primary), var(--shadow-lg); }
.word { font-size: clamp(2.2rem, 10vw, 3.4rem); font-weight: 900; line-height: 1.05; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.word.fr { color: var(--primary); }
.sub { color: var(--muted); font-size: 1.05rem; }
.big-emoji { font-size: clamp(3.5rem, 18vw, 5.5rem); line-height: 1; filter: drop-shadow(0 6px 10px rgba(0,0,0,.12)); }
.hint { color: var(--muted); font-size: .85rem; display: inline-flex; align-items: center; gap: 6px; }
.hint svg { width: 18px; height: 18px; }

.speak {
  width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary);
  transition: transform 90ms;
}
.speak:active { transform: scale(.9); }
.speak svg { width: 28px; height: 28px; }
.speak.xl { width: 120px; height: 120px; background: var(--primary); color: #fff; box-shadow: 0 6px 0 var(--primary-deep); }
.speak.xl svg { width: 56px; height: 56px; }
.speak.xl:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--primary-deep); }
.speak.playing { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 6px 0 var(--primary-deep), 0 0 0 14px color-mix(in srgb, var(--primary) 18%, transparent); } }

.stamp {
  position: absolute; top: 22px; padding: 6px 14px; border-radius: 12px;
  font-weight: 900; font-size: 1.1rem; border: 3px solid currentColor; opacity: 0;
  pointer-events: none; z-index: 3;
}
.stamp.yes { right: 22px; color: var(--good); transform: rotate(10deg); }
.stamp.no { left: 22px; color: var(--bad); transform: rotate(-10deg); }

/* prompt + options */
.prompt-card {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg), inset 0 -6px 0 var(--line);
  padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
}
.prompt-card .big-emoji { font-size: 3.2rem; }
.options { display: grid; gap: 10px; }
.opt {
  min-height: 60px; padding: 10px 16px; border-radius: 18px;
  background: var(--surface); color: var(--ink);
  font-weight: 900; font-size: 1.15rem; text-align: left;
  box-shadow: 0 4px 0 var(--line), inset 0 0 0 2px var(--line);
  display: flex; align-items: center; gap: 12px;
  transition: transform 90ms ease-out, box-shadow 90ms, background .2s;
}
.opt .k {
  width: 30px; height: 30px; border-radius: 10px; flex: none;
  display: grid; place-items: center; font-size: .85rem; color: var(--muted);
  box-shadow: inset 0 0 0 2px var(--line);
}
.opt:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line), inset 0 0 0 2px var(--line); }
.opt.correct { background: var(--good-soft); color: var(--good); box-shadow: 0 4px 0 var(--good), inset 0 0 0 2px var(--good); animation: pop .35s cubic-bezier(.3,1.6,.5,1); }
.opt.correct .k { box-shadow: inset 0 0 0 2px var(--good); color: var(--good); }
.opt.wrong { background: var(--bad-soft); color: var(--bad); box-shadow: 0 4px 0 var(--bad), inset 0 0 0 2px var(--bad); animation: shake .4s; }
.opt[disabled] { cursor: default; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

.feedback {
  border-radius: var(--radius); padding: 14px 16px; font-weight: 800;
  display: flex; align-items: center; gap: 10px;
  animation: viewIn .25s ease-out;
}
.feedback.ok { background: var(--good-soft); color: var(--good); }
.feedback.ko { background: var(--bad-soft); color: var(--bad); }
.feedback b { font-weight: 900; }

.xp-float {
  position: fixed; left: 50%; top: 38%; transform: translateX(-50%);
  font-weight: 900; font-size: 1.6rem; color: var(--sun-deep);
  text-shadow: 0 2px 0 #fff;
  pointer-events: none; z-index: 50;
  animation: floatUp .9s cubic-bezier(.2,.8,.2,1) forwards;
}
@keyframes floatUp { from { opacity: 0; transform: translate(-50%, 10px) scale(.8); } 20% { opacity: 1; transform: translate(-50%, 0) scale(1.1); } to { opacity: 0; transform: translate(-50%, -60px) scale(1); } }

/* ===== Results ===== */
.results { min-height: 100dvh; display: flex; flex-direction: column; gap: 16px; padding: calc(var(--safe-t) + 32px) 16px calc(var(--safe-b) + 20px); text-align: center; }
.results .trophy { font-size: 5rem; line-height: 1; animation: bounceIn .7s cubic-bezier(.3,1.6,.5,1); }
@keyframes bounceIn { from { transform: scale(.2) rotate(-20deg); opacity: 0; } }
.results h1 { font-size: 2.2rem; }
.results .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.results .stat b { color: var(--primary); }
.banner {
  border-radius: var(--radius); padding: 14px; font-weight: 900;
  background: linear-gradient(135deg, #FFD36B, var(--sun)); color: #3A2500;
  display: flex; align-items: center; gap: 12px; text-align: left;
  animation: viewIn .4s .2s both;
}
.banner .em { font-size: 2rem; }
.results .actions { margin-top: auto; display: grid; gap: 12px; }

/* ===== Words list ===== */
.search {
  width: 100%; min-height: 52px; padding: 0 16px 0 46px; border-radius: 16px;
  border: 2px solid var(--line); background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round'%3E%3Ccircle cx='10' cy='10' r='7'/%3E%3Cpath d='m20 20-4.5-4.5'/%3E%3C/svg%3E") no-repeat 14px center;
  font-weight: 800; font-size: 1rem;
}
.search:focus { outline: none; border-color: var(--primary); }
.filters { display: flex; gap: 8px; margin: 12px 0 14px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.filters::-webkit-scrollbar { display: none; }
.filter {
  flex: none; min-height: 40px; padding: 0 14px; border-radius: 999px;
  background: var(--surface); box-shadow: inset 0 0 0 2px var(--line); font-weight: 800; font-size: .9rem;
}
.filter[aria-pressed="true"] { background: var(--primary); color: #fff; box-shadow: none; }
.wlist { display: flex; flex-direction: column; gap: 8px; }
.wrow {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  min-height: 60px; padding: 8px 12px; border-radius: 16px; background: var(--surface);
  content-visibility: auto; contain-intrinsic-size: auto 60px;
}
.wrow:active { transform: scale(.99); }
.wrow .em { width: 36px; text-align: center; font-size: 1.5rem; flex: none; }
.wrow .t { flex: 1; min-width: 0; }
.wrow .t b { display: block; font-size: 1.05rem; }
.wrow .t span { display: block; font-size: .85rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pips { display: flex; gap: 3px; flex: none; }
.pips i { width: 7px; height: 16px; border-radius: 3px; background: var(--line); }
.pips i.on { background: var(--primary); }
.pips.m i.on { background: var(--good); }
.more { margin-top: 12px; }

/* ===== Badges ===== */
.badges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.bdg { background: var(--surface); border-radius: var(--radius); padding: 14px 8px; text-align: center; box-shadow: var(--shadow); }
.bdg .em { font-size: 2.4rem; line-height: 1.1; display: block; }
.bdg b { display: block; font-size: .85rem; margin-top: 6px; line-height: 1.2; }
.bdg span { display: block; font-size: .72rem; color: var(--muted); line-height: 1.25; margin-top: 2px; }
.bdg.locked .em { filter: grayscale(1); opacity: .35; }
.bdg.locked b { color: var(--muted); }

/* ===== Family / leaderboard ===== */
.board { display: flex; flex-direction: column; gap: 10px; }
.brow { display: flex; align-items: center; gap: 12px; background: var(--surface); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); width: 100%; text-align: left; }
.brow.me { box-shadow: 0 0 0 3px var(--primary), var(--shadow); }
.brow .rank { width: 28px; font-size: 1.3rem; text-align: center; font-weight: 900; color: var(--muted); }
.brow .t { flex: 1; min-width: 0; }
.brow .t b { display: block; }
.brow .t span { font-size: .8rem; color: var(--muted); }
.brow .xp { font-weight: 900; color: var(--primary); }

/* ===== Profiles ===== */
.who-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-top: 24px; }
.who-card {
  background: var(--surface); border-radius: var(--radius-lg); padding: 20px 12px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; gap: 10px; min-height: 160px; justify-content: center;
  transition: transform 90ms;
}
.who-card:active { transform: scale(.96); }
.who-card .avatar { width: 80px; height: 80px; font-size: 2.8rem; }
.who-card b { font-size: 1.1rem; }
.who-card span { font-size: .8rem; color: var(--muted); }
.who-card.add { background: transparent; box-shadow: inset 0 0 0 3px var(--line); color: var(--muted); }
.who-card.add .avatar { background: var(--line); }
.brand { text-align: center; margin-top: 24px; }
.brand .logo { font-size: 3.4rem; line-height: 1; }
.brand h1 { font-size: 2.2rem; margin-top: 8px; }
.brand p { color: var(--muted); margin-top: 6px; }

/* ===== Settings ===== */
.group { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden; }
.setting { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 60px; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; }
.setting label, .setting .l { flex: 1; }
.setting small { display: block; color: var(--muted); font-size: .8rem; font-weight: 700; }
.setting select { min-height: 44px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface-2); padding: 0 10px; font-weight: 800; }
.switch { appearance: none; width: 52px; height: 32px; border-radius: 99px; background: var(--line); position: relative; cursor: pointer; transition: background .2s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.2); transition: transform .25s cubic-bezier(.3,1.4,.5,1); }
.switch:checked { background: var(--good); }
.switch:checked::after { transform: translateX(20px); }
.danger { color: var(--bad); }

/* ===== Sheet (dialog) ===== */
.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px;
  border-radius: 28px 28px 0 0; background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-lg);
  max-height: 92dvh;
}
.sheet[open] { animation: sheetIn .4s cubic-bezier(.2,.9,.25,1); }
.sheet::backdrop { background: rgba(10, 8, 30, .45); backdrop-filter: blur(2px); }
@keyframes sheetIn { from { transform: translateY(100%); } }
.sheet form { padding: 12px 20px calc(20px + var(--safe-b)); display: flex; flex-direction: column; gap: 14px; }
.sheet .grab { width: 40px; height: 5px; border-radius: 99px; background: var(--line); margin: 0 auto 4px; }
.sheet h2 { font-size: 1.4rem; }
.sheet label.f { font-size: .9rem; color: var(--muted); font-weight: 800; }
.sheet input[type="text"] {
  min-height: 54px; border-radius: 16px; border: 2px solid var(--line); background: var(--surface-2);
  padding: 0 16px; font-weight: 800; font-size: 1.1rem; width: 100%;
}
.sheet input[type="text"]:focus { outline: none; border-color: var(--primary); }
.sheet fieldset { border: 0; padding: 0; margin: 0; }
.sheet legend { font-size: .9rem; color: var(--muted); font-weight: 800; margin-bottom: 8px; }
.picks { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.picks label { position: relative; }
.picks input { position: absolute; opacity: 0; inset: 0; }
.picks span {
  display: grid; place-items: center; aspect-ratio: 1; border-radius: 14px; font-size: 1.6rem;
  background: var(--surface-2); box-shadow: inset 0 0 0 2px transparent; cursor: pointer; transition: transform 90ms;
}
.picks input:checked + span { box-shadow: inset 0 0 0 3px var(--primary); transform: scale(1.06); }
.picks input:focus-visible + span { outline: 3px solid var(--primary); outline-offset: 2px; }
.picks.colors span { border-radius: 50%; }
.sheet .row { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; margin-top: 6px; }

/* ===== Toast & confetti ===== */
#toast {
  position: fixed; left: 50%; top: calc(var(--safe-t) + 12px); transform: translate(-50%, -150%);
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 16px;
  font-weight: 900; z-index: 100; max-width: calc(100% - 32px); text-align: center;
  transition: transform .4s cubic-bezier(.2,.9,.25,1.2);
  box-shadow: var(--shadow-lg);
}
#toast.show { transform: translate(-50%, 0); }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 90; }

.empty { text-align: center; color: var(--muted); padding: 32px 16px; }
.empty .em { font-size: 3rem; display: block; }

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .flip-inner { transition: opacity .2s !important; }
  .flip.is-flipped .flip-inner { transform: none; }
  .flip .face.back { transform: none; opacity: 0; }
  .flip.is-flipped .face.front { opacity: 0; }
  .flip.is-flipped .face.back { opacity: 1; }
}
