:root {
  --bg: #fffdfa;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #ffd54f;
  --primary-ink: #2c2c2c;
  --accent: #4fc3f7;
  --accent-2: #ff6ec7;
  --success: #34d399;
  --warning: #fb923c;
  --danger: #ef4444;
  --ring: #7c3aed;
  --shadow: 0 10px 20px rgba(31, 41, 55, 0.08), 0 2px 6px rgba(31, 41, 55, 0.08);
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 8px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(1200px 400px at -10% -10%, #fff4d6 0%, transparent 60%),
    radial-gradient(800px 300px at 110% 10%, #e0f7ff 0%, transparent 60%),
    var(--bg);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  line-height: 1.6;
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 16px;
  background: var(--ring);
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--radius-xs);
  text-decoration: none;
  transition: transform 180ms ease, top 180ms ease;
}
.skip-link:focus {
  top: 16px;
}

.title-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: #FFa62b;
  box-shadow: none;
  border-radius: 0;
  margin: 0;
}
.title-bar .site-title {
  margin: 0;
  font-family: "Comic Sans MS", "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-weight: 900;
  letter-spacing: 1px;
  line-height: 1.1;
  font-size: clamp(2rem, 6vw, 3rem);
  color: #2e5aa7;
  text-shadow: none;
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
#settings-form {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}
#settings-form fieldset {
  border: 0;
  padding: 0;
  margin: 0;
}
#settings-form legend {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--muted);
}
.language-select select {
  appearance: none;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  font-weight: 700;
  color: var(--text);
  box-shadow: 0 2px 4px rgba(31, 41, 55, 0.08);
}
.visually-hidden {
  position: absolute !important;
  height: 1px; width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}
.difficulty {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
}
.difficulty input[type="radio"] {
  appearance: none;
  margin: 0;
  width: 0;
  height: 0;
}
.difficulty label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border-radius: 999px;
  background: #f3f4f6;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
  box-shadow: 0 2px 4px rgba(31, 41, 55, 0.08);
}
.difficulty input[type="radio"]:checked + label {
  background: linear-gradient(180deg, var(--accent), #34b6e4);
  color: #0b2239;
  box-shadow: 0 6px 14px rgba(79, 195, 247, 0.35);
  transform: translateY(-1px);
}

button {
  appearance: none;
  border: 0;
  background: linear-gradient(180deg, var(--accent-2), #ff4fbf);
  color: #2b0a1f;
  font-weight: 800;
  letter-spacing: 0.3px;
  padding: 12px 18px;
  border-radius: 999px;
  box-shadow: 0 8px 16px rgba(255, 110, 199, 0.35);
  transition: transform 140ms ease, box-shadow 140ms ease, filter 140ms ease;
}
button:hover {
  transform: translateY(-1px) scale(1.02);
}
button:active {
  transform: translateY(0) scale(0.98);
}
button:focus-visible {
  outline: 3px solid rgba(124, 58, 237, 0.25);
  box-shadow: 0 0 0 6px rgba(124, 58, 237, 0.25);
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 16px;
  max-width: 1100px;
  margin: 0 auto;
}

.screen {
  display: none;
}
.screen.active {
  display: block;
}
.start-screen,
.difficulty-screen {
  display: grid;
  place-items: center;
  padding: 24px;
}
.start-screen h2,
.difficulty-screen h2 {
  margin: 0 0 12px 0;
}
.start-screen p {
  margin: 0 0 16px 0;
  color: var(--muted);
  font-weight: 600;
}

.game {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: grid;
  gap: 16px;
}
.game h2 {
  margin: 0;
  font-size: 1.25rem;
}

#letters {
  display: grid;
  grid-template-columns: repeat(6, minmax(40px, 1fr));
  gap: 10px;
}
#letters > * {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #fff, #f3f4f6);
  color: var(--text);
  font-weight: 800;
  font-size: 1rem;
  box-shadow: 0 2px 6px rgba(31, 41, 55, 0.08);
  user-select: none;
}

.word {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.4rem;
  letter-spacing: 1px;
  background: #fff7ed;
  border-radius: var(--radius-sm);
  box-shadow: inset 0 0 0 2px rgba(251, 146, 60, 0.25);
}

