:root {
  --bg: #070a1d;
  --panel: rgba(14, 19, 49, 0.78);
  --panel-strong: rgba(15, 21, 58, 0.95);
  --text: #f7fbff;
  --muted: #aeb9e8;
  --cyan: #5ee7ff;
  --blue: #5788ff;
  --purple: #bd66ff;
  --pink: #ff8bd1;
  --gold: #ffd36e;
  --danger: #ff6b8b;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 15%, rgba(94, 231, 255, 0.15), transparent 34rem),
    radial-gradient(circle at 80% 10%, rgba(189, 102, 255, 0.18), transparent 28rem),
    radial-gradient(circle at 50% 100%, rgba(87, 136, 255, 0.12), transparent 38rem),
    linear-gradient(145deg, #050716 0%, #0a0f28 52%, #090b20 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle, black, transparent 78%);
}

button {
  font: inherit;
  color: inherit;
}

.page-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(14px, 3vw, 38px);
}

.hero-panel {
  width: min(96vw, 920px);
  display: grid;
  gap: 16px;
  justify-items: center;
}

.title-block {
  text-align: center;
  display: grid;
  gap: 4px;
}

.eyebrow {
  margin: 0;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.28em;
  font-size: clamp(0.64rem, 2vw, 0.78rem);
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2.25rem, 8vw, 5rem);
  line-height: 0.94;
  letter-spacing: -0.07em;
  text-shadow:
    0 0 18px rgba(94, 231, 255, 0.34),
    0 0 42px rgba(189, 102, 255, 0.28);
}

.instructions {
  color: var(--muted);
  font-size: clamp(0.88rem, 2.6vw, 1rem);
}

.hud,
.control-row {
  width: min(100%, 768px);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.stat-card {
  min-width: 118px;
  padding: 10px 14px;
  border: 1px solid rgba(94, 231, 255, 0.22);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(17, 27, 70, 0.88), rgba(10, 15, 43, 0.72));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.08), 0 16px 40px rgba(0, 0, 0, 0.23);
  text-align: center;
}

.stat-card span {
  display: block;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.66rem;
  font-weight: 800;
}

.stat-card strong {
  display: block;
  margin-top: 2px;
  font-size: 1.45rem;
}

.stat-card.best strong {
  color: var(--gold);
}

.segmented,
.ghost-button,
.primary-button {
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(13, 19, 48, 0.72);
  backdrop-filter: blur(12px);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.08), 0 12px 36px rgba(0, 0, 0, 0.2);
}

.segmented {
  display: flex;
  padding: 4px;
  border-radius: 999px;
  gap: 3px;
}

.chip,
.ghost-button,
.primary-button,
.mobile-pad button {
  cursor: pointer;
  border-radius: 999px;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.chip {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 800;
}

.chip.active,
.ghost-button.active {
  color: white;
  background: linear-gradient(135deg, rgba(94, 231, 255, 0.24), rgba(189, 102, 255, 0.24));
  box-shadow: 0 0 22px rgba(94, 231, 255, 0.16);
}

.ghost-button {
  padding: 10px 15px;
  color: var(--muted);
}

.primary-button {
  border: 0;
  padding: 13px 22px;
  color: white;
  font-weight: 900;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, var(--cyan), var(--blue) 48%, var(--purple));
  box-shadow: 0 0 28px rgba(94, 231, 255, 0.36), 0 12px 36px rgba(88, 72, 255, 0.32);
}

.chip:hover,
.ghost-button:hover,
.primary-button:hover,
.mobile-pad button:hover {
  transform: translateY(-1px);
  border-color: rgba(94, 231, 255, 0.48);
}

