:root {
  color-scheme: dark;
  --bg: #03101a;
  --panel: #071827;
  --panel-2: #0b2132;
  --panel-3: #102a3d;
  --line: #2b536e;
  --line-soft: #17394f;
  --cyan: #31dcfa;
  --amber: #ffb323;
  --green: #42e39a;
  --red: #ff5f7f;
  --text: #edf4ff;
  --muted: #9db2c9;
  --dim: #7088a2;
  --mono: "JetBrains Mono", monospace;
  --display: "Rajdhani", sans-serif;
}

* { box-sizing: border-box; }
html { width: 100%; max-width: 100%; overflow-x: hidden; scroll-behavior: smooth; }
body { width: 100%; max-width: 100%; margin: 0; min-width: 0; overflow-x: hidden; color: var(--text); background-color: var(--bg); background-image: linear-gradient(rgba(49,220,250,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(49,220,250,.035) 1px, transparent 1px); background-size: 72px 72px; font-family: var(--display); }
button, input { min-width: 0; font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }
[hidden] { display: none !important; }

.arcade-nav { height: 66px; padding: 0 clamp(18px, 4vw, 58px); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line-soft); background: rgba(3,16,26,.94); }
.arcade-brand, .all-missions { color: var(--text); text-decoration: none; font-family: var(--mono); font-weight: 800; letter-spacing: .08em; }
.arcade-brand { display: flex; align-items: center; gap: 10px; }
.arcade-brand img { width: 34px; height: 34px; object-fit: contain; }
.arcade-brand strong, .all-missions { color: var(--cyan); }
.all-missions { font-size: .76rem; }

.app-stage { min-width: 0; padding: clamp(18px, 3vw, 44px); }
.app { width: min(1480px, 100%); min-width: 0; margin: auto; border: 1px solid var(--line); background: rgba(3,16,26,.94); box-shadow: 0 26px 80px rgba(0,0,0,.28); }
.app-header { padding: clamp(26px, 4vw, 50px); text-align: center; border-bottom: 1px solid var(--line); }
.mission-id, .panel-kicker, .subtitle { margin: 0; color: var(--amber); font-family: var(--mono); font-weight: 800; letter-spacing: .16em; }
.mission-id { font-size: .72rem; }
.app-header h1 { margin: 10px 0 4px; display: flex; align-items: center; justify-content: center; gap: 18px; font-size: clamp(2rem, 5vw, 4.2rem); line-height: 1; }
.brand-hair { width: clamp(24px, 5vw, 72px); height: 2px; background: var(--cyan); }
.subtitle { color: var(--muted); font-size: clamp(.63rem, 1.5vw, .84rem); }

