@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;700;900&family=Inter:wght@400;500;600;700&display=swap');

:root {
  color-scheme: light;
  --bg: #efe7db;
  --bg-accent: #e3d6c1;
  --surface: #f8f4ec;
  --surface-2: #eee4d2;
  --surface-3: #fffdfa;
  --text: #24180e;
  --muted: #7b6f5c;
  --border: #c9b89d;
  --accent: #8f3d12;
  --accent-2: #c98e12;
  --success: #2c6a46;
  --danger: #8f2626;
  --shadow-1: 0 18px 40px rgba(36, 24, 14, 0.10);
  --shadow-2: 0 10px 24px rgba(36, 24, 14, 0.08);
  --ring: rgba(143, 61, 18, 0.22);
}

body.dark {
  color-scheme: dark;
  --bg: #13100d;
  --bg-accent: #1a1612;
  --surface: #1d1915;
  --surface-2: #262019;
  --surface-3: #15110e;
  --text: #f3ebe1;
  --muted: #b9aa94;
  --border: #4c4031;
  --accent: #d66e35;
  --accent-2: #e0a126;
  --success: #72d19a;
  --danger: #ff8f8f;
  --shadow-1: 0 18px 40px rgba(0, 0, 0, 0.34);
  --shadow-2: 0 10px 24px rgba(0, 0, 0, 0.24);
  --ring: rgba(214, 110, 53, 0.25);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(201, 142, 18, 0.08), transparent 32%),
    linear-gradient(180deg, var(--bg), var(--bg-accent));
  transition: background-color 0.2s ease, color 0.2s ease;
  padding: 24px;
}

.shell {
  width: min(100%, 840px);
  margin: 0 auto;
}

.topbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-2);
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  transform: translateY(-1px);
  border-color: var(--accent);
  outline: none;
}

.page {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, var(--surface), var(--surface-3));
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow-1);
  padding: 28px;
}

.page::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(120deg, rgba(201, 142, 18, 0.06), transparent 22%, transparent 78%, rgba(201, 142, 18, 0.05));
}

.header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 20px;
  position: relative;
  z-index: 1;
}

.title-wrap {
  min-width: 0;
}

h1 {
  margin: 0 0 6px;
  font-family: 'Playfair Display', serif;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1;
  letter-spacing: -0.03em;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.4;
  max-width: 40rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
  position: relative;
  z-index: 1;
}

.stat-box {
  background: linear-gradient(180deg, var(--surface-2), color-mix(in srgb, var(--surface-2) 84%, transparent));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px 16px;
  min-width: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}

.stat-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.stat-value {
  display: block;
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  line-height: 1;
}

.stat-value.score-up   { animation: scoreUp 0.35s ease; color: var(--success); }
.stat-value.score-down { animation: scoreDown 0.35s ease; color: var(--danger); }

.history-section { display: none }

@keyframes scoreUp {
  0% { transform: scale(1.16); }
  100% { transform: scale(1); }
}

@keyframes scoreDown {
  0% { transform: scale(1.12) rotate(-2deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.progress-section {
  margin-bottom: 22px;
  position: relative;
  z-index: 1;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.progress-track {
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.35s ease;
}

.input-area {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  margin-bottom: 10px;
  position: relative;
  z-index: 1;
}

.input-wrap {
  position: relative;
}

input[type="text"] {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-3);
  color: var(--text);
  padding: 15px 16px;
  font: 600 1.05rem/1.2 'Inter', system-ui, sans-serif;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input[type="text"]::placeholder {
  color: var(--muted);
  font-style: italic;
  font-weight: 500;
}

input[type="text"]:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--ring);
}

.btn {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 18px;
  background: var(--surface-2);
  color: var(--text);
  font: 700 0.98rem/1 'Inter', system-ui, sans-serif;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:hover,
.btn:focus-visible {
  transform: translateY(-1px);
  outline: none;
}

#submit-btn {
  min-width: 120px;
  background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 78%, black));
  border-color: transparent;
  color: #fff7ef;
  box-shadow: 0 10px 20px rgba(143, 61, 18, 0.22);
}

body.dark #submit-btn {
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.28);
}

#submit-btn:disabled {
  cursor: wait;
  opacity: 0.7;
  transform: none;
}

.feedback {
  margin: 1.5rem;
}

.feedback.good { color: var(--success); }
.feedback.bad  { color: var(--danger); }
.feedback.info { color: var(--muted); }

.alphabet-strip {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  position: relative;
  z-index: 1;
}

.alpha-label {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.alpha-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(48px, 1fr));
  gap: 10px;
}

.alpha-cell {
  aspect-ratio: 1;
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  font-weight: 700;
  user-select: none;
}

.alpha-cell.used {
  background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 72%, black));
  border-color: transparent;
  color: #fff7ef;
}

.count-badge {
  position: absolute;
  right: 7px;
  bottom: 6px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  color: rgba(255, 247, 239, 0.88);
  display: none;
}

.alpha-cell.used .count-badge {
  display: block;
}

.toast {
  position: fixed;
  left: 50%;
  top: 24px;
  transform: translate(-50%, -120%);
  max-width: min(calc(100vw - 32px), 440px);
  background: var(--text);
  color: var(--surface);
  border-radius: 16px;
  padding: 14px 18px;
  box-shadow: var(--shadow-1);
  font-weight: 700;
  text-align: center;
  z-index: 1000;
  transition: transform 0.28s ease;
}

.toast.show {
  transform: translate(-50%, 0);
}


@media (max-width: 700px) {
  body {
    padding: 14px;
  }

  .page {
    padding: 22px 18px;
    border-radius: 20px;
  }

  .header {
    flex-direction: column;
    margin-bottom: 22px;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .input-area {
    grid-template-columns: 1fr;
  }

  #submit-btn {
    width: 100%;
  }

  .progress-label {
    flex-direction: column;
    gap: 4px;
  }
}
