/* ─── Tokens ─────────────────────────────────────────────────────── */
:root {
  --bg:          #0b0613;
  --panel:       #140a21;
  --panel-2:     #1a0e2b;
  --border:      #2a1a45;
  --border-2:    #3d2463;

  --mg:          #ff4fb8;   /* magenta — primary / CTA */
  --mg-glow:     rgba(255,79,184,.45);
  --am:          #ffc24a;   /* amber — secondary */
  --gr:          #8affc1;   /* mint — correct */
  --fail:        #ff6b84;   /* fail / wrong */

  --ink:         #ece4f8;
  --ink-dim:     #a094b8;
  --ink-mute:    #5b4a7a;

  --font-sans:   'Space Grotesk', Arial, sans-serif;
  --font-mono:   'JetBrains Mono', ui-monospace, monospace;
  --font-jp:     'Noto Serif JP', serif;

  --ease-arcade: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ─── Reset ───────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body,
#root {
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
}

body {
  background: #000;
  font-family: var(--font-sans);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

#root {
  display: grid;
  place-items: center;
  padding: 12px;
}

#app {
  position: relative;
  width: min(1024px, calc(100vw - 24px), calc((100dvh - 24px) * 4 / 3));
  aspect-ratio: 4 / 3;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  box-shadow: 0 22px 80px rgba(0,0,0,.55), 0 0 0 1px var(--border);
  border-radius: 18px;
  touch-action: manipulation;
}

#game-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#game-container canvas {
  display: block;
  width: 100%;
  height: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* ─── Slayer mobile keypad ───────────────────────────────────────── */
.slayer-mobile-keypad {
  display: none;
}

/* ─── Primary Button ──────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #1a0010;
  background: linear-gradient(180deg, #ff6fc8 0%, #ff3fa8 100%);
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(255,79,184,.4), 0 14px 40px -8px var(--mg-glow);
  transition: box-shadow .2s var(--ease-arcade), transform .15s var(--ease-arcade);
  align-self: flex-start;
  white-space: nowrap;
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 0 0 1px rgba(255,79,184,.6), 0 16px 48px -6px var(--mg-glow);
  transform: scale(1.03);
}

.btn-primary:disabled {
  background: var(--panel-2);
  color: var(--ink-mute);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-dim);
  background: transparent;
  border: 1px solid var(--border-2);
  border-radius: 9999px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}

.btn-ghost:hover {
  border-color: var(--mg);
  color: var(--ink);
}

/* ─── Overlay base ────────────────────────────────────────────────── */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  color: var(--ink);
  background: rgba(11,6,19,.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 32px;
  text-align: center;
  overflow: hidden;
}

.overlay__content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: min(100%, 720px);
}

.overlay__content .btn-primary,
.overlay__content .btn-ghost {
  align-self: center;
}

/* ─── Torii field backdrop (overlay variant) ─────────────────────── */
.torii-field {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .1;
}

.torii-field__col {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(180deg, transparent 0%, var(--mg) 15%, var(--mg) 85%, transparent 100%);
}

.torii-field__beam {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--mg) 30%, var(--mg) 70%, transparent);
}

/* ─── Splash Screen ───────────────────────────────────────────────── */
.splash-screen {
  position: absolute;
  inset: 0;
  background: var(--bg);
  overflow: hidden;
  z-index: 10;
}

/* ambient glow washes */
.splash-glow-a {
  position: absolute;
  width: 700px; height: 700px;
  left: -220px; bottom: -260px;
  background: radial-gradient(circle, rgba(255,79,184,.25), transparent 60%);
  pointer-events: none;
}

.splash-glow-b {
  position: absolute;
  width: 500px; height: 500px;
  right: -120px; top: -120px;
  background: radial-gradient(circle, rgba(255,194,74,.12), transparent 60%);
  pointer-events: none;
}

/* vertical kanji rail */
.kanji-rail {
  position: absolute;
  top: 80px; bottom: 80px;
  right: 28px;
  width: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  z-index: 1;
}

.kanji-rail__char {
  font-family: var(--font-jp);
  font-weight: 900;
  font-size: 28px;
  color: rgba(255,194,74,.28);
  writing-mode: vertical-rl;
  letter-spacing: .1em;
}

