:root {
  --bg: #020617;
  --panel: rgba(17, 24, 39, 0.9);
  --line: #374151;
  --primary: #3b82f6;
  --primary-2: #60a5fa;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --ok: #86efac;
  --bad: #fbbf24;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  color: var(--text);
  font-family: "OpenDyslexic", "Open Dyslexic", "Segoe UI", sans-serif;
  background: var(--bg);
}

.bg-layer,
.bg-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.bg-layer {
  background: center/cover no-repeat url("./assets/ui/crypt_background.png");
  z-index: 0;
}

.bg-overlay {
  background: linear-gradient(180deg, rgba(2, 6, 23, 0.35), rgba(2, 6, 23, 0.75));
  z-index: 1;
}

.phone-shell {
  position: fixed;
  z-index: 2;
  top: 0.5rem;
  bottom: 0.5rem;
  left: 50%;
  transform: translateX(-50%);
  width: min(100vw - 1rem, 430px);
  background: rgba(2, 6, 23, 0.4);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.55rem;
  overflow: auto;
}

.titlebar {
  text-align: center;
  margin-bottom: 0.45rem;
}

.titlebar h1 {
  margin: 0;
  color: var(--primary-2);
  font-size: 1.9rem;
}

.titlebar p {
  margin: 0.1rem 0 0;
  color: var(--muted);
}

.screen { display: grid; gap: 0.5rem; }
.hidden { display: none; }

.card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 0.9rem;
  padding: 0.6rem;
}

.king-card { padding: 0.35rem; }
.king-card.small { max-height: 220px; overflow: hidden; }
.king-image {
  width: 100%;
  height: min(38vh, 340px);
  object-fit: contain;
  object-position: center bottom;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  background: rgba(2, 6, 23, 0.35);
}

button,
input {
  width: 100%;
  min-height: 44px;
  border-radius: 0.7rem;
  border: 1px solid var(--line);
  background: #1f2937;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  padding: 0.45rem 0.6rem;
}

button { cursor: pointer; }
button.primary {
  background: linear-gradient(180deg, var(--primary-2), var(--primary));
  border-color: #3b82f6;
}
button:disabled { opacity: 0.45; }

.stack,
.stack-2,
.choice-grid,
.region-grid {
  display: grid;
  gap: 0.4rem;
}

.stack-2,
.choice-grid,
.region-grid {
  grid-template-columns: 1fr 1fr;
}

.row.top {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.4rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.stage {
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  height: min(42vh, 320px);
  overflow: hidden;
  background: rgba(2, 6, 23, 0.45);
}

#bone-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

h2 {
  margin: 0.2rem 0;
  font-size: 1.15rem;
}

.muted { color: var(--muted); margin: 0.2rem 0; min-height: 1.1rem; }
.muted.good { color: var(--ok); }
.muted.bad { color: var(--bad); }

.diagram {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  background: rgba(2, 6, 23, 0.45);
}

.group-list,
.dex-list {
  display: grid;
  gap: 0.35rem;
  max-height: 38vh;
  overflow: auto;
}

.group-item,
.dex-item {
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  padding: 0.45rem;
  background: rgba(31, 41, 55, 0.75);
}

.dex-item.locked {
  opacity: 0.5;
  filter: grayscale(0.9);
}

@media (min-width: 900px) {
  .phone-shell {
    width: 430px;
  }
}
