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

:root {
  --bg: #f6faf8;
  --bg-soft: #edf6f3;
  --surface: #ffffff;
  --surface-soft: #f9fcfb;
  --ink: #17202a;
  --muted: #5f6d7a;
  --line: #dce8e4;
  --primary: #2f6f73;
  --primary-strong: #255f63;
  --blue: #3468c2;
  --green: #2f946b;
  --yellow: #f2c14e;
  --red: #d84f4f;
  --shadow: 0 18px 45px rgba(39, 62, 70, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  margin: 0;
  padding: 28px;
  background:
    radial-gradient(circle at 12% 8%, rgba(242, 193, 78, 0.16), transparent 28%),
    radial-gradient(circle at 88% 4%, rgba(52, 104, 194, 0.12), transparent 26%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-soft) 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
}

a {
  color: var(--primary);
}

.top-right-nav {
  position: absolute;
  top: 18px;
  right: 22px;
  z-index: 100;
  display: flex;
  gap: 8px;
  align-items: center;
}

.language-switcher {
  position: relative;
  display: inline-block;
}

.language-switcher summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  list-style: none;
}

.language-switcher summary::-webkit-details-marker {
  display: none;
}

.privacy-btn,
.sound-btn,
.share-btn,
.lang-btn {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.86);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(35, 56, 64, 0.08);
}

.privacy-btn:hover,
.sound-btn:hover,
.share-btn:hover,
.lang-btn:hover {
  color: var(--primary);
  border-color: rgba(47, 111, 115, 0.35);
}

.sound-btn.muted {
  color: #8a6d18;
  background: #fff8de;
  border-color: rgba(242, 193, 78, 0.55);
}

.mode-switcher,
.top-right-nav .share-btn {
  display: none;
}

.seo-content {
  width: min(100%, 1240px);
  margin: 36px auto 10px;
  text-align: left;
}

.seo-content h1 {
  max-width: 1040px;
  margin: 0 0 8px;
  color: var(--ink);
  font-size: clamp(1.85rem, 3.2vw, 3rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: 0;
}

.seo-content p {
  display: inline;
  max-width: 660px;
  margin: 0 12px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.36;
}

.main-content-wrapper {
  display: grid;
  grid-template-columns: 1fr;
  width: min(100%, 1240px);
  margin: 0 auto;
}

#game-container {
  position: relative;
  width: 100%;
  height: min(720px, 76vh);
  min-height: 630px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.background-particles,
#particles-canvas,
#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.background-particles {
  pointer-events: none;
  opacity: 0.26;
  z-index: 1;
}

#game-canvas {
  z-index: 2;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 252, 251, 0.96)),
    repeating-linear-gradient(0deg, transparent 0, transparent 58px, rgba(47, 111, 115, 0.05) 59px);
  cursor: none;
}

.top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 0 18px;
  border-bottom: 1px solid rgba(220, 232, 228, 0.82);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
}

.game-title {
  color: var(--primary);
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: 0;
}

.combo-display {
  display: none;
}

.input-container {
  position: absolute;
  left: 50%;
  bottom: 26px;
  z-index: 11;
  width: min(86%, 420px);
  transform: translateX(-50%);
}

#word-input {
  width: 100%;
  min-height: 54px;
  padding: 0 18px;
  border: 2px solid rgba(47, 111, 115, 0.22);
  border-radius: var(--radius);
  outline: none;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  text-align: center;
  font-size: 1.28rem;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(39, 62, 70, 0.1);
}

#word-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(47, 111, 115, 0.14), 0 10px 24px rgba(39, 62, 70, 0.1);
}

#word-input::placeholder {
  color: #8a98a3;
}

.game-start-screen,
.game-over-screen,
.privacy-screen,
.name-input-screen,
.leaderboard-screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 28px;
  background: rgba(247, 250, 248, 0.94);
  backdrop-filter: blur(10px);
}

.game-over-screen,
.privacy-screen,
.name-input-screen,
.leaderboard-screen {
  display: none;
  justify-content: center;
  z-index: 40;
}

.game-start-screen {
  justify-content: center;
}

