:root {
  color-scheme: light;
  --sky: #29aef5;
  --sky-soft: #8be8ff;
  --grass: #4ed15a;
  --grass-dark: #17863c;
  --cream: #fff5d6;
  --yellow: #ffdc3f;
  --pink: #ff6fb5;
  --orange: #ff8c3a;
  --blue: #1a77ff;
  --ink: #111111;
  --shadow: 5px 5px 0 var(--ink);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overscroll-behavior: none;
}

body {
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 13%, rgba(255, 255, 255, 0.95) 0 34px, transparent 35px),
    radial-gradient(circle at 23% 10%, rgba(255, 255, 255, 0.95) 0 46px, transparent 47px),
    radial-gradient(circle at 78% 12%, rgba(255, 255, 255, 0.95) 0 42px, transparent 43px),
    linear-gradient(180deg, var(--sky) 0%, var(--sky-soft) 58%, var(--grass) 58%, var(--grass-dark) 100%);
  font-family: Chewy, system-ui, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
}

#stage {
  position: fixed;
  inset: 0;
  display: block;
  width: 100vw;
  height: 100dvh;
  touch-action: none;
}

.topbar {
  position: fixed;
  z-index: 20;
  top: max(8px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  right: max(10px, env(safe-area-inset-right));
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto minmax(96px, 1fr);
  align-items: center;
  gap: 10px;
  transition: opacity 160ms ease, transform 160ms ease;
}

.topbar.playing {
  opacity: 0.18;
  transform: translateY(-8px);
}

.topbar.playing:hover,
.topbar.panel-open {
  opacity: 1;
  transform: translateY(0);
}

.brand-lockup {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
}

.brand-lockup img {
  width: min(132px, 34vw);
  height: auto;
  filter: drop-shadow(2px 3px 0 var(--ink));
}

.brand-lockup span,
.score-pill,
.top-button,
.parent-panel,
.session-toast {
  border: 3px solid var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand-lockup span {
  padding: 6px 10px 4px;
  background: var(--cream);
  white-space: nowrap;
  transform: rotate(-2deg);
}

.score-pill {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-width: min(330px, 42vw);
  padding: 7px 12px 5px;
  background: var(--cream);
  text-align: center;
}

.score-pill span + span::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin: 0 8px 1px 0;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--pink);
}

.top-button,
.start-actions button,
.panel-actions button,
.segment,
.theme,
.icon-button {
  min-height: 40px;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: var(--yellow);
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.top-button {
  justify-self: end;
  min-width: 92px;
  padding: 6px 10px 4px;
}

.top-button:hover,
.start-actions button:hover,
.panel-actions button:hover,
.segment:hover,
.theme:hover,
.icon-button:hover {
  transform: translateY(-2px);
  box-shadow: 6px 6px 0 var(--ink);
}

.start-hint {
  position: fixed;
  z-index: 16;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 12px;
  padding: 20px;
  color: #fff9e8;
  text-align: center;
  pointer-events: none;
  text-shadow:
    0 4px 0 var(--ink),
    4px 4px 0 var(--ink),
    -3px 3px 0 var(--ink),
    0 0 12px rgba(17, 17, 17, 0.35);
  transition: opacity 180ms ease, transform 180ms ease;
}

.start-hint.hide {
  opacity: 0;
  transform: scale(0.96);
}

.start-hint strong {
  font-family: Luckiest Guy, Chewy, sans-serif;
  font-size: clamp(44px, 8.4vw, 112px);
  line-height: 0.9;
  letter-spacing: 0;
  -webkit-text-stroke: 2px var(--ink);
}

.start-hint span {
  justify-self: center;
  width: min(88vw, 820px);
  color: var(--cream);
  font-size: clamp(23px, 3vw, 42px);
  line-height: 1.06;
  text-wrap: balance;
  -webkit-text-stroke: 1px var(--ink);
}

.start-actions {
  display: flex;
  justify-content: center;
  margin-top: 8px;
  pointer-events: auto;
  text-shadow: none;
}

.start-actions button {
  min-width: 128px;
  padding: 10px 18px 6px;
  font-family: Luckiest Guy, Chewy, sans-serif;
  font-size: clamp(25px, 3vw, 38px);
}

.session-toast {
  position: fixed;
  z-index: 18;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%) rotate(-1deg);
  padding: 8px 14px 6px;
  background: var(--cream);
  font-size: clamp(20px, 2.6vw, 34px);
  line-height: 1;
  pointer-events: none;
}

