:root {
  --bg-1: #081120;
  --bg-2: #13284b;
  --glass: rgba(9, 17, 32, 0.8);
  --line: rgba(255, 255, 255, 0.1);
  --text: #eff6ff;
  --muted: #9fb4d4;
  --accent: #f59e0b;
  --accent-2: #fb7185;
  --chip: rgba(245, 158, 11, 0.16);
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: Inter, system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.34), transparent 26%),
    radial-gradient(circle at bottom right, rgba(251, 113, 133, 0.18), transparent 22%),
    linear-gradient(135deg, var(--bg-1), var(--bg-2));
}

button { font: inherit; }

.app-shell {
  height: 100vh;
  padding: 10px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
}

.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(255,255,255,0.06);
  padding: 6px;
}

h1, h2 {
  margin: 0;
}

h1 {
  font-size: clamp(1.2rem, 2.2vw, 1.8rem);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stat-pill {
  min-width: 86px;
  padding: 8px 12px;
  border-radius: 16px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
}

.stat-pill__label {
  display: block;
  font-size: .68rem;
  color: var(--muted);
  margin-bottom: 2px;
}

.stat-pill strong {
  font-size: 1.25rem;
}

.playfield {
  min-height: 0;
  display: grid;
  grid-template-columns: 1.55fr .7fr;
  gap: 10px;
}

.panel-stage,
.action-strip {
  min-height: 0;
}

.panel-stage {
  padding: 12px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.category-chip {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--chip);
  color: #fde68a;
  font-weight: 700;
  font-size: .82rem;
}

.result-inline {
  font-weight: 800;
  font-size: clamp(.95rem, 1.5vw, 1.15rem);
  text-align: right;
}

.phrase-board {
  min-height: 0;
  display: grid;
  align-content: center;
  gap: 10px;
  padding: 10px;
  border-radius: 18px;
  background: rgba(255,255,255,0.04);
}

.phrase-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.tile,
.letter-box {
  min-width: clamp(26px, 2.8vw, 40px);
  height: clamp(34px, 5vh, 48px);
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, rgba(255,255,255,0.14), rgba(255,255,255,0.06));
  border: 1px solid rgba(255,255,255,0.08);
  font-size: clamp(.92rem, 1.45vw, 1.25rem);
  font-weight: 800;
}

.tile.space,
.letter-box.space {
  min-width: 14px;
  background: transparent;
  border-color: transparent;
}

.letter-box.revealed {
  color: var(--text);
}

.panel-footer {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 10px;
}

.panel-hint,
.used-letters {
  margin: 0;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.25;
}

.action-strip {
  padding: 12px;
  display: grid;
}

.control-card {
  display: grid;
  gap: 10px;
  border-radius: 24px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 12px;
}

.control-card--center {
  align-content: center;
}

button {
  border: 0;
  border-radius: 16px;
  padding: 12px 14px;
  font-weight: 800;
  cursor: pointer;
}

.primary-btn {
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.primary-btn--big {
  min-height: 56px;
  font-size: 1.02rem;
}

.ghost-btn {
  color: var(--text);
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.08);
}

.overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(3, 7, 18, 0.72);
  z-index: 30;
  padding: 14px;
}

.overlay.visible {
  display: grid;
}

.overlay-card {
  width: min(100%, 1080px);
  max-height: 100%;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.overlay-card--wheel {
  justify-items: center;
}

.overlay-card--keyboard {
  width: min(100%, 1100px);
}

.overlay-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

canvas {
  width: min(100%, 360px);
  aspect-ratio: 1 / 1;
  height: auto;
  max-height: 54vh;
}

.keyboard-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
}

.key-btn {
  min-height: 54px;
  font-size: 1.05rem;
  font-weight: 800;
}

.key-btn:disabled {
  opacity: .35;
  cursor: not-allowed;
}

@media (max-height: 640px) and (orientation: landscape) {
  .app-shell {
    padding: 8px;
    gap: 8px;
  }

  .topbar,
  .panel-stage,
  .action-strip,
  .control-card,
  .overlay-card {
    padding: 10px;
  }

  .brand-icon {
    width: 40px;
    height: 40px;
  }

  h1 {
    font-size: 1.04rem;
  }

  .eyebrow {
    font-size: .58rem;
    margin-bottom: 2px;
  }

  .stat-pill {
    min-width: 72px;
    padding: 7px 10px;
  }

  .stat-pill strong {
    font-size: 1rem;
  }

  .phrase-board {
    gap: 8px;
    padding: 8px;
  }

  .phrase-row {
    gap: 6px;
  }

  .tile,
  .letter-box {
    min-width: 24px;
    height: 28px;
    font-size: .78rem;
    border-radius: 9px;
  }

  .panel-hint,
  .used-letters,
  .result-inline {
    font-size: .78rem;
  }

  .primary-btn--big,
  .ghost-btn,
  .primary-btn {
    min-height: 42px;
    padding: 8px 10px;
    font-size: .88rem;
  }

  canvas {
    width: min(100%, 260px);
    aspect-ratio: 1 / 1;
    max-height: 42vh;
  }

  .keyboard-grid {
    grid-template-columns: repeat(9, minmax(0, 1fr));
    gap: 8px;
  }

  .key-btn {
    min-height: 40px;
    font-size: .9rem;
  }
}

@media (max-width: 900px) {
  html, body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
  }

  .playfield,
  .panel-footer {
    grid-template-columns: 1fr;
  }

  .keyboard-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}
