/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:    #1a1f3a;
  --navy2:   #232946;
  --navy3:   #2e3562;
  --lime:    #7fff00;
  --lime2:   #aaff44;
  --white:   #ffffff;
  --muted:   #a8b2d8;
  --tile-bg: #f5e6c0;
  --tile-border: #c9a84c;
  --tile-text: #1a1f3a;
  --card-bg: #1e2444;
  --radius:  10px;
  --shadow:  0 4px 24px rgba(0,0,0,0.35);
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--navy);
  color: var(--white);
  font-family: 'DM Sans', 'Segoe UI', sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--lime); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Spinner overlay ─────────────────────────────────────────────────────── */
#spinner-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--navy);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 1.2rem;
}
.spinner {
  width: 52px; height: 52px;
  border: 5px solid var(--navy3);
  border-top-color: var(--lime);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#spinner-overlay p { color: var(--muted); font-size: 0.95rem; }

/* ── Header ──────────────────────────────────────────────────────────────── */
header {
  background: var(--navy2);
  border-bottom: 2px solid var(--navy3);
  padding: 0.9rem 1rem 0;
  text-align: center;
}

.logo {
  font-family: 'Russo One', 'Righteous', sans-serif;
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  color: var(--lime);
  letter-spacing: 0.02em;
  display: inline-block;
}

.logo span { color: var(--white); }

.tagline {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.1rem;
  margin-bottom: 0.8rem;
}

/* AdSense top banner */
.ad-top-banner {
  background: var(--navy3);
  border-radius: var(--radius);
  max-width: 728px; height: 90px;
  margin: 0.6rem auto 0;
  display: flex; align-items: center; justify-content: center;
}

/* ── Tab nav ─────────────────────────────────────────────────────────────── */
.tab-nav {
  display: flex;
  gap: 0.25rem;
  justify-content: center;
  margin-top: 0.8rem;
  padding: 0 0.5rem;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius) var(--radius) 0 0;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
  white-space: nowrap;
}

.tab-btn:hover { color: var(--white); background: var(--navy3); }
.tab-btn.active { color: var(--lime); background: var(--navy); border-bottom: 3px solid var(--lime); }

/* ── Main layout ─────────────────────────────────────────────────────────── */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.2rem 1rem;
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.2rem;
}

@media (min-width: 900px) {
  .layout { grid-template-columns: 1fr 300px; }
}

/* ── Panels ──────────────────────────────────────────────────────────────── */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Card ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--navy3);
  border-radius: var(--radius);
  padding: 1.2rem;
}

/* ── Input row ───────────────────────────────────────────────────────────── */
.input-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: stretch;
}

.input-group input {
  flex: 1;
  min-width: 0;
  background: var(--navy);
  border: 2px solid var(--navy3);
  border-radius: var(--radius);
  color: var(--white);
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  padding: 0.65rem 1rem;
  text-transform: uppercase;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}

.input-group input::placeholder { color: var(--muted); letter-spacing: 0; font-weight: 400; text-transform: none; }
.input-group input:focus { outline: none; border-color: var(--lime); }

.btn {
  background: var(--lime);
  border: none;
  border-radius: var(--radius);
  color: var(--navy);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.65rem 1.2rem;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}

.btn:hover { background: var(--lime2); }
.btn:active { transform: scale(0.97); }

.btn-ghost {
  background: transparent;
  border: 2px solid var(--navy3);
  color: var(--muted);
}
.btn-ghost:hover { border-color: var(--muted); background: var(--navy3); color: var(--white); }

/* ── Tile display ────────────────────────────────────────────────────────── */
.tile-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  min-height: 2.6rem;
  margin-top: 0.8rem;
}

.tile {
  background: var(--tile-bg);
  border: 2px solid var(--tile-border);
  border-radius: 6px;
  box-shadow: 0 3px 0 var(--tile-border), inset 0 1px 0 rgba(255,255,255,0.4);
  color: var(--tile-text);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: 'Russo One', sans-serif;
  min-width: 2.6rem;
  min-height: 2.6rem;
  padding: 0.2rem 0.3rem;
  position: relative;
  animation: popIn 0.15s ease;
}

