:root {
  color-scheme: dark;
  --ink: #ffffff;
  --muted: #aaaaaa;
  --void: #000000;
  --navy: #0000aa;
  --panel: #000080;
  --panel-2: #0000aa;
  --line: #55ffff;
  --cyan: #55ffff;
  --green: #55ff55;
  --amber: #ffff55;
  --magenta: #ff55ff;
  --danger: #ff5555;
  --shadow: 8px 8px 0 #000000;
  font-family: "VT323", "Perfect DOS VGA 437", "PxPlus IBM VGA8", Fixedsys, monospace;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--void); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% -10%, rgba(32, 113, 161, .24), transparent 42%),
    linear-gradient(180deg, #06172a 0, #020812 65%);
  overflow-x: hidden;
}

button, input { font: inherit; }
button { color: inherit; }

button:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

.crt {
  position: fixed;
  z-index: 20;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.1) 0, rgba(0,0,0,.1) 1px, transparent 1px, transparent 4px);
  mix-blend-mode: multiply;
  opacity: .52;
}

.crt::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse, transparent 55%, rgba(0, 0, 0, .36) 100%);
}

.shell {
  width: min(1480px, calc(100% - 56px));
  margin: 0 auto;
  padding: 16px 0 12px;
}

.topbar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 18px; }

.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 50px;
  height: 42px;
  border: 2px solid var(--cyan);
  color: var(--cyan);
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -4px;
  box-shadow: inset 0 0 18px rgba(78,232,255,.09), 5px 5px 0 #103c5f;
}
.brand-copy { display: flex; flex-direction: column; gap: 4px; }
.brand-copy strong { text-transform: uppercase; font-size: 16px; letter-spacing: .08em; white-space: nowrap; }
.brand-copy small { color: var(--muted); font-size: 10px; letter-spacing: .1em; }

.system-tools { display: flex; align-items: center; gap: 10px; }
.status-light { margin-right: 12px; color: var(--green); font-size: 11px; letter-spacing: .08em; }
.status-light i { display: inline-block; width: 7px; height: 7px; margin-right: 7px; background: var(--green); border-radius: 50%; box-shadow: 0 0 12px var(--green); }
.icon-button, .text-button, .primary-button, .mode-tab, .lesson-item { border: 0; cursor: pointer; }
.icon-button {
  width: 42px;
  height: 38px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(8, 28, 49, .8);
}
.icon-button:hover, .icon-button[aria-pressed="false"] { color: var(--cyan); border-color: var(--cyan); }

