:root {
  --bg: #0f1116;
  --bg2: #191c25;
  --panel: rgba(25, 28, 38, .86);
  --panel-solid: #1b1e28;
  --raise: rgba(255, 255, 255, .06);
  --raise2: rgba(255, 255, 255, .1);
  --line: rgba(255, 255, 255, .1);
  --ink: #f2f3f7;
  --ink-soft: #a9afc0;
  --ink-faint: #737a8d;
  --accent: #ffc23d;
  --accent-ink: #1d1503;
  --teal: #3ad6a5;
  --red: #ff7272;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .45), 0 2px 8px rgba(0, 0, 0, .25);
  --ui: "Outfit", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--ui); -webkit-text-size-adjust: 100%; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 60; background: var(--panel-solid); padding: 8px 12px; border-radius: 8px; }
.skip-link:focus { left: 8px; }

.pc {
  position: relative; height: 100vh; height: 100svh; min-height: 300px; overflow: hidden; isolation: isolate;
  background:
    radial-gradient(ellipse 70% 60% at 62% 42%, rgba(70, 86, 130, .34), transparent 70%),
    radial-gradient(ellipse 50% 40% at 20% 100%, rgba(255, 194, 61, .07), transparent 70%),
    linear-gradient(180deg, #151821 0%, #0e1015 100%);
}
.stage { position: absolute; inset: 0; outline: none; }
#cube { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: grab; }
#cube:active { cursor: grabbing; }
.webgl-fail { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 24px; max-width: 520px; margin: auto; z-index: 30; }
.webgl-fail h2 { font-size: 26px; margin: 0 0 8px; }
.webgl-fail p { color: var(--ink-soft); line-height: 1.5; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--raise); font-weight: 600; font-size: 15px; white-space: nowrap;
  transition: background .15s, transform .12s, border-color .15s;
}
.btn:hover { background: var(--raise2); border-color: rgba(255, 255, 255, .18); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 700; }
.btn.primary:hover { background: #ffd062; }
.btn.danger { color: var(--red); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.icon-btn { display: inline-flex; align-items: center; gap: 6px; min-width: 44px; min-height: 44px; justify-content: center; border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 0 12px; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); font-weight: 600; }
.icon-btn:hover { background: var(--panel-solid); border-color: rgba(255, 255, 255, .2); }
.round-btn { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line); background: var(--panel); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 6px 20px rgba(0, 0, 0, .3); }
.round-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.round-btn:active { transform: scale(.94); }

