@font-face {
  font-family: "Nunito";
  src: url("./assets/fonts/nunito-variable.ttf") format("truetype");
  font-weight: 200 1000;
  font-display: swap;
}

@font-face {
  font-family: "Belanosima";
  src: url("./assets/fonts/belanosima-bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --ink: #fff8e8;
  --muted: rgba(255, 255, 255, .72);
  --panel: rgba(30, 28, 71, .9);
  --panel-light: rgba(255, 255, 255, .1);
  --purple: #6d46dc;
  --purple-dark: #352077;
  --gold: #ffc640;
  --green: #7edc4c;
  --red: #ff7185;
  --body: "Nunito", system-ui, sans-serif;
  --display: "Belanosima", "Nunito", system-ui, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--body);
  color: var(--ink);
  background:
    radial-gradient(circle at 80% 12%, rgba(110, 70, 220, .34), transparent 30%),
    radial-gradient(circle at 15% 25%, rgba(54, 112, 214, .25), transparent 28%),
    linear-gradient(180deg, #151950 0%, #080b2c 72%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .42;
  background-image:
    radial-gradient(circle, #fff 0 1px, transparent 1.4px),
    radial-gradient(circle, #ffd45a 0 1px, transparent 1.5px);
  background-size: 62px 62px, 107px 107px;
  background-position: 8px 11px, 42px 54px;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.app-shell {
  width: min(100%, 520px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  position: relative;
  z-index: 1;
}

.app-header {
  min-height: 66px;
  display: grid;
  grid-template-columns: 56px 1fr 56px;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.back-link, .header-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 3px solid rgba(255, 255, 255, .7);
  border-radius: 18px;
  background: linear-gradient(180deg, #fff, #ede9fa);
  color: #4e37a4;
  text-decoration: none;
  font-family: var(--display);
  font-size: 27px;
  box-shadow: 0 10px 18px rgba(0, 0, 0, .22), inset 0 -4px 0 rgba(134, 116, 183, .28);
}

.header-mark { color: #8c5600; font-size: 23px; }

.brand { text-align: center; line-height: 1; }
.brand-kicker { display: block; color: #cabdff; font-size: 13px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.brand strong { display: block; margin-top: 4px; font-family: var(--display); font-size: 28px; color: var(--gold); }

.card {
  border: 2px solid rgba(255, 255, 255, .14);
  border-radius: 30px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .11), rgba(255, 255, 255, .045)), var(--panel);
  box-shadow: 0 22px 42px rgba(0, 0, 0, .28), inset 0 2px 0 rgba(255, 255, 255, .1);
}

.home-card { padding: 28px 22px 22px; }
.eyebrow { margin: 0 0 7px; color: #cabdff; font-size: 13px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1, h2 { font-family: var(--display); }
h1 { margin-bottom: 10px; font-size: clamp(37px, 10vw, 51px); line-height: .95; letter-spacing: -.025em; color: #fff; }
.intro { margin-bottom: 22px; color: var(--muted); font-size: 17px; line-height: 1.48; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin: 0 0 20px;
}

.stat {
  min-width: 0;
  padding: 13px 8px 12px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 18px;
  background: rgba(255, 255, 255, .065);
  text-align: center;
}

.stat strong { display: block; font-family: var(--display); font-size: 27px; color: var(--gold); }
.stat span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; font-weight: 800; }

.primary-btn, .secondary-btn, .help-btn, .stop-btn {
  border: 0;
  cursor: pointer;
  font-weight: 900;
}

.primary-btn {
  width: 100%;
  min-height: 70px;
  padding: 12px 20px;
  border: 3px solid #ffeb9f;
  border-radius: 24px;
  background: linear-gradient(180deg, #ffdf64, #f4a71b);
  color: #673a00;
  font-family: var(--display);
  font-size: 27px;
  box-shadow: 0 12px 20px rgba(0, 0, 0, .26), inset 0 3px 0 rgba(255, 255, 255, .38), inset 0 -5px 0 rgba(156, 87, 0, .22);
}

.primary-btn:active, .key:active { transform: translateY(2px); }
.session-note { margin: 12px 0 0; color: var(--muted); font-size: 13px; text-align: center; }
.refresh-note { margin: 13px 0 0; padding: 9px 12px; border-radius: 14px; background: rgba(255, 198, 64, .1); color: #ffe39a; font-size: 13px; font-weight: 800; text-align: center; }
.storage-warning { margin: 16px 0 0; padding: 11px 13px; border-radius: 14px; background: rgba(255, 113, 133, .13); color: #ffd6dc; font-size: 13px; }

.table-overview { margin-top: 18px; padding: 20px; }
.section-title { margin-bottom: 8px; font-size: 24px; color: #fff; }
.table-legend { display: flex; gap: 14px; margin-bottom: 14px; color: var(--muted); font-size: 11px; font-weight: 900; }
.table-legend span { display: inline-flex; align-items: center; gap: 5px; }
.table-legend i { width: 9px; height: 9px; border-radius: 50%; }
.legend-building { background: #8664f0; }
.legend-fluent { background: var(--green); }
.table-grid { display: grid; gap: 8px; }
.table-row { display: grid; grid-template-columns: 74px 1fr 64px; align-items: center; gap: 10px; }
.table-label { font-weight: 900; }
.table-track { position: relative; height: 11px; overflow: hidden; border-radius: 999px; background: rgba(255, 255, 255, .1); }
.table-fill { position: absolute; inset: 0 auto 0 0; border-radius: inherit; transition: width .25s ease; }
.table-fill-building { background: linear-gradient(90deg, #714fe0, #9472f4); }
.table-fill-fluent { z-index: 1; background: linear-gradient(90deg, #5bbf3d, #8be45a); }
.table-count { color: var(--muted); text-align: right; line-height: 1.05; }
.table-count strong, .table-count small { display: block; white-space: nowrap; }
.table-count strong { color: #d8ffc4; font-size: 11px; font-weight: 900; }
.table-count small { margin-top: 3px; font-size: 9px; font-weight: 800; }

.practice-card { min-height: calc(100svh - 112px); padding: 20px 18px 18px; display: flex; flex-direction: column; }
.practice-top { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; }
.progress-copy { font-size: 14px; font-weight: 900; color: #d8ceff; }
.progress-track { height: 9px; margin-top: 8px; border-radius: 999px; background: rgba(255, 255, 255, .11); overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #7a54e6, #ffd052); border-radius: inherit; transition: width .25s ease; }
.stop-btn { padding: 9px 12px; border-radius: 14px; background: rgba(255, 255, 255, .09); color: #ded7f8; }

.sum-area { flex: 1; min-height: 235px; display: grid; align-content: center; justify-items: center; padding: 26px 0 18px; }
.sum { font-family: var(--display); font-size: clamp(57px, 18vw, 86px); line-height: 1; letter-spacing: -.03em; color: #fff; text-shadow: 0 5px 0 rgba(48, 26, 104, .75); }
.answer-display {
  min-width: 150px;
  min-height: 70px;
  margin-top: 20px;
  padding: 7px 24px;
  display: grid;
  place-items: center;
  border: 3px solid rgba(255, 255, 255, .52);
  border-radius: 22px;
  background: rgba(255, 255, 255, .09);
  font-family: var(--display);
  font-size: 43px;
  color: var(--gold);
}
.answer-display.is-empty { color: rgba(255, 255, 255, .28); }
.answer-display.is-wrong { border-color: var(--red); animation: shake .28s ease; }
.answer-display.is-correct { border-color: var(--green); color: var(--green); }
@keyframes shake { 0%, 100% { transform: translateX(0); } 30% { transform: translateX(-8px); } 70% { transform: translateX(8px); } }

.feedback { min-height: 48px; margin: 12px 0 4px; text-align: center; color: var(--muted); font-weight: 800; line-height: 1.35; }
.feedback.is-good { color: #baf3a0; }
.feedback.is-help { color: #ffe19a; }
.hint-card { width: 100%; margin: 6px 0 10px; padding: 13px 15px; border-radius: 18px; background: rgba(255, 199, 64, .1); border: 1px solid rgba(255, 211, 102, .27); }
.hint-card strong { display: block; margin-bottom: 5px; color: #ffdd79; }
.hint-steps { margin: 0; padding-left: 20px; color: #fff4d3; font-size: 14px; }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.key {
  min-height: 58px;
  border: 2px solid rgba(255, 255, 255, .16);
  border-radius: 19px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .18), rgba(255, 255, 255, .08));
  color: #fff;
  font-family: var(--display);
  font-size: 27px;
  cursor: pointer;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .15);
}
.key.is-submit { background: linear-gradient(180deg, #8be051, #4baa2e); border-color: #b9f495; color: #143b0d; }
.key:disabled { opacity: .45; cursor: default; }
.help-btn { width: 100%; margin-top: 10px; padding: 12px; border-radius: 16px; background: transparent; color: #cfc5f7; }

.summary-card { padding: 30px 22px 24px; text-align: center; }
.summary-icon { width: 82px; height: 82px; margin: 0 auto 14px; display: grid; place-items: center; border: 4px solid #ffeb9f; border-radius: 50%; background: linear-gradient(180deg, #ffdc5a, #efa21c); font-size: 38px; box-shadow: 0 14px 25px rgba(0, 0, 0, .25); }
.summary-card h1 { font-size: 44px; }
.summary-card .stats { margin-top: 20px; }
.new-fluent { margin: 18px 0; padding: 14px; border-radius: 17px; background: rgba(126, 220, 76, .12); color: #c9f7b0; }
.summary-actions { display: grid; gap: 10px; }
.secondary-btn { min-height: 52px; border-radius: 18px; background: rgba(255, 255, 255, .09); color: #fff; }

@media (max-height: 760px) {
  .app-header { margin-bottom: 10px; min-height: 58px; }
  .back-link, .header-mark { width: 48px; height: 48px; border-radius: 16px; }
  .practice-card { min-height: calc(100svh - 92px); padding-top: 15px; }
  .sum-area { min-height: 180px; padding: 16px 0 8px; }
  .sum { font-size: clamp(52px, 15vw, 72px); }
  .answer-display { min-height: 58px; margin-top: 12px; font-size: 36px; }
  .key { min-height: 49px; }
  .feedback { min-height: 38px; margin-top: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