.canvas-frame {
  position: relative;
  width: min(92vmin, 768px);
  aspect-ratio: 1;
  border-radius: clamp(18px, 3vw, 30px);
  padding: clamp(7px, 1.5vw, 12px);
  background:
    linear-gradient(#080d27, #080d27) padding-box,
    linear-gradient(135deg, rgba(94, 231, 255, 0.95), rgba(189, 102, 255, 0.95), rgba(255, 139, 209, 0.78)) border-box;
  border: 2px solid transparent;
  box-shadow:
    0 0 30px rgba(94, 231, 255, 0.24),
    0 0 72px rgba(189, 102, 255, 0.17),
    0 24px 80px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.canvas-frame.shake {
  animation: tasteful-shake 320ms ease both;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: clamp(14px, 2.6vw, 24px);
  background: #07122d;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: clamp(7px, 1.5vw, 12px);
  display: grid;
  place-items: center;
  padding: 18px;
  border-radius: clamp(14px, 2.6vw, 24px);
  opacity: 0;
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(21, 30, 76, 0.54), rgba(5, 7, 20, 0.8));
  backdrop-filter: blur(7px);
  transition: opacity 180ms ease;
}

.overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.overlay-card {
  width: min(92%, 420px);
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: clamp(22px, 5vw, 34px);
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(14, 21, 57, 0.94), rgba(8, 12, 34, 0.9));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.1), 0 24px 70px rgba(0, 0, 0, 0.38);
}

.overlay-card.compact {
  width: min(86%, 340px);
}

.overlay-card h2 {
  font-size: clamp(1.9rem, 7vw, 3.2rem);
  letter-spacing: -0.05em;
}

.overlay-card p,
.final-line {
  color: var(--muted);
  line-height: 1.45;
}

.final-line strong {
  color: white;
}

.cat-badge {
  width: 66px;
  height: 66px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  color: #11172d;
  background: linear-gradient(180deg, #ffffff, #dce9ff);
  box-shadow: 0 0 28px rgba(255, 255, 255, 0.32);
  font-weight: 900;
  font-size: 1.2rem;
}

.cat-badge.sad {
  color: var(--danger);
}

.mobile-pad {
  display: none;
  justify-items: center;
  gap: 8px;
  user-select: none;
}

.mobile-pad div {
  display: flex;
  gap: 8px;
}

.mobile-pad button {
  width: 56px;
  height: 48px;
  border: 1px solid rgba(94, 231, 255, 0.25);
  background: rgba(14, 20, 50, 0.82);
  color: white;
  font-weight: 900;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.08), 0 10px 28px rgba(0, 0, 0, 0.24);
}

@keyframes tasteful-shake {
  0%, 100% { transform: translate3d(0, 0, 0); }
  20% { transform: translate3d(-5px, 2px, 0); }
  40% { transform: translate3d(4px, -2px, 0); }
  60% { transform: translate3d(-3px, 1px, 0); }
  80% { transform: translate3d(3px, 0, 0); }
}

@media (max-width: 720px) {
  .page-shell {
    align-items: start;
    padding-top: 16px;
  }

  .hero-panel {
    width: 100%;
  }

  .hud {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    gap: 8px;
  }

  .stat-card {
    width: 100%;
    flex: 1 1 0;
    min-width: 0;
    padding: 9px 7px;
    overflow: hidden;
  }

  .stat-card strong {
    font-size: clamp(1.08rem, 5.3vw, 1.35rem);
    white-space: nowrap;
  }

  .stat-card span {
    letter-spacing: 0.13em;
  }

  .control-row {
    width: 100%;
    gap: 8px;
  }

  .ghost-button,
  .chip {
    padding: 8px 10px;
    font-size: 0.8rem;
  }

  .mobile-pad {
    display: grid;
  }

  .canvas-frame {
    width: min(94vw, 620px);
  }
}

@media (max-width: 420px) {
  .page-shell {
    padding-inline: 12px;
  }

  .instructions {
    max-width: 34ch;
    margin-inline: auto;
    font-size: 0.84rem;
    line-height: 1.35;
  }

  .stat-card {
    border-radius: 15px;
  }

  .stat-card strong {
    font-size: clamp(1rem, 5vw, 1.22rem);
  }

  .chip,
  .ghost-button {
    padding: 8px 9px;
    font-size: 0.78rem;
  }
}

@media (max-height: 760px) and (orientation: landscape) {
  .page-shell {
    padding: 10px;
  }

  .title-block h1 {
    font-size: 2.1rem;
  }

  .instructions,
  .eyebrow {
    display: none;
  }

  .canvas-frame {
    width: min(70vmin, 620px);
  }

  .mobile-pad {
    display: none;
  }
}
