/* Peliadman — page, HUD, overlays and the touch D-pad.
   The maze itself is drawn in WebGL; everything here is chrome around it.
   Colours lean on the theme's amber-on-stone arcade look but are intentionally
   generic so they can be restyled without touching the game. */

:root {
  --bg: #241a10; /* dark-brown parchment backdrop for the whole page */
  --ink: #f6e7c1;
  --amber: #f5b301;
  --amber-dim: #b9820a;
  --stone: #1c1917;
  --stone-line: #3a332c;
  --danger: #ef5350;
  --font: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  /* aged dark-brown parchment: warm base with soft mottled lightening */
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse at 28% 18%, rgba(96, 66, 38, 0.35), transparent 60%),
    radial-gradient(ellipse at 78% 82%, rgba(74, 50, 28, 0.3), transparent 55%),
    radial-gradient(ellipse at 50% 50%, rgba(58, 42, 26, 0.25), transparent 70%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
/* Touch devices: pin the board to the top and hand the rest to the controls. */
html.touch #app {
  justify-content: flex-start;
}

/* The WebGL canvas is inserted into here and sized to fit the viewport. */
#viewport {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none; /* no browser scroll/zoom over the board */
}
html.touch #viewport {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
}
#viewport > canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  image-rendering: auto;
}

/* ---- Overlays (title / ready / game over / paused / error) ---- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: radial-gradient(ellipse at center, rgba(10, 10, 15, 0.72), rgba(10, 10, 15, 0.94));
  text-align: center;
}
.overlay.hidden,
.hidden { display: none !important; }

.panel {
  max-width: 30rem;
  padding: 2rem 2.25rem;
  border: 1px solid var(--stone-line);
  border-radius: 1rem;
  background: linear-gradient(180deg, rgba(28, 25, 23, 0.96), rgba(10, 10, 15, 0.96));
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), inset 0 0 40px rgba(245, 179, 1, 0.05);
}
.panel h2 { margin: 0 0 0.5rem; font-size: 1.8rem; color: var(--amber); letter-spacing: 0.05em; }
.panel p { margin: 0.35rem 0; color: #d8cdb0; }

.title-panel { max-width: 34rem; }
.logo {
  margin: 0;
  font-size: clamp(2.6rem, 10vw, 4.5rem);
  font-weight: 900;
  letter-spacing: 0.14em;
  color: var(--amber);
  text-shadow: 0 0 18px rgba(245, 179, 1, 0.5), 0 4px 0 #7a4c00;
}
.tagline { margin: 0.25rem 0 1.4rem; color: #cdbf9d; font-style: italic; }

.arcade-btn {
  margin-top: 0.5rem;
  padding: 0.8rem 2.2rem;
  font-family: var(--font);
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #1a1206;
  background: linear-gradient(180deg, #ffd257, var(--amber));
  border: none;
  border-radius: 0.7rem;
  box-shadow: 0 6px 0 #8a5f04, 0 10px 22px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: transform 0.06s ease, box-shadow 0.06s ease;
  animation: pulse 1.6s ease-in-out infinite;
}
.arcade-btn:hover { filter: brightness(1.05); }
.arcade-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #8a5f04, 0 4px 12px rgba(0, 0, 0, 0.5); }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }

/* A stacked row of action buttons (pause / game over). No pulse here — the
   pulse is reserved for the single "Press Start" call to action. */
.btn-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1.2rem;
}
.btn-row .arcade-btn {
  margin-top: 0;
  animation: none;
  min-width: 13rem;
  font-size: 1.05rem;
  padding: 0.65rem 1.6rem;
}
/* Secondary (outlined) — e.g. "Return to Title". */
.arcade-btn.secondary {
  color: var(--amber);
  background: transparent;
  border: 2px solid var(--amber-dim);
  box-shadow: none;
  font-weight: 700;
}
.arcade-btn.secondary:hover { border-color: var(--amber); color: #ffd257; filter: none; }
.arcade-btn.secondary:active { transform: translateY(2px); box-shadow: none; }

.controls {
  list-style: none;
  margin: 1.5rem 0 0.5rem;
  padding: 0;
  font-size: 0.95rem;
  line-height: 1.9;
  color: #c9bb98;
}
.keys {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  margin: 0 0.1rem;
  border: 1px solid var(--stone-line);
  border-radius: 0.35rem;
  background: #12100d;
  color: var(--amber);
  font-weight: 700;
  font-size: 0.85rem;
}
.hs { color: var(--amber-dim); font-weight: 700; letter-spacing: 0.05em; }

.banner {
  font-size: clamp(2rem, 8vw, 3.2rem);
  font-weight: 900;
  letter-spacing: 0.12em;
  color: var(--amber);
  text-shadow: 0 0 16px rgba(245, 179, 1, 0.55);
}
.ready-banner { animation: blink 0.5s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0.35; } }

/* ---- HUD ---- */
#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 1.4rem;
  padding: 0.6rem 1rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  background: linear-gradient(180deg, rgba(10, 10, 15, 0.85), rgba(10, 10, 15, 0));
  pointer-events: none;
}
.hud-item { display: flex; align-items: baseline; gap: 0.4rem; }
.hud-label { font-size: 0.7rem; text-transform: uppercase; color: var(--amber-dim); letter-spacing: 0.12em; }
#hud-score, #hud-high { font-size: 1.15rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.lives { display: inline-flex; gap: 0.25rem; }
.lives .pip {
  width: 0.85rem; height: 0.85rem; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffd257, var(--amber));
  box-shadow: 0 0 6px rgba(245, 179, 1, 0.5);
}
.hud-btns { margin-left: auto; display: flex; gap: 0.5rem; pointer-events: auto; }
.hud-btn {
  pointer-events: auto;
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.2rem; height: 2.2rem;
  font-weight: 900; letter-spacing: 0.1em;
  color: var(--amber); background: rgba(28, 25, 23, 0.8);
  border: 1px solid var(--stone-line); border-radius: 0.5rem; cursor: pointer;
}
.hud-btn:hover { color: #ffd257; }
.hud-btn svg { width: 1.25rem; height: 1.25rem; }
.hud-btn .hidden { display: none; }

/* ---- Control strip + permanent analog joystick (touch) ----
   Hidden on desktop; on touch devices it's a fixed strip below the board holding
   a centred joystick. Drag from the base to steer; JS offsets the nub. */
#controls {
  display: none;
}
html.touch #controls {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 100%;
  height: clamp(140px, 26vh, 240px);
  padding-bottom: env(safe-area-inset-bottom);
  touch-action: none;
  background: linear-gradient(180deg, rgba(20, 13, 6, 0), rgba(20, 13, 6, 0.55));
}
#joystick {
  position: relative;
  width: 150px;
  height: 150px;
  touch-action: none;
}
#joy-base {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, rgba(245, 179, 1, 0.1), rgba(28, 25, 23, 0.55));
  border: 2px solid rgba(245, 179, 1, 0.35);
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.45), inset 0 0 18px rgba(0, 0, 0, 0.4);
}
#joy-nub {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 66px;
  height: 66px;
  margin: -33px 0 0 -33px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, #ffd257, var(--amber));
  border: 2px solid #7a4c00;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5), 0 0 12px rgba(245, 179, 1, 0.4);
  will-change: transform;
}