.start-screen-content,
.game-over-content,
.privacy-content,
.name-input-content,
.leaderboard-content {
  width: min(100%, 650px);
  max-height: 100%;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.start-screen-content {
  padding: clamp(16px, 2.5vw, 20px);
}

.start-title {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: clamp(1.45rem, 3.2vw, 2.2rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 0;
}

.spelling-subtitle {
  margin-bottom: 5px;
  color: var(--primary);
  font-size: 0.98rem;
  font-weight: 800;
}

.spelling-intro {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.hero-proof-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
}

.hero-proof-row span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid rgba(47, 111, 115, 0.18);
  border-radius: 999px;
  background: #f2f8f6;
  color: var(--primary-strong);
  font-size: 0.76rem;
  font-weight: 700;
}

.spelling-builder {
  display: grid;
  gap: 7px;
  text-align: left;
}

.spelling-builder > label {
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 800;
}

#custom-word-list {
  width: 100%;
  height: 96px;
  min-height: 86px;
  resize: vertical;
  padding: 14px;
  border: 1px solid #cfded9;
  border-radius: var(--radius);
  outline: none;
  background: #fbfdfc;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.45;
}

#custom-word-list:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(47, 111, 115, 0.12);
}

.spelling-options,
.spelling-actions,
.game-over-buttons,
.name-input-buttons,
.leaderboard-buttons,
.privacy-buttons {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.spelling-options {
  justify-content: space-between;
}

.read-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.read-toggle input {
  width: 17px;
  height: 17px;
  accent-color: var(--primary);
}

#spelling-status {
  margin-left: auto;
  color: #8a6714;
  font-size: 0.84rem;
  font-weight: 800;
}

.spelling-actions {
  justify-content: flex-start;
}

.spelling-actions button,
.restart-btn,
.share-score-btn,
.home-btn,
.leaderboard-btn,
.submit-score-btn,
.skip-btn,
.close-leaderboard-btn,
.close-privacy-btn,
.clear-data-btn {
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--primary);
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 800;
}

.spelling-actions button:hover,
.restart-btn:hover,
.share-score-btn:hover,
.close-privacy-btn:hover {
  border-color: rgba(47, 111, 115, 0.35);
  background: #f4faf8;
}

.start-btn {
  width: 100%;
  min-height: 48px;
  margin-top: 12px;
  padding: 0 20px;
  border-radius: var(--radius);
  background: var(--primary);
  color: #ffffff;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0;
  box-shadow: 0 12px 26px rgba(47, 111, 115, 0.22);
}

.start-btn:hover {
  background: var(--primary-strong);
}

.left-panel,
.stats {
  display: grid;
  gap: 14px;
}

.left-panel {
  height: min(720px, 76vh);
  min-height: 630px;
  grid-template-rows: auto 1fr;
}

.game-instructions,
.power-ups-container,
.stat-item,
.ad-slot,
.spelling-seo-copy,
.seo-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 10px 28px rgba(39, 62, 70, 0.08);
}

.game-instructions,
.power-ups-container {
  padding: 16px;
}

.practice-proof {
  min-height: 0;
}

.instructions-content h3,
.practice-proof-copy h3 {
  margin: 0 0 11px;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 800;
}

.instructions-content h4 {
  margin: 16px 0 7px;
  color: var(--primary) !important;
  font-size: 0.95rem;
  font-weight: 800;
}

.instructions-content p,
.practice-proof-copy p {
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.instructions-content kbd {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 5px;
  border: 1px solid #cbd8d4;
  border-bottom-width: 2px;
  border-radius: 5px;
  background: #f8fbfa;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
}

.practice-proof .power-ups-title,
.practice-proof .power-ups-grid,
.practice-proof .active-effects {
  display: none;
}

.stats {
  position: absolute;
  top: 76px;
  right: 18px;
  z-index: 30;
  grid-template-columns: 1fr;
  width: 142px;
  gap: 10px;
  pointer-events: none;
}

.stat-item {
  padding: 11px 12px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 20px rgba(39, 62, 70, 0.08);
}

.stat-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
}

.stat-value {
  margin-top: 4px;
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 800;
}

#missed-words,
#final-missed {
  color: var(--red) !important;
}

.game-over-content,
.privacy-content,
.name-input-content,
.leaderboard-content {
  padding: 26px;
}

