/* ---------- Fonts, stored inside the game (so it looks right offline and asks Google for nothing) ---------- */
/* "latin" has the English letters, "latin-ext" adds č, š, ž and other accented letters */
@font-face { font-family: "Press Start 2P"; font-display: swap; src: url("fonts/press-start-2p-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Press Start 2P"; font-display: swap; src: url("fonts/press-start-2p-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "VT323"; font-display: swap; src: url("fonts/vt323-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "VT323"; font-display: swap; src: url("fonts/vt323-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* ---------- Colors and basics (the same night colors as Lightbringer Games) ---------- */
:root {
  --night: #0b0a1a;
  --night-2: #15122c;
  --night-3: #1d1940;
  --ink: #ece6ff;
  --dim: #a59fc8;
  --gold: #ffd25e;
  --gold-deep: #ff9f1c;
  --blood: #ff4a5a;
  --sky: #6ad7ff;
  --edge: #2c2650;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--night); color: var(--ink); overflow: hidden; }
body {
  font-family: "VT323", monospace; font-size: 20px; line-height: 1.3;
  -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
  overscroll-behavior: none;
}
a { color: var(--sky); }
button { font: inherit; color: inherit; cursor: pointer; }

/* the whole screen: top bar, then the maze filling the rest (phone notches respected) */
#app {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  padding: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
}

/* ---------- Top bar ---------- */
#hud {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 16px; padding: 2px 4px 6px;
  font-family: "Press Start 2P", monospace; font-size: 10px; line-height: 1.6; min-height: 22px;
}
#hud .hearts { color: var(--blood); letter-spacing: 2px; }
#hud .gold { color: var(--gold); }
/* a power-up's last seconds: the number blinks red */
#hPower.ending { color: var(--blood); animation: blink .25s steps(2) infinite; }
@keyframes blink { 50% { opacity: .25; } }

/* ---------- The maze ---------- */
#stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; touch-action: none; }
#game {
  display: block; image-rendering: pixelated; image-rendering: crisp-edges; background: #000;
  box-shadow: 0 0 0 3px var(--gold), 0 0 0 6px #000, 0 0 40px rgba(255, 210, 94, .2);
}
#stage.shake { animation: shake .25s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* ---------- Menu panel and pages (on top of the maze) ---------- */
.panel {
  position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: rgba(11, 10, 26, .9); padding: 16px 14px 24px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  touch-action: pan-y; user-select: text;
}
.panel[hidden] { display: none; }
.panel > * { max-width: 640px; }
.panel p { margin: 0; }
.title, .panel h2 { font-family: "Press Start 2P", monospace; color: var(--gold); line-height: 1.5; margin: 4px 0; }
.title { font-size: clamp(14px, 4.2vw, 22px); text-shadow: 0 0 18px rgba(255, 210, 94, .45); }
.panel h2 { font-size: 12px; margin-top: 10px; }
.page { text-align: left; background: rgba(11, 10, 26, .98); } /* almost solid, so the menu behind doesn't show through */
.page #pageBody { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.page .btn { align-self: center; }

.btn {
  font-family: "Press Start 2P", monospace; font-size: 13px; padding: 12px 18px;
  background: var(--gold); color: #1a1205; border: 0; box-shadow: 0 4px 0 var(--gold-deep), 0 0 0 3px #000;
}
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--gold-deep), 0 0 0 3px #000; }
.btn.ghost { background: transparent; color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.small-btn { background: var(--night-3); border: 2px solid var(--edge); padding: 4px 10px; font-size: 18px; }
.small-btn:hover, .small-btn:focus-visible { border-color: var(--gold); color: var(--gold); }
.stars { font-size: 24px; letter-spacing: 4px; }

/* the mode row, the weekly maze, and the nights you can replay */
#picker { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
#picker .label { color: var(--dim); font-size: 18px; }
.mode-row { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; }
.mode-row button, .nights button, .gold-btn {
  background: var(--night-3); border: 2px solid #4a4380; padding: 3px 10px; line-height: 1.15; font-size: 17px;
}
.mode-row button.on { background: var(--gold); border-color: var(--gold); color: #000; }
.gold-btn { border-color: var(--gold); color: var(--gold); padding: 4px 16px; }
.nights { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; width: 100%; max-width: 560px; }
.nights button small, .gold-btn small { display: block; color: var(--sky); font-size: 14px; }
.extras { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 6px; }
.extras [hidden] { display: none; }
.extras.about { margin-top: 0; }
.extras.about a { color: inherit; text-decoration: none; }
.copyright { color: var(--dim); font-size: 15px; }
/* Support the developer: the four sizes */
.gifts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; width: 100%; max-width: 360px; align-self: center; }
.gifts .btn { text-align: center; text-decoration: none; }

/* no visible scrollbars (scrolling still works with the wheel, touchpad and finger) */
.panel { scrollbar-width: none; }
.panel::-webkit-scrollbar { display: none; }

/* the top 10 */
.board { list-style: none; margin: 0; padding: 0; width: 100%; }
.board li { display: grid; grid-template-columns: 34px 1fr auto; gap: 8px; padding: 2px 0; border-bottom: 1px solid var(--edge); }

/* ---------- Menu button while playing, toasts, joystick ---------- */
#menuBtn { position: fixed; right: max(8px, env(safe-area-inset-right)); bottom: max(8px, env(safe-area-inset-bottom)); opacity: .8; z-index: 5; }
#menuBtn[hidden] { display: none; }
#toast {
  position: fixed; left: 50%; top: max(40px, calc(env(safe-area-inset-top) + 34px)); transform: translate(-50%, -20px);
  background: var(--night-2); border: 2px solid var(--gold); padding: 6px 14px; max-width: min(92vw, 520px);
  text-align: center; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 10;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#stick {
  position: fixed; width: 72px; height: 72px; margin: -36px 0 0 -36px; border-radius: 50%;
  border: 3px solid rgba(255, 210, 94, .45); background: rgba(255, 210, 94, .06); pointer-events: none; z-index: 4;
}
#stick[hidden] { display: none; }
#stick i {
  position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%;
  background: rgba(255, 210, 94, .55);
}

/* phones held sideways: a smaller top bar so the maze gets all the height */
@media (max-height: 480px) {
  #hud { font-size: 8px; padding-bottom: 3px; gap: 0 12px; }
  .panel { padding: 8px 12px 16px; gap: 8px; }
  .btn { font-size: 11px; padding: 9px 14px; }
  body { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) { #hPower.ending { animation: none; } }
