/* Cluegrid — nonogram picture-logic. Harness CSS per plan33.io template + theme. */

:root {
  --bg: #0b0e14;
  --fg: #e8ecf1;
  --muted: #8b95a5;
  --accent: #4de2a8;
  --bad: #ef6461;
  --scrim: rgba(6, 9, 14, 0.78);
  --panel: rgba(20, 26, 36, 0.94);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  background: var(--bg);
}

/* ---------- corner chrome ---------- */
.chrome {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top));
  right: calc(8px + env(safe-area-inset-right));
  display: flex;
  gap: 8px;
  z-index: 20;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--fg);
  font: 600 16px/1 var(--font);
  cursor: pointer;
  touch-action: manipulation;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.12); }
.icon-btn[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }

/* ---------- touch mode toggle (coarse pointers, while playing/paused) ---------- */
.modepad { display: none; }

@media (pointer: coarse) {
  body.state-playing .modepad,
  body.state-paused .modepad {
    display: block;
    position: fixed;
    left: calc(12px + env(safe-area-inset-left));
    bottom: calc(12px + env(safe-area-inset-bottom));
    z-index: 15;
  }
  .mode-btn {
    min-width: 92px;
    height: 52px;
    padding: 0 18px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.08);
    color: var(--fg);
    font: 700 15px/1 var(--font);
    touch-action: manipulation;
  }
  .mode-btn[data-marking="true"] {
    background: var(--bad);
    color: #2a0b0a;
    border-color: var(--bad);
  }
}

/* ---------- overlays: visibility driven purely by body state class ---------- */
.overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 24px;
  background: var(--scrim);
  backdrop-filter: blur(3px);
  z-index: 30;
  overflow-y: auto;
  pointer-events: none;
}

body.state-menu     .overlay-menu,
body.state-paused   .overlay-paused,
body.state-gameover .overlay-gameover { display: grid; }

.panel {
  width: min(440px, 100%);
  padding: 28px 24px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: var(--panel);
  text-align: center;
  animation: pop 180ms ease-out;
  margin: auto;
  pointer-events: auto;
}

@keyframes pop { from { transform: scale(0.96); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .panel { animation: none; } }

.panel h1 { margin: 0 0 6px; font-size: 30px; letter-spacing: 0.5px; }
.panel h2 { margin: 0 0 14px; font-size: 24px; }
.tagline  { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.score    { margin: 0 0 4px; font-size: 20px; font-weight: 600; }
.hi       { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.hint     { margin: 14px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

.btn {
  display: block;
  width: 100%;
  margin: 8px 0 0;
  padding: 14px 18px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #06210f;
  font: 700 16px/1 var(--font);
  cursor: pointer;
  touch-action: manipulation;
}
.btn:hover { filter: brightness(1.08); }

.btn-ghost {
  background: transparent;
  color: var(--fg);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.btn[hidden] { display: none; }

/* ---------- level select ---------- */
.level-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 4px 0 4px;
}

.level-btn {
  padding: 12px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--fg);
  font: 600 13px/1.3 var(--font);
  cursor: pointer;
  touch-action: manipulation;
}
.level-btn:hover:not([disabled]) { background: rgba(255, 255, 255, 0.12); }
.level-btn[data-current="true"] { border-color: var(--accent); color: var(--accent); }
.level-btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}
.level-btn .size { display: block; color: var(--muted); font-weight: 500; font-size: 11px; margin-top: 2px; }
