:root {
  --cravio-deep-blue: #1B2A4A;
  --cravio-amber: #F5A623;
  --cravio-amber-light: #FFD080;
  --cravio-white: #F0F4F8;
  --cravio-dark-bg: #0D1B2A;
  --cravio-success: #4ECDC4;
  --cravio-error: #FF6B6B;
  --cravio-purple: #7B68EE;
  --cravio-star-gold: #FFD700;
  --cravio-emerald: #37D67A;
  --cravio-silver: #B7C2D8;
  --cravio-bronze: #C98242;
  --cravio-ink: #07111F;
  --white-rgb: 240 244 248;
  --ink-rgb: 7 17 31;
  --deep-blue-rgb: 27 42 74;
  --dark-bg-rgb: 13 27 42;
  --amber-rgb: 245 166 35;
  --amber-light-rgb: 255 208 128;
  --success-rgb: 78 205 196;
  --error-rgb: 255 107 107;
  --purple-rgb: 123 104 238;
  --gold-rgb: 255 215 0;
  --emerald-rgb: 55 214 122;
  --panel-bg: rgb(var(--dark-bg-rgb) / 0.78);
  --panel-strong: rgb(var(--deep-blue-rgb) / 0.88);
  --panel-soft: rgb(var(--white-rgb) / 0.08);
  --line-soft: rgb(var(--white-rgb) / 0.16);
  --line-bright: rgb(var(--amber-rgb) / 0.58);
  --shadow-soft: 0 16px 40px rgb(var(--ink-rgb) / 0.28);
  --shadow-glow: 0 0 22px rgb(var(--amber-rgb) / 0.34);
  --font-title: 'Press Start 2P', monospace;
  --font-ui: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-code: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 1024px;
  min-height: 100%;
}

body {
  margin: 0;
  overflow-x: hidden;
  color: var(--cravio-white);
  background:
    radial-gradient(circle at 22% 12%, rgb(var(--purple-rgb) / 0.2), transparent 30%),
    linear-gradient(145deg, var(--cravio-dark-bg), var(--cravio-deep-blue) 52%, var(--cravio-ink));
  font-family: var(--font-ui);
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

#starfield,
#particle-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#starfield {
  z-index: 0;
}

#particle-canvas {
  z-index: 12;
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

body[data-screen="game"] .top-brand {
  display: none;
}

.top-brand {
  position: fixed;
  top: 18px;
  left: 24px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 12px;
  color: var(--cravio-white);
  background: rgb(var(--dark-bg-rgb) / 0.46);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  backdrop-filter: blur(12px);
}