@keyframes popIn {
  from { transform: scale(0.7); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.tile.blank { background: #e0d4f0; border-color: #9b77c9; }
.tile.sm { min-width: 2rem; min-height: 2rem; font-size: 0.85rem; }

.tile-letter {
  font-size: 1.1rem;
  font-weight: 900;
  line-height: 1;
}

.tile-score {
  font-size: 0.55rem;
  font-weight: 700;
  align-self: flex-end;
  line-height: 1;
  margin-top: -2px;
}

/* ── Wildcard hint ───────────────────────────────────────────────────────── */
.hint {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

/* ── Sort bar ────────────────────────────────────────────────────────────── */
.sort-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.9rem;
  flex-wrap: wrap;
}

.sort-label { color: var(--muted); font-size: 0.82rem; margin-right: 0.2rem; }

.sort-btn {
  background: var(--navy);
  border: 1.5px solid var(--navy3);
  border-radius: 20px;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.85rem;
  transition: all 0.15s;
}

.sort-btn:hover { border-color: var(--muted); color: var(--white); }
.sort-btn.active { background: var(--lime); border-color: var(--lime); color: var(--navy); }

/* ── Word count ──────────────────────────────────────────────────────────── */
.word-count {
  color: var(--lime);
  font-size: 0.88rem;
  font-weight: 700;
  margin-top: 0.6rem;
}

/* ── Results ─────────────────────────────────────────────────────────────── */
.results-panel {
  margin-top: 1rem;
}

.results-inner { display: flex; flex-direction: column; gap: 0.8rem; }

.fade-in { animation: fadeIn 0.35s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.no-results { color: var(--muted); text-align: center; padding: 2rem; }

/* ── Word groups ─────────────────────────────────────────────────────────── */
.word-group {
  background: var(--navy);
  border: 1px solid var(--navy3);
  border-radius: var(--radius);
  overflow: hidden;
}

.word-group summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 0.6rem;
  justify-content: space-between;
  list-style: none;
  padding: 0.65rem 1rem;
  user-select: none;
}

.word-group summary::-webkit-details-marker { display: none; }
.word-group[open] summary { border-bottom: 1px solid var(--navy3); }

.group-label { font-weight: 700; font-size: 0.9rem; }
.group-label::before { content: '▶ '; font-size: 0.7rem; color: var(--lime); transition: transform 0.2s; }
.word-group[open] .group-label::before { content: '▼ '; }

.group-count {
  background: var(--navy3);
  border-radius: 20px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.1rem 0.55rem;
}

.word-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.75rem 0.9rem;
}

/* ── Word chip ───────────────────────────────────────────────────────────── */
.word-chip {
  align-items: center;
  background: var(--card-bg);
  border: 1.5px solid var(--navy3);
  border-radius: 8px;
  color: var(--white);
  cursor: pointer;
  display: inline-flex;
  flex-direction: column;
  font-family: inherit;
  gap: 0.1rem;
  padding: 0.35rem 0.65rem;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  min-width: 3.5rem;
  text-align: center;
}

.word-chip:hover {
  border-color: var(--lime);
  background: var(--navy3);
  transform: translateY(-2px);
}

.wc-word {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.wc-score {
  font-size: 0.65rem;
  color: var(--lime);
  font-weight: 600;
}

/* ── Definition popup ────────────────────────────────────────────────────── */
.def-popup {
  background: var(--navy2);
  border: 1.5px solid var(--lime);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: none;
  max-width: 300px;
  min-width: 220px;
  padding: 1rem;
  position: fixed;
  z-index: 1000;
}

.def-popup.visible { display: block; animation: fadeIn 0.2s ease; }

.def-header {
  align-items: center;
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.def-word { font-size: 1.1rem; letter-spacing: 0.05em; }
.def-score { color: var(--lime); font-size: 0.8rem; margin-left: auto; }

.def-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.1rem 0.3rem;
}

.def-close:hover { color: var(--white); }

.def-meaning { font-size: 0.85rem; color: var(--muted); margin-top: 0.3rem; }
.pos { color: var(--lime2); font-style: italic; margin-right: 0.3rem; font-size: 0.8rem; }
.def-loading { color: var(--muted); font-size: 0.85rem; }

/* ── Calculator ──────────────────────────────────────────────────────────── */
.calc-tiles { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 1rem; }
.calc-total { margin-top: 0.8rem; font-size: 1.15rem; color: var(--white); }
.calc-total strong { color: var(--lime); font-size: 1.4rem; }
.calc-valid { margin-top: 0.5rem; font-size: 0.9rem; }

.valid-badge { color: #4ade80; font-weight: 700; }
.invalid-badge { color: #f87171; font-weight: 700; }

/* ── Right rail ad ───────────────────────────────────────────────────────── */
.ad-rail {
  display: none;
}

@media (min-width: 900px) {
  .ad-rail {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }
  .ad-rail-unit {
    background: var(--navy3);
    border-radius: var(--radius);
    height: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 0.75rem;
    text-align: center;
    padding: 0.5rem;
  }
}

/* ── In-results ad ───────────────────────────────────────────────────────── */
.ad-unit.in-results {
  background: var(--navy3);
  border-radius: var(--radius);
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.ad-label {
  color: var(--muted);
  font-size: 0.7rem;
  position: absolute;
  top: 4px;
  right: 8px;
}

/* ── Error message ───────────────────────────────────────────────────────── */
#error-msg {
  display: none;
  background: #3d1515;
  border: 1px solid #f87171;
  border-radius: var(--radius);
  color: #fca5a5;
  font-size: 0.9rem;
  margin-top: 1rem;
  padding: 0.8rem 1rem;
}

/* ── SEO content section ─────────────────────────────────────────────────── */
.seo-section {
  background: var(--card-bg);
  border-radius: var(--radius);
  margin-top: 3rem;
  padding: 2rem 1.5rem;
}

.seo-section h2 {
  color: var(--lime);
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.seo-section h3 {
  color: var(--lime2);
  font-size: 1.1rem;
  margin: 1.5rem 0 0.5rem;
}

.seo-section p {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.7;
  margin-bottom: 0.8rem;
}

.seo-section ul {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.7;
  margin: 0.5rem 0 0.8rem 1.5rem;
}

/* ── FAQ ─────────────────────────────────────────────────────────────────── */
.faq { margin-top: 1.5rem; display: flex; flex-direction: column; gap: 0.6rem; }

.faq-item {
  background: var(--navy);
  border: 1px solid var(--navy3);
  border-radius: var(--radius);
  overflow: hidden;
}

.faq-item summary {
  color: var(--white);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  list-style: none;
  padding: 0.85rem 1rem;
  user-select: none;
}

.faq-item summary::-webkit-details-marker { display: none; }
.faq-item[open] summary { color: var(--lime); }

.faq-answer {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
  padding: 0 1rem 0.9rem;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
footer {
  background: var(--navy2);
  border-top: 1px solid var(--navy3);
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 3rem;
  padding: 1.5rem 1rem;
  text-align: center;
}

.ad-mobile-bottom {
  background: var(--navy3);
  border-radius: var(--radius);
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  max-width: 320px;
}

@media (min-width: 600px) {
  .ad-mobile-bottom { display: none; }
}

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--navy2); }
::-webkit-scrollbar-thumb { background: var(--navy3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--lime); }

/* ── Hide ad placeholders until real AdSense units are pasted in ────────── */
.ad-top-banner, .ad-rail-unit, .ad-mobile-bottom { display: none; }

/* ── Word of the Day ─────────────────────────────────────────────────────── */
.wotd-card {
  background: linear-gradient(135deg, var(--navy3) 0%, #2a1f5e 100%);
  border: 1px solid rgba(127,255,0,0.25);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.8rem 1.2rem;
  margin-bottom: 1.2rem;
  padding: 1.1rem 1.5rem;
}

.wotd-inner { flex: 1; min-width: 0; }

.wotd-badge {
  color: var(--lime);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.wotd-body {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}

.wotd-word {
  color: var(--white);
  font-family: 'Russo One', sans-serif;
  font-size: clamp(1.3rem, 4vw, 1.9rem);
  letter-spacing: 0.06em;
}

.wotd-pts {
  background: var(--lime);
  border-radius: 20px;
  color: var(--navy);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.1rem 0.55rem;
}

.wotd-def {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.55;
}

.wotd-try {
  background: rgba(127,255,0,0.1);
  border: 1.5px solid rgba(127,255,0,0.35);
  border-radius: var(--radius);
  color: var(--lime);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  transition: background 0.2s, border-color 0.2s;
  white-space: nowrap;
}

.wotd-try:hover { background: rgba(127,255,0,0.2); border-color: var(--lime); }

/* ── Recent searches ─────────────────────────────────────────────────────── */
.recent-searches {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.65rem;
  min-height: 0;
}

.recent-label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.recent-chip {
  background: var(--navy3);
  border: 1.5px solid transparent;
  border-radius: 20px;
  color: var(--muted);
  cursor: pointer;
  font-family: 'Russo One', sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.07em;
  padding: 0.2rem 0.65rem;
  transition: all 0.15s;
}

.recent-chip:hover { border-color: var(--lime); color: var(--lime); }

/* ── Filter row ──────────────────────────────────────────────────────────── */
.filter-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: 0.75rem;
}

.filter-label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.filter-field {
  align-items: center;
  display: flex;
  gap: 0.35rem;
}

.filter-field span {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.filter-field input {
  background: var(--navy);
  border: 1.5px solid var(--navy3);
  border-radius: 6px;
  color: var(--white);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  padding: 0.28rem 0.55rem;
  text-transform: uppercase;
  transition: border-color 0.2s;
  width: 5.5rem;
  -webkit-appearance: none;
}

.filter-field input::placeholder { color: var(--muted); letter-spacing: 0; font-weight: 400; text-transform: none; }
.filter-field input:focus { outline: none; border-color: var(--lime); }

/* ── Count + share row ───────────────────────────────────────────────────── */
.count-row {
  align-items: center;
  display: flex;
  gap: 0.6rem;
  margin-top: 0.6rem;
}

.btn-share {
  align-items: center;
  background: transparent;
  border: 1.5px solid var(--navy3);
  border-radius: 20px;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  gap: 0.3rem;
  padding: 0.25rem 0.75rem;
  transition: all 0.15s;
}

.btn-share:hover { border-color: var(--lime); color: var(--lime); }

/* ── Word chip wrap + copy button ────────────────────────────────────────── */
.word-chip-wrap {
  align-items: stretch;
  display: inline-flex;
}

.word-chip-wrap .word-chip {
  border-radius: 8px 0 0 8px;
  border-right: none;
}

.wc-copy {
  align-items: center;
  background: var(--navy3);
  border: 1.5px solid var(--navy3);
  border-left: none;
  border-radius: 0 8px 8px 0;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  justify-content: center;
  padding: 0 0.45rem;
  transition: background 0.15s, color 0.15s;
}

.wc-copy:hover { background: var(--lime); color: var(--navy); border-color: var(--lime); }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast {
  background: var(--navy2);
  border: 1.5px solid var(--lime);
  border-radius: var(--radius);
  bottom: 1.5rem;
  box-shadow: var(--shadow);
  color: var(--lime);
  font-size: 0.9rem;
  font-weight: 600;
  left: 50%;
  opacity: 0;
  padding: 0.6rem 1.3rem;
  pointer-events: none;
  position: fixed;
  transform: translateX(-50%) translateY(0.6rem);
  transition: opacity 0.22s ease, transform 0.22s ease;
  white-space: nowrap;
  z-index: 9998;
}

.toast.toast-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
