/* Copyright (c) 2026 Geoff Hopcraft. All rights reserved. */

:root {
  --bg: #1a1a2e;
  --panel: #232342;
  --hex: #2f3360;
  --hex-edge: #454a85;
  --text: #f1f1f6;
  --muted: #9a9ab8;
  --gold: #ffd700;
  --good: #55efc4;
  --bad: #ff7675;
  --clue-tile: 24px;
  --clue-row: 28px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

button {
  font: inherit;
  color: var(--text);
  background: var(--hex);
  border: 1px solid var(--hex-edge);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}
button.primary { background: var(--gold); border-color: var(--gold); color: #1a1a2e; font-weight: 600; }

/* ── Celebration canvas ── */

#celebration-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 30;
}

/* ── Game screen: every block has a fixed height except the grid ── */

#game {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  padding: 6px 10px calc(4px + env(safe-area-inset-bottom));
  user-select: none;
  -webkit-user-select: none;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  flex: none;
}
h1 { margin: 0; font-size: 22px; letter-spacing: 1px; }
#btn-settings { font-size: 20px; line-height: 1; padding: 6px 10px; }

/* ── Clues ── */

#clues {
  flex: none;
  display: grid;
  grid-template-rows: repeat(4, var(--clue-row));
  background: var(--panel);
  border-radius: 10px;
  padding: 4px 10px;
}
.clue {
  display: flex;
  align-items: center;
  gap: 3px;
  height: var(--clue-row);
}
.clue .unit {
  width: var(--clue-tile);
  height: var(--clue-tile);
  line-height: var(--clue-tile);
  text-align: center;
  font-weight: 600;
  font-size: 15px;
  border-radius: 4px;
  background: var(--hex);
  color: var(--text);
}
.clue .unit.blank { background: transparent; box-shadow: inset 0 -2px 0 var(--muted); border-radius: 0; }
.clue.idle .unit.blank { opacity: 0.3; }
/* A just-completed clue: green for half a second, then fading out. The total
   matches SOLVED_MS in app.js. */
.clue.solved { animation: solved 0.9s linear forwards; }
.clue.solved .unit { background: transparent; color: var(--good); }
@keyframes solved {
  0%, 55% { opacity: 1; }
  100% { opacity: 0; }
}
.clue.won .unit { background: transparent; color: var(--gold); }
.clue .unit.new { animation: pop 0.5s ease-out; }
@keyframes pop {
  0% { transform: scale(0.3); background: var(--gold); color: #1a1a2e; }
  60% { transform: scale(1.25); background: var(--gold); color: #1a1a2e; }
  100% { transform: scale(1); }
}

/* ── Trace line ── */

#trace {
  flex: none;
  height: 40px;
  line-height: 40px;
  text-align: center;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#trace.msg { font-size: 15px; font-weight: 400; letter-spacing: 0; color: var(--muted); }
#trace.good { color: var(--good); }
#trace.bad { color: var(--bad); }
#trace.win { color: var(--gold); font-size: 16px; letter-spacing: 0; }

/* ── Grid ── */

#grid {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  touch-action: none;
  cursor: pointer;
}
#grid .hex { fill: var(--hex); stroke: var(--hex-edge); stroke-width: 1.5; }
#grid .letter {
  fill: var(--text);
  font-size: 44px;
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}
#grid .cell.sel .hex { fill: var(--gold); stroke: var(--gold); }
#grid .cell.sel .letter { fill: #1a1a2e; }
#grid .cell.good .hex { fill: var(--good); stroke: var(--good); }
#grid .cell.bad .hex { fill: var(--bad); stroke: var(--bad); }
#grid .cell.good .letter, #grid .cell.bad .letter { fill: #1a1a2e; }
#grid .path {
  fill: none;
  stroke: #1a1a2e;
  stroke-opacity: 0.35;
  stroke-width: 12;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

/* ── Bottom bar ── */

#bar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
}
#count { color: var(--muted); font-size: 15px; }
#btn-new { min-width: 130px; }
#count { white-space: nowrap; }
#btn-new.highlight { background: var(--gold); border-color: var(--gold); color: #1a1a2e; font-weight: 600; }

footer {
  flex: none;
  height: 18px;
  line-height: 18px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
}

/* ── Overlays ── */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(10, 10, 25, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.panel {
  width: 100%;
  max-width: 420px;
  max-height: 100%;
  overflow-y: auto;
  background: var(--panel);
  border-radius: 14px;
  padding: 16px 18px;
}
.panel.small { max-width: 320px; text-align: center; }
.panel h2 { margin: 0 0 8px; font-size: 20px; }
.panel h3 { margin: 16px 0 8px; font-size: 14px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 1px; }
.note { margin: 8px 0; font-size: 13px; color: var(--muted); }
.note a { color: var(--text); }
.buttons { display: flex; gap: 10px; justify-content: center; margin-top: 14px; }
#btn-close-settings { display: block; width: 100%; margin-top: 14px; }

#langs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
#styles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.chip { position: relative; padding: 10px 6px; text-align: center; }
#levels { display: grid; gap: 6px; }
.level-row { display: grid; grid-template-columns: 1fr repeat(5, 40px); gap: 6px; align-items: center; }
.level-row .chip { padding: 8px 0; }
.level-row.off { opacity: 0.4; }
.level-row .chip:disabled { cursor: default; }
.level-name { font-size: 15px; }
.chip.on { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
/* The order badge is always laid out, so selecting never resizes a chip. */
.chip .order {
  display: inline-block;
  width: 18px;
  margin-right: 4px;
  border-radius: 9px;
  background: var(--gold);
  color: #1a1a2e;
  font-size: 12px;
  font-weight: 700;
  line-height: 18px;
  visibility: hidden;
}
.chip.on .order { visibility: visible; }
