* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --accent: #6366f1;
  --text: #1e293b;
  --glass: rgba(255, 255, 255, 0.92);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

html,
body {
  height: 100%;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(135deg, #667eea, #764ba2);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.6s ease;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 14px 40px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 100vh;
}

[hidden] {
  display: none !important;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
}

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

.brand-emoji {
  font-size: 34px;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.25));
}

.brand h1 {
  font-size: 1.35rem;
  line-height: 1.1;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.tagline {
  font-size: 0.72rem;
  opacity: 0.85;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.2);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 1.15rem;
  transition: transform 0.15s ease, background 0.2s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.34);
  transform: translateY(-1px);
}

.icon-btn:active {
  transform: scale(0.94);
}

/* ---------- Hint banner ---------- */
.hint {
  background: rgba(255, 255, 255, 0.16);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 14px;
  padding: 9px 12px;
  text-align: center;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.hint strong {
  color: #fde68a;
}

/* ---------- Controls ---------- */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.9);
}

.select {
  appearance: none;
  -webkit-appearance: none;
  padding: 9px 34px 9px 12px;
  border: none;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--text);
  background: var(--glass) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%2364748b' d='M6 8L0 0h12z'/></svg>") no-repeat right 10px center / 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  max-width: 240px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.95rem;
  font-family: inherit;
  color: #fff;
  background: rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
  transition: transform 0.12s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.chip:hover:not(:disabled) {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.4);
}

.chip.active {
  background: var(--accent);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.chip.locked {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ---------- Stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  background: var(--glass);
  border-radius: 18px;
  padding: 10px;
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat-value {
  font-weight: 800;
  font-size: 1.05rem;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #64748b;
}

/* ---------- Board / play area ---------- */
.board {
  position: relative;
  flex: 1 1 auto;
  min-height: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 18px 14px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.05));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18), var(--shadow);
}

.game-area {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 560px;
  margin: auto;
}

/* ---------- Word card ---------- */
.word-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  background: var(--glass);
  border-radius: 22px;
  padding: 18px 14px 16px;
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.word-card.correct {
  animation: cardCorrect 0.55s ease;
}

.word-card.shake {
  animation: shake 0.45s ease;
}

.word-card.miss-flash {
  box-shadow: 0 0 0 3px #ef4444, 0 0 24px rgba(239, 68, 68, 0.55), var(--shadow);
}

.clue {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.clue-icon {
  font-size: clamp(2.8rem, 14vw, 4rem);
  line-height: 1;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.18));
  animation: popIn 0.3s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}

.say-btn {
  width: 42px;
  height: 42px;
  background: var(--accent);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.say-btn:hover {
  background: var(--accent);
  filter: brightness(1.1);
}

/* ---------- Letter slots ---------- */
.slots {
  display: flex;
  justify-content: center;
  gap: 7px;
  width: 100%;
  max-width: 480px;
}

.slot {
  flex: 1 1 0;
  min-width: 0;
  max-width: 58px;
  height: clamp(48px, 15vw, 62px);
  border-radius: 14px;
  border: 3px dashed rgba(100, 116, 139, 0.45);
  background: rgba(241, 245, 249, 0.75);
  font-family: inherit;
  font-size: clamp(1.2rem, 7vw, 1.8rem);
  font-weight: 900;
  color: #0f172a;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  touch-action: manipulation;
}

.slot.empty:hover {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.95);
}

.slot.filled {
  border-style: solid;
  border-color: #cbd5e1;
  background: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  animation: popIn 0.18s ease both;
}

.slot.hover {
  border-color: var(--accent);
  border-style: solid;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.45), 0 6px 16px rgba(0, 0, 0, 0.14);
  transform: scale(1.06);
}

.slot:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Letter tray & tiles ---------- */
.tray {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 9px;
  min-height: clamp(54px, 16vw, 68px);
  padding: 12px 10px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.16);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.tray.shake {
  animation: shake 0.45s ease;
}

