:root {
  color-scheme: dark;
  --bg: #07111f;
  --panel: rgba(11, 20, 35, 0.92);
  --panel-soft: rgba(18, 30, 48, 0.92);
  --text: #e5eef9;
  --muted: #9fb3c8;
  --line: rgba(159, 179, 200, 0.14);
  --brand: #63c8ff;
  --success: #2dd4bf;
  --warm: #f59e0b;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at top, #17304e 0%, #07111f 42%, #020812 100%);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  overflow: hidden;
}
button { font: inherit; }
body { min-height: 100dvh; }
.hidden { display: none !important; }
.app-shell {
  width: min(100vw, 1200px);
  height: 100dvh;
  margin: 0 auto;
  padding: 12px;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 10px;
}
.topbar, .hud-card, .ring-card, .grid-card, .footer-strip, .toast {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(14px);
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-radius: 22px;
}
.eyebrow, .label, .muted { margin: 0; color: var(--muted); }
.eyebrow, .label { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.68rem; }
h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: clamp(1.35rem, 4vw, 2rem); }
.hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.hud-card {
  border-radius: 18px;
  padding: 10px 12px;
  min-height: 70px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.hud-card span { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; }
.hud-card strong { font-size: 1.12rem; }
.hud-card.accent strong { color: #d9fbff; }
.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(280px, 1.05fr);
  gap: 10px;
  min-height: 0;
}
.ring-card, .grid-card {
  border-radius: 22px;
  padding: 12px;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 10px;
}
.ring-head, .panel-head, .footer-strip, .action-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.panel-head.slim { margin-bottom: 6px; }
.status-pill {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(99, 200, 255, 0.12);
  border: 1px solid rgba(99, 200, 255, 0.22);
  color: #d9f1ff;
  font-size: 0.76rem;
}
.ring-shell {
  position: relative;
  width: min(100%, 388px);
  aspect-ratio: 1;
  margin: 0 auto;
  touch-action: none;
  user-select: none;
}
.ring-center {
  position: absolute;
  inset: 22%;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(99,200,255,0.22), rgba(11,20,35,0.97) 68%);
  border: 1px solid rgba(99, 200, 255, 0.16);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 16px;
}
.current-word {
  width: 100%;
  font-size: clamp(1rem, 3vw, 1.3rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.path-hint { color: var(--muted); font-size: 0.78rem; margin-top: 8px; }
.letter-btn {
  position: absolute;
  width: clamp(60px, 12vw, 76px);
  height: clamp(60px, 12vw, 76px);
  border: 2px solid rgba(255,255,255,0.22);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(180deg, #4d7fb4 0%, #16304d 100%);
  color: #ffffff;
  font-size: clamp(1.2rem, 4.2vw, 1.85rem);
  font-weight: 900;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  box-shadow: 0 8px 20px rgba(0,0,0,0.28), inset 0 0 0 1px rgba(255,255,255,0.08);
  user-select: none;
  touch-action: none;
}
.letter-btn.selected {
  background: linear-gradient(180deg, #8ad9ff 0%, #1d4ed8 100%);
  color: white;
  transform: translate(-50%, -50%) scale(1.08);
}
.letter-btn.locked { opacity: 1; }
.action-row { margin-top: auto; }
.secondary-btn, .primary-btn, .ghost-btn {
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 16px;
  padding: 10px 12px;
}
.secondary-btn { background: #16263b; }
.primary-btn { background: linear-gradient(180deg, #1fbf94 0%, #0f8a78 100%); font-weight: 800; }
.ghost-btn { background: transparent; padding-inline: 14px; }
.crossword-grid {
  width: 100%;
  aspect-ratio: 1 / 0.9;
  display: grid;
  gap: 6px;
  align-content: start;
}
.grid-cell {
  position: relative;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: clamp(0.95rem, 2.8vw, 1.15rem);
  font-weight: 800;
  background: rgba(18, 30, 48, 0.95);
  border: 1px solid rgba(159,179,200,0.12);
  min-height: 0;
}
.grid-cell.block { background: transparent; border: 1px dashed rgba(159,179,200,0.1); opacity: 0.25; }
.grid-cell.open { color: rgba(229, 238, 249, 0.15); }
.grid-cell.filled { background: rgba(17, 54, 82, 0.92); border-color: rgba(99,200,255,0.34); }
.grid-cell .number {
  position: absolute;
  top: 5px;
  left: 7px;
  font-size: 0.58rem;
  color: var(--muted);
  font-weight: 700;
}
.clue-box { display: grid; gap: 6px; }
.clue-list {
  display: grid;
  gap: 6px;
  font-size: 0.86rem;
}
.clue-item {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(18, 30, 48, 0.75);
  border: 1px solid rgba(159,179,200,0.1);
}
.clue-item.done { border-color: rgba(45,212,191,0.3); color: #d6fffa; }
.clue-num {
  width: 20px; height: 20px; border-radius: 999px;
  display: grid; place-items: center; flex: 0 0 auto;
  background: rgba(99, 200, 255, 0.16);
  color: #dff5ff;
  font-size: 0.68rem;
}
.footer-strip {
  border-radius: 18px;
  padding: 10px 12px;
  min-height: 70px;
}
.found-strip { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.pill {
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(99,200,255,0.12);
  border: 1px solid rgba(99,200,255,0.18);
  font-size: 0.78rem;
}
.pill.bonus { background: rgba(45,212,191,0.12); border-color: rgba(45,212,191,0.18); }
.toast {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%) translateY(110%);
  opacity: 0;
  max-width: calc(100vw - 18px);
  background: rgba(8, 14, 24, 0.96);
  border: 1px solid rgba(159,179,200,0.18);
  border-radius: 14px;
  padding: 10px 14px;
  transition: transform 180ms ease, opacity 180ms ease;
  z-index: 50;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
@media (max-width: 860px) {
  .app-shell { grid-template-rows: auto auto 1fr auto; }
  .workspace { grid-template-columns: 1fr; }
  .ring-shell { width: min(82vw, 340px); }
  .crossword-grid { aspect-ratio: 1 / 0.72; }
}
@media (max-width: 430px) {
  .app-shell { padding: 8px; gap: 8px; }
  .topbar { padding: 10px 12px; }
  .hud { gap: 6px; }
  .hud-card { min-height: 62px; padding: 8px 10px; }
  .hud-card span { font-size: 0.64rem; }
  .hud-card strong { font-size: 1rem; }
  .ring-card, .grid-card, .footer-strip { padding: 10px; }
  .ring-shell { width: min(84vw, 300px); }
  .grid-cell { border-radius: 10px; }
  .clue-item { padding: 7px 8px; }
}
