/* Slither: temple ruins. The page is a torch-lit temple wall; menus and
   results are carved sandstone tablets with a key-pattern border; the HUD
   is a stone plaque with a sand timer; buttons are stone blocks and gold
   plaques. The board itself is drawn by temple-art.js. */
@import url("https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700;900&family=Alegreya+Sans:ital,wght@0,400;0,500;0,700;0,800;1,500&display=swap");
:root {
  --bg: #15110d;
  --text: #efe3c8;         /* on the dark wall */
  --muted: #b3a283;
  --gold: #e2b653;
  --gold-hi: #fff0bf;
  --gold-lo: #8a6420;
  --stone: #4a3e2f;
  --stone-hi: #6a5a44;
  --stone-lo: #1c160f;
  --sand: #dcc796;         /* tablets */
  --sand-hi: #f1e3bf;
  --sand-lo: #a88d5f;
  --ink: #3b2914;          /* text carved into sand */
  --ink-muted: #654c2c;
  --p1: #3ad08a;           /* jade */
  --p2: #6d9ff2;           /* lapis */
  --display: "Cinzel", Georgia, "Times New Roman", serif;
  --body: "Alegreya Sans", system-ui, sans-serif;
  /* One course of offset ashlar, tiled across the wall. */
  --ashlar: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='80'%3E%3Cpath d='M0 1h160M0 41h160M1 0v40M81 40v40' fill='none' stroke='%23000' stroke-opacity='.32' stroke-width='2'/%3E%3C/svg%3E");
  /* A Greek-key band for the tablets. */
  --key: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='10'%3E%3Cpath d='M0 9h13V1H5v5h4V4' fill='none' stroke='%238a6c42' stroke-width='1.6'/%3E%3C/svg%3E");
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  color: var(--text);
  font-family: var(--body);
  background-color: var(--bg);
  background-image:
    radial-gradient(1100px 600px at 50% 115%, rgba(0,0,0,0.65), transparent 70%),
    var(--ashlar),
    linear-gradient(180deg, #1d1712, #120e0a);
  background-attachment: fixed;
}
/* Torchlight from the two upper corners, with a slow flicker (stops when
   Visual FX is off). */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(520px 360px at 6% -4%, rgba(255,150,60,0.2), transparent 70%),
    radial-gradient(520px 360px at 94% -4%, rgba(255,150,60,0.2), transparent 70%);
  animation: slTorch 3.2s ease-in-out infinite alternate;
}
@keyframes slTorch { 0% { opacity: 0.85; } 45% { opacity: 1; } 60% { opacity: 0.78; } 100% { opacity: 0.95; } }
a { color: var(--gold); text-decoration: none; font-weight: 700; }
.wrap { position: relative; min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 0.9rem 1rem 1.6rem; gap: 0.7rem; }
h1.title {
  font-family: var(--display);
  font-weight: 900;
  font-size: 2.15rem;
  letter-spacing: 0.1em;
  margin: 0;
  line-height: 1.1;
  background: linear-gradient(180deg, var(--gold-hi) 0%, var(--gold) 48%, var(--gold-lo) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 0 rgba(0,0,0,0.7));
}
.subtitle { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.82rem; letter-spacing: 0.14em; text-transform: uppercase; font-weight: 500; }

/* ---- board ---------------------------------------------------------------- */
.board-wrap { display: flex; justify-content: center; width: 100%; }
canvas.board {
  background: #1a1510;
  border-radius: 6px;
  touch-action: none;
  display: block;
  width: min(94vw, 440px);   /* game.js sets the width per board; height follows the canvas's aspect ratio */
  height: auto;
  border: 3px solid #5a4a36;
  box-shadow: 0 0 0 1px #0d0a07, 0 14px 34px rgba(0,0,0,0.7), 0 0 70px rgba(255,160,70,0.07);
}

/* ---- stone buttons -------------------------------------------------------- */
.btn {
  cursor: pointer;
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.86rem;
  letter-spacing: 0.05em;
  border-radius: 7px;
  padding: 0.52rem 0.95rem;
  color: var(--text);
  background: linear-gradient(180deg, var(--stone-hi), var(--stone));
  border: 1px solid var(--stone-lo);
  box-shadow: inset 0 1px 0 rgba(255,235,190,0.22), 0 3px 0 #0d0a07;
  transition: filter 0.15s ease, transform 0.08s ease, box-shadow 0.08s ease;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255,235,190,0.15), 0 1px 0 #0d0a07; }