/* ---------- Home ---------- */
.home {
  position: absolute; z-index: 5; pointer-events: none;
  inset: 0; display: grid; align-content: center; gap: 18px;
  padding: calc(84px + var(--safe-t)) 24px calc(24px + var(--safe-b)) max(40px, calc(6vw + var(--safe-l)));
  width: min(520px, 46vw); min-width: 400px;
}
.home > * { pointer-events: auto; }
.home-brand .kicker { margin: 0 0 4px; color: var(--accent); font-weight: 700; letter-spacing: .14em; text-transform: uppercase; font-size: 12px; }
.home-brand h1 { margin: 0; font-size: clamp(44px, 5.2vw, 68px); line-height: .95; font-weight: 800; letter-spacing: -.03em; }
.home-brand .tagline { margin: 10px 0 0; color: var(--ink-soft); font-size: 18px; }
.modes { display: grid; gap: 10px; }
.mode-card {
  position: relative; display: flex; align-items: center; gap: 14px; text-align: left; padding: 14px 16px; min-height: 72px;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transition: transform .15s, border-color .15s, background .15s; box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
}
.mode-card:hover { transform: translateX(4px); border-color: rgba(255, 194, 61, .45); background: rgba(33, 36, 48, .92); }
.mode-card:active { transform: scale(.985); }
.mode-copy { display: grid; gap: 2px; min-width: 0; }
.mode-copy b { font-size: 18px; font-weight: 700; }
.mode-copy small { color: var(--ink-soft); font-size: 14px; line-height: 1.3; }
.mode-ico { width: 46px; height: 46px; border-radius: 14px; flex: none; background: var(--raise2); display: grid; place-items: center; position: relative; overflow: hidden; }
.mode-ico::before { content: ""; position: absolute; inset: 9px; border-radius: 6px; }
.ico-standard::before { background: conic-gradient(#009b48 0 25%, #c8102e 0 50%, #ffd500 0 75%, #0046ad 0); }
.ico-timed::before { inset: 10px; border-radius: 50%; border: 3px solid var(--accent); background: conic-gradient(var(--accent) 0 30%, transparent 0); }
.ico-learn::before { inset: 11px; border-radius: 4px; background: linear-gradient(#3ad6a5 0 0) 0 0 / 100% 30% no-repeat, linear-gradient(rgba(255, 255, 255, .7) 0 0) 0 50% / 70% 16% no-repeat, linear-gradient(rgba(255, 255, 255, .45) 0 0) 0 100% / 85% 16% no-repeat; }
.ico-daily::before { inset: 10px; border-radius: 6px; border: 3px solid #8fb6ff; border-top-width: 8px; }
.progress-pill { position: absolute; right: 14px; top: 12px; font-size: 12px; font-weight: 700; color: var(--teal); background: rgba(58, 214, 165, .12); padding: 3px 8px; border-radius: 999px; }
.resume { display: flex; align-items: center; gap: 12px; text-align: left; padding: 12px 16px; border-radius: 14px; border: 1px solid rgba(255, 194, 61, .5); background: rgba(255, 194, 61, .1); }
.resume b { display: block; font-size: 16px; }
.resume small { color: var(--ink-soft); }
.resume .go { margin-left: auto; font-size: 20px; color: var(--accent); }
.resume-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(255, 194, 61, .2); flex: none; }
.home-links { display: flex; flex-wrap: wrap; gap: 8px; }
.home-links button { display: inline-flex; align-items: center; gap: 7px; min-height: 42px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--raise); font-weight: 600; font-size: 14px; color: var(--ink-soft); }
.home-links button:hover { color: var(--ink); background: var(--raise2); }
.home-links svg { width: 17px; height: 17px; }
.home-links .short { display: none; }
.pc[data-screen="play"] .home { display: none; }

/* ---------- Solve My Cube card + importer ---------- */
.mode-card.wide { grid-column: 1 / -1; }
.ico-mycube::before { inset: 9px; border-radius: 8px; border: 3px solid #8fb6ff; background: radial-gradient(circle, #8fb6ff 0 22%, transparent 24%); }
.pc[data-screen="import"] .home, .pc[data-screen="import"] .hud, .pc[data-screen="import"] .dock, .pc[data-screen="import"] .cam-tools { display: none; }
.importer {
  position: absolute; inset: 0; z-index: 25; overflow: auto; overscroll-behavior: contain; display: flex; flex-direction: column;
  padding: calc(12px + var(--safe-t)) max(20px, var(--safe-r)) calc(14px + var(--safe-b)) max(20px, var(--safe-l));
  background: linear-gradient(180deg, rgba(16, 18, 24, .97), rgba(12, 13, 18, .99));
}
/* The header shares the top row with the site's two round buttons (top-left). */
.imp-head { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 1080px; min-height: 46px; margin: 0 auto 10px; padding-left: max(0px, calc(120px - max(20px, (100vw - 1080px) / 2))); }
.imp-head h2 { margin: 0; font-size: clamp(18px, 2.4vw, 26px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.imp-step { margin-left: auto; color: var(--accent); font-weight: 800; white-space: nowrap; }
.imp-step:empty { display: none; }

/* Capture: thumbs, frame, one-line instruction and the buttons all fit on one screen, no scrolling. */
.imp-capture {
  flex: 1 1 auto; min-height: 0; width: 100%; max-width: 1080px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 10px;
}
.imp-capture[hidden] { display: none; }
.imp-thumbs { grid-area: thumbs; }
/* The frame is a square as large as fits: full width on phones, shrinking when the screen is short. */
.imp-stage { grid-area: stage; flex: 0 1 calc(100vw - 24px); min-height: 160px; container-type: size; display: grid; place-items: center; }
.imp-howto { grid-area: howto; }
.imp-size { grid-area: size; }
.imp-main { grid-area: main; }
.imp-alt { grid-area: alt; }
.imp-frame { position: relative; width: 100cqmin; height: 100cqmin; border-radius: 20px; overflow: hidden; background: #050608; border: 1px solid var(--line); touch-action: none; }
.imp-frame video, .imp-frame img { position: absolute; inset: 0; width: 100%; height: 100%; }
.imp-frame video { object-fit: cover; }
.imp-frame img { object-fit: contain; }
.imp-grid { position: absolute; transform: translate(-50%, -50%); display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); border: 3px solid rgba(255, 255, 255, .9); border-radius: 14px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .35); cursor: move; }
.imp-grid i { border: 1px solid rgba(255, 255, 255, .45); display: grid; place-items: center; }
.imp-grid i::after { content: ""; width: 22%; height: 22%; border-radius: 50%; background: var(--dot, transparent); box-shadow: 0 0 0 2px rgba(0, 0, 0, .35); }
.imp-msg { position: absolute; left: 12px; right: 12px; bottom: 12px; margin: 0; padding: 8px 12px; border-radius: 12px; background: rgba(20, 22, 30, .92); text-align: center; font-weight: 600; font-size: 14px; }

/* "Side saved" confirmation laid over the frame: the 9 colors that were read plus a big check. */
.imp-ok { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; padding: 16px; text-align: center; background: rgba(8, 40, 28, .74); backdrop-filter: blur(2px); animation: ok-in .2s ease-out; }
.imp-ok[hidden] { display: none; }
.imp-ok.warn { background: rgba(48, 34, 6, .88); }
.imp-ok .read { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; width: min(42cqmin, 180px); padding: 6px; border-radius: 14px; background: #0b0c0f; position: relative; }
.imp-ok .read i { aspect-ratio: 1; border-radius: 6px; }
.imp-ok .badge { position: absolute; right: -16px; bottom: -16px; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--teal); color: #05261b; box-shadow: 0 4px 14px rgba(0, 0, 0, .4); animation: ok-pop .35s .06s cubic-bezier(.3, 1.6, .5, 1) both; }
.imp-ok.warn .badge { background: var(--accent); color: #2a1d00; font-size: 26px; font-weight: 900; }
.imp-ok .badge svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; }
.imp-ok b { font-size: 20px; }
.imp-ok p { margin: 0; max-width: 30ch; color: var(--ink); line-height: 1.4; font-size: 15px; }
.imp-ok .row { display: flex; gap: 8px; }
.imp-ok .row .btn { min-width: 112px; min-height: 46px; }
@keyframes ok-in { from { opacity: 0; } }
@keyframes ok-pop { from { transform: scale(.2); opacity: 0; } }

.imp-howto { display: flex; gap: 12px; align-items: center; padding: 8px 12px; border-radius: 14px; background: var(--raise); }
.imp-howto p { margin: 0; color: var(--ink-soft); line-height: 1.35; font-size: 15px; }
.imp-howto b { color: var(--ink); }
.imp-howto.fresh { animation: howto-in .6s ease-out; }
@keyframes howto-in { from { background: rgba(58, 214, 165, .3); } }
.imp-face { position: relative; flex: none; width: 40px; height: 40px; margin-top: 6px; border-radius: 9px; background: #141518; display: grid; place-items: center; }
.imp-face .center { width: 22px; height: 22px; border-radius: 5px; background: var(--center); }
.imp-face .top { position: absolute; left: 5px; right: 5px; top: -7px; height: 7px; border-radius: 4px 4px 0 0; background: var(--top); }
.imp-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.imp-actions .btn { flex: 1 1 140px; }
.imp-actions .btn[hidden] { display: none; }
.imp-main .btn { min-height: 50px; }
.imp-main #imp-shoot, .imp-main #imp-review { flex: 2 1 180px; font-size: 17px; }
.imp-alt { display: flex; justify-content: center; gap: 22px; margin: 0; }
.linkish { background: none; border: 0; padding: 4px 2px; color: var(--ink-soft); font: inherit; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.linkish:hover { color: var(--ink); }
.linkish[hidden] { display: none; }
.imp-size { display: flex; align-items: center; gap: 10px; color: var(--ink-soft); font-size: 14px; }
.imp-size[hidden] { display: none; }
.imp-size input { flex: 1; }

.imp-thumbs { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.thumb { position: relative; display: grid; gap: 3px; justify-items: center; padding: 5px 2px 4px; border-radius: 12px; border: 2px solid var(--line); background: transparent; min-height: 0; }
.thumb.now { border-color: var(--accent); background: rgba(255, 194, 61, .1); }
.thumb small { font-size: 11px; color: var(--ink-faint); }
.thumb .mini { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; width: 28px; }
.thumb .mini i { aspect-ratio: 1; border-radius: 2px; background: #2c303a; }
.thumb.done { border-color: rgba(58, 214, 165, .55); background: rgba(58, 214, 165, .08); }
.thumb.done.now { border-color: var(--accent); }
.thumb.done small { color: var(--teal); font-weight: 700; }
.thumb.done::after { content: "\2713"; position: absolute; top: -7px; right: -5px; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 900; background: var(--teal); color: #05261b; }
.thumb.done.warn { border-color: rgba(255, 194, 61, .6); }
.thumb.done.warn small { color: var(--accent); }
.thumb.done.warn::after { content: "!"; background: var(--accent); color: #2a1d00; }
.thumb.just::after { animation: ok-pop .35s cubic-bezier(.3, 1.6, .5, 1) both; }

/* The next thing to tap gently pulses. */
.nudge { animation: nudge 1.7s ease-in-out infinite; }
@keyframes nudge {
  0% { box-shadow: 0 0 0 0 rgba(255, 194, 61, .6); transform: scale(1); }
  18% { transform: scale(1.035); }
  36% { transform: scale(1); }
  70%, 100% { box-shadow: 0 0 0 12px rgba(255, 194, 61, 0); }
}
@media (prefers-reduced-motion: reduce) { .nudge { animation: none !important; box-shadow: 0 0 0 3px rgba(255, 194, 61, .55); } }
.pc[data-motion="reduced"] .nudge { animation: none !important; box-shadow: 0 0 0 3px rgba(255, 194, 61, .55); }

/* Review / type colors. */
.imp-editor { width: 100%; max-width: 1060px; margin: 0 auto; display: grid; gap: 10px 24px; grid-template-columns: minmax(0, 1fr) 280px; grid-template-areas: "tip tip" "net pal" "net prob" "net act"; align-items: start; }
.imp-editor[hidden] { display: none; }
.imp-tip { grid-area: tip; margin: 0; color: var(--ink-soft); line-height: 1.45; }
.imp-tip b { color: var(--ink); }
.net { grid-area: net; max-width: 640px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.net-face span { display: block; font-size: 12px; color: var(--ink-faint); margin-bottom: 3px; }
.net-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 5px; border-radius: 12px; background: #0b0c0f; }
.net-grid .st { aspect-ratio: 1; border-radius: 6px; border: 0; min-height: 0; padding: 0; }
.net-grid .st:disabled { cursor: default; box-shadow: inset 0 0 0 3px rgba(0, 0, 0, .25); }
.net-grid .st.empty { background-image: repeating-linear-gradient(45deg, transparent 0 5px, rgba(255, 255, 255, .06) 5px 10px); }
.net-grid .st.doubt { outline: 3px dashed #fff; outline-offset: -3px; }
.net-grid .st.bad { outline: 3px solid var(--red); outline-offset: -3px; animation: pulse 1s ease-in-out infinite alternate; }
@keyframes pulse { to { outline-color: rgba(255, 114, 114, .3); } }
.palette { grid-area: pal; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.pal { display: grid; justify-items: center; gap: 3px; padding: 8px 4px; border-radius: 14px; border: 2px solid var(--line); background: var(--raise); min-height: 60px; }
.pal i { width: 26px; height: 26px; border-radius: 7px; }
.pal span { font-size: 12px; font-weight: 600; }
.pal small { font-size: 11px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.pal small.ok { color: var(--teal); }
.pal small.over { color: var(--red); }
.pal.on { border-color: var(--accent); background: rgba(255, 194, 61, .12); }
.imp-problems { grid-area: prob; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: 14px; background: rgba(255, 114, 114, .1); border: 1px solid rgba(255, 114, 114, .35); }
.imp-problems[hidden] { display: none; }
.imp-problems p { margin: 0; flex: 1 1 200px; line-height: 1.4; font-size: 15px; }
.imp-problems .btn { flex: none; min-height: 42px; }
.imp-problems.fixed { background: rgba(58, 214, 165, .1); border-color: rgba(58, 214, 165, .4); }
.imp-editor > .imp-actions { grid-area: act; flex-direction: column; }
.imp-editor > .imp-actions .btn { flex: none; }
.hold-line { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; font-size: 13px; color: var(--ink-soft); }
.hold-line i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }

/* Wide screens: frame on the left, everything else in a column on the right. */
@media (min-width: 821px) {
  .imp-capture { display: grid; grid-template-columns: minmax(0, 1fr) 340px; grid-template-rows: auto auto auto auto auto 1fr; grid-template-areas: "stage thumbs" "stage howto" "stage size" "stage main" "stage alt" "stage ."; gap: 14px 24px; }
  .imp-stage { grid-row: 1 / -1; height: 100%; }
}
@media (max-width: 820px) {
  .imp-editor { grid-template-columns: 1fr; grid-template-areas: "tip" "net" "prob" "pal" "act"; }
  .palette { position: sticky; bottom: calc(-10px - var(--safe-b)); z-index: 2; grid-template-columns: repeat(6, 1fr); padding: 6px; margin: 0 -4px; border-radius: 16px; background: rgba(16, 18, 24, .96); border: 1px solid var(--line); }
  .palette .pal { min-height: 52px; padding: 5px 2px; }
  .palette .pal span { font-size: 10.5px; }
  .imp-editor > .imp-actions { flex-direction: row; }
  .imp-editor > .imp-actions .btn { flex: 1 1 28%; }
  .imp-editor > .imp-actions #imp-solve { flex: 1 1 100%; min-height: 50px; font-size: 17px; }
}
@media (max-width: 720px) {
  .importer { padding: calc(10px + var(--safe-t)) 12px calc(10px + var(--safe-b)); }
  .imp-head { padding-left: 104px; margin-bottom: 8px; }
  .importer[data-view="capture"] .imp-head h2 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .imp-head .icon-btn span { display: none; }
  .imp-step { font-size: 18px; margin-left: 4px; }
  .imp-capture { gap: 8px; }
  .imp-actions .btn { flex: 1 1 45%; min-height: 44px; font-size: 14px; padding: 0 10px; }
  .imp-main .btn { min-height: 50px; }
  .imp-main #imp-shoot, .imp-main #imp-review { font-size: 16px; }
  .imp-howto p { font-size: 14px; }
  .thumb small { font-size: 10px; }
  .net { gap: 5px; }
  .net-grid { gap: 2px; padding: 3px; border-radius: 8px; }
  .net-grid .st { border-radius: 3px; }
  .net-face span { font-size: 10px; white-space: nowrap; overflow: hidden; }
  .imp-tip { font-size: 14px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .importer { padding-top: calc(8px + var(--safe-t)); padding-bottom: calc(8px + var(--safe-b)); }
  .imp-head { margin-bottom: 6px; }
  .importer[data-view="capture"] .imp-head h2 { position: static; width: auto; height: auto; clip: auto; }
  .imp-capture { display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, 320px); grid-template-rows: auto auto auto auto auto 1fr; grid-template-areas: "stage thumbs" "stage howto" "stage size" "stage main" "stage alt" "stage ."; gap: 8px 16px; }
  .imp-stage { grid-row: 1 / -1; height: 100%; }
  .thumb small { display: none; }
  /* Review: the map is sized by the screen height; palette and buttons share the narrow right column. */
  .imp-editor { grid-template-columns: auto minmax(250px, 300px); gap: 8px 18px; justify-content: center; }
  .imp-tip { font-size: 13.5px; line-height: 1.35; }
  .net { width: calc((100svh - 120px) * 1.3); max-width: 100%; gap: 4px; }
  .net-face span { font-size: 9.5px; margin-bottom: 1px; white-space: nowrap; overflow: hidden; }
  .net-grid { gap: 2px; padding: 3px; border-radius: 8px; }
  .palette { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .pal { min-height: 0; padding: 4px 2px; gap: 1px; }
  .pal i { width: 20px; height: 20px; }
  .imp-editor > .imp-actions { flex-direction: row; }
  .imp-editor > .imp-actions .btn { flex: 1 1 40%; min-height: 40px; }
  .imp-editor > .imp-actions #imp-solve { flex: 1 1 100%; min-height: 46px; }
  .imp-problems { padding: 6px 10px; }
  .imp-problems p { font-size: 13.5px; }
}

/* ---------- Play HUD ---------- */
.hud {
  position: absolute; z-index: 8; top: calc(12px + var(--safe-t)); left: calc(128px + var(--safe-l)); right: calc(14px + var(--safe-r));
  display: flex; align-items: center; gap: 12px; pointer-events: none;
}
.hud > * { pointer-events: auto; }
.hud .back { height: 48px; }
.hud .back span { font-size: 15px; }
.hud-title { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.mode-chip { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-sub { color: var(--ink-soft); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.readouts { margin-left: auto; display: flex; gap: 8px; }
.readout { min-width: 76px; padding: 6px 12px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); text-align: right; }
.readout span { display: block; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); font-weight: 600; }
.readout b { font-size: 21px; font-variant-numeric: tabular-nums; font-weight: 700; }
.readout.running b { color: var(--accent); }
.scramble-line {
  position: absolute; z-index: 7; top: calc(70px + var(--safe-t)); left: 50%; transform: translateX(-50%); max-width: min(760px, calc(100% - 28px));
  margin: 0; padding: 7px 14px; border-radius: 12px; background: rgba(15, 17, 22, .7); border: 1px solid var(--line); font: 600 14px/1.5 var(--mono); color: var(--ink-soft); text-align: center; word-spacing: 3px; width: max-content;
}
.inspection { position: absolute; z-index: 9; top: 50%; left: max(28px, 4vw); transform: translateY(-50%); width: 220px; text-align: left; pointer-events: none; text-shadow: 0 4px 24px rgba(0, 0, 0, .6); }
.insp-label { margin: 0; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); font-size: 14px; }
.insp-count { margin: 0; font-size: clamp(72px, 9vw, 120px); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.insp-count.go { color: var(--teal); }
.insp-help { margin: 8px 0 0; color: var(--ink-soft); font-size: 14px; line-height: 1.45; }

.toast {
  position: absolute; z-index: 20; left: 50%; bottom: calc(108px + var(--safe-b)); transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  padding: 10px 18px; border-radius: 999px; background: rgba(20, 22, 30, .94); border: 1px solid var(--line); font-weight: 600; box-shadow: var(--shadow);
  transition: opacity .2s, transform .2s; width: max-content; max-width: min(520px, calc(100vw - 32px)); text-align: center; line-height: 1.35;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.good { border-color: rgba(58, 214, 165, .6); }
.pc[data-mode="replay"] .toast, .pc[data-mode="mycube"] .toast { bottom: auto; top: calc(118px + var(--safe-t)); }

.first-tip {
  position: absolute; z-index: 12; left: 50%; bottom: calc(110px + var(--safe-b)); transform: translateX(-50%); width: min(380px, calc(100% - 28px));
  display: grid; grid-template-columns: 54px 1fr; gap: 6px 14px; align-items: center; padding: 14px 16px; border-radius: var(--radius);
  background: rgba(22, 25, 34, .95); border: 1px solid rgba(255, 194, 61, .45); box-shadow: var(--shadow); animation: rise .35s ease-out;
}
.first-tip p { margin: 0; font-size: 15px; line-height: 1.4; }
.tip-close { grid-column: 1 / -1; justify-self: end; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 700; border-radius: 999px; padding: 8px 16px; min-height: 40px; }
.tip-anim { width: 54px; height: 54px; border-radius: 12px; background: linear-gradient(135deg, #009b48 33%, #f4f4ee 33% 66%, #c8102e 66%); position: relative; overflow: hidden; }
.tip-anim .finger { position: absolute; width: 18px; height: 18px; border-radius: 50%; background: rgba(255, 255, 255, .95); box-shadow: 0 0 0 5px rgba(255, 255, 255, .3); left: 6px; top: 18px; animation: swipe 1.6s ease-in-out infinite; }
@keyframes swipe { 0%, 15% { transform: translateX(0); opacity: 0; } 25% { opacity: 1; } 70% { transform: translateX(26px); opacity: 1; } 85%, 100% { transform: translateX(26px); opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 16px); } }

/* ---------- Dock ---------- */
.dock {
  position: absolute; z-index: 8; left: 50%; bottom: calc(16px + var(--safe-b)); transform: translateX(-50%);
  display: flex; gap: 6px; padding: 6px; border-radius: 22px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); max-width: calc(100% - 24px);
}
.dock button {
  display: flex; align-items: center; gap: 7px; min-height: 48px; padding: 0 16px; border: 0; border-radius: 16px; background: transparent; font-weight: 600; font-size: 15px; white-space: nowrap; color: var(--ink);
  transition: background .15s;
}
.dock button:hover { background: var(--raise2); }
.dock button:active { background: rgba(255, 255, 255, .16); }
.dock button.primary { background: var(--accent); color: var(--accent-ink); }
.dock button.primary:hover { background: #ffd062; }
.dock button:disabled { opacity: .38; cursor: not-allowed; }
.dock button[aria-pressed="true"] { background: rgba(255, 194, 61, .18); color: var(--accent); }
.dock .badge { font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); }
.cam-tools { position: absolute; z-index: 8; right: calc(16px + var(--safe-r)); bottom: calc(96px + var(--safe-b)); display: grid; gap: 10px; }

/* ---------- Coach panel ---------- */
.coach {
  position: absolute; z-index: 9; left: calc(18px + var(--safe-l)); top: calc(84px + var(--safe-t)); width: 350px; max-height: calc(100% - 190px); overflow: auto;
  padding: 16px 18px 14px; border-radius: 20px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); animation: fade .25s ease-out; overscroll-behavior: contain;
}
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }
.coach-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.coach-kicker { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--teal); }
.coach-toggle { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: transparent; display: grid; place-items: center; }
.coach[data-collapsed="true"] .coach-toggle svg { transform: rotate(180deg); }
.coach[data-collapsed="true"] .coach-body { display: none; }
.coach h2 { margin: 6px 0 6px; font-size: 20px; line-height: 1.2; }
.coach-text { margin: 0 0 10px; color: var(--ink-soft); line-height: 1.45; font-size: 15px; }
.coach-text b { color: var(--ink); }
.coach-plain { margin: 8px 0 0; font-size: 14px; color: var(--ink-soft); min-height: 1em; }
.coach-plain:empty { display: none; }
.alg { display: flex; flex-wrap: wrap; gap: 6px; }
.alg:empty { display: none; }
.alg .mv {
  min-width: 40px; height: 38px; padding: 0 8px; display: inline-grid; place-items: center; border-radius: 10px; font: 700 17px var(--mono);
  background: var(--raise); border: 1px solid var(--line); color: var(--ink-soft); transition: background .2s, color .2s, transform .2s;
}
.alg .mv.done { background: rgba(58, 214, 165, .16); border-color: rgba(58, 214, 165, .4); color: var(--teal); }
.alg .mv.next { background: var(--accent); color: var(--accent-ink); border-color: transparent; transform: translateY(-2px); box-shadow: 0 6px 16px rgba(255, 194, 61, .3); }
.alg .mv.demo { outline: 2px solid #8fb6ff; }
.alg .mv.undo { background: rgba(255, 114, 114, .14); border-color: rgba(255, 114, 114, .45); color: #ffb3b3; }
.coach-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.coach-actions:empty { display: none; }
.coach-actions .btn { min-height: 42px; padding: 0 14px; font-size: 14px; }
.coach .note { margin: 10px 0 0; padding: 9px 12px; border-radius: 12px; font-size: 14px; line-height: 1.4; background: rgba(255, 114, 114, .1); border: 1px solid rgba(255, 114, 114, .3); }
.coach .note.good { background: rgba(58, 214, 165, .1); border-color: rgba(58, 214, 165, .35); }
.explain { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; font-size: 14px; color: var(--ink-soft); }
.explain summary { cursor: pointer; color: var(--accent); font-weight: 600; min-height: 32px; display: flex; align-items: center; }
.explain p { margin: 6px 0; line-height: 1.45; }
.hint-levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; width: 100%; }
.hint-levels .btn { padding: 0 8px; min-height: 42px; font-size: 13.5px; gap: 5px; }
.hint-levels .btn b { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: rgba(255, 255, 255, .12); font-size: 12px; }
.hint-levels .btn.primary b { background: rgba(0, 0, 0, .15); }
.used-pill { margin-left: 6px; padding: 2px 8px; border-radius: 999px; background: rgba(255, 194, 61, .16); color: var(--accent); letter-spacing: 0; text-transform: none; font-size: 11.5px; }
.legend { display: inline-flex; align-items: center; gap: 5px; margin-left: 4px; font-size: 12.5px; color: var(--ink-faint); white-space: nowrap; }
.legend i { width: 11px; height: 11px; border-radius: 3px; border: 2px solid #fff; display: inline-block; }
.legend i.lg-target { border-color: #ffc23d; margin-left: 4px; }
.stage-dots { display: flex; gap: 5px; margin: 2px 0 0; }
.stage-dots i { width: 22px; height: 5px; border-radius: 3px; background: var(--raise2); }
.stage-dots i.done { background: var(--teal); }
.stage-dots i.now { background: var(--accent); }

/* ---------- Move pad ---------- */
.movepad {
  position: absolute; z-index: 8; right: calc(16px + var(--safe-r)); top: 50%; transform: translateY(-50%); width: 200px; padding: 10px; border-radius: 18px;
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.pad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pad-grid button, .pad-cam button { min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--raise); font: 700 16px var(--mono); }
.pad-grid button:hover, .pad-cam button:hover { background: var(--raise2); }
.pad-grid button:active, .pad-cam button:active { background: var(--accent); color: var(--accent-ink); }
.pad-cam { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.pad-cam button { font-family: var(--ui); font-size: 18px; }

/* ---------- Replay ---------- */
.replay-bar {
  position: absolute; z-index: 9; left: 50%; bottom: calc(86px + var(--safe-b)); transform: translateX(-50%); width: min(720px, calc(100% - 24px));
  padding: 12px 14px; border-radius: 20px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.replay-seq { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; font: 600 14px var(--mono); }
.replay-seq span { padding: 3px 6px; border-radius: 6px; color: var(--ink-faint); flex: none; }
.replay-seq span.done { color: var(--ink-soft); }
.replay-seq span.now { background: var(--accent); color: var(--accent-ink); }
#replay-scrub { width: 100%; accent-color: var(--accent); margin: 4px 0; display: block; }
.scrub-wrap { position: relative; padding-top: 8px; }
.replay-marks { position: absolute; left: 8px; right: 8px; top: 0; height: 10px; pointer-events: none; }
.replay-marks i { position: absolute; top: 0; width: 4px; height: 12px; margin-left: -2px; border-radius: 2px; background: var(--accent); box-shadow: 0 0 0 2px rgba(255, 194, 61, .25); }
.replay-seq .hint-mark { flex: none; padding: 3px 8px; border-radius: 999px; background: rgba(255, 194, 61, .18); color: var(--accent); font: 700 12px var(--ui); white-space: nowrap; }
.replay-banner { position: absolute; z-index: 8; top: calc(70px + var(--safe-t)); left: 50%; transform: translateX(-50%); width: max-content; max-width: min(640px, calc(100vw - 28px)); margin: 0; padding: 8px 16px; border-radius: 14px; font-size: 14px; line-height: 1.4; text-align: center; background: rgba(20, 22, 30, .92); border: 1px solid var(--line); }
.replay-banner.hinted { border-color: rgba(255, 194, 61, .6); background: rgba(60, 46, 12, .9); }
.replay-banner.hinted b { color: var(--accent); }
.replay-banner.verified { border-color: rgba(58, 214, 165, .5); }
.replay-banner.verified b { color: var(--teal); }
.replay-buttons { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.ctl { width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: var(--raise); display: grid; place-items: center; }
.ctl.big { width: 54px; height: 54px; background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.ctl svg { fill: currentColor; stroke: none; }
.speed { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-soft); font-size: 14px; }
.speed select { background: var(--raise); border: 1px solid var(--line); border-radius: 8px; padding: 6px; min-height: 38px; }
.speed select option { background: var(--panel-solid); }

/* ---------- Sheets / dialogs ---------- */
.sheet { padding: 0; border: 0; background: transparent; color: var(--ink); max-width: none; max-height: none; width: 100%; height: 100%; overflow: visible; }
.sheet::backdrop { background: rgba(5, 6, 10, .6); backdrop-filter: blur(3px); }
.sheet[open] { display: grid; place-items: center; }
.sheet-inner {
  width: min(600px, calc(100% - 32px)); max-height: min(88vh, 860px); display: flex; flex-direction: column; border-radius: 24px; background: var(--panel-solid);
  border: 1px solid var(--line); box-shadow: 0 30px 80px rgba(0, 0, 0, .6); animation: pop .22s ease-out; overflow: hidden;
}
.sheet.wide .sheet-inner { width: min(860px, calc(100% - 32px)); }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 10px; }
.sheet-head h2 { margin: 0; font-size: 24px; }
.sheet-body { padding: 4px 20px 22px; overflow: auto; overscroll-behavior: contain; }
.sheet-body h3 { margin: 18px 0 8px; font-size: 16px; }
.sheet-body p { color: var(--ink-soft); line-height: 1.5; margin: 6px 0; }
.sheet .actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.sheet .actions .btn { flex: 1 1 160px; }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.choice {
  display: grid; gap: 6px; align-content: start; text-align: left; padding: 18px; border-radius: 18px; border: 1px solid var(--line); background: var(--raise); min-height: 140px;
  transition: border-color .15s, background .15s, transform .12s;
}
.choice:hover { border-color: rgba(255, 194, 61, .55); background: var(--raise2); }
.choice:active { transform: scale(.98); }
.choice b { font-size: 19px; }
.choice small { color: var(--ink-soft); font-size: 14px; line-height: 1.4; }
.choice .tag { justify-self: start; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: rgba(255, 194, 61, .16); color: var(--accent); }
.choice .tag.teal { background: rgba(58, 214, 165, .14); color: var(--teal); }
.rules { margin: 14px 0 0; padding: 12px 14px; border-radius: 14px; background: var(--raise); font-size: 14px; color: var(--ink-soft); line-height: 1.5; }
.rules li { margin: 2px 0; }
.field { display: grid; gap: 6px; margin-top: 12px; }
.field label { font-weight: 600; }
.field input[type="text"] { min-height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); font-size: 17px; }
.field small { color: var(--ink-faint); }
.form-error { color: var(--red); font-weight: 600; min-height: 1.2em; margin: 8px 0 0; }

/* Settings */
.set-group { display: grid; gap: 10px; margin-top: 8px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 48px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-row > span { display: grid; gap: 2px; }
.set-row small { color: var(--ink-faint); font-size: 13px; }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); flex-wrap: wrap; }
.seg button { border: 0; background: transparent; min-height: 38px; padding: 0 12px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--ink-soft); }
.seg button[aria-pressed="true"] { background: var(--raise2); color: var(--ink); }
.switch { position: relative; width: 52px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--raise2); transition: background .15s; pointer-events: none; }
.switch i::after { content: ""; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + i { background: var(--teal); }
.switch input:checked + i::after { transform: translateX(22px); }
.switch input:focus-visible + i { outline: 3px solid var(--accent); outline-offset: 2px; }
input[type="range"] { accent-color: var(--accent); width: 150px; min-height: 30px; }
.swatches { display: flex; gap: 3px; }
.swatches i { width: 14px; height: 14px; border-radius: 4px; }

/* Stats / boards */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 12px; }
.tabs button { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent; font-weight: 600; font-size: 14px; color: var(--ink-soft); }
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--bg); border-color: transparent; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat { padding: 12px 14px; border-radius: 14px; background: var(--raise); }
.stat span { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); font-weight: 600; }
.stat b { font-size: 24px; font-variant-numeric: tabular-nums; }
.spark { width: 100%; height: 70px; margin-top: 12px; display: block; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 9px 8px; border-bottom: 1px solid var(--line); }
.table tr.me td { background: rgba(255, 194, 61, .1); }
.table td.rank { width: 44px; color: var(--ink-soft); font-weight: 700; }
.table td.time { font-weight: 700; }
.table .tag { font-size: 11px; padding: 2px 7px; border-radius: 999px; background: var(--raise2); color: var(--ink-soft); margin-left: 4px; white-space: nowrap; }
.table .tag.hint { background: rgba(255, 194, 61, .16); color: var(--accent); }
.table .tag.ok { background: rgba(58, 214, 165, .14); color: var(--teal); }
.table button.link { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 4px; min-height: 36px; }
.empty { padding: 20px; text-align: center; color: var(--ink-faint); border: 1px dashed var(--line); border-radius: 14px; }
.board-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.board-filters select { min-height: 40px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); padding: 0 10px; }
.notice { padding: 10px 14px; border-radius: 12px; background: rgba(143, 182, 255, .1); border: 1px solid rgba(143, 182, 255, .3); color: var(--ink-soft); font-size: 14px; margin: 10px 0; }
.notice.warn { background: rgba(255, 114, 114, .1); border-color: rgba(255, 114, 114, .35); }

/* Completion */
.complete { text-align: center; }
.complete .burst { width: 150px; height: 150px; margin: 0 auto 4px; display: block; }
.complete h3 { font-size: 32px; margin: 0; }
.complete .sub { margin: 6px 0 0; color: var(--ink-soft); }
.complete .hint-badge { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; padding: 7px 14px; border-radius: 999px; background: rgba(255, 194, 61, .16); color: var(--accent); font-weight: 700; }
.complete .demo-badge { background: rgba(143, 182, 255, .16); color: #b9d0ff; }
.complete .ok-badge { background: rgba(58, 214, 165, .16); color: var(--teal); }
.result-row { display: flex; justify-content: center; gap: 12px; margin: 18px 0 4px; flex-wrap: wrap; }
.result-row .stat { min-width: 120px; }
.pb { margin: 10px 0 0; color: var(--teal); font-weight: 700; }

/* Patterns, lessons */
.pattern-grid, .lesson-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.pattern-card, .lesson-card { display: grid; gap: 4px; justify-items: center; text-align: center; padding: 12px; border-radius: 16px; border: 1px solid var(--line); background: var(--raise); }
.pattern-card:hover, .lesson-card:hover { border-color: rgba(255, 194, 61, .5); background: var(--raise2); }
.pattern-card img { width: 100px; height: 100px; }
.pattern-card b, .lesson-card b { font-size: 15px; }
.pattern-card small, .lesson-card small { color: var(--ink-faint); font-size: 13px; line-height: 1.3; }
.lesson-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.lesson-card { justify-items: start; text-align: left; position: relative; }
.lesson-card .num { font: 700 13px var(--mono); color: var(--accent); }
.lesson-card .check { position: absolute; right: 12px; top: 12px; color: var(--teal); font-weight: 800; }
.lesson-card .row { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.lesson-card .row .btn { min-height: 38px; padding: 0 12px; font-size: 13px; }
.kbd { font: 600 13px var(--mono); padding: 2px 6px; border-radius: 6px; background: var(--raise2); border: 1px solid var(--line); color: var(--ink); }
.help-list { padding-left: 18px; color: var(--ink-soft); line-height: 1.55; margin: 6px 0; }
.daily-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.daily-head b { font-size: 20px; }
.countdown { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 700; }

/* ---------- Tablet ---------- */
@media (max-width: 1100px) and (min-width: 721px) {
  .home { width: min(480px, 52vw); min-width: 360px; }
}
@media (max-width: 900px) and (min-width: 721px) and (orientation: portrait) {
  .home { width: auto; min-width: 0; inset: auto 0 0 0; align-content: end; padding: 24px 32px calc(28px + var(--safe-b)); }
  .home-brand { position: fixed; top: calc(86px + var(--safe-t)); left: 32px; right: 32px; text-align: center; }
  .modes { grid-template-columns: 1fr 1fr; }
  .home-links { justify-content: center; }
}

/* Portrait tablets: guidance sits under the cube instead of beside it. */
@media (min-width: 721px) and (orientation: portrait) {
  .coach { left: 50%; transform: translateX(-50%); top: auto; bottom: calc(98px + var(--safe-b)); width: min(600px, calc(100% - 32px)); max-height: 34%; }
  @keyframes fade { from { opacity: 0; } }
}

/* ---------- Phones ---------- */
@media (max-width: 720px) {
  .home { width: auto; min-width: 0; inset: auto 0 0 0; align-content: end; gap: 10px; padding: 10px 12px calc(10px + var(--safe-b)); }
  .home-brand { position: fixed; top: calc(70px + var(--safe-t)); left: 0; right: 0; text-align: center; padding: 0 16px; pointer-events: none; }
  .home-brand .kicker { display: none; }
  .home-brand h1 { font-size: clamp(32px, 9.5vw, 44px); }
  .home-brand .tagline { font-size: 14.5px; margin-top: 4px; }
  .modes { grid-template-columns: 1fr 1fr; gap: 8px; }
  .mode-card { gap: 10px; padding: 10px; min-height: 64px; border-radius: 16px; }
  .mode-card:hover { transform: none; }
  .mode-copy b { font-size: 15px; line-height: 1.15; }
  .mode-copy small { display: none; }
  .mode-ico { width: 36px; height: 36px; border-radius: 10px; }
  .mode-ico::before { inset: 8px; }
  .progress-pill { top: 6px; right: 6px; font-size: 10px; padding: 2px 6px; }
  .home-links { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
  .home-links button { flex-direction: column; justify-content: center; gap: 3px; min-height: 52px; padding: 4px 2px; font-size: 11.5px; border-radius: 14px; }
  .home-links svg { width: 19px; height: 19px; }
  .home-links .long { display: none; }
  .home-links .short { display: inline; }
  .resume { padding: 9px 12px; }
  .resume small { font-size: 12.5px; }

  .hud { left: calc(124px + var(--safe-l)); right: calc(10px + var(--safe-r)); gap: 8px; }
  .hud .back span { display: none; }
  .hud .back { width: 48px; padding: 0; }
  .hud-title { display: none; }
  .readout { min-width: 0; padding: 4px 10px; }
  .readout b { font-size: 18px; }
  .readout span { font-size: 10px; }
  .scramble-line { top: calc(70px + var(--safe-t)); left: calc(10px + var(--safe-l)); right: calc(62px + var(--safe-r)); transform: none; width: auto; max-width: none; font-size: 11.5px; line-height: 1.4; padding: 5px 9px; text-align: left; word-spacing: 1px; }
  .inspection { top: calc(124px + var(--safe-t)); left: 50%; transform: translateX(-50%); width: auto; text-align: center; display: flex; align-items: baseline; gap: 12px; }
  .inspection[hidden] { display: none; }
  .insp-count { font-size: 56px; }
  .insp-help { display: none; }

  .dock { left: 0; right: 0; bottom: 0; transform: none; max-width: none; border-radius: 22px 22px 0 0; padding: 6px 8px calc(6px + var(--safe-b)); justify-content: space-around; gap: 2px; border-bottom: 0; }
  .dock button { flex: 1 1 0; flex-direction: column; gap: 3px; min-height: 56px; padding: 4px 2px; font-size: 12px; min-width: 0; }
  .dock button svg { width: 22px; height: 22px; }
  .dock .badge { position: absolute; transform: translate(14px, -10px); font-size: 10px; }
  .dock button { position: relative; }
  .cam-tools { right: calc(8px + var(--safe-r)); top: calc(72px + var(--safe-t)); bottom: auto; gap: 8px; }
  .cam-tools .round-btn { width: 44px; height: 44px; }

  .coach { left: 8px; right: 8px; width: auto; top: auto; bottom: calc(78px + var(--safe-b)); max-height: 44%; padding: 10px 12px; border-radius: 18px; display: flex; flex-direction: column; }
  .coach .coach-body { display: flex; flex-direction: column; }
  .coach .coach-actions { order: -1; margin: 4px 0 8px; }
  .coach-toggle { width: 32px; height: 32px; }
  .coach h2 { font-size: 17px; margin: 4px 0; }
  .coach-text { font-size: 14px; margin-bottom: 8px; }
  .alg .mv { min-width: 36px; height: 34px; font-size: 15px; }
  .coach-actions .btn { min-height: 40px; font-size: 13px; padding: 0 12px; }

  .movepad { left: 8px; right: 8px; width: auto; top: auto; transform: none; bottom: calc(78px + var(--safe-b)); padding: 8px; display: grid; grid-template-columns: 1fr; }
  .pc[data-pad="open"] .coach { bottom: calc(78px + var(--pad-h, 140px) + 6px + var(--safe-b)); max-height: 32%; }
  .pad-grid { grid-template-columns: repeat(6, 1fr); gap: 5px; }
  .pad-grid button { min-height: 42px; font-size: 14px; }
  .pad-cam { margin-top: 6px; }

  .replay-bar { bottom: calc(78px + var(--safe-b)); padding: 10px; }
  .replay-banner { left: 10px; right: 62px; transform: none; width: auto; max-width: none; font-size: 13px; padding: 7px 10px; text-align: left; }
  .toast { bottom: calc(92px + var(--safe-b)); }
  .first-tip { bottom: calc(92px + var(--safe-b)); }

  .sheet[open] { place-items: end center; }
  .sheet-inner { width: 100%; max-height: 90vh; max-height: 90svh; border-radius: 24px 24px 0 0; padding-bottom: var(--safe-b); animation: slide .25s ease-out; }
  .sheet.wide .sheet-inner { width: 100%; }
  @keyframes slide { from { transform: translateY(40px); opacity: .4; } }
  .sheet-head { padding: 16px 16px 8px; }
  .sheet-head h2 { font-size: 21px; }
  .sheet-body { padding: 2px 16px 20px; }
  .choice-grid { grid-template-columns: 1fr; }
  .choice { min-height: 0; padding: 14px 16px; }
  .set-row { flex-wrap: wrap; }
}
@media (max-width: 720px) and (min-height: 740px) {
  .mode-card { flex-direction: column; align-items: flex-start; min-height: 104px; padding: 12px; }
  .mode-copy small { display: block; font-size: 12.5px; }
}
@media (max-width: 720px) and (max-height: 600px) {
  .home-brand .tagline { display: none; }
  .home-brand h1 { font-size: 30px; }
}
@media (max-width: 360px) {
  .dock button { font-size: 11px; }
  .readout { padding: 4px 7px; }
}

/* ---------- Phone landscape ---------- */
@media (max-height: 520px) and (orientation: landscape) {
  .home { width: min(440px, 52vw); min-width: 0; inset: 0 auto 0 0; align-content: center; gap: 8px; padding: calc(70px + var(--safe-t)) 12px calc(10px + var(--safe-b)) calc(16px + var(--safe-l)); }
  .home-brand { position: static; text-align: left; padding: 0; }
  .home-brand h1 { font-size: 32px; }
  .home-brand .tagline, .home-brand .kicker { display: none; }
  .modes { grid-template-columns: 1fr 1fr; gap: 8px; }
  .mode-card { flex-direction: row; padding: 9px 10px; min-height: 0; gap: 10px; }
  .mode-copy small { display: none; }
  .mode-ico { width: 32px; height: 32px; }
  .home-links button { min-height: 36px; font-size: 12.5px; padding: 0 10px; }
  .resume { padding: 7px 12px; }

  .dock { left: auto; right: calc(10px + var(--safe-r)); top: calc(68px + var(--safe-t)); bottom: calc(10px + var(--safe-b)); transform: none; flex-direction: column; width: 78px; border-radius: 20px; padding: 6px; justify-content: center; }
  .dock button { flex-direction: column; gap: 1px; min-height: 0; flex: 1 1 0; max-height: 60px; padding: 2px; font-size: 10.5px; border-radius: 12px; }
  .dock button svg { width: 19px; height: 19px; }
  .dock .badge { position: absolute; transform: translate(14px, -12px); font-size: 10px; }
  .dock button { position: relative; }
  .cam-tools { right: calc(98px + var(--safe-r)); bottom: calc(12px + var(--safe-b)); grid-auto-flow: column; }
  .coach { left: calc(10px + var(--safe-l)); top: calc(68px + var(--safe-t)); bottom: auto; right: auto; width: min(320px, 42vw); max-height: calc(100% - 78px - var(--safe-t) - var(--safe-b)); padding: 10px 12px; }
  .coach .coach-body { display: flex; flex-direction: column; }
  .coach .coach-actions { order: -1; margin: 2px 0 8px; }
  .coach h2 { font-size: 16px; }
  .coach-text { font-size: 13px; }
  .movepad { left: auto; right: calc(98px + var(--safe-r)); top: calc(68px + var(--safe-t)); bottom: auto; width: 190px; transform: none; }
  .pad-grid { grid-template-columns: repeat(3, 1fr); }
  .pad-grid button { min-height: 36px; }
  .replay-bar { bottom: calc(10px + var(--safe-b)); left: calc(50% - 44px); width: min(560px, calc(100% - 120px)); padding: 8px 10px; }
  .replay-seq { display: none; }
  .inspection { top: 55%; left: calc(16px + var(--safe-l)); transform: translateY(-50%); width: 160px; text-align: left; display: block; }
  .insp-count { font-size: 64px; }
  .insp-help { display: none; }
  .toast, .first-tip { bottom: calc(14px + var(--safe-b)); }
  .scramble-line { top: calc(64px + var(--safe-t)); }
  .sheet-inner { max-height: 94vh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
.pc[data-motion="reduced"] *, .pc[data-motion="reduced"] *::before { animation-duration: .01ms !important; transition-duration: .01ms !important; }

