:root {
  --bg: #0f172a;
  --bg-alt: #1e293b;
  --fg: #e2e8f0;
  --muted: #94a3b8;
  --panel: rgba(30, 41, 59, 0.75);
  --border: rgba(148, 163, 184, 0.25);
  --tile: rgba(15, 23, 42, 0.75);
  --tile-border: rgba(148, 163, 184, 0.22);
  --absent: #475569;
  --present: #f59e0b;
  --correct: #22c55e;
  --key-bg: rgba(148, 163, 184, 0.18);
  --key-fg: #f8fafc;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.18);
  --danger: #ef4444;
  --toast: linear-gradient(135deg, rgba(56, 189, 248, 0.95), rgba(129, 140, 248, 0.92));
}

[v-cloak] { display: none; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(circle at top, rgba(56, 189, 248, 0.2), transparent 60%),
    radial-gradient(circle at bottom, rgba(249, 115, 22, 0.14), transparent 45%),
    linear-gradient(160deg, var(--bg), var(--bg-alt));
  color: var(--fg);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100%;
  padding-bottom: 32px;
}

.topbar {
  width: min(92vw, 520px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  margin-top: 26px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  backdrop-filter: blur(16px);
}

.title {
  margin: 0;
  font-size: 22px;
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 700;
}

.actions { display: flex; align-items: center; gap: 10px; }

.btn {
  background: var(--accent-soft);
  color: var(--fg);
  border: 1px solid rgba(56, 189, 248, 0.35);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.3px;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.btn:hover {
  transform: translateY(-1px);
  background: rgba(56, 189, 248, 0.28);
  border-color: rgba(56, 189, 248, 0.55);
}

.btn:active { transform: translateY(0); box-shadow: none; }

.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.game {
  width: min(92vw, 520px);
  padding: 22px;
  margin-top: 16px;
}

.board {
  width: 100%;
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: 22px;
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.15);
}

.row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }

.tile {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  border: 2px solid var(--tile-border);
  background: var(--tile);
  display: grid;
  place-items: center;
  text-transform: uppercase;
  font-weight: 700;
  font-size: 24px;
  color: var(--fg);
  line-height: 1;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.tile.flip { animation: flip 0.6s ease both; }

.tile.correct {
  background: linear-gradient(145deg, rgba(34, 197, 94, 0.95), rgba(22, 163, 74, 0.95));
  border-color: rgba(34, 197, 94, 0.7);
}

.tile.present {
  background: linear-gradient(145deg, rgba(245, 158, 11, 0.95), rgba(217, 119, 6, 0.95));
  border-color: rgba(245, 158, 11, 0.7);
}

.tile.absent {
  background: linear-gradient(150deg, rgba(15, 23, 42, 0.95), rgba(15, 23, 42, 0.88));
  border-color: rgba(15, 23, 42, 0.75);
  color: rgba(148, 163, 184, 0.7);
}

.tile.filled {
  border-color: rgba(56, 189, 248, 0.55);
  background: rgba(56, 189, 248, 0.22);
  color: #e0f2fe;
}

.row.shake { animation: shake 0.65s; }

.keyboard { margin-top: 26px; user-select: none; }
.kb-row { display: flex; justify-content: center; gap: 8px; margin-bottom: 10px; }

.key {
  background: var(--key-bg);
  color: var(--key-fg);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 12px;
  padding: 12px 10px;
  min-width: 36px;
  font-weight: 700;
  letter-spacing: 0.4px;
  cursor: pointer;
  font-size: 13px;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  backdrop-filter: blur(6px);
}

.key:hover { transform: translateY(-1px); }
.key:active { transform: translateY(0); box-shadow: none; }
.key.wide { min-width: 64px; padding: 12px 14px; }
.key.correct { background: rgba(34, 197, 94, 0.92); border-color: rgba(34, 197, 94, 0.6); }
.key.present { background: rgba(249, 115, 22, 0.9); border-color: rgba(249, 115, 22, 0.6); }
.key.absent {
  background: rgba(15, 23, 42, 0.88);
  border-color: rgba(15, 23, 42, 0.65);
  color: rgba(148, 163, 184, 0.8);
}

.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--toast);
  color: #0f172a;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.footer {
  margin: 36px 0 20px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

