/* Весёлая тема: скруглённый шрифт, объёмные «конфетные» кнопки, свой цвет у каждого уровня. */
:root {
  --bg: #fff4e0;
  --bg2: #ffe3ec;
  --card: #ffffff;
  --text: #2d2342;
  --muted: #8b80a3;
  --line: #f1e4d3;
  --key: #ffffff;
  --key-edge: #e9dccb;
  --key-press: #fff1e2;
  --ok: #22c55e;
  --ok-edge: #16a34a;
  --bad: #ff4d6d;
  --bad-edge: #e11d48;
  --accent: #ff8a1f;
  --accent-edge: #e5670a;
  --accent-soft: #ffe7cc;
  --radius: 24px;
  --shadow: 0 6px 18px rgba(120, 70, 20, .10);
  --dots: rgba(255, 138, 31, .10);
}
:root[data-level="medium"] { --accent: #2f8cff; --accent-edge: #1667d8; --accent-soft: #d9eaff; --bg: #eaf4ff; --bg2: #e8e6ff; --dots: rgba(47,140,255,.10); }
:root[data-level="hard"]   { --accent: #9b5cff; --accent-edge: #7535e0; --accent-soft: #ece0ff; --bg: #f3ecff; --bg2: #ffe3f3; --dots: rgba(155,92,255,.10); }
:root[data-level="champ"]  { --accent: #f5b700; --accent-edge: #c98f00; --accent-soft: #fff1bf; --bg: #fff8d6; --bg2: #ffe6cc; --dots: rgba(245,183,0,.14); }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1e1830; --bg2: #2a1e3a; --card: #2d2542; --text: #f6f2ff; --muted: #a79cc4;
    --line: #3b3254; --key: #352c4d; --key-edge: #221b35; --key-press: #40365b;
    --accent-soft: #4a3220; --shadow: 0 6px 18px rgba(0, 0, 0, .35); --dots: rgba(255,255,255,.05);
  }
  :root[data-level="medium"] { --accent-soft: #1d3355; --bg: #16203a; --bg2: #1d1b3d; }
  :root[data-level="hard"]   { --accent-soft: #34245a; --bg: #1f1736; --bg2: #2d1a38; }
  :root[data-level="champ"]  { --accent-soft: #4a3c0f; --bg: #221d14; --bg2: #2c1f16; }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; position: fixed; width: 100%;
  color: var(--text);
  background:
    radial-gradient(var(--dots) 2px, transparent 2.5px) 0 0 / 26px 26px,
    linear-gradient(170deg, var(--bg) 0%, var(--bg2) 100%);
  background-color: var(--bg);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", system-ui, -apple-system, sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none; touch-action: manipulation;
  font-size: 17px; line-height: 1.3;
  transition: background-color .3s;
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; margin: 0; cursor: pointer; }
button:disabled { opacity: .4; cursor: default; }

#app {
  height: 100%;
  display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 12px) calc(env(safe-area-inset-right) + 16px) calc(env(safe-area-inset-bottom) + 12px) calc(env(safe-area-inset-left) + 16px);
  max-width: 480px; margin: 0 auto;
  overflow: hidden;
}
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; margin: 0 -8px; padding: 0 8px 8px; }

/* chunky press-down: a darker edge under the button that disappears on press */
.chunky { box-shadow: 0 5px 0 var(--edge, var(--key-edge)); transform: translateY(0); transition: transform .06s, box-shadow .06s, background .15s, color .15s; }
.chunky:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--edge, var(--key-edge)); }

/* ---------- common ---------- */
.topbar { display: flex; align-items: center; gap: 10px; min-height: 48px; }
.topbar h1 { font-size: 26px; margin: 0; flex: 1; font-weight: 900; letter-spacing: -.01em; }
.iconbtn {
  width: 46px; height: 46px; border-radius: 16px; background: var(--card);
  display: grid; place-items: center; font-size: 22px; font-weight: 800;
  box-shadow: 0 4px 0 var(--key-edge); transition: transform .06s, box-shadow .06s;
}
.iconbtn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--key-edge); }
.section { margin-top: 18px; }
.label { font-size: 13px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 0 0 8px 4px; }

.hello { display: flex; align-items: flex-end; gap: 10px; margin-top: 10px; }
.hello .owl { font-size: 54px; line-height: 1; animation: bob 2.4s ease-in-out infinite; transform-origin: 50% 100%; }
.bubble {
  position: relative; background: var(--card); border-radius: 20px; padding: 12px 16px; font-weight: 800; font-size: 17px;
  box-shadow: var(--shadow); margin-bottom: 14px;
}
.bubble::before { content: ""; position: absolute; left: -8px; bottom: 12px; border: 9px solid transparent; border-right-color: var(--card); border-left: 0; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-6px) rotate(3deg); } }

