/* Fonts are bundled (SIL OFL, see fonts/) so the game works offline. */
@font-face {
  font-family: 'Creepster';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/creepster-latin.woff2') format('woff2');
}

@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('fonts/fredoka-latin.woff2') format('woff2');
}

:root {
  --bg: #0b0620;
  --ink: #f3ecff;
  --muted: #b3a6d9;
  --panel: rgba(20, 11, 40, 0.42);
  --panel-border: rgba(190, 160, 255, 0.22);
  --orange: #ff8a1c;
  --lime: #b8ff7a;
  --purple: #9b63f2;
  --c-i: #35c8e6;
  --c-o: #ff8a1c;
  --c-t: #9b63f2;
  --c-s: #6ad36a;
  --c-z: #f04f4a;
  --c-j: #6f82ff;
  --font-ui: 'Fredoka', system-ui, sans-serif;
  --font-spooky: 'Creepster', 'Fredoka', cursive;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#gl {
  position: fixed;
  inset: 0;
  display: block;
}

#safe-probe {
  position: fixed;
  inset: 0;
  visibility: hidden;
  pointer-events: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.hidden {
  display: none !important;
}

/* ---------- HUD ---------- */

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

#hud.off {
  opacity: 0;
  visibility: hidden;
}

.panel {
  position: absolute;
  padding: 10px 12px 12px;
  border-radius: 16px;
  background: var(--panel);
  border: 1.5px solid var(--panel-border);
  box-shadow: 0 0 24px rgba(120, 70, 220, 0.12) inset;
}

.panel h3 {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}

.preview {
  height: 84px;
}

.preview.small {
  height: 58px;
}

#hold-panel.used h3 {
  color: rgba(179, 166, 217, 0.45);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
}

.stat .label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat .value {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat.big .value {
  font-size: 30px;
  color: var(--orange);
  text-shadow: 0 0 14px rgba(255, 138, 28, 0.45);
}

.stat-row {
  display: flex;
  justify-content: space-around;
  margin: 10px 0;
}

.stat.best .value {
  font-size: 18px;
  color: var(--lime);
}

#buttons {
  position: absolute;
  display: flex;
  gap: 10px;
  justify-content: center;
}

.icon-btn {
  pointer-events: auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid var(--panel-border);
  background: var(--panel);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s ease, background 0.15s ease;
}

.icon-btn:hover {
  background: rgba(60, 35, 110, 0.6);
}

.icon-btn:active {
  transform: scale(0.92);
}

.icon-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.icon-btn svg .stroke {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.sound-off,
body.muted .sound-on {
  display: none;
}

body.muted .sound-off {
  display: block;
}

#hud.compact .extra {
  display: none;
}

#hud.compact .panel {
  padding: 6px 10px 8px;
}

#hud.compact .preview {
  height: 64px;
}

#hud.compact .stat-row {
  margin: 4px 0;
}

#hud.compact .stat.big .value {
  font-size: 24px;
}

/* Portrait phones: compact top bar. */
#hud.mode-top .panel {
  padding: 6px 8px;
  border-radius: 14px;
}

#hud.mode-top .panel h3 {
  font-size: 10px;
  margin-bottom: 0;
}

#hud.mode-top .preview {
  height: calc(100% - 14px);
}

#hud.mode-top .extra,
#hud.mode-top .stat.best {
  display: none;
}

#hud.mode-top #stats-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

#hud.mode-top .stat.big .value {
  font-size: 24px;
}

#hud.mode-top .stat-row {
  margin: 4px 0 0;
}

#hud.mode-top .stat .label {
  font-size: 10px;
}

#hud.mode-top .stat .value {
  font-size: 17px;
}

#hud.mode-top #buttons {
  flex-direction: column;
  justify-content: flex-start;
  gap: 8px;
}

#hud.mode-top .icon-btn {
  width: 40px;
  height: 40px;
}

/* ---------- popups ---------- */

#popups {
  position: fixed;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.popup {
  font-family: var(--font-spooky);
  font-size: clamp(30px, 7vmin, 56px);
  color: #fff3d6;
  letter-spacing: 0.04em;
  -webkit-text-stroke: 2px #2a0f45;
  paint-order: stroke fill;
  text-shadow: 0 0 18px rgba(255, 160, 60, 0.7), 0 4px 0 #2a0f45;
  animation: pop 1.3s cubic-bezier(0.2, 0.9, 0.3, 1.2) forwards;
  white-space: nowrap;
}

.popup.big {
  font-size: clamp(44px, 12vmin, 96px);
  color: var(--orange);
  text-shadow: 0 0 28px rgba(255, 138, 28, 0.9), 0 0 60px rgba(184, 255, 122, 0.4), 0 5px 0 #2a0f45;
  animation-duration: 1.7s;
}

.popup.combo {
  font-size: clamp(22px, 5vmin, 36px);
  color: var(--lime);
}

.popup.level {
  color: #c9b4ff;
  text-shadow: 0 0 20px rgba(155, 99, 242, 0.9), 0 4px 0 #2a0f45;
}

@keyframes pop {
  0% {
    opacity: 0;
    transform: scale(0.3) rotate(-8deg);
  }
  18% {
    opacity: 1;
    transform: scale(1.12) rotate(3deg);
  }
  30% {
    transform: scale(1) rotate(0deg);
  }
  75% {
    opacity: 1;
    transform: translateY(-10px);
  }
  100% {
    opacity: 0;
    transform: translateY(-40px) scale(0.95);
  }
}

