:root {
  --bg: #0c0c0c;
  --panel: rgba(17, 17, 17, 0.78);
  --panel-strong: rgba(29, 29, 29, 0.9);
  --text: #fff8f1;
  --muted: #e8d7ca;
  --border: rgba(255, 255, 255, 0.12);
  --accent: #f28c28;
  --accent-soft: rgba(242, 140, 40, 0.2);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
}

body[data-theme="light"] {
  --bg: #ffffff;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-strong: rgba(255, 255, 255, 0.98);
  --text: #16110d;
  --muted: #6f5742;
  --border: rgba(242, 140, 40, 0.18);
  --accent: #ef6c00;
  --accent-soft: rgba(239, 108, 0, 0.14);
  --shadow: 0 20px 56px rgba(239, 108, 0, 0.12);
}

@font-face {
  font-family: "Straight Feather v2";
  src: url("/static/fonts/Straight_Feather_v2.ttf") format("truetype");
}

@font-face {
  font-family: "Calligraphic Avali Scratch";
  src: url("/static/fonts/CalligraphicAvaliScratch-Regular.ttf") format("truetype");
}

@font-face {
  font-family: "Roundfeather";
  src: url("/static/fonts/Roundfeather.ttf") format("truetype");
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, rgba(242, 140, 40, 0.16), transparent 32%),
    linear-gradient(160deg, var(--bg) 0%, #111111 48%, var(--bg) 100%);
  color: var(--text);
  transition: background 220ms ease, color 220ms ease;
}

body[data-theme="light"] {
  background:
    radial-gradient(circle at top, rgba(239, 108, 0, 0.16), transparent 34%),
    linear-gradient(180deg, #ffffff 0%, #fff8f1 45%, #ffffff 100%);
}

.page-shell {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  padding: 40px 24px 56px;
}

.sky {
  position: absolute;
  width: 26rem;
  height: 26rem;
  border-radius: 50%;
  filter: blur(24px);
  opacity: 0.4;
  pointer-events: none;
  animation: drift 12s ease-in-out infinite;
}

.sky-left {
  top: -8rem;
  left: -6rem;
  background: radial-gradient(circle, rgba(242, 140, 40, 0.48), transparent 70%);
}

.sky-right {
  right: -7rem;
  bottom: 6rem;
  animation-delay: -4s;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.18), transparent 68%);
}

.hero,
.layout,
.site-footer {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.9fr);
  gap: 24px;
  align-items: start;
  margin-bottom: 28px;
}

.eyebrow,
.stats-title,
.card-topline,
.subhead,
label span,
.summary-item span {
  letter-spacing: 0.04em;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.82rem;
}

h1 {
  margin: 0;
  font-size: clamp(2.4rem, 5vw, 4.5rem);
  line-height: 0.98;
  max-width: 14ch;
}

.subhead {
  max-width: 58ch;
  color: var(--muted);
  font-size: 1.05rem;
  margin-top: 14px;
}

.control-panel,
.flashcard,
.stats-card {
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.control-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 16px;
  padding: 18px;
  border-radius: 22px;
  max-width: 430px;
  justify-self: end;
  align-self: start;
}

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.92rem;
}

.switch-row {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.switch-control {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.switch-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-slider {
  position: relative;
  width: 54px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-strong);
  transition: background 160ms ease, border-color 160ms ease;
}

.switch-slider::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: transform 160ms ease;
}

.switch-control input:checked + .switch-slider {
  background: linear-gradient(135deg, rgba(242, 140, 40, 0.35), rgba(242, 140, 40, 0.16));
  border-color: rgba(242, 140, 40, 0.6);
}

.switch-control input:checked + .switch-slider::after {
  transform: translateX(24px);
}

.switch-control input:focus-visible + .switch-slider {
  outline: 2px solid rgba(242, 140, 40, 0.38);
  outline-offset: 2px;
}

select,
input,
button {
  font: inherit;
}

select,
input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel-strong);
  color: var(--text);
  padding: 12px 14px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(280px, 0.9fr);
  gap: 24px;
}

.deck-bar,
.utility-row,
.choices,
.summary-list {
  display: grid;
  gap: 12px;
}

.deck-bar {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.utility-row {
  grid-template-columns: 1fr auto;
  align-items: end;
  margin-bottom: 16px;
}

.level-control {
  max-width: 220px;
}

.flashcard {
  position: relative;
  border-radius: 28px;
  padding: 28px;
  min-height: 490px;
  overflow: hidden;
}

.card-glow {
  position: absolute;
  inset: auto -10% -28% auto;
  width: 17rem;
  height: 17rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(242, 140, 40, 0.28), transparent 72%);
  pointer-events: none;
}

.card-topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.9rem;
  text-transform: uppercase;
}