.music-toggle,
.safe-corner {
  position: fixed;
  z-index: 22;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: var(--cream);
  box-shadow: 4px 4px 0 var(--ink);
}

.music-toggle {
  left: max(12px, env(safe-area-inset-left));
  bottom: max(12px, env(safe-area-inset-bottom));
  width: 46px;
  height: 46px;
}

.music-toggle::before {
  content: "♪";
  font-family: Luckiest Guy, Chewy, sans-serif;
  font-size: 28px;
}

.music-toggle[aria-pressed="false"]::after {
  content: "";
  position: absolute;
  inset: 20px 8px auto 8px;
  height: 4px;
  border-radius: 999px;
  background: var(--ink);
  transform: rotate(-35deg);
}

.safe-corner {
  top: 0;
  left: 0;
  width: 54px;
  height: 54px;
  opacity: 0.01;
  box-shadow: none;
}

.safe-corner.holding {
  opacity: 0.85;
  background: var(--yellow);
}

.parent-panel {
  position: fixed;
  z-index: 30;
  top: max(68px, calc(env(safe-area-inset-top) + 58px));
  right: max(12px, env(safe-area-inset-right));
  display: grid;
  gap: 14px;
  width: min(380px, calc(100vw - 24px));
  max-height: calc(100dvh - 92px);
  overflow: auto;
  padding: 16px;
  background: var(--cream);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel-kicker {
  margin: 0 0 2px;
  font-family: "Space Mono", monospace;
  font-size: 12px;
  text-transform: uppercase;
}

.parent-panel h1 {
  margin: 0;
  font-family: Luckiest Guy, Chewy, sans-serif;
  font-size: 38px;
  line-height: 0.88;
  letter-spacing: 0;
}

.icon-button {
  width: 40px;
  min-width: 40px;
  font-family: "Space Mono", monospace;
}

.control-group,
.slider-row,
.switch-row {
  display: grid;
  gap: 7px;
}

.control-label,
.slider-row span {
  font-family: "Space Mono", monospace;
  font-size: 12px;
  text-transform: uppercase;
}

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

.segment,
.theme {
  min-width: 0;
  padding: 6px 6px 4px;
  font-size: 17px;
  background: white;
}

.segment.active,
.theme.active {
  background: var(--pink);
}

.slider-row input {
  width: 100%;
  accent-color: var(--blue);
}

.switch-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.switch-row label {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px;
  border: 3px solid var(--ink);
  border-radius: 8px;
  background: white;
}

.switch-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--pink);
}

.panel-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.panel-actions button {
  min-width: 0;
  padding: 7px 5px 5px;
  font-size: 16px;
}

.panel-note {
  margin: 0;
  font-size: 18px;
  line-height: 1.1;
}

body[data-theme="space"] {
  background:
    radial-gradient(circle at 18% 18%, #ffffff 0 3px, transparent 4px),
    radial-gradient(circle at 68% 10%, #ffffff 0 4px, transparent 5px),
    radial-gradient(circle at 82% 36%, #ffffff 0 2px, transparent 3px),
    linear-gradient(180deg, #2634a5 0%, #7352d6 58%, #ffb84d 58%, #ff6f45 100%);
}

body[data-theme="party"] {
  background:
    radial-gradient(circle at 16% 16%, #fff 0 32px, transparent 33px),
    linear-gradient(135deg, rgba(255, 220, 63, 0.45) 0 16%, transparent 16% 32%, rgba(255, 111, 181, 0.46) 32% 48%, transparent 48% 64%, rgba(26, 119, 255, 0.38) 64% 80%, transparent 80%),
    linear-gradient(180deg, #7be7ff 0%, #ffe06b 58%, #5ad85a 58%, #168b3d 100%);
}

@media (max-width: 760px) {
  .topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .brand-lockup {
    flex: 1 1 150px;
  }

  .brand-lockup span {
    display: none;
  }

  .score-pill {
    order: 3;
    flex: 0 0 min(330px, calc(100vw - 26px));
    min-width: 0;
    margin: 0 auto;
    padding-block: 5px;
  }

  .top-button {
    flex: 0 0 auto;
  }

  .topbar.playing {
    transform: translateY(-48px);
  }

  .parent-panel {
    top: max(96px, calc(env(safe-area-inset-top) + 86px));
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    width: auto;
    max-height: calc(100dvh - 112px);
  }

  .start-hint span {
    width: min(86vw, 360px);
    font-size: clamp(19px, 5.2vw, 26px);
    line-height: 1.12;
  }

  .switch-row,
  .panel-actions {
    grid-template-columns: 1fr;
  }
}
