:root {
  --surface: #ffffff;
  --page: #faf9f5;
  --border: rgba(0, 0, 0, 0.12);
  --border-strong: rgba(0, 0, 0, 0.24);
  --text: #1a1a18;
  --text-muted: #6b6b66;
  --accent: #185fa5;
  --accent-bg: #e6f1fb;
  --accent-border: #85b7eb;
  --danger: #a32d2d;
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface: #2a2a28;
    --page: #1c1c1a;
    --border: rgba(255, 255, 255, 0.14);
    --border-strong: rgba(255, 255, 255, 0.28);
    --text: #f0efe9;
    --text-muted: #a5a49e;
    --accent: #85b7eb;
    --accent-bg: #0c447c;
    --accent-border: #378add;
    --danger: #f09595;
  }
}

* { box-sizing: border-box; }

html {
  height: 100%;
  overscroll-behavior-y: contain;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  background: var(--page);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overscroll-behavior-y: contain;
  -webkit-text-size-adjust: 100%;
}

.app { width: 100%; max-width: 480px; }

.logo {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 0 1.25rem;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

.label {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 6px;
}

.row { display: flex; gap: 8px; margin-bottom: 1rem; }
.row.controls { margin-top: 1rem; margin-bottom: 0; }

#mode-row { margin-bottom: 1.5rem; }
#mode-row .mode,
#style-row .style-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}
#mode-row .mode.active,
#style-row .style-btn.active {
  background: var(--accent-bg);
  color: var(--accent);
  border-color: var(--accent-border);
}

#difficulty-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
#difficulty-row .diff {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.timer-select {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.timer-value {
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.timer-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 44px;
  margin: 0 0 1.25rem;
  background: transparent;
  touch-action: manipulation;
}

.timer-slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: var(--border-strong);
}

.timer-slider::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: var(--border-strong);
}

.timer-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  margin-top: -10px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--accent-border);
  cursor: pointer;
}

.timer-slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--accent-border);
  cursor: pointer;
}

button {
  font: inherit;
  cursor: pointer;
  color: var(--text);
  background: transparent;
  border: 0.5px solid var(--border-strong);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  min-height: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: background 0.15s, transform 0.05s;
}
button:hover { background: rgba(0, 0, 0, 0.04); }
button:active { transform: scale(0.98); }
@media (prefers-color-scheme: dark) {
  button:hover { background: rgba(255, 255, 255, 0.06); }
}

.dot { font-size: 11px; margin-right: 6px; }
.diff-item .dot { color: #639922; }
.diff-tag .dot { color: #ef9f27; }
.diff-mural .dot { color: #e24b4a; }
.diff-events .dot { color: #a855f7; }

.diff-item.active { background: #eaf3de; color: #3b6d11; border-color: #97c459; }
.diff-tag.active { background: #faeeda; color: #854f0b; border-color: #ef9f27; }
.diff-mural.active { background: #fcebeb; color: #a32d2d; border-color: #e24b4a; }
.diff-events.active { background: #f3e8ff; color: #6b21a8; border-color: #c084fc; }

.card {
  position: relative;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem 1.5rem 1.5rem;
  text-align: center;
  min-height: 170px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.badge {
  position: absolute;
  top: 12px; left: 12px;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 12px 4px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-transform: capitalize;
}
.badge i { font-size: 10px; }

.context {
  display: none;
  font-size: 13px;
  font-weight: 500;
  color: #a855f7;
  margin-top: 18px;
}
.context.show { display: block; }

.prompt {
  font-size: 30px;
  font-weight: 500;
  line-height: 1.25;
  margin-top: 10px;
}

.context.show + .prompt { margin-top: 2px; }

.ready, .timer, .done { display: none; }
.ready.show, .timer:not(.hidden), .done.show { display: block; }

.ready { font-size: 18px; color: var(--text-muted); }
.ready.show { display: block; }

.timer {
  font-size: 44px;
  font-weight: 500;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.timer.hidden { display: none; }

.done { font-size: 16px; font-weight: 500; color: var(--danger); }
.done.show { display: block; }

.controls button {
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.controls i { font-size: 18px; }

.btn-primary { flex: 2; font-size: 17px; font-weight: 500; }
.btn { flex: 1; font-size: 15px; }
.hidden { display: none !important; }

/* ---- letter generator ---- */

.letter-input {
  display: block;
  width: 100%;
  font: inherit;
  font-size: 20px;
  font-weight: 600;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text);
  background: var(--surface);
  border: 0.5px solid var(--border-strong);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 1.25rem;
  min-height: 52px;
}
.letter-input:focus { outline: none; border-color: var(--accent-border); }
.letter-input::placeholder { color: var(--text-muted); text-transform: none; }

.letter-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 1.25rem;
}
.letter-key {
  padding: 0;
  min-height: 38px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
}

.letter-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem 1rem;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.letter-display {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
}

.letter-display .gl-img {
  display: block;
  height: 100px;
  width: auto;
  margin-left: -14px;
}
.letter-display .gl-img:first-child { margin-left: 0; }
.letter-display .gl-sp { width: 0.4em; }

/* Fallback for a letter with no image asset yet at src/letters/<style>/. */
.letter-display .gl-fallback {
  display: inline-block;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--page);
  border: 2px dashed var(--border-strong);
  border-radius: 10px;
  padding: 0 0.15em;
  margin-left: 4px;
  line-height: 1.6;
}

.letter-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
  margin: 0.75rem 0.25rem 0;
}
.letter-hint code {
  background: var(--surface);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11.5px;
}