/* giant deco 語 */
.splash-deco-kanji {
  position: absolute;
  right: 80px; top: 50px;
  font-family: var(--font-jp);
  font-size: clamp(300px, 50vw, 520px);
  font-weight: 900;
  line-height: .82;
  background: linear-gradient(180deg, #ff4fb8 0%, #8b2a6e 60%, transparent 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 40px rgba(255,79,184,.25));
  pointer-events: none;
  user-select: none;
  opacity: .85;
}

.splash-content {
  position: absolute;
  left: 72px; top: 84px;
  width: min(520px, calc(100% - 80px));
  display: flex;
  flex-direction: column;
  gap: 20px;
  z-index: 3;
}

.splash-kami-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--am);
  letter-spacing: .3em;
  text-transform: uppercase;
}

.splash-kami-label::after {
  content: '';
  display: block;
  width: 40px; height: 1px;
  background: linear-gradient(90deg, var(--am), transparent);
}

.splash-title {
  font-family: var(--font-sans);
  font-size: clamp(52px, 9vw, 96px);
  font-weight: 700;
  line-height: .92;
  letter-spacing: -.03em;
  color: var(--ink);
}

.splash-title span {
  color: var(--mg);
  text-shadow: 0 0 18px var(--mg-glow), 0 0 40px rgba(255,79,184,.2);
}

.splash-subtitle {
  font-size: 13px;
  color: var(--ink-dim);
  line-height: 1.6;
  max-width: 420px;
}

/* session card */
.splash-session-card {
  margin-top: 8px;
  padding: 20px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: rgba(20,10,33,.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  gap: 18px;
  align-items: center;
}

.splash-level-badge {
  width: 56px; height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ff4fb8, #8b2a6e);
  box-shadow: 0 10px 30px -10px #ff4fb8;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 16px;
  color: #1a0010;
  letter-spacing: .06em;
  flex-shrink: 0;
}

.splash-session-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.splash-session-label {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--ink-dim);
  letter-spacing: .3em;
  text-transform: uppercase;
}

.splash-session-sublevel {
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
}

.splash-session-words {
  font-size: 11px;
  color: var(--ink-dim);
}

.splash-streak {
  text-align: right;
}

.splash-streak-label {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--ink-dim);
  letter-spacing: .3em;
  text-transform: uppercase;
}

.splash-streak-value {
  font-family: var(--font-sans);
  font-size: 22px;
  font-weight: 700;
  color: var(--gr);
}

.splash-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.splash-enter-hint {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-mute);
  letter-spacing: .25em;
}

/* footer strip */
.splash-footer {
  position: absolute;
  bottom: 20px;
  left: 72px; right: 72px;
  display: flex;
  align-items: center;
  gap: 18px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--ink-mute);
  letter-spacing: .25em;
  text-transform: uppercase;
  z-index: 3;
}

.splash-footer-dot {
  color: var(--mg);
}

.splash-footer-line {
  flex: 1;
  border-top: 1px dashed var(--border);
}

/* ─── Hub Screen ──────────────────────────────────────────────────── */
.hub-screen {
  position: absolute;
  inset: 0;
  background: var(--bg);
  overflow: hidden;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* push the 語 deco to the far right so it doesn't cover cards */
.hub-screen .splash-deco-kanji {
  right: -50px;
  top: 10px;
  font-size: clamp(200px, 34vw, 400px);
  opacity: 0.7;
}

.hub-content {
  position: relative;
  z-index: 3;
  width: min(820px, calc(100% - 48px));
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 32px;
}

/* smaller title on hub so cards have room */
.hub-screen .splash-title {
  font-size: clamp(36px, 6vw, 64px);
}

.hub-cards {
  display: flex;
  gap: 14px;
  align-items: stretch;
}

.hub-game-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: rgba(20,10,33,.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: border-color .2s var(--ease-arcade), transform .15s var(--ease-arcade);
}

.hub-game-card:hover {
  border-color: var(--border-2);
  transform: scale(1.01);
}

.hub-game-card--slayer {
  border-color: rgba(255,194,74,.25);
}

.hub-game-card--slayer:hover {
  border-color: rgba(255,194,74,.55);
}

.hub-game-card__eyebrow {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--ink-mute);
  letter-spacing: .35em;
  text-transform: uppercase;
}

