/* Levels to This — design system (approved concept: modern, sleek, smooth) */
:root {
  --ink: #0d0d10; --panel: #16161b; --card: #1e1e25; --line: #2b2b33;
  --white: #f5f5f7; --mute: #9aa0ab;
  --blue: #4a7cd6; --green: #8dc63f; --orange: #f0512e; --gold: #c99a2e;
  --link: #8fb0e8; --danger: #e5484d; --r: 16px;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body {
  min-height: 100%;
  background: radial-gradient(1100px 700px at 75% -10%, #1a2033 0%, var(--ink) 55%);
  background-attachment: fixed;
  color: var(--white);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding-bottom: calc(74px + env(safe-area-inset-bottom));
}
#app { max-width: 480px; margin: 0 auto; padding: 18px 16px 24px; }
button { font-family: inherit; }
a { color: var(--link); }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 0 16px; }
.lmark { display: grid; gap: 2.5px; }
.lmark span { width: 11px; height: 11px; border-radius: 2.5px; display: block; }
.lmark span:nth-child(1) { background: var(--blue); }
.lmark span:nth-child(2) { background: var(--green); }
.lmark span:nth-child(3) { background: var(--orange); }
.lmark span:nth-child(4) { background: var(--gold); width: 24px; }
.brand h1 { font-size: 21px; font-weight: 900; letter-spacing: .5px; }
.brand small { display: block; font-size: 10px; font-weight: 700; letter-spacing: 2px; color: var(--gold); text-transform: uppercase; }

/* ---------- views ---------- */
.view { animation: slidein .3s ease; }
@keyframes slidein { from { opacity: 0; transform: translateX(12px); } }
h2 { font-size: 24px; font-weight: 800; line-height: 1.15; margin-bottom: 8px; }
.sub { color: var(--mute); font-size: 13.5px; line-height: 1.55; margin-bottom: 16px; }
.section { font-size: 11px; font-weight: 800; letter-spacing: 1.6px; text-transform: uppercase; color: var(--gold); margin: 18px 0 10px; }

/* ---------- cards & buttons ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 12px; }
.btn {
  display: block; width: 100%; background: var(--white); color: var(--ink);
  border: none; border-radius: 14px; padding: 15px; font-size: 15.5px; font-weight: 800;
  cursor: pointer; transition: transform .15s ease, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .35; pointer-events: none; }
.btn.ghost { background: var(--card); color: var(--white); border: 1px solid var(--line); font-weight: 600; }
.btn.small { padding: 10px 14px; font-size: 13px; width: auto; display: inline-block; }
.btn.danger { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
.mode { display: flex; gap: 13px; align-items: flex-start; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 10px; width: 100%; cursor: pointer; color: var(--white); transition: transform .15s, border-color .2s; }
.mode:active { transform: scale(.985); }
.mode .sq { width: 22px; height: 22px; border-radius: 5px; flex: none; margin-top: 2px; }
.mode b { font-size: 15.5px; display: block; margin-bottom: 3px; }
.mode span { font-size: 12.5px; color: var(--mute); line-height: 1.45; display: block; }

/* ---------- forms ---------- */
.field { background: var(--card); border: 1px solid var(--line); border-radius: 13px; padding: 11px 14px; margin-bottom: 11px; transition: border-color .2s; }
.field:focus-within { border-color: var(--blue); }
.field.ok { border-color: rgba(141, 198, 63, .5); }
.field label { display: block; font-size: 10px; font-weight: 700; letter-spacing: 1.2px; color: var(--mute); text-transform: uppercase; margin-bottom: 4px; }
.field.ok label::after { content: " ✓"; color: var(--green); }
.field input, .field select {
  width: 100%; background: transparent; border: none; outline: none;
  color: var(--white); font-size: 15px; font-family: inherit;
}
.field select option { background: var(--card); color: var(--white); }
.steps { display: flex; gap: 5px; margin: 2px 0 16px; }
.steps i { height: 4px; flex: 1; border-radius: 99px; background: var(--line); }
.steps i.done { background: var(--green); }
.steps i.now { background: var(--white); }
.choice-row { display: flex; gap: 8px; margin-bottom: 12px; }
.choice-row button { flex: 1; background: var(--card); border: 1px solid var(--line); color: var(--mute); border-radius: 12px; padding: 11px 6px; font-size: 12.5px; font-weight: 600; cursor: pointer; transition: all .2s; }
.choice-row button.pick { background: rgba(141, 198, 63, .14); border-color: var(--green); color: var(--white); }
.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; font-size: 12.5px; color: var(--mute); line-height: 1.5; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--green); flex: none; margin-top: 1px; }
.linkcard { display: block; background: linear-gradient(135deg, #1d2b45, #16233a); border: 1px solid #2e4166; border-radius: 13px; padding: 13px 15px; text-decoration: none; margin-bottom: 12px; }
.linkcard b { color: var(--white); font-size: 14px; }
.linkcard span { display: block; color: var(--link); font-size: 12px; margin-top: 3px; line-height: 1.45; }
.fine { color: var(--mute); font-size: 10.5px; line-height: 1.55; margin-top: 10px; }

/* ---------- gameplay ---------- */
.hud { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
.chip { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 7px 12px; font-size: 11px; font-weight: 700; color: var(--mute); }
.chip b { font-size: 15px; display: block; color: var(--white); }
.chip.score b { color: var(--green); }
.chip.streak b { color: var(--orange); }
.timerwrap { margin-left: auto; position: relative; width: 46px; height: 46px; flex: none; }
.timerwrap svg { transform: rotate(-90deg); display: block; }
.timerwrap .t { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; }
.lvl { font-size: 10.5px; font-weight: 800; letter-spacing: 1.5px; color: var(--gold); text-transform: uppercase; margin-bottom: 8px; }
.qcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 17px; font-size: 14.5px; line-height: 1.6; margin-bottom: 13px; min-height: 96px; }
.answers { display: grid; gap: 9px; margin-bottom: 14px; }
.ans { background: var(--panel); border: 1px solid var(--line); border-radius: 13px; padding: 13px 15px; font-size: 14px; font-weight: 600; color: var(--white); text-align: left; cursor: pointer; transition: border-color .18s, transform .18s, background .18s; }
.ans:active { transform: translateX(3px); }
.ans.right { background: rgba(141, 198, 63, .16); border-color: var(--green); }
.ans.wrong { background: rgba(240, 81, 46, .14); border-color: var(--orange); }
.ans[disabled] { pointer-events: none; }
.explain { font-size: 12px; color: var(--mute); line-height: 1.5; background: var(--panel); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; animation: slidein .25s ease; }
.stage { display: flex; align-items: flex-end; justify-content: center; min-height: 128px; padding: 6px 0 2px; }
.towercol { display: flex; flex-direction: column-reverse; align-items: center; gap: 3.5px; }
.blk { width: 58px; height: 15px; border-radius: 4px; animation: drop .45s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes drop { 0% { transform: translateY(-80px) scale(1.05); opacity: 0; } 60% { transform: translateY(3px); } 100% { transform: none; opacity: 1; } }
.shake { animation: shake .4s ease; }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-6px) rotate(-1deg); } 75% { transform: translateX(6px) rotate(1deg); } }
.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%) translateY(8px) scale(.95);
  background: var(--white); color: var(--ink); font-weight: 800; font-size: 14px;
  padding: 11px 20px; border-radius: 999px; opacity: 0; pointer-events: none;
  transition: all .28s ease; z-index: 50; max-width: 90vw; text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.toast.show { opacity: 1; transform: translateX(-50%) scale(1); }

