:root {
  --ui-scale: 1;
  --ink: #fff;
  --muted: #9fb3c8;
  --accent: #ffd166;
  --accent-ink: #2a1a00;
  --panel: rgba(11, 45, 58, 0.9);
  --edge: rgba(255, 255, 255, 0.14);
  font-family: "Trebuchet MS", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #05070f;
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

canvas#game {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  touch-action: none;
}

body.in-game canvas#game { cursor: none; }

/* Menus are laid out on the same 450x800 logical playfield as the game,
   then scaled and placed over it (main.js sets the variables). */
#ui {
  position: fixed;
  left: var(--ui-x, 0px);
  top: var(--ui-y, 0px);
  width: 450px;
  height: 800px;
  transform-origin: 0 0;
  transform: scale(var(--ui-scale));
  pointer-events: none;
}

.screen {
  display: none;
  position: absolute;
  inset: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: auto;
}
.screen.open { display: flex; }

.screen.panel { background: rgba(5, 7, 15, 0.55); }
.screen.panel { padding: 0 34px; }
.screen.panel > * { max-width: 382px; }
.screen.panel::before {
  content: "";
  position: absolute;
  top: 40px;
  bottom: 80px;
  left: 16px;
  right: 16px;
  background: var(--panel);
  border: 2px solid var(--edge);
  border-radius: 24px;
  z-index: -1;
}
.screen.panel { isolation: isolate; }

#title { justify-content: flex-start; padding-top: 110px; }
#title .menu { gap: 10px; }

.logo {
  margin: 0 0 8px;
  font-size: 72px;
  line-height: 0.9;
  font-weight: 900;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #ffffff;
  -webkit-text-stroke: 4px #0a0f24;
  paint-order: stroke fill;
  text-shadow: 0 8px 0 #0a0f24, 0 14px 24px rgba(0, 0, 0, 0.5);
}
.logo span { color: var(--accent); font-size: 78px; }

h2 {
  margin: 0 0 16px;
  font-size: 38px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--accent);
}

p { font-size: 17px; line-height: 1.4; margin: 6px 0; }
p.small { font-size: 15px; color: var(--muted); }
.tag { color: var(--muted); font-size: 17px; margin-bottom: 14px; }

.menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 18px;
  min-width: 260px;
}

button {
  font: inherit;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 12px 22px;
  border-radius: 14px;
  border: 3px solid transparent;
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.08s, background 0.08s;
}
button:hover, button:focus-visible, button:focus {
  outline: none;
  background: var(--accent);
  color: var(--accent-ink);
  transform: scale(1.04);
}

.slider {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  width: 360px;
  font-size: 18px;
  font-weight: 700;
  margin: 8px 0;
}
input[type="range"] { width: 170px; height: 32px; accent-color: var(--accent); }
input[type="range"]:focus { outline: 3px solid var(--accent); outline-offset: 4px; border-radius: 6px; }

.legend {
  list-style: none;
  padding: 0;
  margin: 10px 0;
  text-align: left;
  font-size: 16px;
}
.legend li { display: flex; align-items: center; gap: 12px; margin: 6px 0; }
.dot { width: 22px; height: 22px; border-radius: 50%; flex: none; display: inline-block; }
.screen.panel p { text-align: left; }
#packs .menu button { font-size: 18px; padding: 10px 16px; }
#packs .menu button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
#title-pack { font-size: 15px; }

#achievement-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  text-align: left;
  width: 360px;
}
#achievement-list li { display: flex; flex-direction: column; opacity: 0.45; font-size: 13px; }
#achievement-list li.got { opacity: 1; }
#achievement-list strong { font-size: 16px; color: var(--accent); }

.final-score { font-size: 76px; font-weight: 900; margin: 0; line-height: 1; }
.new-best { color: var(--accent); font-weight: 800; font-size: 28px; }
#final-stats {
  display: grid;
  grid-template-columns: auto auto;
  gap: 6px 24px;
  font-size: 18px;
  margin: 14px 0 0;
}
#final-stats dt { color: var(--muted); text-align: right; }
#final-stats dd { margin: 0; text-align: left; font-weight: 800; }

#toast {
  position: absolute;
  left: 50%;
  top: 118px;
  width: max-content;
  max-width: 400px;
  transform: translate(-50%, -20px);
  opacity: 0;
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 14px;
  padding: 10px 18px;
  font-size: 16px;
  font-weight: 800;
  transition: opacity 0.25s, transform 0.25s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  button, #toast { transition: none; }
}