.hub-game-card__title {
  font-family: var(--font-sans);
  font-size: clamp(18px, 2.4vw, 26px);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.hub-game-card__jp {
  font-family: var(--font-jp);
  font-size: clamp(12px, 1.4vw, 16px);
  color: var(--ink-mute);
  font-weight: 400;
}

.hub-game-card__meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hub-game-card__meta-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.hub-game-card__meta-label {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--ink-mute);
  letter-spacing: .25em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.hub-game-card__meta-value {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--ink-dim);
  font-weight: 600;
}

.hub-game-card__meta-value--score {
  color: var(--gr);
}

.hub-game-card__cta-slayer {
  background: linear-gradient(180deg, #ffd76a 0%, #ffb020 100%);
  color: #1a0800;
  box-shadow: 0 0 0 1px rgba(255,194,74,.4), 0 14px 40px -8px rgba(255,194,74,.35);
}

.hub-game-card__cta-slayer:hover:not(:disabled) {
  box-shadow: 0 0 0 1px rgba(255,194,74,.6), 0 16px 48px -6px rgba(255,194,74,.45);
}

.hub-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* ─── Home button (game screens) ─────────────────────────────────── */
.home-btn {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 30;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(20,10,33,.92);
  border: 1px solid rgba(61,36,99,.95);
  color: var(--ink-dim);
  font-family: var(--font-mono);
  font-size: clamp(8px, .9vw, 10px);
  font-weight: 700;
  letter-spacing: .22em;
  height: clamp(24px, 3vw, 28px);
  padding: 0 clamp(7px, 1vw, 10px);
  border-radius: 999px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  transition: border-color .15s, color .15s, background .15s, transform .15s;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 0 0 1px rgba(11,6,19,.45);
}

.home-btn:hover {
  border-color: var(--mg);
  color: var(--ink);
  background: rgba(37,21,64,.96);
  transform: translateY(-1px);
}

.hub-footer {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--ink-mute);
  letter-spacing: .25em;
  text-transform: uppercase;
  margin-top: 4px;
}

@media (max-width: 640px), (max-height: 560px) {
  .hub-content {
    width: 100%;
    padding: 24px 16px 16px;
    gap: 12px;
  }

  .hub-cards {
    flex-direction: column;
  }

  .hub-game-card {
    padding: 14px;
  }
}

/* ─── Vocab Token Card ────────────────────────────────────────────── */
.vocab-token {
  padding: 26px 42px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(42,14,30,.9), rgba(26,6,19,.9));
  border: 1px solid #5a2040;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: min(460px, 100%);
  position: relative;
}

.vocab-token__label {
  position: absolute;
  top: 10px; left: 16px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: #8b4f6a;
  letter-spacing: .3em;
  text-transform: uppercase;
}

.vocab-token__kanji {
  font-family: var(--font-jp);
  font-size: clamp(40px, 8vw, 52px);
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
  margin-top: 6px;
}

.vocab-token__detail {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  align-items: baseline;
  justify-content: center;
}

.vocab-token__reading {
  font-family: var(--font-jp);
  font-size: 18px;
  color: var(--am);
}

.vocab-token__meaning {
  font-size: 15px;
  font-weight: 600;
  color: var(--gr);
}

.vocab-token__selected {
  font-family: var(--font-mono);
  font-size: 10px;
  color: #8b4f6a;
  letter-spacing: .2em;
}

.vocab-token__selected span {
  color: var(--fail);
  font-weight: 700;
}

/* ─── Wrong overlay ───────────────────────────────────────────────── */
.overlay--wrong .overlay-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 30%, rgba(255,79,184,.25), transparent 60%);
  pointer-events: none;
}

.signal-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.signal-header {
  display: flex;
  align-items: center;
  gap: 18px;
}

.signal-title {
  font-family: var(--font-sans);
  font-size: clamp(36px, 5.5vw, 54px);
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--mg);
  text-shadow: 0 0 18px var(--mg-glow), 0 0 40px rgba(255,79,184,.2);
  line-height: 1;
}