.hints {
  display: grid;
  gap: 10px;
}
.hints-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#hints-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}
#hints-list li {
  display: grid;
  grid-template-columns: 120px 1fr;
  align-items: start;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius-xs);
  background: #fcfcfd;
}
#hints-list .level {
  font-weight: 800;
  color: var(--muted);
}
#hints-list .text {
  font-weight: 600;
  color: var(--text);
}

.guess {
  display: grid;
  gap: 10px;
}
.guess label {
  font-weight: 700;
  color: var(--muted);
}
.guess input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 2px solid #e5e7eb;
  font-size: 1.05rem;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.guess input[type="text"]:focus-visible {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 6px rgba(124, 58, 237, 0.2);
}
.guess-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
  overflow-x: auto;
  justify-content: start;
}
.guess-actions > button {
  flex: 0 0 auto;
}

.scoreboard {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: grid;
  gap: 16px;
}
.scoreboard .stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.chip {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fafafa;
}
.chip .label {
  font-weight: 700;
  color: var(--muted);
}
.chip output {
  font-weight: 800;
  font-size: 1rem;
  color: var(--text);
}
.chip.timer output {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  padding: 4px 8px;
  border-radius: 8px;
  background: #edf2ff;
  color: #1e3a8a;
}
#streak-stars {
  grid-column: 1 / -1;
  font-size: 0.95rem;
  color: #b45309;
}
.scoreboard h2 {
  margin: 0;
  font-size: 1.25rem;
}
.score {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
}
#score {
  font-weight: 800;
  font-size: 2rem;
  color: #0b3b2f;
  background: linear-gradient(180deg, #a7f3d0, #6ee7b7);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.score-label {
  color: var(--muted);
  font-weight: 700;
}
.progress {
  display: grid;
  gap: 8px;
}
.lives, .streak, .multiplier, .timer {
  display: grid;
  gap: 6px;
}
#lives {
  font-size: 1.2rem;
}
#streak-stars {
  font-size: 1.1rem;
}
.leaderboard ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.leaderboard li {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  background: #f9fafb;
  border: 1px solid #e5e7eb;
}
.leaderboard .rank {
  font-weight: 800;
  color: var(--muted);
}
.leaderboard .name {
  font-weight: 700;
}
.leaderboard .score {
  font-weight: 800;
}
progress {
  width: 100%;
  height: 16px;
  appearance: none;
}
progress::-webkit-progress-bar {
  background-color: #f3f4f6;
  border-radius: 999px;
}
progress::-webkit-progress-value {
  background: linear-gradient(90deg, var(--success), #22c55e);
  border-radius: 999px;
}
progress::-moz-progress-bar {
  background: linear-gradient(90deg, var(--success), #22c55e);
  border-radius: 999px;
}
.found-words {
  display: grid;
  gap: 8px;
}
#found-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}
#found-list li {
  background: #f0f9ff;
  color: #0b2239;
  border-radius: var(--radius-xs);
  padding: 8px 10px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 2px 4px rgba(11, 34, 57, 0.08);
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: var(--muted);
}

:focus-visible {
  scroll-margin-top: 100px;
}

.anim-pop {
  animation: pop 160ms ease;
}
.anim-shake {
  animation: shake 380ms ease;
}
.anim-pulse {
  animation: pulse 900ms ease infinite;
}

@keyframes pop {
  0% { transform: scale(0.94); }
  60% { transform: scale(1.04); }
  100% { transform: scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); filter: brightness(1.06); }
  100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .anim-pop, .anim-shake, .anim-pulse {
    animation: none;
  }
  * {
    transition: none !important;
  }
}

@media (min-width: 320px) {
  .site-header h1 {
    font-size: 1.6rem;
  }
}

@media (min-width: 768px) {
  .layout {
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    padding: 20px;
  }
  .site-header h1 {
    font-size: 1.8rem;
  }
  #letters {
    grid-template-columns: repeat(7, minmax(44px, 1fr));
  }
  .guess-actions {
    justify-content: start;
  }
}

@media (min-width: 1024px) {
  .layout {
    grid-template-columns: 3fr 1.5fr;
    gap: 24px;
    padding: 24px;
  }
  .site-header h1 {
    font-size: 2rem;
  }
  #letters {
    grid-template-columns: repeat(8, minmax(48px, 1fr));
  }
}