.prompt {
  margin: 26px 0 32px;
  line-height: 1.15;
  font-size: clamp(3rem, 6vw, 5.3rem);
  min-height: 10rem;
  display: flex;
  align-items: center;
  animation: revealCard 360ms ease;
}

.avali-font {
  font-family: var(--avali-font, "Straight Feather v2"), "Trebuchet MS", sans-serif;
}

.card-ruby-stack {
  position: relative;
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  padding-top: clamp(2.1rem, 4vw, 3rem);
  isolation: isolate;
}

.card-ruby-stack:focus-visible {
  outline: 2px solid rgba(242, 140, 40, 0.38);
  outline-offset: 8px;
}

.ruby-base {
  position: relative;
  z-index: 2;
  display: inline-block;
  pointer-events: none;
}

.ruby-hint-layer {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 1;
  display: inline-block;
  min-width: max-content;
  transform: translateX(-50%);
  font-family: "Noto Sans", "Trebuchet MS", sans-serif;
  font-size: clamp(1rem, 2vw, 1.35rem);
  font-style: normal;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: rgba(255, 248, 241, 0.08);
  filter: blur(14px);
  opacity: 0;
  text-shadow:
    0 0 28px rgba(255, 248, 241, 0.98),
    0 0 64px rgba(255, 248, 241, 0.72),
    0 0 108px rgba(255, 248, 241, 0.46);
  user-select: none;
  transition: opacity 180ms ease, color 180ms ease, filter 180ms ease;
  pointer-events: none;
}

.hint-enabled .ruby-hint-layer {
  color: rgba(255, 248, 241, 0.92);
  filter: blur(10px);
  opacity: 1;
}

.hint-enabled .card-ruby-stack {
  cursor: pointer;
}

.hint-revealed .ruby-hint-layer {
  color: rgba(255, 248, 241, 0.42);
  filter: blur(0);
  text-shadow:
    0 0 10px rgba(255, 248, 241, 0.2),
    0 0 24px rgba(255, 248, 241, 0.12);
}

.choices[hidden],
.typing-form[hidden] {
  display: none;
}

.choices {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.typing-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

.feedback {
  min-height: 1.5rem;
  margin-top: 18px;
  color: var(--muted);
}

.feedback.correct {
  color: #f7b267;
}

.feedback.incorrect {
  color: #ffb2a2;
}

.chip-button,
.deck-button,
.choice-button,
.secondary-button,
.primary-button {
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  color: var(--text);
  background: var(--panel-strong);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.chip-button,
.secondary-button,
.primary-button {
  padding: 12px 14px;
}

.deck-button,
.choice-button {
  padding: 15px 16px;
}

.deck-button.active,
.choice-button:hover,
.chip-button:hover,
.secondary-button:hover,
.primary-button:hover,
.choice-button:focus-visible,
.primary-button:focus-visible,
.chip-button:focus-visible {
  border-color: rgba(242, 140, 40, 0.6);
  transform: translateY(-1px);
}

.deck-button.active,
.primary-button {
  background: linear-gradient(135deg, rgba(242, 140, 40, 0.22), rgba(242, 140, 40, 0.12));
}

.stats-panel {
  display: grid;
  gap: 18px;
}

.site-footer {
  margin-top: 24px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer a {
  color: var(--accent);
  text-decoration: none;
}

.site-footer a:hover,
.site-footer a:focus-visible {
  text-decoration: underline;
}

.stats-card {
  border-radius: 24px;
  padding: 20px;
}

.stats-title {
  margin: 0 0 16px;
  color: var(--accent);
  text-transform: uppercase;
  font-size: 0.82rem;
  font-weight: 700;
}

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

.stats-grid div,
.summary-item {
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
}

.stats-grid span,
.summary-item span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  margin-bottom: 6px;
}

.stats-grid strong,
.summary-item strong {
  font-size: 1.4rem;
}

.summary-list {
  grid-template-columns: 1fr;
}

.summary-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

@keyframes revealCard {
  from {
    transform: translateY(10px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes drift {
  0%, 100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  50% {
    transform: translate3d(0, 16px, 0) scale(1.05);
  }
}

@media (max-width: 960px) {
  .hero,
  .layout {
    grid-template-columns: 1fr;
  }

  .deck-bar,
  .choices,
  .control-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .control-panel {
    max-width: none;
    justify-self: stretch;
  }
}

@media (max-width: 640px) {
  .page-shell {
    padding: 24px 14px 36px;
  }

  .deck-bar,
  .choices,
  .control-panel,
  .typing-form,
  .utility-row {
    grid-template-columns: 1fr;
  }

  .flashcard {
    min-height: 420px;
    padding: 22px;
  }

  .prompt {
    margin-top: 28px;
    min-height: 6rem;
  }
}