.signal-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .35em;
  color: var(--ink-dim);
  text-transform: uppercase;
}

.result-msg {
  font-size: 12px;
  color: var(--ink-dim);
  letter-spacing: .04em;
  line-height: 1.7;
  max-width: 54ch;
}

.overlay-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

/* ─── Sector Cleared ──────────────────────────────────────────────── */
.overlay--clear .overlay-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 50%, rgba(255,194,74,.15), transparent 60%);
  pointer-events: none;
}

.clear-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--am);
  letter-spacing: .4em;
  text-transform: uppercase;
}

.clear-kanji {
  font-family: var(--font-jp);
  font-weight: 900;
  font-size: clamp(52px, 9vw, 88px);
  background: linear-gradient(180deg, #ff4fb8 0%, #ffc24a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: .02em;
  line-height: 1;
}

.clear-level-name {
  font-size: clamp(20px, 3vw, 28px);
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--ink);
}

.clear-level-name span {
  color: var(--mg);
}

.clear-next-hint {
  font-size: 13px;
  color: var(--ink-dim);
}

/* stats pills */
.stats-pills {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.stat-pill {
  padding: 12px 18px;
  border-radius: 14px;
  background: rgba(20,10,33,.7);
  border: 1px solid var(--border);
  min-width: 90px;
  text-align: center;
}

.stat-pill__label {
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--ink-mute);
  letter-spacing: .3em;
  text-transform: uppercase;
}

.stat-pill__value {
  font-family: var(--font-sans);
  font-size: 20px;
  font-weight: 700;
  margin-top: 4px;
}

/* JLPT track */
.jlpt-track {
  display: flex;
  align-items: center;
  gap: 8px;
}

.jlpt-track__pip {
  padding: 6px 12px;
  border-radius: 9999px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: .08em;
  border: 1.5px solid var(--border);
  color: var(--ink-mute);
  background: transparent;
  transition: all .2s;
}

.jlpt-track__pip--active {
  box-shadow: 0 0 18px -8px var(--mg);
}

.jlpt-track__line {
  width: 18px; height: 1px;
  background: var(--border);
}

/* ─── All-Pass overlay ────────────────────────────────────────────── */
.overlay--allpass .overlay-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 40%, rgba(138,255,193,.18), transparent 55%);
  pointer-events: none;
}

.allpass-title {
  font-family: var(--font-jp);
  font-weight: 900;
  font-size: clamp(40px, 7vw, 64px);
  background: linear-gradient(135deg, var(--mg), var(--am));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1;
}

.allpass-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-dim);
  letter-spacing: .3em;
  text-transform: uppercase;
}