.game-over-title,
.privacy-title,
.name-input-title,
.leaderboard-title {
  margin: 0 0 16px;
  color: var(--ink);
  font-size: clamp(1.55rem, 4vw, 2.3rem);
  font-weight: 800;
  text-align: center;
}

.final-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 16px;
}

.final-stats p {
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 700;
}

.final-stats span:last-child {
  color: var(--ink);
  font-weight: 800;
}

.spelling-summary {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 12px 0 18px;
  color: var(--muted);
}

.spelling-summary[hidden] {
  display: none;
}

#spelling-result {
  margin-bottom: 10px;
  color: var(--primary);
  font-weight: 800;
  text-align: center;
}

#missed-word-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 0 auto 12px;
}

.word-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(216, 79, 79, 0.25);
  border-radius: 999px;
  background: #fff5f5;
  color: #9a3333;
  font-size: 0.9rem;
  font-weight: 800;
}

.game-over-buttons,
.privacy-buttons {
  justify-content: center;
}

.restart-btn,
.share-score-btn,
.close-privacy-btn {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.clear-data-btn,
.home-btn,
.skip-btn {
  color: #9a3333;
  border-color: rgba(216, 79, 79, 0.28);
  background: #fff7f7;
}

.privacy-text h3,
.privacy-text h4 {
  margin: 18px 0 8px;
  color: var(--ink);
}

.privacy-text p {
  margin: 0 0 8px;
  color: var(--muted);
  line-height: 1.55;
}

.privacy-update {
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
  text-align: center;
}

.ad-slot {
  display: none;
  align-items: center;
  justify-content: center;
  width: min(100%, 728px);
  min-height: 90px;
  margin: 24px auto;
  border-style: dashed;
  color: #8a98a3;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.below-game {
  width: min(100%, 1240px);
  margin: 20px auto 0;
  text-align: left;
}

.spelling-seo-copy {
  padding: 28px;
}

.practice-info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.practice-info-grid .game-instructions,
.practice-info-grid .power-ups-container {
  padding: 28px;
}

.below-game .practice-info-grid h3 {
  margin: 0 0 16px;
  color: var(--ink);
  font-size: 1.45rem;
  line-height: 1.2;
}

.below-game .practice-info-grid h4 {
  margin: 20px 0 8px;
  color: var(--primary) !important;
  font-size: 1.05rem;
}

.below-game .practice-info-grid p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

.below-game .practice-info-grid p:last-child {
  margin-bottom: 0;
}

.below-game h2,
.below-game h3 {
  margin: 0 0 12px;
  color: var(--ink);
  font-weight: 800;
}

.below-game h3 {
  margin-top: 24px;
  color: var(--primary);
  font-size: 1.05rem;
}

.below-game p,
.below-game li {
  color: var(--muted);
  line-height: 1.6;
}

.below-game ul {
  margin-top: 8px;
  padding-left: 20px;
}

footer {
  width: min(100%, 1240px);
  margin: 34px auto 0 !important;
  padding: 18px 0 !important;
  border-top: 1px solid var(--line) !important;
}

footer p {
  color: var(--muted) !important;
  line-height: 1.8;
}

footer a {
  color: var(--primary) !important;
  font-weight: 700;
  text-decoration: none;
}

.seo-landing {
  width: min(100%, 980px);
  margin: 80px auto 24px;
}

.content-page {
  width: min(100%, 920px);
  margin-top: 92px;
}

.content-page .seo-hero {
  text-align: left;
}

.content-page .seo-hero h1,
.content-page .seo-hero p {
  margin-left: 0;
  margin-right: 0;
}

.content-page .seo-panel {
  background: rgba(255, 255, 255, 0.88);
}

.content-page .text-link {
  font-weight: 800;
  text-decoration: none;
}

.seo-hero {
  margin-bottom: 24px;
  text-align: center;
}

.seo-hero h1 {
  margin: 0 auto 12px;
  color: var(--ink);
  font-size: clamp(2rem, 5vw, 3.7rem);
  font-weight: 800;
  line-height: 1.05;
}

.seo-hero p {
  max-width: 760px;
  margin: 0 auto 10px;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.6;
}

.seo-panel {
  padding: 24px;
  margin-bottom: 18px;
}

.seo-panel h2 {
  margin: 0 0 12px;
  color: var(--primary);
  font-size: 1.25rem;
  font-weight: 800;
}

.seo-panel p,
.seo-panel li {
  color: var(--muted);
  line-height: 1.6;
}

.seo-panel ul {
  padding-left: 20px;
}

.seo-cta {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: 10px;
  padding: 0 16px;
  border-radius: var(--radius);
  background: var(--primary);
  color: #ffffff;
  font-weight: 800;
  text-decoration: none;
}

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

.seo-link-grid a {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--primary);
  font-weight: 800;
  text-decoration: none;
}