.search-console { min-width: 0; margin: clamp(20px, 3vw, 42px); padding: clamp(22px, 3vw, 36px); border: 1px solid var(--line); background: linear-gradient(120deg, rgba(11,33,50,.96), rgba(5,22,34,.96)); display: grid; grid-template-columns: minmax(230px,.7fr) minmax(320px,1.6fr); gap: 20px 34px; align-items: center; }
.search-copy h2 { margin: 7px 0 0; font-size: clamp(1.5rem, 3vw, 2.35rem); }
.panel-kicker { color: var(--cyan); font-size: .72rem; }
.search-field { min-width: 0; min-height: 64px; display: flex; align-items: center; gap: 14px; padding: 0 18px; border: 2px solid var(--cyan); background: #02101b; box-shadow: 0 0 24px rgba(49,220,250,.08); }
.search-field > span { color: var(--cyan); font: 800 2rem var(--mono); transform: translateY(-2px); }
.search-field input { width: 100%; border: 0; outline: 0; color: var(--text); background: transparent; font-size: 1.08rem; font-weight: 600; }
.search-field input::placeholder { color: #6f88a1; }
.search-field kbd { min-width: 26px; padding: 4px; border: 1px solid var(--line); color: var(--dim); text-align: center; font: 700 .75rem var(--mono); }
.quick-stats { grid-column: 1 / -1; display: flex; gap: 10px; flex-wrap: wrap; }
.quick-stats span { padding: 9px 13px; border: 1px solid var(--line-soft); color: var(--muted); font: 700 .68rem var(--mono); letter-spacing: .08em; }
.quick-stats b { color: var(--cyan); }

.trainer-modes { min-width: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0 clamp(20px, 3vw, 42px); border: 1px solid var(--line); }
.mode-btn { min-height: 56px; border: 0; border-right: 1px solid var(--line); background: #071725; color: var(--muted); cursor: pointer; font: 800 .82rem var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.mode-btn:last-child { border-right: 0; }
.mode-btn.active { color: #03101a; background: var(--cyan); }
.filter-rail { min-width: 0; max-width: 100%; margin: 14px clamp(20px, 3vw, 42px) 0; padding-bottom: 7px; display: flex; gap: 9px; overflow-x: auto; scrollbar-width: thin; }
.filter-chip { flex: 0 0 auto; padding: 11px 15px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); cursor: pointer; font: 800 .69rem var(--mono); letter-spacing: .08em; }
.filter-chip.active { border-color: var(--amber); color: var(--amber); background: rgba(255,179,35,.08); }
.mode-panel { min-width: 0; padding: 14px clamp(20px, 3vw, 42px) clamp(30px, 5vw, 58px); }

.reference-layout { min-width: 0; min-height: 680px; display: grid; grid-template-columns: minmax(270px, .78fr) minmax(0, 1.75fr); border: 1px solid var(--line); }
.library-panel { min-width: 0; border-right: 1px solid var(--line); background: #051421; }
.library-heading { height: 53px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); color: var(--cyan); font: 800 .68rem var(--mono); letter-spacing: .1em; }
.library-heading small { color: var(--dim); }
.mnemonic-list { min-width: 0; max-width: 100%; max-height: 745px; overflow: auto; }
.mnemonic-item { width: 100%; padding: 17px 18px; display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; border: 0; border-bottom: 1px solid var(--line-soft); background: transparent; text-align: left; cursor: pointer; }
.mnemonic-item:hover { background: rgba(49,220,250,.05); }
.mnemonic-item.active { background: var(--panel-2); box-shadow: inset 5px 0 var(--cyan); }
.mnemonic-item strong { color: var(--text); font: 800 1rem var(--mono); letter-spacing: .05em; }
.mnemonic-item p { grid-column: 1 / -1; margin: 1px 0 0; color: var(--muted); line-height: 1.25; }
.mnemonic-item .star { color: var(--amber); font-size: 1.05rem; }
.mnemonic-item small { grid-column: 1 / -1; color: var(--dim); font: 700 .59rem var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.empty-state { padding: 30px 20px; color: var(--muted); text-align: center; }

.detail-panel { min-width: 0; padding: clamp(24px, 4vw, 54px); background: linear-gradient(145deg, rgba(11,33,50,.88), rgba(3,16,26,.92)); }
.detail-topline { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.detail-code { margin: 0; color: var(--cyan); font: 800 clamp(2rem, 6vw, 5.6rem)/.95 var(--mono); letter-spacing: .04em; overflow-wrap: anywhere; }
.detail-actions { display: flex; gap: 8px; }
.icon-btn { width: 48px; height: 48px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); cursor: pointer; font-size: 1.15rem; }
.icon-btn.active { border-color: var(--amber); color: var(--amber); }
.detail-title { min-width: 0; margin: 13px 0 7px; overflow-wrap: anywhere; font-size: clamp(1.55rem, 3vw, 2.5rem); line-height: 1.05; }
.detail-trigger { min-width: 0; max-width: 850px; margin: 0; overflow-wrap: anywhere; color: var(--muted); font-size: 1.16rem; line-height: 1.5; }
.tag-row { margin: 17px 0 25px; display: flex; flex-wrap: wrap; gap: 8px; }
.tag { padding: 6px 9px; border: 1px solid var(--line); color: var(--dim); font: 800 .6rem var(--mono); letter-spacing: .09em; text-transform: uppercase; }
.tag.source-official { border-color: rgba(66,227,154,.55); color: var(--green); }
.tag.source-common { border-color: rgba(255,179,35,.55); color: var(--amber); }
.expansion-list { display: grid; gap: 8px; }
.expansion-row { width: 100%; min-width: 0; max-width: 100%; min-height: 61px; display: grid; grid-template-columns: minmax(58px, auto) minmax(0, 1fr); align-items: stretch; border: 1px solid var(--line); background: rgba(3,16,26,.66); }
.expansion-row b { min-width: 58px; padding: 15px 17px; display: grid; place-items: center; border-right: 1px solid var(--line); color: var(--cyan); font: 800 1.15rem var(--mono); }
.expansion-row span { min-width: 0; padding: 14px 18px; align-self: center; overflow-wrap: anywhere; font-size: 1.08rem; font-weight: 700; }
.detail-notes { margin-top: 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.note-box { padding: 18px; border-left: 4px solid var(--cyan); background: rgba(7,24,39,.86); }
.note-box.caution { border-left-color: var(--amber); }
.note-box small { color: var(--dim); font: 800 .62rem var(--mono); letter-spacing: .1em; }
.note-box p { margin: 6px 0 0; overflow-wrap: anywhere; color: var(--muted); line-height: 1.45; }
.source-line { margin-top: 20px; padding-top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid var(--line-soft); }
.source-line span { color: var(--dim); font: 700 .63rem var(--mono); letter-spacing: .08em; }
.source-line a { min-width: 0; max-width: 100%; overflow-wrap: anywhere; color: var(--cyan); font-weight: 800; text-decoration: none; }

.learn-layout { min-width: 0; min-height: 610px; display: grid; grid-template-columns: minmax(250px,.72fr) minmax(0,1.65fr); border: 1px solid var(--line); background: var(--panel); }
.deck-sidebar { padding: clamp(24px, 3vw, 38px); border-right: 1px solid var(--line); }
.deck-sidebar h2 { margin: 8px 0; font-size: 2rem; }
.deck-sidebar > p:not(.panel-kicker) { color: var(--muted); line-height: 1.5; }
.deck-meter { margin-top: 28px; color: var(--muted); font: 800 .65rem var(--mono); letter-spacing: .09em; }
.deck-meter i, .drill-progress i { height: 5px; margin-top: 10px; display: block; background: var(--line-soft); }
.deck-meter b, .drill-progress b { height: 100%; display: block; background: var(--cyan); transition: width .2s; }
.deck-controls { margin-top: 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.deck-controls button, #new-drill, .next-question { min-height: 46px; border: 1px solid var(--line); background: #081b2b; cursor: pointer; color: var(--text); font: 800 .66rem var(--mono); letter-spacing: .08em; }
.study-card { margin: clamp(22px, 4vw, 54px); min-height: 480px; padding: clamp(28px, 4vw, 55px); display: flex; flex-direction: column; justify-content: center; border: 2px solid var(--cyan); background: radial-gradient(circle at 80% 20%, rgba(49,220,250,.09), transparent 32%), #061725; cursor: pointer; text-align: center; }
.study-card .study-label { color: var(--dim); font: 800 .66rem var(--mono); letter-spacing: .13em; }
.study-card h2 { margin: 18px 0 12px; color: var(--cyan); font: 800 clamp(2.6rem, 8vw, 6.5rem)/1 var(--mono); overflow-wrap: anywhere; }
.study-card h3 { margin: 0; font-size: clamp(1.4rem, 3vw, 2.25rem); }
.study-card .tap-prompt { margin-top: 35px; color: var(--amber); font: 800 .72rem var(--mono); letter-spacing: .12em; }
.study-card.revealed { justify-content: flex-start; text-align: left; }
.study-card.revealed h2 { margin-top: 8px; font-size: clamp(2rem, 5vw, 4.2rem); }
.study-card .study-expansions { width: 100%; margin-top: 22px; display: grid; gap: 7px; }
.study-card .study-expansions span { min-width: 0; padding: 10px 12px; overflow-wrap: anywhere; border-bottom: 1px solid var(--line-soft); font-weight: 700; }
.study-card .study-expansions b { min-width: 42px; display: inline-block; color: var(--cyan); font-family: var(--mono); }
.study-rating { width: 100%; margin-top: auto; padding-top: 26px; display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.study-rating button { min-height: 44px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; font: 800 .63rem var(--mono); letter-spacing: .07em; }
.study-rating button[data-rating="mastered"] { border-color: var(--green); color: var(--green); }

.drill-layout { min-width: 0; min-height: 610px; padding: clamp(22px, 4vw, 48px); border: 1px solid var(--line); background: var(--panel); }
.drill-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.drill-header h2 { margin: 7px 0 0; font-size: clamp(1.6rem, 3vw, 2.4rem); }
#new-drill { min-width: 132px; border-color: var(--amber); color: var(--amber); }
.drill-progress { margin: 22px 0; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px; color: var(--dim); font: 800 .63rem var(--mono); letter-spacing: .08em; }
.drill-progress i { margin: 0; }
.question-card { width: 100%; min-width: 0; max-width: 950px; margin: 32px auto 0; padding: clamp(24px, 4vw, 48px); border: 1px solid var(--line); background: #061522; }
.question-context { margin: 0; color: var(--amber); font: 800 .75rem var(--mono); letter-spacing: .14em; }
.question-card h3 { margin: 12px 0 26px; font-size: clamp(1.7rem, 4vw, 3rem); line-height: 1.1; }
.answer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.answer-choice { min-width: 0; min-height: 74px; padding: 14px 16px; overflow-wrap: anywhere; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; text-align: left; font-weight: 700; }
.answer-choice:hover:not(:disabled) { border-color: var(--cyan); }
.answer-choice.correct { border-color: var(--green); background: rgba(66,227,154,.11); color: var(--green); }
.answer-choice.incorrect { border-color: var(--red); background: rgba(255,95,127,.1); color: var(--red); }
.answer-choice:disabled { cursor: default; }
.drill-feedback { margin-top: 16px; padding: 16px 18px; border-left: 4px solid var(--green); background: rgba(66,227,154,.08); color: var(--muted); line-height: 1.45; }
.drill-feedback.incorrect { border-left-color: var(--red); background: rgba(255,95,127,.08); }
.drill-feedback strong { display: block; margin-bottom: 4px; color: var(--text); font-family: var(--mono); }
.next-question { width: 100%; margin-top: 14px; border-color: var(--cyan); color: var(--cyan); }

.app-footer { min-height: 62px; padding: 14px 22px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid var(--line); color: var(--dim); font: 700 .58rem var(--mono); letter-spacing: .08em; }
.trainer-seo-guide { width: min(1240px, calc(100% - 40px)); margin: 18px auto 60px; padding: clamp(26px, 4vw, 46px); border: 1px solid var(--line); background: rgba(3,16,26,.94); }
.seo-kicker { color: var(--cyan); font: 800 .7rem var(--mono); letter-spacing: .14em; }
.trainer-seo-guide h2 { margin: 8px 0 12px; font-size: clamp(1.7rem, 3vw, 2.5rem); }
.trainer-seo-guide > p:not(.seo-kicker) { color: var(--muted); line-height: 1.55; }
.trainer-seo-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-top: 24px; }
.trainer-seo-grid article { padding: 18px; border: 1px solid var(--line-soft); }
.trainer-seo-grid h3 { margin: 0 0 7px; }
.trainer-seo-grid p { margin: 0; color: var(--muted); line-height: 1.45; }
.seo-disclaimer { margin-top: 22px; padding-top: 17px; border-top: 1px solid var(--line-soft); font-size: .9rem; }

@media (max-width: 860px) {
  .search-console { grid-template-columns: 1fr; }
  .quick-stats { grid-column: auto; }
  .reference-layout, .learn-layout { grid-template-columns: 1fr; }
  .reference-layout { border: 0; }
  .library-panel { border: 1px solid var(--line); border-right: 1px solid var(--line); }
  .mnemonic-list { display: flex; overflow-x: auto; }
  .mnemonic-item { min-width: 235px; max-width: 78vw; border-right: 1px solid var(--line-soft); }
  .detail-panel { border: 1px solid var(--line); border-top: 0; }
  .deck-sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .study-card { min-height: 430px; }
  .trainer-seo-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .arcade-nav { height: 56px; padding: 0 14px; }
  .arcade-brand img { width: 29px; height: 29px; }
  .arcade-brand { font-size: .8rem; }
  .all-missions { font-size: .62rem; }
  .app-stage { padding: 6px; }
  .app-header { padding: 22px 14px; }
  .app-header h1 { font-size: 1.85rem; }
  .brand-hair { display: none; }
  .search-console { margin: 12px; padding: 18px 14px; gap: 15px; }
  .search-field { min-height: 55px; padding: 0 12px; }
  .search-field input { font-size: .94rem; }
  .search-field kbd { display: none; }
  .quick-stats { flex-wrap: nowrap; overflow-x: auto; }
  .quick-stats span { white-space: nowrap; }
  .trainer-modes, .filter-rail { margin-left: 12px; margin-right: 12px; }
  .mode-btn { min-height: 49px; font-size: .68rem; }
  .mode-panel { padding: 8px 12px 28px; }
  .reference-layout, .library-panel, .mnemonic-list, .detail-panel { width: 100%; min-width: 0; max-width: 100%; }
  .library-panel, .detail-panel { overflow: hidden; }
  .detail-panel { padding: 20px 13px; }
  .detail-topline { align-items: center; flex-wrap: wrap; }
  .detail-code { font-size: clamp(1.9rem, 12vw, 3.3rem); }
  .detail-title { font-size: 1.45rem; line-height: 1.12; }
  .detail-trigger { font-size: 1rem; line-height: 1.42; }
  .detail-actions .icon-btn:last-child { display: none; }
  .detail-notes { grid-template-columns: 1fr; }
  .source-line { align-items: flex-start; flex-direction: column; }
  .expansion-row { grid-template-columns: 46px minmax(0, 1fr); }
  .expansion-row b { min-width: 0; padding: 12px 7px; font-size: 1rem; }
  .expansion-row span { padding: 12px 10px; font-size: .98rem; line-height: 1.3; }
  .learn-layout { min-height: 0; }
  .deck-sidebar { padding: 19px 16px; }
  .deck-sidebar > p:not(.panel-kicker) { display: none; }
  .deck-sidebar h2 { font-size: 1.5rem; }
  .study-card { min-height: 390px; margin: 12px; padding: 24px 16px; }
  .study-rating { grid-template-columns: 1fr; }
  .drill-layout { padding: 20px 14px; }
  .drill-header { align-items: flex-start; }
  #new-drill { min-width: auto; padding: 0 10px; }
  .drill-progress { grid-template-columns: 1fr auto; }
  .drill-progress i { grid-column: 1 / -1; grid-row: 2; }
  .question-card { margin-top: 18px; padding: 22px 14px; }
  .answer-grid { grid-template-columns: 1fr; }
  .app-footer { align-items: flex-start; flex-direction: column; }
  .trainer-seo-guide { width: calc(100% - 20px); }
}

@media (max-width: 390px) {
  .arcade-brand { font-size: .7rem; }
  .all-missions { font-size: .56rem; }
  .app-header h1 { font-size: 1.55rem; }
  .subtitle { letter-spacing: .1em; }
  .mode-btn { padding: 7px 4px; font-size: .6rem; letter-spacing: .07em; }
  .detail-actions { width: 100%; }
  .icon-btn { width: 42px; height: 42px; }
  .tag-row { margin-bottom: 18px; }
  .question-card h3 { overflow-wrap: anywhere; }
}