/* ─── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 900px), (max-height: 760px) {
  #root { padding: 8px; }

  #app {
    width: min(1024px, calc(100vw - 16px), calc((100dvh - 16px) * 4 / 3));
    border-radius: 14px;
  }

  .splash-content {
    left: 48px;
    top: 72px;
  }

  .splash-footer {
    left: 48px; right: 48px;
  }
}

@media (max-width: 640px), (max-height: 560px) {
  #root { padding: 0; }

  #app {
    width: 100vw;
    height: 100svh;
    aspect-ratio: auto;
    box-shadow: none;
    border-radius: 0;
  }

  .splash-screen {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .splash-content {
    position: static;
    width: 100%;
    padding: 36px 24px;
    gap: 16px;
  }

  .splash-deco-kanji {
    position: absolute;
    right: -20px;
    top: auto;
    bottom: -20px;
    font-size: clamp(160px, 42vw, 240px);
    opacity: .5;
  }

  .splash-session-card {
    padding: 14px;
    gap: 12px;
  }

  .splash-level-badge {
    width: 44px; height: 44px;
    font-size: 13px;
    border-radius: 12px;
  }

  .kanji-rail { display: none; }

  .splash-footer {
    left: 24px; right: 24px;
    bottom: 12px;
  }

  .overlay {
    padding: calc(16px + env(safe-area-inset-top, 0px))
             calc(14px + env(safe-area-inset-right, 0px))
             calc(24px + env(safe-area-inset-bottom, 0px))
             calc(14px + env(safe-area-inset-left, 0px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .overlay::-webkit-scrollbar { display: none; }

  .vocab-token {
    padding: 16px;
    min-width: 0;
    width: 100%;
  }

  .stats-pills { gap: 8px; }

  .stat-pill {
    min-width: 70px;
    padding: 10px 12px;
  }

  .stat-pill__value { font-size: 16px; }

  .signal-header { flex-direction: column; gap: 6px; }

  .jlpt-track__pip { padding: 5px 9px; font-size: 10px; }

  .jlpt-track__line { width: 10px; }

  .btn-primary { padding: 12px 22px; font-size: 13px; }
  .btn-ghost   { padding: 10px 18px; font-size: 11px; }

  .home-btn {
    top: calc(env(safe-area-inset-top) + 8px);
    left: calc(env(safe-area-inset-left) + 8px);
    height: 24px;
    padding: 0 7px;
    font-size: 8px;
    letter-spacing: .16em;
  }
}

@media (pointer: coarse) {
  #root { padding: 0; }

  #app {
    width: 100vw;
    height: 100svh;
    aspect-ratio: auto;
    box-shadow: none;
    border-radius: 0;
  }

  .slayer-mobile-input-shell {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: calc(env(safe-area-inset-bottom) + 10px);
    z-index: 35;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .slayer-mobile-keypad {
    position: absolute;
    left: calc(env(safe-area-inset-left) + 10px);
    right: calc(env(safe-area-inset-right) + 10px);
    bottom: calc(env(safe-area-inset-bottom) + 10px);
    z-index: 36;
    display: flex;
    justify-content: flex-start;
    padding: 5px;
    border: 1px solid rgba(255, 79, 184, .34);
    border-radius: 8px;
    background:
      linear-gradient(180deg, rgba(26, 14, 43, .88), rgba(11, 6, 19, .92));
    box-shadow: 0 10px 28px rgba(0, 0, 0, .42), 0 0 22px rgba(255, 79, 184, .12);
    pointer-events: auto;
    touch-action: none;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-user-select: none;
    user-select: none;
  }

  .slayer-mobile-keypad::-webkit-scrollbar {
    display: none;
  }

  .slayer-mobile-keypad__keys {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 6px;
    width: max-content;
  }

  /* non-root scrollable row — tablet default (≥ 480 px): matches root height */
  .slayer-mobile-keypad__key {
    flex: 0 0 56px;
    height: 56px;
    border: 1px solid rgba(255, 194, 74, .62);
    border-radius: 10px;
    background: rgba(37, 21, 64, .96);
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: 20px;
    font-weight: 800;
    line-height: 1;
    text-transform: uppercase;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
    -webkit-tap-highlight-color: transparent;
  }

  .slayer-mobile-keypad__key:active {
    border-color: var(--am);
    background: rgba(255, 194, 74, .18);
    color: var(--am);
    transform: translateY(1px);
  }

  /* ── root grid: tablet / wide touch (≥ 480 px) — 8 cols, 3 rows, 56 px tall ── */
  .slayer-mobile-keypad--root {
    overflow-x: hidden;
  }

  .slayer-mobile-keypad--root .slayer-mobile-keypad__keys {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
  }

  .slayer-mobile-keypad--root .slayer-mobile-keypad__key {
    width: 100%;
    min-width: 0;
    height: 56px;
    font-size: 20px;
  }
}

/* ── narrow phone (< 480 px) — root: 11 cols / 2 rows; non-root scrollable row ── */
@media (pointer: coarse) and (max-width: 479px) {
  /* non-root scrollable row: match phone root height */
  .slayer-mobile-keypad__key {
    flex: 0 0 48px;
    height: 48px;
    font-size: 18px;
  }

  .slayer-mobile-keypad--root .slayer-mobile-keypad__keys {
    grid-template-columns: repeat(11, minmax(0, 1fr));
  }

  /* specificity (0,2,0) wins over the key rule above */
  .slayer-mobile-keypad--root .slayer-mobile-keypad__key {
    height: 48px;
    font-size: 15px;
  }
}

/* ─── Card 3D flip ────────────────────────────────────────────────── */
.reveal-stage {
  perspective: 900px;
}