.mode-tabs { display: flex; align-self: stretch; justify-self: center; gap: 4px; margin: 0; border: 0; }
.mode-tab {
  position: relative;
  padding: 8px 17px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.mode-tab span { margin-right: 9px; color: #3e6a88; }
.mode-tab:hover { color: var(--ink); }
.mode-tab.active { color: var(--cyan); background: rgba(33, 104, 148, .08); }
.mode-tab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: var(--cyan); box-shadow: 0 -4px 13px rgba(78,232,255,.45); }

.panel { border: 1px solid var(--line); background: linear-gradient(145deg, rgba(11, 34, 61, .96), rgba(5, 20, 38, .96)); box-shadow: var(--shadow); }
.dashboard { display: grid; grid-template-columns: 285px minmax(0, 1fr); gap: 14px; width: 100%; min-width: 0; margin-top: 12px; }
.dashboard.test-mode { grid-template-columns: minmax(0, 1fr); }
.dashboard > * { min-width: 0; }
.lesson-panel { display: flex; flex-direction: column; min-width: 0; min-height: 720px; padding: 24px 18px 18px; }
.panel-heading, .trainer-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.panel-heading { padding: 0 8px 18px; border-bottom: 1px solid var(--line); }
.eyebrow { display: block; margin-bottom: 7px; color: var(--cyan); font-size: 9px; letter-spacing: .17em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
.panel-heading h1, .trainer-header h2, .game-hud h1 { margin-bottom: 0; font-size: 20px; letter-spacing: .03em; }
.disk-icon { color: var(--amber); font-size: 22px; }
.lesson-list { display: grid; gap: 7px; padding: 18px 0; }
.lesson-item {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 13px 10px;
  color: var(--muted);
  text-align: left;
  background: transparent;
  border-left: 2px solid transparent;
}
.lesson-item:hover { color: var(--ink); background: rgba(41, 106, 147, .12); }
.lesson-item.active { color: var(--ink); background: #0d2b4a; border-left-color: var(--cyan); }
.lesson-number { color: #4c718c; font-size: 11px; }
.lesson-name { display: flex; flex-direction: column; gap: 3px; font-size: 12px; }
.lesson-name small { color: #52748d; font-size: 9px; }
.lesson-progress { width: 30px; height: 3px; background: #17344c; }
.lesson-progress i { display: block; height: 100%; background: var(--green); }
.goal-card { margin-top: auto; padding: 15px; border: 1px solid #1f4e6d; background: rgba(5, 18, 33, .55); }
.goal-card > span { display: block; margin-bottom: 10px; color: var(--muted); font-size: 9px; }
.goal-card div { color: var(--muted); font-size: 11px; }
.goal-card strong { color: var(--amber); font-size: 17px; }
.goal-card b { padding: 0 7px; color: #355d78; }

.trainer-panel { min-width: 0; padding: 24px; }
.trainer-header { min-height: 54px; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.text-button { padding: 11px 14px; color: var(--muted); background: transparent; }
.text-button:hover { color: var(--ink); }
kbd { padding: 2px 5px; border: 1px solid #395971; border-bottom-width: 2px; color: #a5bdcd; background: #0a1a2b; font-size: 9px; }
.primary-button { padding: 12px 17px; color: #00101b; background: var(--cyan); font-weight: 800; box-shadow: 4px 4px 0 #176477; }
.primary-button:hover { filter: brightness(1.12); transform: translate(-1px, -1px); box-shadow: 5px 5px 0 #176477; }
.primary-button span { margin-left: 8px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 22px 0 12px; }
.stat-card { position: relative; min-width: 0; padding: 14px 15px 12px; border: 1px solid #1a425f; background: rgba(3, 16, 30, .67); overflow: hidden; }
.stat-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: currentColor; box-shadow: 4px 0 18px currentColor; }
.stat-card > span { display: block; color: var(--muted); font-size: 8px; letter-spacing: .05em; }
.stat-card strong { display: block; margin: 6px 0 3px; color: currentColor; font-size: clamp(25px, 3vw, 36px); line-height: 1; letter-spacing: -.07em; }
.stat-card sup { margin-left: 2px; font-size: 12px; }
.stat-card small { color: #54738a; font-size: 8px; }
.cyan { color: var(--cyan); }.green { color: var(--green); }.amber { color: var(--amber); }.magenta { color: var(--magenta); }

.paper { position: relative; min-height: 224px; padding: 19px 22px 26px; border: 1px solid #315a77; background: #061322; cursor: text; overflow: hidden; }
.paper::after { content: ""; position: absolute; left: 0; right: 0; top: 42px; height: 1px; background: #17364d; }
.paper-topline { display: flex; justify-content: space-between; color: #55758c; font-size: 8px; letter-spacing: .12em; }
.text-display { position: relative; z-index: 1; max-width: 100%; margin-top: 26px; color: #6f8fa5; font-size: clamp(18px, 2vw, 26px); line-height: 1.9; letter-spacing: .025em; white-space: pre-wrap; overflow-wrap: anywhere; word-break: normal; user-select: none; }
.char { position: relative; white-space: pre-wrap; }
.char.correct { color: var(--green); }
.char.incorrect { color: var(--danger); background: rgba(255, 77, 108, .15); }
.char.current { color: #03101b; background: var(--cyan); box-shadow: 0 0 15px rgba(78,232,255,.5); animation: currentBlink .9s steps(1) infinite; }
@keyframes currentBlink { 50% { background: #d9fbff; } }
.start-overlay { position: absolute; z-index: 3; inset: 43px 0 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: rgba(3, 15, 28, .92); }
.start-overlay.hidden { display: none; }
.start-overlay strong { color: var(--ink); font-size: 18px; }
.start-overlay small { color: var(--muted); font-size: 10px; }
.overlay-cursor { color: var(--cyan); animation: blink .7s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.keyboard-wrap { margin-top: 12px; padding: 14px 15px 15px; border: 1px solid #173e5a; background: rgba(2, 12, 23, .55); }
.keyboard-meta { display: flex; justify-content: space-between; margin-bottom: 11px; color: #55758c; font-size: 8px; letter-spacing: .08em; }
.keyboard-meta strong { color: var(--cyan); }.keyboard-meta b { color: var(--amber); font-weight: 400; }
.keyboard { display: grid; gap: 5px; }
.key-row { display: flex; justify-content: center; gap: 5px; }
.key {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 0;
  max-width: 62px;
  height: 36px;
  border: 1px solid #2a506a;
  border-bottom-width: 3px;
  color: #7895aa;
  background: linear-gradient(#102b44, #0a1d30);
  font-size: 10px;
  border-radius: 2px;
}
.key.wide { flex-grow: 1.55; max-width: 90px; font-size: 7px; }
.key.space { flex-grow: 6; max-width: 390px; }
.key.next { color: #00131c; background: var(--cyan); border-color: #b9f8ff; box-shadow: 0 0 18px rgba(78,232,255,.48); }
.key.pressed { transform: translateY(2px); border-bottom-width: 1px; }

.game-view { margin-top: 12px; overflow: hidden; }
.game-hud { display: grid; grid-template-columns: 1fr repeat(4, auto) auto; align-items: center; gap: 22px; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.game-title-block { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; min-width: 245px; }
.game-title-block > div { min-width: 0; }
.game-trend-button { flex: 0 0 auto; padding: 7px 8px; white-space: nowrap; }
.game-stat { display: flex; flex-direction: column; gap: 5px; }
.game-stat span { color: var(--muted); font-size: 8px; }
.game-stat strong { color: var(--amber); font-size: 17px; }
.combo-stat strong { color: var(--green); }
.game-stage { position: relative; height: min(61vh, 600px); min-height: 430px; background: #020a16; overflow: hidden; }
.stars { position: absolute; inset: 0; opacity: .7; background-image: radial-gradient(#547d9a 1px, transparent 1px), radial-gradient(#30516b 1px, transparent 1px); background-size: 70px 70px, 43px 43px; background-position: 0 0, 12px 17px; }
.stars::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(9,39,67,.2), transparent 50%, rgba(29,117,139,.11)); }
.game-message { position: absolute; z-index: 3; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 13px; text-align: center; background: rgba(2, 10, 22, .68); }
.game-message.hidden { display: none; }
.game-message > span { color: var(--cyan); font-size: 10px; letter-spacing: .2em; }
.game-message > strong { font-size: 27px; line-height: 1.55; text-transform: uppercase; }
.game-message > small { color: var(--muted); }
.game-settings { display: grid; grid-template-columns: auto auto; align-items: end; gap: 28px; min-width: min(520px, calc(100% - 40px)); margin-top: 10px; padding: 15px 17px; border: 1px solid #214d6b; background: rgba(4, 19, 35, .92); text-align: left; }
.setting-block > span { display: block; margin-bottom: 9px; color: var(--muted); font-size: 8px; letter-spacing: .12em; }
.difficulty-options { display: flex; gap: 5px; }
.difficulty-options button { min-width: 75px; padding: 8px 10px; border: 1px solid #294d68; color: #69889e; background: #081a2d; cursor: pointer; font-size: 9px; }
.difficulty-options button:hover { color: var(--ink); border-color: #4c7a98; }
.difficulty-options button.active { color: #00121d; border-color: var(--cyan); background: var(--cyan); box-shadow: 2px 2px 0 #176477; font-weight: 900; }
.case-setting { display: grid; grid-template-columns: 33px 1fr; align-items: center; gap: 10px; min-width: 170px; cursor: pointer; }
.case-setting input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.case-setting > i { position: relative; width: 33px; height: 17px; border: 1px solid #315b76; background: #071626; }
.case-setting > i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 9px; height: 9px; background: #5a788d; transition: transform .15s ease, background .15s ease; }
.case-setting input:checked + i { border-color: var(--green); }
.case-setting input:checked + i::after { background: var(--green); transform: translateX(16px); box-shadow: 0 0 9px rgba(122,255,186,.5); }
.case-setting b { display: block; margin-bottom: 3px; color: var(--ink); font-size: 9px; }
.case-setting small { display: block; color: var(--muted); font-size: 7px; }
.invader { position: absolute; z-index: 2; top: -55px; min-width: 70px; height: 40px; display: grid; place-items: center; padding: 0 13px; border: 1px solid var(--magenta); color: var(--magenta); background: #110a25; font-size: 15px; font-weight: 900; letter-spacing: .09em; white-space: nowrap; box-shadow: 0 0 18px rgba(255,103,212,.24), inset 0 0 14px rgba(255,103,212,.09); }
.invader::before { content: "⌄"; position: absolute; top: -13px; color: #8b4f91; font-size: 13px; }
.invader.targeted { border-color: var(--cyan); box-shadow: 0 0 18px rgba(78,232,255,.28), inset 0 0 14px rgba(78,232,255,.1); }
.invader.targeted::after { content: "LOCK"; position: absolute; right: -1px; bottom: -14px; color: var(--cyan); font-size: 9px; letter-spacing: .12em; }
.invader.fast { border-color: var(--danger); color: var(--danger); }
.invader.bonus { border-color: var(--amber); color: var(--amber); }
.invader .typed { color: var(--cyan); text-shadow: 0 0 8px rgba(78,232,255,.75); }
.invader.hit { animation: explode .22s ease-out forwards; }
@keyframes explode { to { scale: 1.8; opacity: 0; filter: brightness(2); } }
.target-guide { position: absolute; z-index: 1; width: 2px; height: var(--guide-length, 0); visibility: hidden; opacity: 0; pointer-events: none; background: repeating-linear-gradient(to bottom, var(--cyan) 0 7px, transparent 7px 13px); transform-origin: 50% 0; transform: rotate(var(--guide-angle, 0rad)); }
.target-guide.active { visibility: visible; opacity: .9; animation: targetGuideMarch .45s steps(2) infinite; }
.target-guide::after { content: ""; position: absolute; left: 50%; bottom: -4px; width: 7px; height: 7px; border: 1px solid var(--cyan); background: #000; transform: translateX(-50%) rotate(45deg); }
@keyframes targetGuideMarch { to { background-position: 0 13px; } }
.laser { position: absolute; z-index: 3; width: 2px; height: var(--laser-length); background: var(--cyan); box-shadow: 0 0 9px var(--cyan); transform-origin: 50% 0; transform: rotate(var(--laser-angle)) scaleY(0); animation: laser .09s ease-out forwards; }
.laser::after { content: ""; position: absolute; left: 50%; bottom: -4px; width: 8px; height: 8px; border: 1px solid #fff; background: var(--cyan); box-shadow: 0 0 14px var(--cyan); transform: translateX(-50%); }
@keyframes laser { to { transform: rotate(var(--laser-angle)) scaleY(1); } }
.turret { position: absolute; z-index: 4; bottom: 21px; left: 50%; width: 34px; height: 61px; transform: translateX(-50%); pointer-events: none; }
.turret img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; filter: drop-shadow(0 0 4px rgba(85,255,255,.65)); }
.turret-swivel { clip-path: inset(0 0 25% 0); transform-origin: 50% 74%; transform: rotate(var(--turret-angle, 0deg)); transition: transform .08s linear; }
.turret-base { clip-path: inset(70% 0 0 0); }
.ground-line { position: absolute; left: 0; right: 0; bottom: 21px; height: 1px; background: var(--cyan); box-shadow: 0 0 15px rgba(78,232,255,.5); }
.game-help { display: flex; justify-content: center; gap: 36px; padding: 14px; color: var(--muted); font-size: 9px; }
.wave-banner { position: absolute; z-index: 5; left: 50%; top: 43%; padding: 8px 22px; border: 2px solid var(--cyan); color: var(--ink); background: var(--navy); box-shadow: 5px 5px 0 #000; font-size: 30px; letter-spacing: .18em; transform: translate(-50%, -50%); animation: waveReveal 1.1s steps(5) both; }
@keyframes waveReveal { 0% { opacity: 0; scale: .6; } 18%, 72% { opacity: 1; scale: 1; } 100% { opacity: 0; scale: 1.25; } }
.overdrive-status { position: absolute; z-index: 5; top: 58px; left: 50%; display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 245px; padding: 8px 14px; border: 2px solid var(--amber); color: var(--amber); background: #000080; box-shadow: 4px 4px 0 #000; transform: translateX(-50%); animation: timeSlowPulse .8s steps(2) infinite; }
.overdrive-status strong { font-size: 18px; letter-spacing: .14em; }
.overdrive-status span { color: #fff; font-size: 10px; letter-spacing: .06em; }
@keyframes timeSlowPulse { 50% { border-color: #fff; color: #fff; } }
.overdrive-hud { position: absolute; z-index: 4; left: 18px; bottom: 36px; display: grid; grid-template-columns: auto 150px 38px auto; align-items: center; gap: 9px; padding: 7px 9px; border: 1px solid #aaaaff; color: #aaa; background: #000080; font-size: 11px; }
.overdrive-track { width: 150px; height: 8px; border: 1px solid #fff; background: #000; }
.overdrive-track i { display: block; width: 0; height: 100%; background: var(--amber); transition: width .15s steps(5); }
.overdrive-hud.ready { color: var(--amber); border-color: var(--amber); animation: readyPulse .7s steps(2) infinite; }
.overdrive-hud.active { color: #000; border-color: #fff; background: var(--amber); }
.overdrive-hud.active .overdrive-track i { background: var(--danger); }
@keyframes readyPulse { 50% { filter: brightness(1.45); } }
.game-stage.overdrive { outline: 3px solid var(--amber); outline-offset: -3px; }
.game-stage.overdrive::after { content: ""; position: absolute; z-index: 1; inset: 0; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(85,255,255,.045) 0 2px, transparent 2px 8px); animation: timeScan 1.4s steps(7) infinite; }
.game-stage.overdrive .stars { animation: starDrift 2.4s steps(8) infinite; }
.game-stage.overdrive .turret img { filter: drop-shadow(0 0 11px #55ffff) brightness(1.2); }
@keyframes starDrift { to { background-position: 0 26px, 12px 34px; } }
@keyframes timeScan { to { translate: 0 8px; } }
.pixel-burst { position: absolute; z-index: 6; width: 1px; height: 1px; pointer-events: none; }
.pixel-burst i { position: absolute; width: 6px; height: 6px; background: var(--burst-color, var(--cyan)); animation: pixelBurst .48s steps(5) forwards; }
@keyframes pixelBurst { to { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0); } }
.score-popup { position: absolute; z-index: 7; color: var(--amber); font-size: 22px; font-weight: 900; pointer-events: none; text-shadow: 2px 2px #000; animation: scoreRise .7s steps(6) forwards; }
@keyframes scoreRise { to { opacity: 0; transform: translateY(-42px); } }
.game-stage.damage { animation: stageDamage .25s steps(3); }
@keyframes stageDamage { 25% { translate: -7px 0; background: #aa0000; } 50% { translate: 7px 0; } 75% { translate: -4px 0; } }

.input-alert { position: fixed; z-index: 30; right: 24px; bottom: 24px; width: min(390px, calc(100% - 32px)); padding: 17px 46px 17px 18px; border: 1px solid var(--amber); background: #171608; box-shadow: 0 15px 45px rgba(0,0,0,.5), 0 0 24px rgba(255,211,94,.12); }
.input-alert > span { display: block; margin-bottom: 6px; color: var(--amber); font-size: 8px; letter-spacing: .16em; }
.input-alert > strong { display: block; margin-bottom: 4px; color: var(--ink); font-size: 13px; }
.input-alert > small { color: #a89b6b; font-size: 9px; line-height: 1.5; }
.input-alert button { position: absolute; top: 9px; right: 10px; border: 0; color: #a89b6b; background: transparent; cursor: pointer; font-size: 20px; }
.input-alert button:hover { color: var(--ink); }

.footer { display: flex; justify-content: space-between; gap: 20px; padding: 9px 2px 0; color: #3d6079; font-size: 8px; letter-spacing: .04em; }
.hidden { display: none !important; }

.result-dialog { width: min(480px, calc(100% - 32px)); padding: 0; color: var(--ink); border: 1px solid var(--cyan); background: #081b31; box-shadow: 0 0 0 100vmax rgba(0, 5, 12, .78), 0 0 45px rgba(78,232,255,.2); }
.result-dialog::backdrop { background: transparent; }
.result-dialog form { padding: 28px; }
.result-dialog h2 { margin-bottom: 8px; font-size: 25px; }
.result-dialog p { color: var(--muted); font-size: 11px; line-height: 1.7; }
.result-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin: 22px 0; }
.result-grid div { padding: 15px; border: 1px solid var(--line); background: #051426; }
.result-grid span { display: block; color: var(--muted); font-size: 8px; }
.result-grid strong { display: block; margin-top: 7px; color: var(--green); font-size: 23px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

.trend-dialog { width: min(840px, calc(100% - 28px)); max-height: calc(100dvh - 28px); padding: 0; color: #fff; border: 2px solid #fff; background: #000080; box-shadow: 8px 8px 0 #000; }
.trend-dialog::backdrop { background: rgba(0,0,0,.82); }
.trend-dialog form { padding: 22px; }
.trend-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.trend-header h2 { margin-bottom: 0; font-size: 28px; }
.daily-best-grid { display: grid; grid-template-columns: 1fr 1fr 1.35fr; gap: 8px; margin: 18px 0 12px; }
.daily-best-grid > div { min-width: 0; padding: 12px 14px; border: 2px solid #55ffff; background: #000; }
.daily-best-grid span { display: block; color: #aaa; font-size: 12px; }
.daily-best-grid strong { display: block; margin-top: 5px; color: #ffff55; font-size: 24px; white-space: nowrap; }
.trend-chart-panel { padding: 12px; border: 2px solid #aaaaff; background: #000; }
.trend-chart-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; color: #fff; font-size: 12px; }
.trend-legend { display: flex; gap: 16px; color: #aaa; }
.trend-legend span { display: flex; align-items: center; gap: 6px; }
.trend-legend i { width: 18px; height: 3px; background: currentColor; }
.wpm-legend { color: #55ffff; }
.accuracy-legend { color: #55ff55; }
.score-legend { color: #ffff55; }
.wave-legend { color: #55ffff; }
.trend-chart { display: block; width: 100%; height: auto; margin-top: 8px; overflow: visible; }
.trend-grid-line { stroke: #555; stroke-width: 1; stroke-dasharray: 3 5; }
.trend-axis-label, .trend-date-label, .trend-axis-title { fill: #aaa; font: 13px "VT323", monospace; }
.trend-axis-title { fill: #fff; }
.trend-line { fill: none; stroke-width: 3; vector-effect: non-scaling-stroke; }
.wpm-line { stroke: #55ffff; }
.accuracy-line { stroke: #55ff55; }
.score-line { stroke: #ffff55; }
.wave-line { stroke: #55ffff; }
.trend-dot { stroke: #000; stroke-width: 2; vector-effect: non-scaling-stroke; }
.wpm-dot { fill: #55ffff; }
.accuracy-dot { fill: #55ff55; }
.score-dot { fill: #ffff55; }
.wave-dot { fill: #55ffff; }
.game-daily-best-grid { grid-template-columns: repeat(4, 1fr); }
.trend-empty { display: grid; min-height: 220px; margin: 8px 0 0; place-items: center; color: #aaa; text-align: center; }
.trend-storage-note { margin: 10px 0 0; color: #aaaaff; font-size: 12px; }

.highscore-dialog { width: min(560px, calc(100% - 28px)); max-height: calc(100dvh - 28px); padding: 0; overflow: auto; color: #fff; border: 5px solid transparent; background: linear-gradient(#000080, #000080) padding-box, repeating-linear-gradient(90deg, #ff5555 0 20px, #ffff55 20px 40px, #55ff55 40px 60px, #55ffff 60px 80px, #5555ff 80px 100px, #ff55ff 100px 120px) border-box; background-size: auto, 120px 100%; box-shadow: 10px 10px 0 #000; animation: highscoreBorder .75s steps(6) infinite; }
.highscore-dialog::backdrop { background: rgba(0,0,0,.82); }
.highscore-dialog form { padding: 28px; text-align: center; }
.highscore-stars { margin-bottom: 8px; color: #ffff55; font-size: 22px; letter-spacing: .24em; animation: highscoreFlash .6s steps(2) infinite; }
.highscore-dialog h2 { margin: 7px 0 4px; color: #55ffff; font-size: clamp(34px, 7vw, 52px); line-height: 1; text-shadow: 3px 3px 0 #000; }
.highscore-value { display: block; margin: 10px 0 6px; color: #ffff55; font-size: clamp(48px, 11vw, 78px); line-height: 1; letter-spacing: .05em; text-shadow: 4px 4px 0 #aa0000; }
.highscore-dialog > form > p { max-width: 430px; margin: 10px auto 18px; color: #fff; font-size: 16px; line-height: 1.35; }
.highscore-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-bottom: 20px; }
.highscore-grid > div { min-width: 0; padding: 10px 8px; border: 2px solid #55ffff; background: #000; }
.highscore-grid span { display: block; color: #aaa; font-size: 10px; }
.highscore-grid strong { display: block; margin-top: 5px; color: #55ff55; font-size: 22px; overflow-wrap: anywhere; }
.highscore-actions { justify-content: center; }
@keyframes highscoreBorder { to { background-position: 0 0, 120px 0; } }
@keyframes highscoreFlash { 50% { color: #ff55ff; } }

/* IBM PC-compatible 16-color treatment; layout intentionally remains modern. */
body {
  background: #0000aa;
}

.crt {
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.12) 0, rgba(0,0,0,.12) 1px, transparent 1px, transparent 4px);
  mix-blend-mode: multiply;
  opacity: .32;
}

.topbar {
  padding: 7px 10px;
  border: 2px solid #aaaaff;
  background: #000080;
  box-shadow: 5px 5px 0 #000;
}

.brand-mark {
  border-color: #fff;
  color: #fff;
  background: #0000aa;
  box-shadow: 4px 4px 0 #000;
}

.brand-copy strong { color: #fff; }
.brand-copy small { color: #55ffff; }
.status-light { color: #55ff55; }
.status-light i { background: #55ff55; box-shadow: none; }
.icon-button { border: 1px solid #fff; color: #fff; background: #000; }
.icon-button:hover, .icon-button[aria-pressed="false"] { color: #000; border-color: #ffff55; background: #ffff55; }

.mode-tabs { border: 0; }
.mode-tab { color: #aaa; }
.mode-tab span { color: #55ffff; }
.mode-tab.active { color: #000; background: #55ffff; }
.mode-tab.active::after { display: none; }

.panel {
  border: 2px solid #aaaaff;
  background: #000080;
  box-shadow: 8px 8px 0 #000;
}

.panel-heading, .paper::after, .game-hud { border-color: #55ffff; }
.eyebrow { color: #55ffff; }
.disk-icon { color: #ffff55; }
.lesson-item { color: #aaa; }
.lesson-item:hover { color: #fff; background: #0000aa; }
.lesson-item.active { color: #fff; border-left-color: #ffff55; background: #0000aa; }
.lesson-number { color: #55ffff; }
.lesson-name small { color: #aaaaff; }
.lesson-progress { background: #000; }
.lesson-progress i { background: #55ff55; }
.goal-card { border-color: #ff55ff; background: #000; }
.goal-card > span { color: #ff55ff; }

.primary-button {
  color: #000;
  border: 1px solid #fff;
  background: #55ffff;
  box-shadow: 4px 4px 0 #000;
}
.primary-button:hover { filter: none; box-shadow: 5px 5px 0 #000; }
.text-button { color: #aaa; }
.text-button:hover { color: #ffff55; }
kbd { border-color: #aaa; color: #fff; background: #000; }

.stat-card { border: 1px solid #aaaaff; background: #000; }
.stat-card::before { box-shadow: none; }
.stat-card > span, .stat-card small { color: #aaa; }

.paper { border: 2px solid #fff; background: #000; }
.paper::after { background: #aaa; }
.paper-topline { color: #55ffff; }
.text-display { color: #aaa; }
.char.correct { color: #55ff55; }
.char.incorrect { color: #fff; background: #aa0000; }
.char.current { color: #000; background: #ffff55; box-shadow: none; }
.start-overlay { background: rgba(0,0,0,.96); }
.start-overlay strong { color: #fff; }
.start-overlay small { color: #aaa; }
.overlay-cursor { color: #ffff55; }

.keyboard-wrap { border: 2px solid #55ffff; background: #0000aa; }
.keyboard-meta { color: #aaaaff; }
.key { border-color: #aaa; color: #fff; background: #000; box-shadow: 2px 2px 0 #000080; }
.key.next { color: #000; border-color: #fff; background: #ffff55; box-shadow: 2px 2px 0 #000; }

.game-hud { background: #000080; }
.game-stage { background: #000; }
.stars { opacity: .48; }
.game-message { background: rgba(0,0,0,.88); }
.game-settings { border-color: #55ffff; background: #000080; }
.difficulty-options button { border-color: #aaa; color: #aaa; background: #000; }
.difficulty-options button.active { color: #000; border-color: #fff; background: #55ffff; box-shadow: 3px 3px 0 #000; }
.case-setting > i { border-color: #fff; background: #000; }
.case-setting > i::after { background: #aaa; }
.invader { border-color: #ff55ff; color: #ff55ff; background: #000080; box-shadow: 3px 3px 0 #000; }
.invader.targeted { border-color: #55ffff; box-shadow: 3px 3px 0 #000; }
.invader .typed { color: #ffff55; text-shadow: none; }
.laser, .ground-line { background: #55ffff; box-shadow: none; }
.target-guide { background: repeating-linear-gradient(to bottom, #55ffff 0 7px, transparent 7px 13px); }
.laser::after { background: #fff; box-shadow: none; }
.game-help { border-top: 2px solid #55ffff; color: #aaa; background: #000080; }

.footer { color: #55ffff; }
.result-dialog { border: 2px solid #fff; background: #000080; box-shadow: 8px 8px 0 #000; }
.result-grid div { border-color: #55ffff; background: #000; }
.input-alert { border: 2px solid #ffff55; background: #aa5500; box-shadow: 6px 6px 0 #000; }

/* Keep terminal labels comfortably readable on modern high-DPI displays. */
.brand-copy small { font-size: 13px; }
.status-light { font-size: 14px; }
.mode-tab { font-size: 16px; }
.eyebrow { font-size: 12px; }
.lesson-number { font-size: 14px; }
.lesson-name { font-size: 16px; }
.lesson-name small { font-size: 12px; }
.goal-card > span { font-size: 12px; }
.goal-card div { font-size: 14px; }
kbd { font-size: 11px; }
.stat-card > span { font-size: 12px; }
.stat-card small { font-size: 12px; }
.paper-topline { font-size: 12px; }
.start-overlay small { font-size: 14px; }
.keyboard-meta { font-size: 12px; }
.key { font-size: 14px; }
.key.wide { font-size: 10px; }
.game-stat span { font-size: 12px; }
.game-message > span { font-size: 13px; }
.game-message > small { font-size: 15px; }
.setting-block > span { font-size: 12px; }
.difficulty-options button { font-size: 13px; }
.case-setting b { font-size: 12px; }
.case-setting small { font-size: 10px; }
.game-help { font-size: 12px; }
.footer { font-size: 11px; }
.result-dialog p { font-size: 14px; }
.result-grid span { font-size: 11px; }
.input-alert > span { font-size: 11px; }
.input-alert > strong { font-size: 16px; }
.input-alert > small { font-size: 12px; }

@media (max-width: 1200px) {
  .brand-copy small, .status-light { display: none; }
  .mode-tab { padding-inline: 12px; }
}

@media (max-width: 900px) {
  .shell { width: min(960px, calc(100% - 32px)); }
  .topbar { gap: 10px; }
  .mode-tab { padding-inline: 8px; }
  .dashboard { grid-template-columns: 1fr; }
  .lesson-panel { min-height: auto; }
  .lesson-list { grid-template-columns: repeat(3, 1fr); }
  .goal-card { margin-top: 0; }
  .game-hud { grid-template-columns: 1fr repeat(3, auto); }
  .game-hud .primary-button { grid-column: 1 / -1; }
}

/* Fit the complete desktop interface inside shorter laptop viewports. */
@media (min-width: 901px) and (max-height: 900px) {
  html, body { height: 100%; }
  body { overflow: hidden; }
  .shell { display: flex; flex-direction: column; height: 100dvh; padding: 10px 0 6px; }
  .topbar { flex: 0 0 auto; padding: 6px 10px; }
  .brand-mark { width: 50px; height: 40px; font-size: 24px; }
  .dashboard, .game-view { flex: 1 1 auto; min-height: 0; margin-top: 8px; }
  .dashboard { height: auto; }
  .lesson-panel, .trainer-panel { height: 100%; min-height: 0; overflow: auto; scrollbar-gutter: stable; }
  .lesson-panel { padding: 10px 12px; }
  .panel-heading { padding: 0 6px 8px; }
  .lesson-list { gap: 3px; padding: 6px 0; }
  .lesson-item { padding: 6px 8px; }
  .goal-card { padding: 8px 10px; }
  .goal-card > span { margin-bottom: 4px; }
  .trainer-panel { display: flex; flex-direction: column; padding: 10px 12px; }
  .trainer-header { flex: 0 0 auto; min-height: 42px; }
  .stats-grid { flex: 0 0 auto; gap: 6px; margin: 8px 0; }
  .stat-card { padding: 7px 10px 6px; }
  .stat-card strong { margin: 3px 0 1px; font-size: 24px; }
  .paper { flex: 1 1 auto; min-height: 150px; padding: 12px 18px 16px; }
  .paper::after { top: 34px; }
  .text-display { margin-top: 18px; font-size: clamp(17px, 1.5vw, 22px); line-height: 1.55; }
  .start-overlay { inset-block-start: 35px; }
  .keyboard-wrap { flex: 0 0 auto; margin-top: 8px; padding: 7px 9px 8px; }
  .keyboard-meta { margin-bottom: 5px; }
  .keyboard { gap: 3px; }
  .key-row { gap: 3px; }
  .key { height: 26px; }
  .game-view { display: flex; flex-direction: column; }
  .game-hud { flex: 0 0 auto; padding: 10px 18px; }
  .game-stage { flex: 1 1 auto; height: auto; min-height: 260px; }
  .game-help { flex: 0 0 auto; padding: 7px; }
  .footer { flex: 0 0 auto; padding-top: 5px; }
}

@media (max-width: 720px) {
  .shell { width: calc(100% - 20px); padding-top: 8px; }
  .topbar { grid-template-columns: 1fr auto; }
  .mode-tabs { grid-column: 1 / -1; grid-row: 2; width: 100%; min-height: 36px; }
  .brand-copy small, .status-light, .footer span:last-child { display: none; }
  .mode-tab { flex: 1; padding-inline: 6px; font-size: 12px; }
  .mode-tab span { display: none; }
  .lesson-list { display: flex; width: 100%; max-width: 100%; min-width: 0; overflow-x: auto; }
  .lesson-item { min-width: 180px; }
  .trainer-panel { padding: 15px; }
  .trainer-header { align-items: flex-start; }
  .trainer-header .text-button:not(.trend-button) { display: none; }
  .trend-button { padding-inline: 8px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .paper { min-height: 260px; padding-inline: 14px; }
  .text-display { font-size: 18px; line-height: 1.8; }
  .keyboard-wrap { overflow-x: auto; padding-inline: 8px; }
  .keyboard { min-width: 610px; }
  .game-hud { grid-template-columns: 1fr 1fr; gap: 14px; }
  .game-hud > div:first-child { grid-column: 1 / -1; }
  .game-title-block { min-width: 0; }
  .game-stat:nth-of-type(4) { display: none; }
  .game-help { flex-wrap: wrap; gap: 15px; }
  .overdrive-status { top: 72px; min-width: 220px; }
  .overdrive-hud { left: 8px; grid-template-columns: auto minmax(70px, 1fr) 38px auto; width: calc(100% - 16px); }
  .overdrive-track { width: auto; }
  .turret { width: 32px; height: 57px; }
  .game-settings { grid-template-columns: 1fr; gap: 15px; min-width: calc(100% - 24px); }
  .difficulty-options button { flex: 1; min-width: 0; }
  .footer { justify-content: center; }
  .trend-dialog form { padding: 14px; }
  .daily-best-grid { grid-template-columns: 1fr 1fr; }
  .daily-best-grid > div:last-child { grid-column: 1 / -1; }
  .game-daily-best-grid > div:last-child { grid-column: auto; }
  .daily-best-grid strong { font-size: 20px; }
  .trend-chart-header { align-items: flex-start; flex-direction: column; }
  .highscore-dialog form { padding: 20px 16px; }
  .highscore-grid strong { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