.quest-journey-link {
  position: fixed;
  z-index: 40;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-bright);
  border-radius: 8px;
  color: var(--cravio-white);
  font-weight: 900;
  backdrop-filter: blur(12px);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.quest-back-link {
  position: fixed;
  z-index: 40;
  top: 18px;
  left: 239px;
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  color: var(--cravio-white);
  background: rgb(var(--dark-bg-rgb) / 0.5);
  border: 1px solid var(--line-bright);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 900;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

body[data-screen="splash"] .quest-back-link {
  display: inline-flex;
}

.quest-journey-link {
  display: inline-flex;
  right: 24px;
  bottom: 24px;
  min-height: 52px;
  padding: 0 24px;
  color: var(--cravio-ink);
  background: linear-gradient(135deg, var(--cravio-amber), var(--cravio-star-gold));
  box-shadow: 0 0 24px rgb(var(--amber-rgb) / 0.32);
  font-size: 16px;
}

.quest-journey-link:hover {
  transform: translateY(-1px);
  border-color: var(--cravio-amber-light);
  box-shadow: 0 0 24px rgb(var(--amber-rgb) / 0.3);
}

.quest-back-link:hover {
  transform: translateY(-1px);
  background: rgb(var(--amber-rgb) / 0.16);
  border-color: var(--cravio-amber-light);
  box-shadow: 0 0 18px rgb(var(--amber-rgb) / 0.22);
}

.brand-mark {
  color: var(--cravio-amber);
  font-family: var(--font-title);
  font-size: 12px;
}

.brand-slogan {
  color: rgb(var(--white-rgb) / 0.78);
  font-size: 13px;
  font-weight: 700;
}

.screen {
  display: none;
  min-height: 100vh;
  padding: 86px 44px 40px;
}

.screen.is-active {
  display: block;
}

.splash-screen {
  display: none;
  grid-template-columns: minmax(360px, 46vw) minmax(420px, 1fr);
  align-items: center;
  gap: 46px;
  padding: 88px 68px 48px;
}

.splash-screen.is-active {
  display: grid;
}

.splash-art-wrap {
  position: relative;
  min-height: 500px;
  animation: flyIn 900ms cubic-bezier(0.2, 0.82, 0.2, 1) both;
}

.splash-art {
  width: 100%;
  height: 560px;
  object-fit: cover;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: var(--shadow-soft), var(--shadow-glow);
}

.splash-copy {
  max-width: 620px;
}

.pixel-kicker,
.section-label {
  margin: 0 0 12px;
  color: var(--cravio-success);
  font-family: var(--font-title);
  font-size: 11px;
  line-height: 1.6;
}

h1,
h2,
h3,
p {
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  color: var(--cravio-white);
}

h1 {
  font-family: var(--font-title);
  font-size: clamp(30px, 4vw, 52px);
  line-height: 1.38;
  text-shadow: 0 0 24px rgb(var(--amber-rgb) / 0.34);
}

h2 {
  font-size: 32px;
  line-height: 1.25;
}

h3 {
  margin: 0;
}

.splash-subtitle {
  margin: 24px 0 30px;
  color: rgb(var(--white-rgb) / 0.82);
  font-size: 20px;
  line-height: 1.8;
}

.splash-footnote {
  margin: 18px 0 0;
  color: rgb(var(--white-rgb) / 0.68);
  font-weight: 700;
}

.primary-action,
.ghost-action,
.icon-action {
  min-height: 44px;
  border: 1px solid var(--line-bright);
  border-radius: 8px;
  color: var(--cravio-white);
  font-weight: 900;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.primary-action {
  padding: 0 24px;
  background: linear-gradient(135deg, var(--cravio-amber), var(--cravio-star-gold));
  color: var(--cravio-ink);
  box-shadow: 0 0 20px rgb(var(--amber-rgb) / 0.28);
}

.ghost-action {
  padding: 0 18px;
  background: rgb(var(--white-rgb) / 0.08);
}

.icon-action {
  width: 48px;
  background: rgb(var(--white-rgb) / 0.1);
  font-size: 18px;
}

.exit-action {
  min-width: 72px;
  padding: 0 18px;
  color: var(--cravio-amber-light);
  background: rgb(var(--ink-rgb) / 0.42);
}

.primary-action:hover,
.ghost-action:hover,
.icon-action:hover {
  transform: translateY(-1px);
  border-color: var(--cravio-amber-light);
  box-shadow: 0 0 22px rgb(var(--amber-rgb) / 0.28);
}

.pulse-action {
  animation: pulseGlow 1600ms ease-in-out infinite;
}

.screen-toolbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin: 0 auto 18px;
  max-width: 1180px;
}

.toolbar-actions {
  display: flex;
  gap: 12px;
}

.map-screen {
  position: relative;
  overflow: hidden;
}

.map-bg,
.leaderboard-bg,
.result-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.38;
  z-index: -1;
}

.map-bg {
  background-image: linear-gradient(rgb(var(--dark-bg-rgb) / 0.18), rgb(var(--dark-bg-rgb) / 0.24)), url("../assets/images/img-02-map-bg.png");
  background-size: cover;
  background-position: center;
}

.player-summary {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  max-width: 1180px;
  margin: 0 auto 18px;
}