.lang-menu {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 1000;
  display: none;
  min-width: 160px;
  margin-top: 6px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.lang-menu.show,
.language-switcher[open] .lang-menu {
  display: block;
}

.lang-option {
  display: block;
  padding: 9px 12px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.lang-option:hover,
.lang-option.active,
.lang-option[aria-current="page"] {
  background: #f2f8f6;
  color: var(--primary);
}

.active-effect {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: #f2f8f6;
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 800;
}

@media (max-width: 1080px) {
  body {
    padding: 22px;
  }

  .seo-content {
    margin-top: 56px;
  }

  .left-panel {
    order: 2;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: none;
    height: auto;
    min-height: 0;
  }

  .stats {
    top: 72px;
    right: 14px;
    width: 136px;
  }
}

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

  .top-right-nav {
    top: 10px;
    right: 10px;
  }

  .privacy-btn,
  .sound-btn {
    min-height: 36px;
    padding: 0 9px;
    font-size: 0.78rem;
  }

  .seo-content {
    margin-top: 54px;
  }

  #game-container {
    min-height: 660px;
    height: 74vh;
    border-radius: 10px;
  }

  .game-start-screen,
  .game-over-screen,
  .privacy-screen,
  .name-input-screen,
  .leaderboard-screen {
    padding: 14px;
  }

  .start-screen-content,
  .game-over-content,
  .privacy-content,
  .name-input-content,
  .leaderboard-content {
    border-radius: 10px;
  }

  .start-screen-content {
    width: 100%;
    overflow-x: hidden;
    padding: 14px;
  }

  .start-title {
    font-size: 1.32rem;
  }

  .spelling-intro {
    font-size: 0.86rem;
    line-height: 1.32;
    margin-bottom: 8px;
  }

  .hero-proof-row {
    margin-bottom: 8px;
  }

  .hero-proof-row span {
    min-height: 26px;
    padding: 0 7px;
    font-size: 0.7rem;
  }

  #custom-word-list {
    height: 76px;
    min-height: 70px;
  }

  .spelling-options {
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
  }

  #spelling-status {
    margin-left: 0;
  }

  .start-btn {
    min-height: 46px;
    margin-top: 8px;
  }

  .left-panel {
    grid-template-columns: 1fr;
  }

  .stats {
    top: 68px;
    right: 12px;
    left: 12px;
    z-index: 18;
    width: auto;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 5px;
  }

  .stat-item {
    min-width: 0;
    padding: 7px 4px;
    border-radius: 10px;
  }

  .stat-label {
    overflow: hidden;
    font-size: 0.52rem;
    white-space: nowrap;
  }

  .stat-value {
    margin-top: 2px;
    font-size: 0.88rem;
  }

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

  .below-game {
    padding: 0;
  }

  .practice-info-grid {
    grid-template-columns: 1fr;
  }

  .practice-info-grid .game-instructions,
  .practice-info-grid .power-ups-container {
    padding: 20px;
  }

  .spelling-seo-copy {
    padding: 20px;
  }
}

@media (max-width: 430px) {
  .seo-content h1 {
    font-size: 2rem;
  }

  #game-container {
    min-height: 680px;
    height: 78vh;
  }

  .top-bar {
    padding: 0 12px;
  }

  .game-title {
    font-size: 0.9rem;
  }

  .spelling-actions,
  .game-over-buttons,
  .privacy-buttons {
    flex-direction: column;
    align-items: stretch;
  }

  .spelling-actions button,
  .restart-btn,
  .share-score-btn,
  .close-privacy-btn,
  .clear-data-btn {
    width: 100%;
  }
}