/* Animations */
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}

@keyframes flip {
  0% { transform: rotateX(0); }
  50% { transform: rotateX(90deg); }
  100% { transform: rotateX(0); }
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.65);
  display: grid;
  place-items: center;
  backdrop-filter: blur(6px);
}

.modal {
  background: rgba(15, 23, 42, 0.92);
  color: var(--fg);
  width: min(92vw, 480px);
  border-radius: 22px;
  padding: 22px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  backdrop-filter: blur(16px);
}

.modal h2 { margin: 4px 0 8px; font-size: 24px; }
.modal h3 { margin: 22px 0 12px; font-size: 16px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.2px; }

.stats-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }

.stat-card {
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 16px;
  padding: 12px;
  text-align: center;
}

.stat-card .num { font-size: 24px; font-weight: 700; }
.stat-card .label { font-size: 11px; color: var(--muted); letter-spacing: 0.8px; text-transform: uppercase; }

.dist { display: grid; gap: 6px; }
.dist-row { display: grid; grid-template-columns: 16px 1fr; gap: 10px; align-items: center; }
.dist-label { font-size: 12px; color: var(--muted); }

.dist-bar { background: rgba(148, 163, 184, 0.18); border-radius: 999px; overflow: hidden; }
.dist-fill { background: linear-gradient(135deg, rgba(56, 189, 248, 0.85), rgba(129, 140, 248, 0.88)); color: #0f172a; font-weight: 700; font-size: 11px; padding: 5px 10px; min-width: 36px; text-align: right; border-radius: 999px; }

.modal-actions { display: flex; justify-content: flex-end; margin-top: 20px; gap: 10px; }

.result-modal .round-status {
  margin: 4px 0 16px;
  color: var(--muted);
  font-size: 14px;
}

.result-answer {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 18px;
}

.result-answer .label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  color: var(--muted);
}

.result-answer .word {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 2px;
}

.dictionary-block {
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.18);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 18px;
}

.dictionary-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.dictionary-word {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1.5px;
}

.dictionary-phonetic {
  font-size: 14px;
  color: var(--muted);
}

.dictionary-meaning + .dictionary-meaning { margin-top: 12px; }

.dictionary-meaning .part-of-speech {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  margin-bottom: 6px;
}

.definitions {
  margin: 0;
  padding-left: 16px;
  display: grid;
  gap: 8px;
  font-size: 14px;
  color: var(--fg);
}

.definitions li { list-style: disc; }