.summary-item,
.mini-stat {
  padding: 12px 14px;
  background: var(--panel-bg);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.summary-item span,
.mini-stat dt {
  display: block;
  margin-bottom: 6px;
  color: rgb(var(--white-rgb) / 0.66);
  font-size: 12px;
}

.summary-item strong,
.mini-stat dd {
  margin: 0;
  color: var(--cravio-amber-light);
  font-size: 20px;
}

.map-stage {
  position: relative;
  width: min(1180px, calc(100vw - 88px));
  height: min(540px, calc(100vh - 260px));
  min-height: 430px;
  margin: 0 auto;
}

.map-path {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.map-path path {
  fill: none;
  stroke: var(--cravio-amber-light);
  stroke-width: 4;
  stroke-dasharray: 12 16;
  stroke-linecap: round;
  filter: drop-shadow(0 0 8px rgb(var(--amber-rgb) / 0.7));
  animation: dashTravel 8s linear infinite;
}

.level-planets {
  position: absolute;
  inset: 0;
}

.planet-node {
  position: absolute;
  width: 146px;
  height: 174px;
  transform: translate(-50%, -50%);
  text-align: center;
}

.planet-button {
  position: relative;
  width: 136px;
  height: 136px;
  padding: 0;
  overflow: hidden;
  border: 2px solid rgb(var(--amber-rgb) / 0.7);
  border-radius: 50%;
  background: rgb(var(--deep-blue-rgb) / 0.7);
  box-shadow: 0 0 20px rgb(var(--amber-rgb) / 0.2);
}

.planet-button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.planet-button.locked {
  border-color: rgb(var(--white-rgb) / 0.22);
  filter: grayscale(1);
  opacity: 0.55;
}

.planet-button.locked::after {
  content: "锁";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--cravio-white);
  background: rgb(var(--ink-rgb) / 0.42);
  font-weight: 900;
}

.planet-name {
  display: block;
  margin-top: 8px;
  color: var(--cravio-white);
  font-size: 14px;
  font-weight: 900;
}

.planet-stars {
  color: var(--cravio-star-gold);
  font-size: 16px;
  min-height: 20px;
}

.game-screen {
  padding-top: 28px;
}

.game-hud {
  display: grid;
  grid-template-columns: 1fr auto auto 52px;
  gap: 12px;
  align-items: center;
  max-width: 1180px;
  margin: 0 auto 18px;
}

.hud-pill {
  min-height: 48px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--panel-bg);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.hearts {
  justify-content: flex-start;
  font-size: 20px;
  color: var(--cravio-error);
}

.level-title-row {
  max-width: 1180px;
  margin: 0 auto 14px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}

.level-progress {
  min-width: 100px;
  padding: 10px 14px;
  color: var(--cravio-amber-light);
  background: rgb(var(--white-rgb) / 0.08);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  text-align: center;
  font-weight: 900;
}

.game-root {
  position: relative;
  width: min(1180px, calc(100vw - 88px));
  min-height: calc(100vh - 210px);
  margin: 0 auto;
  overflow: hidden;
  background: rgb(var(--dark-bg-rgb) / 0.52);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.level-panel {
  position: relative;
  min-height: calc(100vh - 212px);
  padding: 28px;
}

.center-stack {
  display: grid;
  place-items: center;
  gap: 22px;
}

.target-bubble {
  width: 150px;
  height: 150px;
  display: grid;
  place-items: center;
  color: var(--cravio-ink);
  background: radial-gradient(circle at 35% 28%, var(--cravio-white), var(--cravio-amber-light) 42%, var(--cravio-amber));
  border: 3px solid var(--cravio-amber-light);
  border-radius: 50%;
  font-family: var(--font-title);
  font-size: 52px;
  box-shadow: 0 0 36px rgb(var(--amber-rgb) / 0.42);
  animation: floatSoft 1800ms ease-in-out infinite;
}

.target-bubble.pop {
  animation: bubblePop 260ms ease forwards;
}

.keyboard-shell {
  width: min(100%, 960px);
  margin: 0 auto;
  padding: 18px;
  background: rgb(var(--ink-rgb) / 0.36);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin-bottom: 7px;
}

.keycap {
  min-width: 54px;
  height: 48px;
  display: grid;
  place-items: center;
  color: var(--cravio-white);
  background: linear-gradient(180deg, rgb(var(--white-rgb) / 0.12), rgb(var(--white-rgb) / 0.04));
  border: 1px solid rgb(var(--white-rgb) / 0.18);
  border-radius: 8px;
  font-family: var(--font-code);
  font-weight: 800;
  box-shadow: inset 0 -4px 0 rgb(var(--ink-rgb) / 0.3);
}

.keycap.space {
  width: 340px;
}

.keycap.wide {
  min-width: 76px;
}

.keycap.active {
  color: var(--cravio-ink);
  background: var(--cravio-amber);
  border-color: var(--cravio-amber-light);
  box-shadow: 0 0 24px rgb(var(--amber-rgb) / 0.72), inset 0 -4px 0 rgb(var(--ink-rgb) / 0.2);
  animation: keyPulse 760ms ease-in-out infinite;
}

.keycap.correct {
  color: var(--cravio-ink);
  background: var(--cravio-success);
}

.keycap.error {
  color: var(--cravio-white);
  background: var(--cravio-error);
  animation: shake 250ms ease;
}

.finger-guide {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 18px;
  align-items: center;
  width: min(100%, 820px);
  margin: 14px auto 0;
  color: rgb(var(--white-rgb) / 0.82);
}

.hand {
  display: flex;
  gap: 6px;
  align-items: end;
  justify-content: center;
  min-height: 76px;
  padding: 12px;
  background: rgb(var(--white-rgb) / 0.06);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}

.finger {
  width: 24px;
  height: 52px;
  border-radius: 8px 8px 6px 6px;
  background: rgb(var(--white-rgb) / 0.22);
}

.finger:nth-child(1),
.finger:nth-child(5) {
  height: 34px;
}

.finger:nth-child(2),
.finger:nth-child(4) {
  height: 46px;
}

.finger.active {
  background: var(--cravio-amber);
  box-shadow: 0 0 16px rgb(var(--amber-rgb) / 0.6);
}

.finger-text {
  text-align: center;
  font-weight: 900;
  color: var(--cravio-amber-light);
}

.meteor-stage {
  position: relative;
  height: calc(100vh - 256px);
  min-height: 520px;
  overflow: hidden;
}

.difficulty-screen {
  display: grid;
  align-content: center;
  gap: 24px;
}

.difficulty-copy {
  max-width: 760px;
  margin: 0 auto;
  text-align: center;
}

.difficulty-copy h3 {
  margin: 0 0 12px;
  color: var(--cravio-white);
  font-size: 32px;
}

.difficulty-copy p {
  margin: 0;
  color: rgb(var(--white-rgb) / 0.76);
  font-size: 17px;
  line-height: 1.7;
}

.difficulty-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.difficulty-card {
  min-height: 250px;
  padding: 18px;
  display: grid;
  align-content: start;
  gap: 12px;
  color: var(--cravio-white);
  background:
    radial-gradient(circle at 20% 10%, rgb(var(--amber-rgb) / 0.18), transparent 34%),
    rgb(var(--ink-rgb) / 0.46);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  text-align: left;
  box-shadow: var(--shadow-soft);
}

.difficulty-card:hover,
.difficulty-card:focus-visible {
  transform: translateY(-2px);
  border-color: var(--cravio-amber-light);
  box-shadow: 0 0 24px rgb(var(--amber-rgb) / 0.25);
  outline: none;
}

.difficulty-index {
  width: fit-content;
  padding: 6px 10px;
  color: var(--cravio-ink);
  background: var(--cravio-amber);
  border-radius: 8px;
  font-family: var(--font-title);
  font-size: 10px;
}

.difficulty-card strong {
  color: var(--cravio-white);
  font-size: 30px;
}

.difficulty-card em {
  color: var(--cravio-success);
  font-style: normal;
  font-weight: 900;
}

.difficulty-card span:not(.difficulty-index) {
  color: rgb(var(--white-rgb) / 0.78);
  line-height: 1.7;
}

.difficulty-card small {
  align-self: end;
  color: var(--cravio-amber-light);
  font-weight: 900;
}

.sublevel-screen {
  justify-items: center;
}

.sublevel-grid {
  width: 100%;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.sublevel-grid.two-col {
  max-width: 780px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.sublevel-card {
  pointer-events: none;
}

.sublevel-card.is-current {
  border-color: var(--cravio-amber-light);
  box-shadow: 0 0 28px rgb(var(--amber-rgb) / 0.24);
}

.sublevel-card.is-done {
  border-color: rgb(var(--success-rgb) / 0.58);
  background:
    radial-gradient(circle at 20% 10%, rgb(var(--success-rgb) / 0.18), transparent 34%),
    rgb(var(--ink-rgb) / 0.46);
}

.sublevel-card.is-locked {
  opacity: 0.56;
}

.sublevel-start {
  justify-self: center;
  min-width: 180px;
}

.meteor-sublevel {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgb(var(--ink-rgb) / 0.48);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}

.meteor-sublevel span {
  color: var(--cravio-ink);
  background: var(--cravio-amber);
  padding: 5px 8px;
  border-radius: 8px;
  font-weight: 900;
}

.meteor-sublevel strong {
  color: var(--cravio-white);
}

.meteor-sublevel small {
  color: rgb(var(--white-rgb) / 0.72);
}

.ground-line {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 56px;
  height: 4px;
  background: var(--cravio-error);
  box-shadow: 0 0 16px rgb(var(--error-rgb) / 0.76);
}

.meteor {
  position: absolute;
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  color: var(--cravio-white);
  background: radial-gradient(circle at 35% 30%, var(--cravio-silver), var(--cravio-deep-blue) 58%, var(--cravio-ink));
  border: 2px solid rgb(var(--amber-rgb) / 0.52);
  border-radius: 50%;
  font-family: var(--font-title);
  font-size: 26px;
  box-shadow: 0 -32px 28px rgb(var(--amber-rgb) / 0.32), 0 0 18px rgb(var(--amber-rgb) / 0.26);
}

.meteor::before {
  content: "";
  position: absolute;
  top: -84px;
  width: 20px;
  height: 86px;
  background: linear-gradient(to top, rgb(var(--amber-rgb) / 0.86), transparent);
  border-radius: 999px;
}

.combo-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 56px rgb(var(--amber-rgb) / 0.52);
  opacity: 0;
}

.combo-flash.show {
  animation: flashEdge 560ms ease;
}

.floating-callout {
  position: absolute;
  left: 50%;
  top: 18%;
  transform: translateX(-50%);
  color: var(--cravio-star-gold);
  font-family: var(--font-title);
  font-size: 22px;
  opacity: 0;
}

.floating-callout.show {
  animation: calloutFloat 900ms ease;
}

.bubble-stage {
  position: relative;
  height: calc(100vh - 258px);
  min-height: 520px;
}

.word-bubble {
  position: absolute;
  min-width: 128px;
  height: 94px;
  display: grid;
  place-items: center;
  padding: 0 18px;
  color: var(--cravio-white);
  background: radial-gradient(circle at 35% 22%, rgb(var(--white-rgb) / 0.5), rgb(var(--success-rgb) / 0.18) 44%, rgb(var(--purple-rgb) / 0.16));
  border: 2px solid rgb(var(--success-rgb) / 0.56);
  border-radius: 999px;
  box-shadow: 0 0 28px rgb(var(--success-rgb) / 0.22);
  font-family: var(--font-code);
  font-size: 24px;
  font-weight: 900;
}

.word-bubble.locked {
  border-color: var(--cravio-amber);
  box-shadow: 0 0 28px rgb(var(--amber-rgb) / 0.45);
}

.word-bubble .done-char {
  color: var(--cravio-success);
}

.word-bubble.shake {
  animation: shake 260ms ease;
}

.race-layout {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 22px;
}

.race-track {
  position: relative;
  min-height: 350px;
  margin: 20px 0;
  border-top: 2px dashed rgb(var(--white-rgb) / 0.18);
  border-bottom: 2px dashed rgb(var(--white-rgb) / 0.18);
}

.track-line {
  position: absolute;
  left: 4%;
  right: 4%;
  height: 110px;
  border-bottom: 3px solid rgb(var(--amber-rgb) / 0.45);
}

.track-line.player-lane {
  top: 150px;
}

.track-line.ai-lane {
  top: 28px;
  border-color: rgb(var(--success-rgb) / 0.42);
}

.ship {
  position: absolute;
  width: 92px;
  height: 92px;
  object-fit: contain;
  transform: translateX(0);
  transition: left 160ms linear;
  filter: drop-shadow(0 0 14px rgb(var(--amber-rgb) / 0.45));
}

.ship.player {
  top: 166px;
}

.ship.ai {
  top: 44px;
  filter: drop-shadow(0 0 14px rgb(var(--success-rgb) / 0.45));
}

.phrase-card,
.code-workbench,
.ai-chat-panel {
  padding: 20px;
  background: rgb(var(--ink-rgb) / 0.42);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}

.phrase-text {
  min-height: 84px;
  font-family: var(--font-code);
  font-size: 26px;
  line-height: 1.8;
}

.char-ok {
  color: var(--cravio-amber);
}

.char-current {
  color: var(--cravio-white);
  border-bottom: 3px solid var(--cravio-amber-light);
  animation: blink 800ms ease-in-out infinite;
}

.char-wait {
  color: rgb(var(--white-rgb) / 0.45);
}

.char-bad {
  color: var(--cravio-error);
}

.stats-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.stats-chip {
  padding: 8px 12px;
  color: var(--cravio-amber-light);
  background: rgb(var(--white-rgb) / 0.08);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  font-weight: 900;
}

.code-workbench {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}

.code-pane {
  min-height: 330px;
  overflow: auto;
  background: var(--cravio-ink);
  border: 1px solid rgb(var(--white-rgb) / 0.12);
  border-radius: 8px;
}

.code-pane-title {
  padding: 10px 12px;
  color: var(--cravio-amber-light);
  background: rgb(var(--white-rgb) / 0.06);
  font-weight: 900;
}

.code-lines {
  margin: 0;
  padding: 14px;
  color: var(--cravio-white);
  font-family: var(--font-code);
  font-size: 16px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.line-no {
  display: inline-block;
  min-width: 28px;
  margin-right: 12px;
  color: rgb(var(--white-rgb) / 0.35);
  user-select: none;
}

.token-string {
  color: var(--cravio-success);
}

.token-keyword {
  color: var(--cravio-purple);
}

.token-number {
  color: var(--cravio-star-gold);
}

.typing-caret {
  display: inline-block;
  width: 9px;
  height: 19px;
  vertical-align: middle;
  background: var(--cravio-amber);
  animation: blink 820ms ease infinite;
}

.run-output {
  min-height: 50px;
  margin-top: 12px;
  padding: 12px;
  color: var(--cravio-success);
  background: rgb(var(--ink-rgb) / 0.46);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  font-family: var(--font-code);
}

.ai-chat-panel {
  min-height: calc(100vh - 246px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 16px;
}

.ai-task {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 16px;
  background: rgb(var(--white-rgb) / 0.08);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}

.timer {
  color: var(--cravio-amber-light);
  font-family: var(--font-title);
  font-size: 18px;
}

.chat-stream {
  display: grid;
  align-content: start;
  gap: 12px;
  overflow: auto;
}

.chat-message {
  max-width: 76%;
  padding: 14px 16px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  line-height: 1.7;
}

.chat-message.user {
  justify-self: end;
  background: rgb(var(--amber-rgb) / 0.16);
}

.chat-message.ai {
  justify-self: start;
  background: rgb(var(--success-rgb) / 0.13);
}

.prompt-input {
  min-height: 78px;
  padding: 16px;
  color: var(--cravio-white);
  background: var(--cravio-ink);
  border: 1px solid rgb(var(--amber-rgb) / 0.48);
  border-radius: 8px;
  font-family: var(--font-code);
  font-size: 20px;
}

.prompt-input .ghost {
  color: rgb(var(--white-rgb) / 0.35);
}

.result-screen {
  position: relative;
  display: none;
  place-items: center;
}

.result-screen.is-active {
  display: grid;
}

.result-panel {
  position: relative;
  width: min(720px, calc(100vw - 90px));
  padding: 30px;
  background: rgb(var(--dark-bg-rgb) / 0.82);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: var(--shadow-soft), var(--shadow-glow);
  text-align: center;
}

.big-stars {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--cravio-star-gold);
  font-size: 46px;
}

.big-stars span {
  display: inline-block;
  animation: starDrop 540ms ease both;
}

.result-stats,
.mini-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 12px;
  margin: 20px 0;
}

.result-stats div,
.mini-stats div {
  padding: 12px;
  background: rgb(var(--white-rgb) / 0.08);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}

.result-stats dt,
.mini-stats dt {
  margin-bottom: 6px;
  color: rgb(var(--white-rgb) / 0.62);
}

.result-stats dd,
.mini-stats dd {
  margin: 0;
  color: var(--cravio-amber-light);
  font-size: 20px;
  font-weight: 900;
}

.result-message {
  min-height: 42px;
  color: var(--cravio-white);
  font-size: 18px;
  line-height: 1.7;
}

.result-actions,
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 22px;
}

.modal-actions.stacked {
  flex-direction: column;
}

.leaderboard-screen {
  position: relative;
}

.leaderboard-card {
  position: relative;
  max-width: 1100px;
  margin: 40px auto 24px;
  overflow: hidden;
  background: rgb(var(--dark-bg-rgb) / 0.78);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 16px 18px;
  border-bottom: 1px solid rgb(var(--white-rgb) / 0.1);
  text-align: left;
}

th {
  color: var(--cravio-amber-light);
  font-size: 13px;
}

tbody tr:hover {
  background: rgb(var(--amber-rgb) / 0.12);
}

.powered {
  text-align: center;
  color: rgb(var(--white-rgb) / 0.72);
  font-weight: 800;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  place-items: center;
  padding: 28px;
  background: rgb(var(--ink-rgb) / 0.72);
  backdrop-filter: blur(12px);
}

.modal.is-open {
  display: grid;
}

.modal-panel {
  width: min(520px, 100%);
  padding: 26px;
  background: var(--panel-strong);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.field-label {
  display: block;
  margin: 18px 0 8px;
  color: rgb(var(--white-rgb) / 0.76);
  font-weight: 900;
}

.text-field {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  color: var(--cravio-white);
  background: rgb(var(--ink-rgb) / 0.48);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  outline: none;
}

.text-field:focus {
  border-color: var(--cravio-amber);
  box-shadow: 0 0 0 3px rgb(var(--amber-rgb) / 0.18);
}

.color-options,
.existing-players {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.color-swatch {
  width: 46px;
  height: 46px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: var(--cravio-amber);
}

.color-swatch.color-teal {
  background: var(--cravio-success);
}

.color-swatch.color-purple {
  background: var(--cravio-purple);
}

.color-swatch.is-selected {
  border-color: var(--cravio-white);
  box-shadow: 0 0 0 3px rgb(var(--amber-rgb) / 0.28);
}

.player-chip {
  min-height: 38px;
  padding: 0 12px;
  color: var(--cravio-white);
  background: rgb(var(--white-rgb) / 0.08);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}

.level-modal-panel {
  text-align: center;
}

.level-modal-img {
  width: 164px;
  height: 164px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid var(--line-bright);
  box-shadow: var(--shadow-glow);
}

.modal-copy {
  color: rgb(var(--white-rgb) / 0.76);
  line-height: 1.8;
}

.empty-state {
  padding: 28px;
  text-align: center;
  color: rgb(var(--white-rgb) / 0.72);
}

.screen-shake {
  animation: shake 260ms ease;
}

.hidden {
  display: none !important;
}

@keyframes flyIn {
  from {
    opacity: 0;
    transform: scale(0.74) translateY(30px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes pulseGlow {
  0%,
  100% {
    box-shadow: 0 0 16px rgb(var(--amber-rgb) / 0.28);
  }
  50% {
    box-shadow: 0 0 34px rgb(var(--amber-rgb) / 0.72);
  }
}

@keyframes dashTravel {
  to {
    stroke-dashoffset: -120;
  }
}

@keyframes floatSoft {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-12px);
  }
}

@keyframes bubblePop {
  to {
    opacity: 0;
    transform: scale(1.35);
  }
}

@keyframes keyPulse {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-7px);
  }
  75% {
    transform: translateX(7px);
  }
}

@keyframes flashEdge {
  0% {
    opacity: 0;
  }
  30% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes calloutFloat {
  0% {
    opacity: 0;
    transform: translate(-50%, 10px) scale(0.86);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -32px) scale(1.08);
  }
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.32;
  }
}

@keyframes starDrop {
  from {
    opacity: 0;
    transform: translateY(-24px) scale(0.7);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 760px) {
  .sublevel-grid.two-col {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 760px) {
  .game-screen {
    padding-top: 22px;
  }

  .game-hud {
    margin-bottom: 10px;
  }

  .level-title-row {
    margin-bottom: 10px;
  }

  .level-panel {
    padding: 18px;
  }

  .target-bubble {
    width: 120px;
    height: 120px;
    font-size: 42px;
  }

  .center-stack {
    gap: 16px;
  }

  .keyboard-shell {
    padding: 12px;
  }

  .keyboard-row {
    gap: 6px;
    margin-bottom: 6px;
  }

  .keycap {
    min-width: 48px;
    height: 40px;
  }

  .keycap.space {
    width: 300px;
  }

  .finger-guide {
    margin-top: 10px;
  }

  .hand {
    min-height: 56px;
    padding: 8px;
  }

  .finger {
    width: 20px;
    height: 38px;
  }

  .finger:nth-child(1),
  .finger:nth-child(5) {
    height: 27px;
  }

  .finger:nth-child(2),
  .finger:nth-child(4) {
    height: 34px;
  }
}
