/* ==========================================================================
   Tile Blast styles
   Colors used inside the canvas live in js/config.js (THEME).
   ========================================================================== */

:root {
  color-scheme: dark;
  --bg: #151432;
  --panel: #201f45;
  --line: #34336a;
  --ink: #f3f1ff;
  --muted: #a19fd0;
  --gold: #ffcf3f;
  --warn-bg: #5a1f3a;
  --warn-line: #ff5c8a;
  --radius: 12px;
  --font-display: "Lilita One", system-ui, sans-serif;
  --font-body: Nunito, system-ui, -apple-system, "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  min-width: 0;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font-body);
  overflow-x: clip;
}

body {
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- layout ---------- */

#app {
  max-width: 540px;
  margin: 0 auto;
  padding: 12px 14px 24px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

h1 {
  margin: 0;
  font: 400 26px/1 var(--font-display);
  letter-spacing: 0.5px;
}

h1 span,
.gold {
  color: var(--gold);
}

/* ---------- buttons ---------- */

button {
  min-height: 40px;
  padding: 0 14px;
  font: 700 14px var(--font-body);
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}

button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Sound buttons: round icons. aria-pressed="true" = turned off */
.controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.round-button {
  display: grid;
  place-items: center;
  width: 40px;
  padding: 0;
  border-radius: 50%;
}

.round-button[aria-pressed="true"] {
  color: var(--muted);
}

.round-button .icon-off,
.round-button[aria-pressed="true"] .icon-on {
  display: none;
}

.round-button[aria-pressed="true"] .icon-off {
  display: inline;
}

button.is-confirming {
  background: var(--warn-bg);
  border-color: var(--warn-line);
}

/* ---------- HUD ---------- */

.hud {
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.stat {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 6px 10px;
  text-align: center;
}

.stat small {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.stat b {
  display: block;
  font: 400 22px/1.15 var(--font-display);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--muted);
}

.progress span {
  white-space: nowrap;
}

.bar {
  flex: 1;
  height: 8px;
  background: var(--panel);
  border-radius: 4px;
  overflow: hidden;
}

.bar i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--gold);
  border-radius: 4px;
  transition: width 0.35s;
}

/* ---------- board ---------- */

#stage {
  position: relative;
  display: flex;
  justify-content: center;
}

canvas {
  display: block;
  touch-action: none;
}

#toast {
  position: absolute;
  left: 50%;
  top: 38%;
  width: max-content;
  max-width: 90%;
  padding: 12px 18px;
  text-align: center;
  font: 400 20px/1.2 var(--font-display);
  color: var(--ink);
  background: rgba(21, 20, 50, 0.92);
  border: 2px solid var(--gold);
  border-radius: 14px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.9);
  transition: opacity 0.25s, transform 0.25s;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

#toast small {
  display: block;
  margin-top: 4px;
  font: 700 14px var(--font-body);
  color: var(--muted);
}

/* ---------- rules ---------- */

.rules {
  margin-top: 14px;
  padding: 10px 14px;
  font-size: 15px;
  color: var(--muted);
  background: var(--panel);
  border-radius: var(--radius);
}

.rules summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--ink);
}

.rules ul {
  margin: 8px 0 4px;
  padding-left: 18px;
}

.rules b {
  color: var(--ink);
}

.noscript {
  text-align: center;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  #toast,
  .bar i {
    transition: none;
  }
}