.levels { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.level {
  --edge: var(--key-edge);
  padding: 12px 12px 12px 10px; border-radius: 20px; background: var(--card);
  text-align: left; display: flex; align-items: center; gap: 8px;
}
.level .emoji { font-size: 32px; line-height: 1; transition: transform .2s; }
.level b { display: block; font-size: 18px; font-weight: 900; }
.level span.sub { font-size: 13px; color: var(--muted); font-weight: 700; }
.level[aria-pressed="true"] { background: var(--accent); color: #fff; --edge: var(--accent-edge); }
.level[aria-pressed="true"] span.sub { color: rgba(255,255,255,.9); }
.level[aria-pressed="true"] .emoji { transform: scale(1.15) rotate(-8deg); }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: var(--card); padding: 6px; border-radius: 20px; box-shadow: 0 4px 0 var(--key-edge); }
.seg button { padding: 12px 4px; border-radius: 15px; font-weight: 800; font-size: 15px; color: var(--muted); transition: background .15s, color .15s; }
.seg button .sym { display: block; font-size: 22px; line-height: 1; margin-bottom: 4px; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.seg.off { opacity: .45; }
.seg button:disabled { opacity: .35; }
.seg.off button:disabled { opacity: 1; }
.seg.three button { padding: 14px 2px; font-size: 14px; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pills { display: flex; gap: 6px; background: var(--card); padding: 5px; border-radius: 16px; box-shadow: 0 4px 0 var(--key-edge); }
.pills button { padding: 8px 14px; border-radius: 12px; font-weight: 800; color: var(--muted); }
.pills button[aria-pressed="true"] { background: var(--accent); color: #fff; }

.switch { width: 54px; height: 32px; border-radius: 16px; background: var(--line); position: relative; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.2); transition: left .2s; }
.switch[aria-checked="true"] { background: var(--ok); }
.switch[aria-checked="true"]::after { left: 25px; }

.big {
  display: block; width: 100%; padding: 18px; border-radius: var(--radius);
  background: var(--accent); color: #fff; font-size: 23px; font-weight: 900; letter-spacing: .01em;
  box-shadow: 0 6px 0 var(--accent-edge); transition: transform .06s, box-shadow .06s;
}
.big:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 1px 0 var(--accent-edge); }
.big.secondary { background: var(--card); color: var(--text); box-shadow: 0 6px 0 var(--key-edge); }
.big.secondary:active { box-shadow: 0 1px 0 var(--key-edge); }
.big.go { animation: wiggle 3.5s ease-in-out infinite; }
@keyframes wiggle { 0%, 88%, 100% { transform: rotate(0); } 91% { transform: rotate(-2deg) scale(1.02); } 94% { transform: rotate(2deg) scale(1.02); } 97% { transform: rotate(-1deg); } }
.stack { display: grid; gap: 14px; }
.footer { margin-top: auto; padding-top: 16px; }
.hint { color: var(--muted); font-size: 14px; font-weight: 600; text-align: center; margin: 12px 0 0; }
.section .hint { text-align: left; margin: 8px 4px 0; }

/* ---------- game ---------- */
.progress { flex: 1; height: 16px; border-radius: 8px; background: rgba(0,0,0,.07); overflow: hidden; }
.progress i {
  display: block; height: 100%; border-radius: 8px; transition: width .35s cubic-bezier(.3,1.4,.6,1);
  background: repeating-linear-gradient(-45deg, var(--accent) 0 10px, color-mix(in srgb, var(--accent) 80%, #fff) 10px 20px);
  background-size: 28px 28px; animation: stripes 1s linear infinite; min-width: 16px;
}
@keyframes stripes { to { background-position: 28px 0; } }
.streak { font-weight: 900; font-size: 19px; min-width: 56px; text-align: right; color: var(--accent); }
.streak:empty { min-width: 0; }
.streak:not(:empty) { animation: pop .35s; }

.arena { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; min-height: 0; position: relative; }
.level-tag { font-size: 13px; font-weight: 800; color: var(--accent); background: var(--accent-soft); padding: 5px 12px; border-radius: 999px; text-transform: uppercase; letter-spacing: .06em; }
.question {
  font-weight: 900; letter-spacing: -.02em; line-height: 1;
  display: flex; align-items: baseline; gap: .25em; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.answer { min-width: 1.4em; text-align: left; color: var(--accent); position: relative; }
.answer.empty::after { content: "?"; color: var(--muted); opacity: .5; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .15; } }
.feedback { min-height: 36px; font-size: 24px; font-weight: 900; text-align: center; }
.feedback.ok { color: var(--ok); animation: pop .4s; }
.feedback.bad { color: var(--bad); }
.arena.ok .answer { color: var(--ok); animation: pop .4s; display: inline-block; }
.arena.bad .question { animation: shake .45s; }
.arena.bad .answer { color: var(--bad); }
@keyframes shake { 20% { transform: translateX(-10px); } 40% { transform: translateX(10px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(6px); } }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }
.correct-line { font-size: 22px; font-weight: 800; color: var(--muted); }

.keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding-bottom: 5px; }
.key {
  height: clamp(54px, 8.3vh, 74px); border-radius: 20px; background: var(--key);
  font-size: 31px; font-weight: 900;
  box-shadow: 0 5px 0 var(--key-edge); transition: transform .05s, box-shadow .05s, background .1s;
}
.key:active, .key.pressed { transform: translateY(4px); box-shadow: 0 1px 0 var(--key-edge); background: var(--key-press); }
.key.ok { background: var(--ok); color: #fff; box-shadow: 0 5px 0 var(--ok-edge); }
.key.ok:active { box-shadow: 0 1px 0 var(--ok-edge); background: var(--ok); }
.key.del { font-size: 26px; }
.key.hintkey { font-size: 28px; background: var(--accent-soft); }

.choices { display: grid; gap: 12px; padding-bottom: 6px; }
.choice {
  height: clamp(62px, 10vh, 82px); border-radius: 22px; background: var(--card);
  font-size: 34px; font-weight: 900; font-variant-numeric: tabular-nums;
  box-shadow: 0 6px 0 var(--key-edge); transition: transform .06s, box-shadow .06s, background .15s, color .15s, opacity .15s;
}
.choice:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--key-edge); }
.choice.right { background: var(--ok); color: #fff; box-shadow: 0 6px 0 var(--ok-edge); animation: pop .4s; }
.choice.wrong { background: var(--bad); color: #fff; box-shadow: 0 6px 0 var(--bad-edge); animation: shake .45s; }
.choice.faded { opacity: .35; }

/* ---------- column ---------- */
.col-arena { justify-content: flex-start; padding-top: 6px; gap: 8px; }
.col-q { font-size: 20px; font-weight: 900; color: var(--muted); font-variant-numeric: tabular-nums; }
.cgrid {
  --cw: min(44px, calc((min(100vw, 480px) - 66px) / var(--cols)),
    calc((100vh - 330px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) / (var(--rows) * 1.12 - .32)));
  --cw: min(44px, calc((min(100vw, 480px) - 66px) / var(--cols)),
    calc((100dvh - 330px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) / (var(--rows) * 1.12 - .32)));
  display: grid; grid-template-columns: repeat(var(--cols), var(--cw)); grid-template-rows: calc(var(--cw) * .8); grid-auto-rows: calc(var(--cw) * 1.12);
  background: var(--card); padding: 12px 14px; border-radius: 22px; box-shadow: var(--shadow);
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: var(--cw) calc(var(--cw) * 1.12); background-position: 14px calc(12px + var(--cw) * .8);
  overflow: hidden; max-width: 100%; flex: none;
}
.cc { display: grid; place-items: center; font-size: calc(var(--cw) * .66); font-weight: 900; font-variant-numeric: tabular-nums; position: relative; }
.cc.sign { color: var(--muted); }
.cc.ul { box-shadow: inset 0 -3px 0 var(--text); }
.cc.bar { box-shadow: inset 3px 0 0 var(--text); }
.cc.bar.ul { box-shadow: inset 3px 0 0 var(--text), inset 0 -3px 0 var(--text); }
.cc.slot::before {
  content: ""; position: absolute; inset: 3px; border-radius: 8px; border: 2px dashed color-mix(in srgb, var(--muted) 45%, transparent);
}
.cc.slot.cur::before { border: 3px solid var(--accent); background: var(--accent-soft); animation: glow 1.1s ease-in-out infinite; }
.cc.slot.cur.shake::before { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 18%, transparent); }
.cc.slot.cur.shake { animation: shake .4s; }
@keyframes glow { 50% { transform: scale(1.08); } }
.cc.filled { color: var(--accent); animation: pop .3s; }
.cc.filled.hinted { color: var(--bad); }

/* ---------- results ---------- */
.result { text-align: center; padding-top: 5vh; }
.result .owl { font-size: 64px; line-height: 1; animation: bob 2.4s ease-in-out infinite; }
.stars { font-size: 52px; letter-spacing: .08em; margin: 6px 0; }
.stars span { display: inline-block; color: #ffc21a; text-shadow: 0 3px 0 #e59a00; animation: star .5s backwards; }
.stars span:nth-child(2) { animation-delay: .25s; }
.stars span:nth-child(3) { animation-delay: .5s; }
.stars span.dim { color: var(--line); text-shadow: none; }
@keyframes star { 0% { transform: scale(0) rotate(-90deg); } 70% { transform: scale(1.3) rotate(10deg); } 100% { transform: scale(1) rotate(0); } }
.score { font-size: 58px; font-weight: 900; letter-spacing: -.02em; }
.score small { font-size: 22px; color: var(--muted); font-weight: 800; }
.praise { font-size: 24px; font-weight: 900; margin: 2px 0; color: var(--accent); }
.time { color: var(--muted); font-weight: 700; }
.mistakes { margin: 20px 0 0; text-align: left; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px 18px; }
.mistakes div { padding: 12px 0; border-bottom: 2px dashed var(--line); font-size: 20px; font-weight: 800; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.mistakes div:last-child { border-bottom: 0; }
.mistakes .given { color: var(--bad); font-size: 15px; font-weight: 700; text-decoration: line-through; }
.mistakes .note { color: var(--bad); font-size: 14px; font-weight: 700; white-space: nowrap; }

.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 10; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ---------- stats ---------- */
.grid { display: grid; grid-template-columns: 22px repeat(10, 1fr); gap: 3px; margin-top: 8px; }
.grid .h { font-size: 12px; font-weight: 800; color: var(--muted); text-align: center; align-self: center; }
.cell { aspect-ratio: 1; border-radius: 7px; background: var(--card); display: grid; place-items: center; font-size: 11px; font-weight: 800; color: var(--muted); }
.cell.l1 { background: #ff4d6d; color: #fff; }
.cell.l2 { background: #ffb020; color: #fff; }
.cell.l3 { background: #86d99b; color: #fff; }
.cell.l4 { background: #22c55e; color: #fff; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; font-weight: 700; color: var(--muted); margin-top: 12px; }
.legend span::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 5px; vertical-align: -1px; background: var(--card); }
.legend .l1::before { background: #ff4d6d; } .legend .l2::before { background: #ffb020; } .legend .l3::before { background: #86d99b; } .legend .l4::before { background: #22c55e; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.kpis.two { grid-template-columns: 1fr 1fr; margin-top: 8px; }
.kpis.two b { font-size: 20px; }
.kpi { background: var(--card); border-radius: 18px; box-shadow: 0 4px 0 var(--key-edge); padding: 12px 8px; text-align: center; }
.kpi b { display: block; font-size: 26px; font-weight: 900; color: var(--accent); }
.kpi span { font-size: 12px; color: var(--muted); font-weight: 700; }
.danger { color: var(--bad); font-weight: 800; padding: 14px; width: 100%; text-align: center; }

/* ---------- account ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-top: 16px; display: grid; gap: 14px; }
.card.center { text-align: center; justify-items: center; gap: 6px; }
.lead { margin: 0; font-size: 17px; font-weight: 700; line-height: 1.4; }
.field {
  width: 100%; font: inherit; font-size: 20px; font-weight: 800; color: var(--text);
  background: var(--bg); border: 3px solid transparent; border-radius: 18px; padding: 14px 16px;
  -webkit-user-select: text; user-select: text; outline: none; -webkit-appearance: none; appearance: none;
}
.field::placeholder { color: var(--muted); opacity: .45; }
.field:focus { border-color: var(--accent); }
.field.code { font-size: 34px; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.links { display: flex; justify-content: space-between; gap: 12px; }
.link { color: var(--accent); font-weight: 800; padding: 6px 0; }
.error { color: var(--bad); font-weight: 800; margin: 0; min-height: 1.3em; }
.error:empty { display: none; }
.mascot { font-size: 60px; line-height: 1; animation: bob 2.4s ease-in-out infinite; }
.big-text { font-size: 20px; font-weight: 900; margin: 6px 0 0; word-break: break-all; }

/* ---------- records ---------- */
.record-banner {
  margin: 14px auto 0; display: inline-flex; flex-direction: column; align-items: center; gap: 2px;
  background: linear-gradient(135deg, #ffd23f, #ff9f1c); color: #4a2a00; font-weight: 900; font-size: 22px;
  padding: 12px 22px; border-radius: 20px; box-shadow: 0 5px 0 #d97a00; animation: pop .5s .4s backwards;
}
.record-banner + .record-banner { margin-left: 8px; }
.record-banner small { font-size: 13px; font-weight: 800; opacity: .75; }
.record-banner.soft { background: var(--accent-soft); color: var(--text); box-shadow: 0 5px 0 var(--key-edge); font-size: 19px; }
.rec-card { background: var(--card); border-radius: var(--radius); box-shadow: 0 5px 0 var(--key-edge); padding: 14px 16px 6px; margin-top: 14px; }
.rec-head { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 900; margin-bottom: 4px; }
.rec-head .emoji { font-size: 28px; }
.rec-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 10px 0; border-top: 2px dashed var(--line); font-weight: 700; }
.rec-kind { color: var(--muted); font-size: 15px; }
.rec-kind b { color: var(--accent); font-size: 18px; }
.rec-val { font-weight: 900; font-size: 17px; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- timer ---------- */
.timer { position: relative; width: 52px; height: 52px; flex: none; }
.timer svg { width: 100%; height: 100%; display: block; }
.t-track { fill: var(--card); stroke: rgba(0, 0, 0, .08); stroke-width: 7; }
.t-arc { fill: none; stroke-width: 7; stroke-linecap: round; }
.t-num { position: absolute; inset: 0; display: grid; place-items: center; font-size: 17px; font-weight: 900; font-variant-numeric: tabular-nums; }
.timer.hurry { animation: hurry .5s ease-in-out infinite alternate; }
.timer.hurry .t-num { color: var(--bad); }
@keyframes hurry { to { transform: scale(1.12); } }
.streak-slot { width: 0; }
.timeout { font-size: 24px; color: var(--bad); }
.tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.level-tag.again { color: #fff; background: #ff9f1c; }
.level-tag.fire { color: #fff; background: #ff4d6d; animation: pop .35s; }

/* ---------- my successes ---------- */
.seg.tabs { margin-top: 12px; }
.seg.tabs button { padding: 11px 2px; font-size: 14px; }
.ach-count { margin-top: 16px; display: flex; align-items: center; gap: 12px; font-weight: 800; color: var(--muted); }
.ach-count b { font-size: 28px; color: var(--accent); }
.ach-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.ach {
  background: var(--card); border-radius: 18px; padding: 12px 8px 10px; text-align: center;
  box-shadow: 0 4px 0 var(--key-edge); display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.ach .ach-emoji { font-size: 34px; line-height: 1.1; filter: grayscale(1); opacity: .35; }
.ach b { font-size: 13px; font-weight: 900; line-height: 1.15; }
.ach small { font-size: 11px; color: var(--muted); font-weight: 700; line-height: 1.2; }
.ach:not(.got) b { color: var(--muted); }
.ach.got { background: linear-gradient(160deg, var(--card), var(--accent-soft)); box-shadow: 0 4px 0 var(--accent-edge); }
.ach.got .ach-emoji { filter: none; opacity: 1; }
.ach-bar { width: 80%; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 4px; }
.ach-bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.ach-num { font-variant-numeric: tabular-nums; }

.ach-new { margin-top: 18px; display: grid; gap: 10px; }
.ach-new-title { font-size: 22px; font-weight: 900; color: var(--accent); animation: pop .5s .5s backwards; }
.ach-pop {
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: linear-gradient(135deg, #fff6d6, #ffe0f0); color: #3a2a00; border-radius: 20px; padding: 12px 16px;
  box-shadow: 0 5px 0 #f0c36b; animation: achIn .6s cubic-bezier(.3, 1.6, .6, 1) backwards;
}
.ach-pop .ach-emoji { font-size: 40px; line-height: 1; }
.ach-pop b { display: block; font-size: 18px; font-weight: 900; }
.ach-pop small { font-size: 13px; font-weight: 700; opacity: .7; }
@keyframes achIn { 0% { transform: scale(.3) rotate(-8deg); opacity: 0; } 100% { transform: scale(1) rotate(0); opacity: 1; } }

.weak { display: flex; flex-wrap: wrap; gap: 8px; }
.weak-chip {
  font-size: 18px; font-weight: 900; padding: 8px 12px; border-radius: 14px; color: #fff;
  background: color-mix(in srgb, #ff4d6d calc(var(--heat) * 100%), #ffb020);
  box-shadow: 0 3px 0 rgba(0, 0, 0, .12);
}

/* ---------- column: tappable cells and the draft row ---------- */
button.cc { font: inherit; font-size: calc(var(--cw) * .66); font-weight: 900; cursor: pointer; padding: 0; }
.cc.slot:not(.cur):active::before { background: var(--accent-soft); }
.cc.draftcell {
  /* handwriting, like a pencil note above the number */
  font-family: "Noteworthy", "Bradley Hand", "Chalkboard SE", "Segoe Print", "Comic Sans MS", cursive;
  font-size: calc(var(--cw) * .52); font-weight: 700; color: #2f6fd6;
  align-items: end; padding-bottom: 1px; transform: rotate(-4deg);
}
@media (prefers-color-scheme: dark) { .cc.draftcell { color: #7fb0ff; } }
.cc.draftcell::before {
  content: ""; position: absolute; left: 22%; right: 22%; bottom: 2px; border-bottom: 2px dotted color-mix(in srgb, #2f6fd6 35%, transparent);
}
.cc.draftcell.cur::before { inset: 2px; border: 2px solid #2f6fd6; border-radius: 8px; background: color-mix(in srgb, #2f6fd6 12%, transparent); }
.col-help { margin: 0; font-size: 13px; font-weight: 700; color: var(--muted); text-align: center; }
.pills.wide { display: grid; grid-template-columns: repeat(5, 1fr); }
.pills.wide button { padding: 10px 2px; }

/* ---------- avatars ---------- */
.ava { display: block; width: 100%; height: 100%; }
.me {
  position: relative; flex: none; width: 66px; height: 66px; border-radius: 50%; overflow: visible;
  box-shadow: 0 4px 0 var(--key-edge), 0 0 0 3px #fff; transition: transform .1s;
}
.me > svg { border-radius: 50%; overflow: hidden; }
.me:active { transform: scale(.94); }
.me .pen { position: absolute; right: -6px; bottom: -4px; font-size: 18px; background: var(--card); border-radius: 50%; width: 28px; height: 28px; display: grid; place-items: center; box-shadow: 0 2px 0 var(--key-edge); }
.me.big { width: 110px; height: 110px; margin: 0 auto; }
.me.huge { width: 170px; height: 170px; margin: 0 auto; box-shadow: 0 6px 0 var(--key-edge), 0 0 0 5px #fff; }
.me .badge { position: absolute; right: -10px; top: -10px; font-size: 36px; animation: pop .5s .3s backwards; }
.result .me.big { animation: bob 2.4s ease-in-out infinite; }
.hello .me { animation: bob 2.4s ease-in-out infinite; transform-origin: 50% 100%; }
.boing { animation: boing .45s cubic-bezier(.3, 1.8, .6, 1); }
@keyframes boing { 0% { transform: scale(.85) rotate(-4deg); } 100% { transform: scale(1) rotate(0); } }
.ava-stage { text-align: center; margin-top: 8px; }
.ava-name { margin: 10px 0 0; font-size: 20px; font-weight: 900; }
.ava-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 14px 4px 10px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; flex: none; }
.ava-tabs::-webkit-scrollbar { display: none; }
.ava-tabs button {
  flex: none; display: flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 999px;
  background: var(--card); font-weight: 800; font-size: 15px; color: var(--muted); box-shadow: 0 3px 0 var(--key-edge);
}
.ava-tabs button span { font-size: 18px; }
.ava-tabs button[aria-pressed="true"] { background: var(--accent); color: #fff; box-shadow: 0 3px 0 var(--accent-edge); }
.ava-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding-bottom: 10px; }
.ava-opt { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 4px; border-radius: 18px; background: var(--card); box-shadow: 0 3px 0 var(--key-edge); }
.ava-opt .ava { width: 100%; aspect-ratio: 1; height: auto; border-radius: 50%; }
.ava-opt small { font-size: 11px; font-weight: 800; color: var(--muted); line-height: 1.15; text-align: center; min-height: 2.3em; }
.ava-opt[aria-pressed="true"] { background: var(--accent-soft); box-shadow: 0 0 0 3px var(--accent), 0 3px 0 var(--accent-edge); }
.ava-opt[aria-pressed="true"] small { color: var(--text); }

/* ---------- wardrobe and presents ---------- */
.wardrobe { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-weight: 800; color: var(--muted); font-size: 14px; }
.wardrobe b { color: var(--accent); font-size: 18px; }
.wardrobe .progress { height: 10px; }
.next-gift { margin-top: 8px; background: var(--card); border-radius: 16px; padding: 10px 14px; box-shadow: 0 3px 0 var(--key-edge); font-size: 14px; font-weight: 700; }
.next-gift small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.next-gift .ach-bar { width: 100%; margin-top: 6px; }
.ava-opt { position: relative; }
.ava-opt.locked .ava { filter: grayscale(.85) brightness(1.05); opacity: .45; }
.ava-opt.locked small { opacity: .6; }
.ava-opt .lock { position: absolute; top: 30%; left: 50%; transform: translate(-50%, -50%); font-size: 24px; filter: drop-shadow(0 2px 2px rgba(0,0,0,.25)); }
.lock-hint {
  display: flex; gap: 10px; align-items: center; margin: 4px 0 12px; padding: 12px 14px; border-radius: 18px;
  background: linear-gradient(135deg, #fff6d6, #ffe0f0); color: #3a2a00; font-size: 14px; font-weight: 700; line-height: 1.35;
  box-shadow: 0 4px 0 #f0c36b; animation: pop .35s;
}
.lock-hint .ach-emoji { font-size: 34px; }
.lock-hint em { font-style: normal; font-weight: 900; color: #c2185b; white-space: nowrap; }
.gift { background: var(--card); border-radius: 20px; padding: 12px; box-shadow: 0 4px 0 var(--key-edge); animation: achIn .6s cubic-bezier(.3, 1.6, .6, 1) backwards; }
.gift-title { font-weight: 900; font-size: 16px; }
.gift-items { display: flex; justify-content: center; gap: 14px; margin-top: 8px; }
.gift-item { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 96px; }
.gift-item .ava { width: 80px; height: 80px; border-radius: 50%; box-shadow: 0 0 0 3px #ffd23f, 0 4px 0 #e0a400; animation: wiggle 2.5s ease-in-out infinite; }
.gift-item small { font-size: 12px; font-weight: 800; line-height: 1.2; }
.gift-help { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.ach-gift { margin-top: 4px; color: var(--accent) !important; font-weight: 800 !important; }

/* ---------- battle ---------- */
.my-id { font-size: 44px; font-weight: 900; letter-spacing: .06em; color: var(--accent); font-variant-numeric: tabular-nums; -webkit-user-select: text; user-select: text; }
.b-list { display: grid; gap: 10px; padding-bottom: 12px; }
.b-item, .b-invite {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: var(--card); border-radius: 18px; padding: 10px 12px; box-shadow: 0 4px 0 var(--key-edge);
}
.b-ava { flex: none; width: 46px; height: 46px; border-radius: 50%; overflow: hidden; box-shadow: 0 0 0 2px #fff; }
.b-mid { flex: 1; min-width: 0; }
.b-mid b, .b-invite b { display: block; font-size: 16px; font-weight: 900; }
.b-mid small, .b-invite small { display: block; font-size: 12px; color: var(--muted); font-weight: 700; }
.b-st { text-align: right; }
.b-st b { display: block; font-size: 13px; font-weight: 900; white-space: nowrap; }
.b-st small { font-size: 16px; font-weight: 900; font-variant-numeric: tabular-nums; }
.b-item.win { box-shadow: 0 4px 0 #e0a400, 0 0 0 2px #ffd23f; }
.b-item.invite, .b-item.play { box-shadow: 0 4px 0 var(--accent-edge), 0 0 0 2px var(--accent); }
.b-item.declined { opacity: .55; }
.b-invite { margin-top: 10px; background: linear-gradient(135deg, #fff6d6, #ffe0f0); color: #3a2a00; box-shadow: 0 4px 0 #f0c36b; animation: pop .4s; }
.b-invite small { color: #7a6650; }
.b-invite > span:nth-child(2) { flex: 1; min-width: 0; }
.b-btns { display: flex; flex-direction: column; gap: 6px; }
.b-yes, .b-no { padding: 7px 12px; border-radius: 12px; font-weight: 900; font-size: 14px; }
.b-yes { background: var(--ok); color: #fff; box-shadow: 0 3px 0 var(--ok-edge); }
.b-no { background: rgba(0, 0, 0, .06); color: #7a6650; }
.opp { display: flex; align-items: center; gap: 4px; flex: none; background: var(--card); border-radius: 999px; padding: 3px 10px 3px 3px; box-shadow: 0 3px 0 var(--key-edge); }
.opp-ava { width: 34px; height: 34px; border-radius: 50%; overflow: hidden; display: block; transition: transform .2s; }
.opp-ava.ahead { animation: bob 1s ease-in-out infinite; }
.opp-txt { font-size: 14px; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.opp-txt b { color: var(--text); font-size: 16px; }
.b-banner { font-size: 28px; font-weight: 900; color: var(--accent); margin-bottom: 14px; animation: pop .5s; }
.b-banner.win { color: #e0a400; }
.b-banner.wait { color: var(--muted); font-size: 22px; }
.b-vs { display: flex; align-items: center; justify-content: center; gap: 8px; }
.b-side { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.b-side b { font-size: 17px; font-weight: 900; }
.b-side .me.big { width: 96px; height: 96px; }
.b-side.winner .me.big { box-shadow: 0 4px 0 #e0a400, 0 0 0 4px #ffd23f; }
.b-score { font-size: 34px; font-weight: 900; }
.b-score small { font-size: 15px; color: var(--muted); }
.b-time { color: var(--muted); font-weight: 700; }
.vs { font-size: 24px; font-weight: 900; color: #fff; background: var(--bad); border-radius: 50%; width: 52px; height: 52px; display: grid; place-items: center; flex: none; box-shadow: 0 4px 0 var(--bad-edge); transform: rotate(-8deg); }
.invite-card { background: linear-gradient(160deg, var(--card), var(--accent-soft)); }
.invite-link { font-size: 14px; font-weight: 800; color: var(--accent); background: var(--bg); border-radius: 12px; padding: 10px 12px; word-break: break-all; -webkit-user-select: text; user-select: text; }

/* column mode: a two-row keypad leaves the screen to the notebook */
.keys.compact { grid-template-columns: repeat(6, 1fr); gap: 7px; }
.keys.compact .key { height: clamp(46px, 6.4vh, 58px); font-size: 26px; border-radius: 16px; }
.keys.compact .key.del { font-size: 22px; }
.key.draftkey { font-size: 22px; background: color-mix(in srgb, #2f6fd6 12%, var(--key)); }
.key.draftkey.on { background: #2f6fd6; color: #fff; box-shadow: 0 5px 0 #1f4fa6; }
.col-arena { gap: 6px; padding-top: 0; }
.col-arena .col-q { font-size: 18px; }
.col-help { font-size: 12px; }

/* ---------- time before the start ---------- */
.sheet-back { position: fixed; inset: 0; z-index: 20; background: rgba(30, 20, 50, .45); display: flex; align-items: flex-end; justify-content: center; animation: fadeIn .2s; }
.sheet {
  width: 100%; max-width: 480px; background: var(--card); border-radius: 28px 28px 0 0; text-align: center;
  padding: 22px 16px calc(18px + env(safe-area-inset-bottom)); animation: up .28s cubic-bezier(.3, 1.3, .6, 1);
}
.sheet-title { font-size: 22px; font-weight: 900; margin-bottom: 16px; }
.sheet-opts { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 10px; }
.sheet-opts button { padding: 14px 2px 10px; border-radius: 18px; background: var(--bg); box-shadow: 0 4px 0 var(--key-edge); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.sheet-opts b { font-size: 26px; font-weight: 900; }
.sheet-opts small { font-size: 11px; font-weight: 800; color: var(--muted); }
.sheet-opts button[aria-pressed="true"] { background: var(--accent); color: #fff; box-shadow: 0 4px 0 var(--accent-edge); }
.sheet-opts button[aria-pressed="true"] small { color: rgba(255, 255, 255, .85); }
.sheet-opts button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--key-edge); }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes up { from { transform: translateY(100%); } }
.logout { margin-top: 12px; padding: 10px 18px; border-radius: 14px; font-weight: 800; color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, transparent); }
.logout:active { transform: scale(.97); }

/* ---------- Telegram ---------- */
.big.tg { background: #2aabee; box-shadow: 0 6px 0 #1b8cc7; }
.big.tg:active:not(:disabled) { box-shadow: 0 1px 0 #1b8cc7; }
.tg-card .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 700; font-size: 15px; }
.ok-mark { font-size: 12px; font-weight: 900; color: #fff; background: var(--ok); border-radius: 999px; padding: 2px 8px; vertical-align: 2px; }
.danger-link { color: var(--bad); }
.or { text-align: center; color: var(--muted); font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; margin: 14px 0 -4px; }
a.link { text-decoration: none; }
