:root {
  --bg: #0b0d16;
  --surface: #131626;
  --surface-2: #1a1e33;
  --surface-3: #232843;
  --text: #eceaf6;
  --muted: #9b9fbd;
  --accent: #7c6cf0;
  --accent-hover: #6b5ce0;
  --border: #262b45;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Letter feedback (Option C): colour carries brand tone, badges carry meaning. */
  --correct: #7c6cf0;
  --correct-border: #9d90f5;
  --present: #ff9f5a;
  --present-border: #ffb87d;
  --absent-border: #343a5a;
  --danger: #ff6b6b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background-color: var(--bg);
  background-image: radial-gradient(900px 420px at 50% -80px, rgba(124, 108, 240, 0.2), transparent 70%);
  background-repeat: no-repeat;
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

h2 {
  font-size: 2rem;
  margin: 0 0 0.5rem;
}

h3 {
  font-size: 1.25rem;
  margin: 2rem 0 0.75rem;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.screen {
  animation: screen-in 0.28s ease both;
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Header */

.site-header {
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--border);
}

.header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.logo-btn {
  display: inline-flex;
  align-items: center;
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  cursor: pointer;
}

.logo-btn::after {
  content: "";
  width: 0.4em;
  height: 0.4em;
  margin: 0.25em 0 0 0.16em;
  border-radius: 3px;
  background: var(--accent);
}

.nav {
  display: flex;
  gap: 0.25rem;
}

.nav-btn {
  white-space: nowrap;
  background: none;
  border: none;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.nav-btn:hover {
  color: var(--text);
  background: var(--surface-2);
}

main {
  padding: 2.5rem 1.5rem 4rem;
  min-height: 60vh;
}

/* Buttons */

button {
  font-family: inherit;
}

button:focus-visible,
.mode-card:focus-visible {
  outline: 2px solid var(--correct-border);
  outline-offset: 2px;
}

.primary-btn {
  width: 100%;
  padding: 0.85rem 1.5rem;
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, #8677f5, #6f5fe6);
  box-shadow: 0 6px 18px rgba(124, 108, 240, 0.35);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
}

.primary-btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.primary-btn:disabled {
  background: var(--surface-2);
  box-shadow: none;
  color: var(--muted);
  cursor: not-allowed;
  transform: none;
  filter: none;
}

.ghost-btn {
  padding: 0.75rem 1.4rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.ghost-btn:hover {
  border-color: var(--correct-border);
  background: var(--surface-2);
}

.text-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.4rem 0;
}

.text-btn:hover {
  color: var(--text);
}

/* Home */

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin: 1.5rem 0 1rem;
}

.mode-card {
  padding: 1.3rem 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.mode-card:hover {
  transform: translateY(-3px);
  border-color: var(--correct-border);
  box-shadow: var(--shadow);
}

.mode-len {
  display: block;
  font-family: var(--font-display);
  font-size: 2.8rem;
  font-weight: 700;
  line-height: 1;
  color: var(--correct-border);
}

.mode-card h4 {
  margin: 0.5rem 0 0.15rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0;
}

.mode-card .level-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.mini-bar {
  height: 4px;
  margin-top: 0.85rem;
  border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
}

.mini-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
}

.mode-card.completed {
  border-color: var(--correct-border);
}

.daily-card {
  margin-top: 1.25rem;
  padding: 1.6rem;
  border: 1px solid rgba(157, 144, 245, 0.4);
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(124, 108, 240, 0.18), rgba(124, 108, 240, 0.02)), var(--surface);
  box-shadow: var(--shadow);
}

.daily-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.daily-card-top h3 {
  margin: 0;
}

.daily-card p {
  margin: 0.5rem 0 1.25rem;
}

.badge-pill {
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-pill.solved {
  background: rgba(124, 108, 240, 0.22);
  color: var(--correct-border);
}

/* Gameplay */

.game-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.guesses-remaining {
  margin-bottom: 1.1rem;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

.tile-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.tile-row {
  display: flex;
  gap: 0.5rem;
}

.tile {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.2rem;
  height: 3.2rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  text-transform: uppercase;
}

.tile.filled {
  border-color: var(--muted);
}

.tile.correct {
  background: var(--correct);
  border-color: var(--correct-border);
  color: #fff;
}

.tile.present {
  background: var(--present);
  border-color: var(--present-border);
  color: #2a1a05;
}

.tile.absent {
  background: var(--surface-2);
  border-color: var(--absent-border);
  color: var(--muted);
}

.tile.warn {
  border-color: var(--danger);
  background: rgba(255, 107, 107, 0.14);
}

.tile.reveal {
  animation: reveal 0.4s ease both;
  animation-delay: calc(var(--i) * 90ms);
}

@keyframes reveal {
  from {
    transform: rotateX(-90deg);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.tile .badge {
  position: absolute;
  top: -8px;
  right: -8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 19px;
  border: 2px solid var(--bg);
  border-radius: 50%;
  background: var(--bg);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

.tile.correct .badge {
  color: var(--correct-border);
}

.tile.present .badge {
  color: var(--present-border);
}

.guess-warning {
  max-width: 24rem;
  margin: 0 auto 1.25rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  background: rgba(255, 107, 107, 0.08);
  font-size: 0.9rem;
}

.guess-warning ul {
  margin: 0.5rem 0 0.9rem;
  padding-left: 1.1rem;
}

.guess-warning-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.clue-box {
  max-width: 24rem;
  margin: 0 auto 1.25rem;
  padding: 0.85rem 1.1rem;
  border: 1px dashed var(--correct-border);
  border-radius: var(--radius);
  background: rgba(124, 108, 240, 0.06);
  text-align: center;
}

.clue-box p {
  margin: 0.25rem 0 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-style: italic;
}

.clue-label,
.coach-label {
  color: var(--correct-border);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.ad-bonus-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  text-align: center;
}

.keyboard {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
}

.keyboard-row {
  display: flex;
  gap: 0.3rem;
  width: 100%;
  max-width: 34rem;
}

.keyboard-row:nth-child(2) {
  padding: 0 4.5%;
}

.key {
  position: relative;
  isolation: isolate;
  flex: 1 1 0;
  min-width: 0;
  padding: 0.8rem 0;
  border: none;
  border-radius: 8px;
  background: var(--surface-2);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.12s, transform 0.08s;
}

.key:hover {
  background: var(--surface-3);
}

.key:active {
  transform: translateY(1px);
}

.key.wide {
  flex: 1.7 1 0;
  font-size: 0.72rem;
}

.key.correct {
  background: var(--correct);
  color: #fff;
}

.key.present {
  background: var(--present);
  color: #2a1a05;
}

/* Wrong letters: red X drawn behind the letter so the letter stays readable. */
.key.absent {
  overflow: hidden;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px rgba(255, 107, 107, 0.5);
  color: #dcdff3;
}

.key.absent::before,
.key.absent::after {
  content: "";
  position: absolute;
  z-index: -1;
  left: 6%;
  right: 6%;
  top: 50%;
  height: 2px;
  margin-top: -1px;
  border-radius: 1px;
  background: var(--danger);
}

.key.absent::before {
  transform: rotate(45deg);
}

.key.absent::after {
  transform: rotate(-45deg);
}

/* Tutorial */

.coach {
  max-width: 28rem;
  margin: 0 auto 1.25rem;
  padding: 1rem 1.1rem;
  border: 1px solid rgba(157, 144, 245, 0.5);
  border-radius: var(--radius);
  background: rgba(124, 108, 240, 0.1);
  font-size: 0.92rem;
}

.coach p {
  margin: 0.4rem 0;
}

.coach ul {
  margin: 0.4rem 0;
  padding-left: 1.1rem;
}

.coach .ghost-btn {
  margin-top: 0.4rem;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

.intro-panel {
  max-width: 36rem;
  margin: 0 auto;
}

.intro-legend,
.intro-rules {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin: 1.4rem 0;
  padding: 0;
  list-style: none;
}

.intro-legend li {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.intro-rules li {
  padding-left: 1rem;
  border-left: 2px solid var(--surface-3);
}

.legend-tile {
  flex: none;
}

.red-x {
  color: var(--danger);
}

.intro-leaderboard {
  margin: 1.6rem 0;
  padding: 1.2rem 1.25rem;
  border: 1px solid rgba(157, 144, 245, 0.4);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(124, 108, 240, 0.16), rgba(124, 108, 240, 0.02)), var(--surface);
}

.intro-leaderboard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.intro-leaderboard p {
  margin: 0.5rem 0 0.9rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.soon-pill {
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 159, 90, 0.16);
  color: var(--present-border);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tier-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tier-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0.8rem;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 0.88rem;
  font-weight: 600;
}

.tier-list li span:last-child {
  color: var(--muted);
  font-weight: 500;
}

.intro-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

/* Result */

.result-panel {
  max-width: 30rem;
  margin: 0 auto;
  padding: 2.25rem 2rem;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.result-panel h2 {
  font-size: 1.5rem;
  color: var(--muted);
}

.result-word {
  margin: 0.25rem 0 0.75rem;
  color: var(--correct-border);
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: capitalize;
}

.result-def {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-style: italic;
}

.result-example {
  margin: 0;
  color: var(--muted);
}

.result-meta {
  margin: 1.25rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.6rem;
}

/* My Words */

.journal-lead {
  margin: 0 0 1.25rem;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.chip {
  padding: 0.45rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.chip span {
  margin-left: 0.25rem;
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
}

.chip:hover {
  color: var(--text);
  border-color: var(--correct-border);
}

.chip.active {
  border-color: var(--accent);
  background: rgba(124, 108, 240, 0.2);
  color: var(--text);
}

.word-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.word-card {
  padding: 1.15rem 1.3rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}

.word-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.word-title {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  text-transform: capitalize;
}

.word-status {
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.word-card.solved .word-status {
  background: rgba(124, 108, 240, 0.2);
  color: var(--correct-border);
}

.word-card.missed .word-status {
  background: rgba(255, 107, 107, 0.16);
  color: var(--danger);
}

.word-def {
  margin: 0.3rem 0 0.35rem;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-style: italic;
}

.word-example {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.word-meta {
  margin: 0.7rem 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Stats */

.stats-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin: 1.25rem 0 0.5rem;
}

.stat-tile {
  padding: 1.1rem 1rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  text-align: center;
}

.stat-tile .stat-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
}

.stat-tile .stat-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.stats-modes {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.stats-mode-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  font-weight: 600;
}

.progress-bar {
  flex: 1;
  height: 6px;
  margin: 0 1rem;
  border-radius: 3px;
  background: var(--surface-3);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
}

.stats-daily {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stats-daily-row {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.stats-words-btn {
  width: 100%;
  margin-top: 1.75rem;
}

.empty-note {
  color: var(--muted);
  font-style: italic;
}

.site-footer {
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 480px) {
  h2 {
    font-size: 1.65rem;
  }
  .mode-grid,
  .stats-summary {
    grid-template-columns: 1fr;
  }
  .tile {
    width: 2.7rem;
    height: 2.7rem;
    font-size: 1.3rem;
  }
  .key {
    padding: 0.75rem 0;
  }
  .result-panel {
    padding: 1.75rem 1.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .screen,
  .tile.reveal {
    animation: none;
  }
  .mode-card,
  .primary-btn {
    transition: none;
  }
}

/* Advertisement bar: fixed to the bottom, labelled, one slim row. */

body.has-ad {
  padding-bottom: 4.25rem;
}

.ad-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  padding: 0.5rem 0.75rem calc(0.5rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: rgba(11, 13, 22, 0.94);
  backdrop-filter: blur(10px);
}

.ad-inner {
  position: relative;
  max-width: 728px;
  margin: 0 auto;
}

.ad-tag {
  position: absolute;
  top: -0.95rem;
  left: 0;
  padding: 0 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.ad-slot {
  min-height: 3rem;
}

.ad-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3rem;
  padding: 0.35rem 0.5rem 0.35rem 0.6rem;
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.3;
  text-decoration: none;
}

a.ad-card:hover {
  background: var(--surface-2);
}

.ad-image {
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 6px;
  object-fit: cover;
}

.ad-copy {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.ad-copy strong {
  color: var(--text);
}

.ad-cta {
  flex: none;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(124, 108, 240, 0.22);
  color: var(--correct-border);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}