.card-3d {
  position: relative;
  transform-style: preserve-3d;
  transition: transform 650ms cubic-bezier(0.34, 1.26, 0.64, 1);
}

.card-3d.is-flipped {
  transform: rotateY(180deg);
}

.card-face {
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.card-face--back {
  position: absolute;
  inset: 0;
  transform: rotateY(180deg);
}


/* ─── Card fly animation ──────────────────────────────────────────── */
.card-fly {
  animation: card-fly-anim 500ms cubic-bezier(0.55, 0, 1, 0.45) forwards;
  pointer-events: none;
}

@keyframes card-fly-anim {
  to {
    transform: translate(var(--fly-x, 0), var(--fly-y, 0)) scale(0.08);
    opacity: 0;
  }
}

/* ─── Card Reveal overlay ─────────────────────────────────────────── */
.overlay--reveal .overlay-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.reveal-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .4em;
  text-transform: uppercase;
}

.reveal-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .2em;
}

/* ─── Toolbox button ──────────────────────────────────────────────── */
.toolbox-btn {
  position: absolute;
  top: 10px;
  right: 52px;
  width: 32px;
  height: 32px;
  background: url('/assets/toolbox.png') no-repeat;
  background-size: 200% 100%;
  background-position: 0% 0%;
  border: none;
  cursor: pointer;
  z-index: 30;
  padding: 0;
  image-rendering: pixelated;
  transition: transform .15s;
}

.toolbox-btn.is-open {
  background-position: 100% 0%;
}

.toolbox-btn.is-pulsing {
  animation: toolbox-pulse 320ms ease-out;
}

@keyframes toolbox-pulse {
  0%   { transform: scale(1);    filter: none; }
  50%  { transform: scale(1.45); filter: drop-shadow(0 0 8px var(--level-color, #ff4fb8)); }
  100% { transform: scale(1);    filter: none; }
}

/* ─── Toolbox overlay ─────────────────────────────────────────────── */
.toolbox-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}

.toolbox-modal {
  position: relative;
  width: 88%;
  height: 82%;
  background: rgba(20,10,33,.97);
  border: 1px solid var(--border-2);
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0,0,0,.7), 0 0 0 1px rgba(255,79,184,.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--ink);
}

.toolbox__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.toolbox__title {
  font-family: var(--font-jp);
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}

.toolbox__title span {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-dim);
  letter-spacing: .25em;
  margin-left: 8px;
}

.toolbox__subtitle {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-mute);
  letter-spacing: .2em;
  margin-top: 2px;
}

.toolbox__close {
  background: none;
  border: 1px solid var(--border-2);
  color: var(--ink-dim);
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s, color .15s;
  flex-shrink: 0;
}

.toolbox__close:hover {
  border-color: var(--mg);
  color: var(--ink);
}

.toolbox__body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-2) transparent;
}

.toolbox__empty {
  font-size: 13px;
  color: var(--ink-mute);
  text-align: center;
  padding: 40px 0;
  line-height: 1.7;
}

.toolbox__section {
  margin-bottom: 28px;
}

.toolbox__section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .2em;
  margin-bottom: 12px;
}

.toolbox__section-line {
  flex: 1;
  height: 1px;
  background: currentColor;
  opacity: .2;
}

.toolbox__section-count {
  opacity: .6;
  font-size: 10px;
}

.toolbox__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.toolbox-card-btn {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  border-radius: 10px;
  transition: transform .15s ease, filter .15s ease;
}

.toolbox-card-btn:hover {
  transform: translateY(-2px);
  filter: drop-shadow(0 8px 18px rgba(0,0,0,.3));
}

.toolbox-card-btn:focus-visible {
  outline: 2px solid var(--mg);
  outline-offset: 3px;
}

.toolbox__detail {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: rgba(7, 2, 14, .82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.toolbox__detail-card {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  max-width: calc(100% - 24px);
  max-height: calc(100% - 24px);
}

.toolbox__detail-card > div {
  display: flex;
  align-items: center;
}

@media (max-width: 720px) {
  .toolbox__detail {
    padding: 12px;
  }

  .toolbox__detail-card {
    max-width: calc(100% - 12px);
    max-height: calc(100% - 12px);
  }
}