.row { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; align-items: center; }

/* Gold plaques for the main action of each screen. */
#play-btn, #result-primary, #pause-resume {
  color: #3a2608;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold) 55%, #b98a32);
  border-color: #6f4e15;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 3px 0 #5a3e0e, 0 0 18px rgba(226,182,83,0.25);
  text-shadow: 0 1px 0 rgba(255,245,210,0.6);
}

/* ---- HUD ---------------------------------------------------------------------- */
.stat { font-size: 0.9rem; color: var(--muted); font-weight: 500; }
.stat b { color: #f3d68c; font-variant-numeric: tabular-nums; font-weight: 800; }
.lab-hud {
  width: min(94vw, 640px);   /* width follows the board (game.js) */
  display: flex; flex-direction: column; gap: 0.3rem;
  padding: 0.35rem 0.6rem 0.4rem;
  background: linear-gradient(180deg, #2b2319, #1f1912);
  border: 1px solid #4a3c2a;
  border-radius: 7px;
  box-shadow: inset 0 1px 0 rgba(255,230,180,0.12), 0 4px 12px rgba(0,0,0,0.45);
}
.lab-stats { gap: 0.9rem; }
.lab-stats .stat { color: #d9c9a6; }
#lab-level { font-family: var(--display); font-weight: 700; font-size: 0.82rem; letter-spacing: 0.04em; }
.lab-chip { display: inline-flex; align-items: center; gap: 0.3rem; }
/* Pack runs (Ziggy rules) on the level select. */
.lab-runs { text-align: left; margin: 0.2rem 0 0.4rem; padding: 0.45rem 0.65rem; border: 1px solid rgba(122,92,52,0.35); border-radius: 10px; background: rgba(255,248,230,0.35); }
.lab-runs p { margin: 0.15rem 0 0.45rem; font-size: 0.82rem; color: var(--ink-muted); line-height: 1.3; }
.lab-runs .row { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: flex-start; }
.lab-runs .btn { font-size: 0.82rem; padding: 0.35rem 0.7rem; }
.lab-runs .btn small { font-weight: 700; opacity: 0.8; margin-left: 0.25rem; }
.lab-runs .btn.cont { border-color: #8a6420; box-shadow: 0 0 0 2px var(--gold); }
.lab-runs .btn:disabled { opacity: 0.45; cursor: not-allowed; filter: grayscale(0.4); }
.lab-runs > summary { cursor: pointer; list-style: none; margin: 0; }
.lab-runs > summary::-webkit-details-marker { display: none; }
.lab-runs > summary::before { content: "▸ "; display: inline-block; transition: transform 0.15s ease; }
.lab-runs[open] > summary::before { transform: rotate(90deg); }
.lab-runs[open] > summary { margin-bottom: 0.2rem; }
.lab-meter { display: inline-block; width: 54px; height: 7px; border-radius: 4px; background: #120e0a; border: 1px solid #3a2f22; overflow: hidden; vertical-align: middle; }
.lab-meter i { display: block; height: 100%; width: 0; background: #cdefff; transition: width 0.12s linear; }
#lab-ghost.on .lab-meter i { background: #8fe4ff; box-shadow: 0 0 6px #8fe4ff; }
/* The clock is sand draining from a stone channel. */
.lab-timebar { height: 7px; border-radius: 4px; background: #120e0a; border: 1px solid #3a2f22; overflow: hidden; }
.lab-timebar i {
  display: block; height: 100%; width: 100%;
  background-color: #e8c26a;
  background-image: repeating-linear-gradient(90deg, rgba(255,255,255,0.18) 0 2px, transparent 2px 5px);
}
.lab-hint { margin: 0; text-align: center; color: #bfae8b; font-size: 0.86rem; font-style: italic; line-height: 1.3; min-height: 1.15em; }

/* ---- touch controls: carved stone keys ------------------------------------------ */
.dpads { display: flex; gap: 2rem; justify-content: center; margin-top: 0.5rem; flex-wrap: wrap; }
.dpad-block { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; }
.dpad-name { font-family: var(--body); font-weight: 800; font-size: 0.82rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); } /* Cinzel's 1 reads as I */
.p1-color { color: var(--p1); }
.p2-color { color: var(--p2); }
.dpad {
  display: grid;
  grid-template-columns: repeat(3, 42px);
  grid-template-rows: repeat(2, 42px);
  gap: 4px;
  justify-items: center;
  align-items: center;
}
.dbtn, .ebtn {
  width: 44px; height: 44px;   /* accessible tap-target floor on iOS/Android */
  border-radius: 8px;
  background: linear-gradient(180deg, #5c4e3b, #3a3025);
  border: 1px solid var(--stone-lo);
  color: #f0d898;
  font-size: 1.05rem;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;      /* a tap must never scroll the page mid-run */
  box-shadow: inset 0 1px 0 rgba(255,235,190,0.25), 0 3px 0 #0d0a07;
}
.dbtn:active, .dbtn.held, .ebtn:active { transform: translateY(2px); background: #3a3025; box-shadow: inset 0 1px 0 rgba(255,235,190,0.12), 0 1px 0 #0d0a07; }
/* Fire Eggs: lay an egg, in the d-pad's empty top-right corner */
.ebtn { grid-column: 3; grid-row: 1; border-color: #b8652a; background: linear-gradient(180deg, #7a4a2a, #4a2c18); }
.dbtn.up { grid-column: 2; grid-row: 1; }
.dbtn.left { grid-column: 1; grid-row: 2; }
.dbtn.right { grid-column: 3; grid-row: 2; }
.dbtn.down { grid-column: 2; grid-row: 2; }
.lab-btn-row { display: flex; gap: 0.6rem; height: 88px; align-items: center; }
.pbtn {
  width: 58px; height: 58px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #6e5d47, #3a3025 72%);
  border: 2px solid var(--stone-lo);
  color: var(--text);
  font-size: 1.5rem; cursor: pointer;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  touch-action: none;
  box-shadow: inset 0 1px 0 rgba(255,235,190,0.25), 0 3px 0 #0d0a07;
}
.pbtn.held { transform: translateY(2px); border-color: var(--gold); box-shadow: 0 0 14px rgba(226,182,83,0.45), 0 1px 0 #0d0a07; }

/* ---- tablets (menu, pause, results) ------------------------------------------------ */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  display: flex; padding: 1.1rem;
  /* Tall cards (the Labyrinth menu on a phone) scroll instead of losing their top. */
  overflow-y: auto;
  background: radial-gradient(900px 600px at 50% 40%, rgba(20,15,10,0.82), rgba(5,4,3,0.94));
}
.overlay.hidden { display: none; }
.card {
  position: relative;
  margin: auto;
  max-width: 560px; width: 100%;
  text-align: center;
  color: var(--ink);
  padding: 1.35rem 1.4rem 1.25rem;
  border-radius: 10px;
  border: 3px solid #7d6139;
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(255,248,225,0.45), transparent 60%),
    radial-gradient(90% 60% at 80% 100%, rgba(120,90,50,0.18), transparent 70%),
    linear-gradient(180deg, #e6d3a8, var(--sand) 55%, #c9ae78);
  box-shadow: inset 0 0 0 2px var(--sand-hi), inset 0 0 0 5px rgba(125,97,57,0.3), 0 22px 60px rgba(0,0,0,0.7);
}
.card::before, .card::after {
  content: "";
  position: absolute; left: 12px; right: 12px; height: 10px;
  background: var(--key) repeat-x center / 18px 10px;
  opacity: 0.8;
  pointer-events: none;
}
.card::before { top: 7px; }
.card::after { bottom: 7px; }
.card h2 {
  margin: 0.2rem 0 0.25rem;
  font-family: var(--display);
  font-weight: 900;
  font-size: 1.75rem;
  letter-spacing: 0.06em;
  color: #4a3216;
  /* Carved in: light catches the lower lip of the letters. */
  text-shadow: 0 1px 0 rgba(255,246,222,0.85), 0 -1px 0 rgba(60,40,15,0.25);
}
.card p { color: var(--ink-muted); margin: 0.3rem 0 0.8rem; line-height: 1.45; font-size: 0.95rem; }
.card .btn {
  color: var(--ink);
  background: linear-gradient(180deg, #f3e6c4, #d9c290);
  border: 1px solid #9c7f52;
  box-shadow: inset 0 1px 0 #fffaf0, 0 3px 0 #8d7148;
}
.card .btn:active { box-shadow: inset 0 1px 0 #fffaf0, 0 1px 0 #8d7148; }
/* Chosen options are inlaid with gold. */
.card .btn.sel {
  background: linear-gradient(180deg, #ffe9a6, #e2b653);
  border-color: #6f4e15;
  box-shadow: inset 0 1px 0 #fff7da, inset 0 0 0 1px rgba(111,78,21,0.35), 0 3px 0 #6f4e15;
}
.group { margin: 0.65rem 0; }
.group .lbl {
  font-family: var(--display);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #7a5c34;
  font-weight: 700;
  margin-bottom: 0.35rem;
}
.keys { color: var(--ink-muted); font-size: 0.82rem; line-height: 1.6; margin-top: 0.5rem; }
details.dict-wrap { text-align: left; margin-top: 0.85rem; background: rgba(110,80,40,0.1); border: 1px solid rgba(125,97,57,0.5); border-radius: 8px; padding: 0.35rem 0.8rem; }
details.dict-wrap summary { cursor: pointer; font-family: var(--display); font-weight: 700; font-size: 0.86rem; color: #4a3216; padding: 0.35rem 0; list-style: none; }
details.dict-wrap summary::-webkit-details-marker { display: none; }
details.dict-wrap summary::after { content: " ▾"; color: var(--ink-muted); }
details.dict-wrap[open] summary::after { content: " ▴"; }
.dict-item { font-size: 0.86rem; color: #54401f; padding: 0.3rem 0; line-height: 1.45; border-top: 1px solid rgba(125,97,57,0.3); }
.dict-item b { color: #2e1f0c; }
#byline { color: #7d6e55; font-size: 75%; margin-top: 0.4rem; }

/* ---- level select: small carved tiles ---------------------------------------------- */
.lab-tools { margin-top: 0.6rem; }
#lab-levels { display: flex; flex-direction: column; gap: 0.35rem; max-height: 46vh; overflow-y: auto; padding: 0 0.2rem 0.3rem; }
.lab-zone { font-family: var(--display); font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; color: #7a5c34; font-weight: 700; text-align: left; margin-top: 0.3rem; }
.lab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 0.45rem; }
.lab-lv {
  cursor: pointer; display: flex; flex-direction: column; align-items: flex-start; gap: 0.05rem;
  color: var(--ink);
  background: linear-gradient(180deg, #f3e6c4, #dcc592);
  border: 1px solid #a88a5c; border-radius: 7px;
  box-shadow: inset 0 1px 0 #fffaf0, 0 2px 0 #9c7f52;
  padding: 0.38rem 0.5rem; font-family: var(--body); text-align: left; min-height: 3.4rem;
  transition: filter 0.15s ease, transform 0.08s ease;
}
.lab-lv b { font-family: var(--display); font-size: 1rem; font-weight: 900; color: #4a3216; }
.lab-lv span { font-size: 0.8rem; color: var(--ink-muted); line-height: 1.15; font-weight: 500; }
.lab-lv em { font-style: normal; font-size: 0.74rem; color: #1b6b43; font-weight: 800; font-variant-numeric: tabular-nums; }
.lab-lv:hover:not(:disabled) { filter: brightness(1.05); transform: translateY(-1px); }
.lab-lv.done { border-color: #3f8a60; box-shadow: inset 0 1px 0 #fffaf0, inset 0 0 0 1px rgba(63,138,96,0.35), 0 2px 0 #6f8a6a; }
.lab-lv.next { border-color: #8a6420; box-shadow: inset 0 1px 0 #fffaf0, 0 0 0 2px var(--gold), 0 2px 0 #8a6420; }
.lab-lv:disabled { cursor: not-allowed; opacity: 0.5; background: linear-gradient(180deg, #d9c8a0, #c4ab7a); }

/* Phones: the fixed back / sound / Visual FX buttons cover the top ~50px,
   so the title and the tablets start below them; the subtitle and tighter
   gaps win that height back (no screen is taller than before the restyle). */
@media (max-width: 560px) {
  .wrap { padding: 3.3rem 1rem 1rem; gap: 0.55rem; }
  .subtitle { display: none; }
  .overlay { padding-top: 3.6rem; }
  .card { padding: 1.15rem 1rem 1.05rem; }
  .card h2 { font-size: 1.55rem; margin-top: 0.1rem; }
  .card p { font-size: 0.9rem; line-height: 1.38; margin-bottom: 0.55rem; }
  .group { margin: 0.5rem 0; }
  .keys { line-height: 1.45; }
}

.overlay:not(.hidden) .card { animation: slRise 0.34s cubic-bezier(0.2,0.8,0.2,1) both; }
@keyframes slRise { from { opacity: 0; transform: translateY(16px) scale(0.98); } to { opacity: 1; transform: none; } }