.tile {
  width: clamp(46px, 13vw, 58px);
  height: clamp(46px, 13vw, 58px);
  border-radius: 16px;
  border: none;
  background: linear-gradient(180deg, #ffffff, #eef2f7);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.18), inset 0 -3px 6px rgba(0, 0, 0, 0.08), inset 0 2px 3px rgba(255, 255, 255, 0.9);
  font-family: inherit;
  font-size: clamp(1.25rem, 7vw, 1.7rem);
  font-weight: 900;
  color: #0f172a;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: transform 0.12s ease, box-shadow 0.15s ease;
  animation: popIn 0.25s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}

.tile:hover {
  transform: translateY(-3px) rotate(-2deg);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
}

.tile:active {
  transform: scale(0.94);
  cursor: grabbing;
}

.tile:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

.tile.returning {
  animation: tileReturn 0.28s ease;
}

.ghost {
  position: fixed;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff, #eef2f7);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.32);
  font-family: inherit;
  font-size: clamp(1.25rem, 7vw, 1.7rem);
  font-weight: 900;
  color: #0f172a;
  pointer-events: none;
  transform: scale(1.12) rotate(3deg);
  will-change: left, top;
}

/* ---------- Word actions ---------- */
.word-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.check-btn {
  min-width: 130px;
}

.check-btn.ready {
  animation: pulse 1.1s ease infinite;
}

.clear-btn {
  background: #e2e8f0;
  color: #475569;
}

/* ---------- Start panel ---------- */
.start-panel {
  position: relative;
  z-index: 2;
  max-width: 440px;
  margin: 12px;
  padding: 30px 26px;
  text-align: center;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-radius: 24px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25), var(--shadow);
  animation: popIn 0.35s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}

.start-panel[hidden] {
  display: none;
}

.start-panel h2 {
  font-size: 1.5rem;
  margin-bottom: 8px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.start-panel p {
  font-size: 0.92rem;
  line-height: 1.5;
  margin-bottom: 10px;
}

.start-tips {
  font-size: 0.78rem !important;
  opacity: 0.85;
}

.btn-big {
  margin-top: 6px;
  padding: 14px 30px;
  font-size: 1.1rem;
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.75rem;
  margin-top: auto;
  padding-top: 12px;
}

/* ---------- Win overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  padding: 18px;
  animation: fadeIn 0.25s ease both;
}

.overlay[hidden] {
  display: none;
}

.modal {
  width: min(92vw, 400px);
  background: #fff;
  border-radius: 24px;
  padding: 26px 22px;
  text-align: center;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  animation: popIn 0.35s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}

.modal-stars {
  font-size: 2.4rem;
  letter-spacing: 6px;
  line-height: 1;
}

.star {
  color: #cbd5e1;
}

.star.lit {
  color: #f59e0b;
  filter: drop-shadow(0 2px 5px rgba(245, 158, 11, 0.6));
}

.modal h2 {
  margin: 8px 0 2px;
  font-size: 1.5rem;
  color: #0f172a;
}

.modal-subtitle {
  color: #64748b;
  font-size: 0.9rem;
  margin-bottom: 14px;
}

.modal-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 16px 0 20px;
}

.modal-stats div {
  background: #f1f5f9;
  border-radius: 12px;
  padding: 8px 2px;
}

.modal-stats span {
  display: block;
  font-weight: 800;
  font-size: 0.95rem;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}

.modal-stats label {
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn {
  padding: 12px 16px;
  border: none;
  border-radius: 14px;
  font-weight: 700;
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  background: #f1f5f9;
  color: #334155;
  transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.btn-primary:hover {
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
}

.btn-ghost {
  background: transparent;
  color: #64748b;
}

/* ---------- Effects canvas ---------- */
.fx-canvas {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
}

/* ---------- No JS ---------- */
.noscript {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: #f8fafc;
  color: #334155;
  font-weight: 600;
}

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

@keyframes tileReturn {
  from {
    transform: scale(0.75);
    opacity: 0.4;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

@keyframes cardCorrect {
  0% { box-shadow: var(--shadow); }
  30% {
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.45), 0 0 28px rgba(16, 185, 129, 0.6), var(--shadow);
    transform: scale(1.02);
  }
  100% { box-shadow: var(--shadow); }
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.65), 0 8px 20px rgba(0, 0, 0, 0.2);
  }
  50% {
    box-shadow: 0 0 0 9px rgba(255, 255, 255, 0), 0 8px 20px rgba(0, 0, 0, 0.2);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- Small screens ---------- */
@media (max-width: 400px) {
  .slots {
    gap: 5px;
  }

  .tray {
    gap: 7px;
  }

  .word-actions {
    flex-direction: row;
  }

  .check-btn {
    min-width: 112px;
  }
}