.definitions .example {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.dictionary-error {
  margin: 0;
  color: var(--danger);
  font-size: 14px;
}

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

/* Responsive tweaks */
@media (max-width: 640px) {
  /* Softer light palette for small screens */
  :root {
    --bg: #f8fafc;
    --bg-alt: #e0f2fe;
    --fg: #0f172a;
    --muted: #475569;
    --panel: rgba(255, 255, 255, 0.92);
    --border: rgba(148, 163, 184, 0.4);
    --tile: rgba(255, 255, 255, 0.96);
    --tile-border: rgba(148, 163, 184, 0.35);
    --absent: #1f2937;
    --present: #f97316;
    --correct: #16a34a;
    --key-bg: rgba(148, 163, 184, 0.14);
    --key-fg: #0f172a;
    --accent: #3b82f6;
    --accent-soft: rgba(59, 130, 246, 0.16);
    --danger: #dc2626;
    --toast: linear-gradient(135deg, rgba(148, 163, 184, 0.9), rgba(59, 130, 246, 0.85));
  }

  body {
    background: #f4f9ff;
    color: var(--fg);
  }

  .topbar {
    padding: 12px 16px;
    border-radius: 16px;
    width: min(94vw, 460px);
    background: var(--panel);
    border: 1px solid rgba(148, 163, 184, 0.35);
    box-shadow: none;
    backdrop-filter: none;
  }

  .title { font-size: 20px; color: var(--fg); }
  .game { padding: 16px; }

  .board {
    padding: 14px;
    border-radius: 18px;
    gap: 8px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(148, 163, 184, 0.3);
    box-shadow: none;
  }

  .row { gap: 6px; }

  .tile {
    border-radius: 14px;
    font-size: 22px;
    background: var(--tile);
    color: var(--fg);
    box-shadow: none;
    transition: transform 0.1s ease-out, background 0.1s ease-out, border-color 0.1s ease-out;
  }

  .tile.absent {
    background: #1f2937;
    border-color: rgba(15, 23, 42, 0.78);
    color: #e2e8f0;
    box-shadow: none;
  }

  .tile.filled {
    border-color: rgba(59, 130, 246, 0.55);
    background: rgba(59, 130, 246, 0.16);
    color: #1d4ed8;
    box-shadow: none;
  }

  .tile.correct {
    background: #dcfce7;
    border-color: rgba(22, 163, 74, 0.7);
    color: #14532d;
    box-shadow: none;
  }

  .tile.present {
    background: #fef3c7;
    border-color: rgba(234, 88, 12, 0.7);
    color: #78350f;
    box-shadow: none;
  }

  .keyboard { margin-top: 22px; max-width: 98%; margin-left: auto; margin-right: auto; }
  .kb-row { gap: 4px; }

  .key {
    border-radius: 10px;
    padding: 8px 6px;
    min-width: 28px;
    font-size: 11px;
    background: var(--key-bg);
    color: var(--key-fg);
    border: 1px solid rgba(148, 163, 184, 0.35);
    box-shadow: none;
    backdrop-filter: none;
    transition: transform 0.08s ease-out, background 0.08s ease-out, border-color 0.08s ease-out;
  }

  .key.wide { min-width: 48px; padding: 8px 10px; }

  .key.absent {
    background: #1f2937;
    border-color: rgba(15, 23, 42, 0.8);
    color: #e2e8f0;
  }

  .key.correct {
    background: #16a34a;
    border-color: #15803d;
    color: #ecfdf5;
    box-shadow: none;
  }

  .key.present {
    background: #f97316;
    border-color: #ea580c;
    color: #fff7ed;
    box-shadow: none;
  }

  .tile.flip { animation: flip-mobile 0.22s ease-out both; }
  .row.shake { animation: shake-mobile 0.32s ease; }

  .modal-backdrop { background: rgba(15, 23, 42, 0.35); }

  .modal {
    background: rgba(255, 255, 255, 0.95);
    color: var(--fg);
    border: 1px solid rgba(148, 163, 184, 0.35);
    box-shadow: none;
    backdrop-filter: none;
  }

  .stat-card {
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
    box-shadow: none;
  }

  .result-modal .round-status { font-size: 13px; }

  .result-answer {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .result-answer .word { font-size: 24px; }

  .dictionary-block {
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
  }

  .dictionary-word { font-size: 20px; }
  .dictionary-phonetic { font-size: 13px; }
  .definitions { font-size: 13px; }
  .definitions .example { font-size: 11px; }

  .dist-bar { background: rgba(226, 232, 240, 0.8); }

  .dist-fill {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.85), rgba(96, 165, 250, 0.88));
    color: #0f172a;
  }

  .stats-cards { grid-template-columns: repeat(2, 1fr); }

  @keyframes flip-mobile {
    0% { transform: scale(0.96); }
    60% { transform: scale(1.02); }
    100% { transform: scale(1); }
  }

  @keyframes shake-mobile {
    0%, 100% { transform: translateX(0); }
    40% { transform: translateX(-3px); }
    70% { transform: translateX(3px); }
  }
}
