/* Chimp Chain — presentation. CSS custom properties are the single source of truth for color;
   the canvas reads these same tokens at runtime, so theming (incl. shell dark mode) flows from here. */

:root {
  color-scheme: dark;

  /* Jungle-temple palette — deliberately not the cream/terracotta or black/acid-green defaults. */
  --bg: #0e1a17;
  --bg-glow: #16342b;
  --stone: #5b5245;
  --stone-dark: #322d26;
  --stone-edge: #7a6c55;
  --gold: #e8c069;
  --text: #ece7db;
  --muted: #9a9384;
  --danger: #e5484d;

  /* Gem hues, keyed to the core's R / G / B ids. */
  --gem-r: #ef5a6f;
  --gem-g: #46b483;
  --gem-b: #4a90e2;
  --gem-hi: rgba(255, 255, 255, 0.9);

  --panel: rgba(16, 26, 23, 0.86);
  --panel-line: rgba(232, 192, 105, 0.28);
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #efe7d6;
  --bg-glow: #fbf6ea;
  --stone: #b9ac93;
  --stone-dark: #8f8269;
  --stone-edge: #d8cbac;
  --gold: #b8862a;
  --text: #2c2822;
  --muted: #6f6857;
  --gem-r: #e03b54;
  --gem-g: #2f9d6c;
  --gem-b: #2f76cf;
  --panel: rgba(251, 246, 234, 0.9);
  --panel-line: rgba(184, 134, 42, 0.32);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

#stage {
  position: fixed;
  inset: 0;
  display: block;
}

#board {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* HUD — kept quiet; the gem chain is the star. */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  pointer-events: none;
  font-size: 14px;
}

#hud .left,
#hud .right { display: flex; align-items: center; gap: 14px; }

#level-name { font-weight: 600; letter-spacing: 0.02em; }

.stat { color: var(--muted); font-variant-numeric: tabular-nums; }
.stat b { color: var(--text); font-weight: 600; }

.iconbtn {
  pointer-events: auto;
  appearance: none;
  border: 1px solid var(--panel-line);
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  width: 38px;
  height: 38px;
  font-size: 16px;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.iconbtn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.iconbtn:active { transform: translateY(1px); }

/* Center overlay for win / lose / pause. */
#overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: color-mix(in srgb, var(--bg) 62%, transparent);
  backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease;
}
#overlay.show { opacity: 1; visibility: visible; }

.card {
  width: min(360px, 100%);
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  padding: 22px 22px 18px;
  text-align: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
}
.card h1 { margin: 2px 0 6px; font-size: 22px; letter-spacing: 0.01em; }
.card p { margin: 0 0 16px; color: var(--muted); font-size: 14px; line-height: 1.4; }

.btnrow { display: flex; gap: 10px; justify-content: center; }
.btn {
  appearance: none;
  border: none;
  border-radius: 11px;
  padding: 11px 18px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.btn.primary { background: var(--gold); color: #201a0c; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--panel-line); }
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.btn:active { transform: translateY(1px); }

/* Dev-only overlay, injected by js/dev.mjs when isDev is set. */
#dev {
  position: absolute;
  left: 10px;
  bottom: 10px;
  font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  padding: 8px 10px;
  pointer-events: auto;
  white-space: pre;
}
#dev button {
  font: inherit;
  margin-top: 6px;
  cursor: pointer;
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--panel-line);
  border-radius: 6px;
  padding: 3px 8px;
}

@media (prefers-reduced-motion: reduce) {
  #overlay { transition: none; }
}