/* results */
.big { font-size: 44px; font-weight: 900; }
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 14px 0; }
.result-grid .card { margin: 0; text-align: center; padding: 13px; }
.result-grid .card b { font-size: 22px; display: block; }
.result-grid .card span { font-size: 10.5px; color: var(--mute); text-transform: uppercase; letter-spacing: 1px; }

/* ---------- leaderboard ---------- */
.filters { display: flex; gap: 7px; margin-bottom: 14px; flex-wrap: wrap; }
.f { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 7px 13px; font-size: 12px; font-weight: 600; color: var(--mute); cursor: pointer; transition: all .2s; }
.f.on { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.row { display: flex; align-items: center; gap: 11px; background: var(--card); border: 1px solid var(--line); border-radius: 13px; padding: 11px 14px; margin-bottom: 8px; font-size: 13.5px; }
.row .rk { width: 22px; font-weight: 900; color: var(--mute); flex: none; }
.row .rk.top { color: var(--gold); }
.row .nm { font-weight: 700; }
.row .co { color: var(--mute); font-size: 11px; display: block; }
.row .pt { margin-left: auto; font-weight: 800; color: var(--green); }
.row .tm { color: var(--mute); font-size: 11px; width: 46px; text-align: right; flex: none; }
.row.me { border-color: var(--blue); background: rgba(74, 124, 214, .1); }
.empty { text-align: center; color: var(--mute); font-size: 13px; padding: 30px 10px; line-height: 1.6; }

/* ---------- library ---------- */
.acc { background: var(--card); border: 1px solid var(--line); border-radius: 13px; margin-bottom: 9px; overflow: hidden; }
.acc summary { padding: 14px 16px; font-weight: 800; font-size: 14.5px; cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; }
.acc summary::-webkit-details-marker { display: none; }
.acc summary .sq { width: 16px; height: 16px; border-radius: 4px; }
.acc .off { padding: 0 16px 8px; }
.acc .off div { padding: 9px 0; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--mute); line-height: 1.5; }
.acc .off b { color: var(--white); display: block; margin-bottom: 2px; font-size: 13px; }

/* ---------- pass & play ---------- */
.pp-player { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-bottom: 8px; font-size: 14px; }
.pp-player.turn { border-color: var(--green); }
.pp-player.out { opacity: .4; text-decoration: line-through; }
.pp-player .bl { margin-left: auto; font-weight: 800; color: var(--gold); font-size: 13px; }
.pp-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 12px; }
.pp-actions .wide { grid-column: 1 / -1; }

/* ---------- bottom nav ---------- */
nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  background: rgba(13, 13, 16, .92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-around; padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
}
nav button { background: none; border: none; color: var(--mute); font-size: 10px; font-weight: 700; letter-spacing: .3px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 10px; border-radius: 10px; transition: color .2s; }
nav button svg { width: 21px; height: 21px; }
nav button.on { color: var(--white); }
nav button.on svg { stroke: var(--green); }

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