/* ---------- menu screens ---------- */

#overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(ellipse at center, rgba(11, 6, 32, 0.35), rgba(5, 2, 14, 0.8));
}

.card {
  width: min(440px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 26px 26px 20px;
  border-radius: 24px;
  text-align: center;
  background: rgba(22, 12, 44, 0.78);
  border: 1.5px solid var(--panel-border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(155, 99, 242, 0.18);
  animation: card-in 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.96);
  }
}

.logo {
  margin: 0;
  font-family: var(--font-spooky);
  font-weight: 400;
  font-size: clamp(64px, 18vw, 104px);
  line-height: 1;
  letter-spacing: 0.04em;
  -webkit-text-stroke: 3px #1a0a30;
  paint-order: stroke fill;
}

.logo span {
  display: inline-block;
  animation: float 3s ease-in-out infinite;
  text-shadow: 0 0 22px currentColor, 0 6px 0 #1a0a30;
}

.logo span:nth-child(2) { animation-delay: -0.5s; }
.logo span:nth-child(3) { animation-delay: -1s; }
.logo span:nth-child(4) { animation-delay: -1.5s; }
.logo span:nth-child(5) { animation-delay: -2s; }
.logo span:nth-child(6) { animation-delay: -2.5s; }

.c-t { color: var(--c-t); }
.c-i { color: var(--c-i); }
.c-o { color: var(--c-o); }
.c-s { color: var(--c-s); }
.c-z { color: var(--c-z); }
.c-j { color: var(--c-j); }

@keyframes float {
  0%,
  100% {
    transform: translateY(0) rotate(-2deg);
  }
  50% {
    transform: translateY(-6px) rotate(2deg);
  }
}

.card h2 {
  margin: 0;
  font-family: var(--font-spooky);
  font-weight: 400;
  font-size: clamp(40px, 11vw, 60px);
  color: var(--orange);
  letter-spacing: 0.03em;
  text-shadow: 0 0 20px rgba(255, 138, 28, 0.6);
}

.tagline {
  margin: 6px 0 20px;
  color: var(--muted);
  font-size: 16px;
}

.btn {
  display: block;
  width: 100%;
  margin: 10px 0 0;
  padding: 13px 20px;
  border-radius: 999px;
  border: 1.5px solid var(--panel-border);
  background: rgba(60, 35, 110, 0.5);
  color: var(--ink);
  font: 600 18px var(--font-ui);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn.primary {
  background: linear-gradient(180deg, #ffa54a, #ff7a10);
  border-color: transparent;
  color: #2a0f00;
  font-weight: 700;
  font-size: 20px;
  box-shadow: 0 6px 0 #a84400, 0 0 26px rgba(255, 138, 28, 0.45);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(3px);
}

.btn.primary:active {
  box-shadow: 0 2px 0 #a84400, 0 0 18px rgba(255, 138, 28, 0.45);
}

.btn:focus-visible,
.icon-btn:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 3px;
}

.controls {
  list-style: none;
  margin: 22px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

.controls b {
  color: var(--ink);
  font-weight: 600;
}

kbd {
  display: inline-block;
  min-width: 24px;
  padding: 1px 6px;
  margin: 0 1px;
  border-radius: 6px;
  border: 1px solid rgba(190, 160, 255, 0.35);
  border-bottom-width: 3px;
  background: rgba(60, 35, 110, 0.5);
  color: var(--ink);
  font: 500 13px var(--font-ui);
}

.controls.touch {
  display: none;
}

@media (pointer: coarse) {
  .controls.keys {
    display: none;
  }
  .controls.touch {
    display: grid;
  }
}

.studio {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid rgba(190, 160, 255, 0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.studio img {
  height: 100px;
  width: auto;
  opacity: 0.92;
  filter: drop-shadow(0 0 14px rgba(200, 180, 255, 0.3));
}

/* Short screens (itch.io embeds, phones lying down): tighter title card so it fits without scrolling. */
@media (max-height: 720px) {
  .card {
    padding: 18px 22px 14px;
  }
  .logo {
    font-size: clamp(52px, 11vh, 76px);
  }
  .tagline {
    margin: 4px 0 12px;
    font-size: 15px;
  }
  .btn {
    padding: 10px 18px;
    margin-top: 8px;
  }
  .controls {
    margin-top: 12px;
    gap: 3px;
    font-size: 13px;
  }
  kbd {
    font-size: 12px;
  }
  .studio {
    margin-top: 12px;
    padding-top: 10px;
    gap: 6px;
  }
  .studio img {
    height: 64px;
  }
}

@media (max-height: 480px) {
  .card {
    width: min(560px, 100%);
  }
  .logo {
    font-size: 50px;
  }
  .tagline {
    margin-bottom: 8px;
  }
  .controls {
    grid-template-columns: 1fr 1fr;
    column-gap: 14px;
  }
  .studio {
    flex-direction: row;
    justify-content: center;
    gap: 14px;
  }
  .studio img {
    height: 44px;
  }
}

.credit {
  margin: 0;
  font-size: 13px;
  color: rgba(179, 166, 217, 0.6);
}

.record {
  margin: 8px 0 0;
  font-weight: 700;
  font-size: 18px;
  color: var(--lime);
  animation: float 1.6s ease-in-out infinite;
}

.summary {
  display: flex;
  justify-content: space-around;
  margin: 18px 0 14px;
}

.summary dt {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.summary dd {
  margin: 2px 0 0;
  font-size: 24px;
  font-weight: 700;
}
