:root {
  color-scheme: dark;
  --ink: #f6f3e9;
  --muted: #b8c4c7;
  --panel: rgba(14, 20, 25, 0.78);
  --line: rgba(255, 255, 255, 0.16);
  --accent: #ffcc4d;
  --teal: #47dbc2;
  --rose: #ff5f7b;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: #10161b;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
}

.shell {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    radial-gradient(circle at 15% 15%, rgba(71, 219, 194, 0.18), transparent 34%),
    linear-gradient(140deg, #0f1820 0%, #172129 45%, #251720 100%);
}

.game-wrap {
  position: relative;
  width: min(100%, 1280px);
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 36px);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #111b22;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.42);
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.hud {
  position: absolute;
  top: 14px;
  right: 14px;
  left: 14px;
  display: grid;
  grid-template-columns: repeat(5, minmax(76px, 1fr));
  gap: 8px;
  z-index: 2;
  pointer-events: none;
}

.hud > div {
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(10, 16, 21, 0.72);
  backdrop-filter: blur(10px);
}

.label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hud strong {
  display: block;
  margin-top: 2px;
  font-size: clamp(18px, 2.5vw, 30px);
  line-height: 1;
  white-space: nowrap;
}

.level-progress {
  position: absolute;
  top: 108px;
  right: 14px;
  left: 14px;
  display: grid;
  grid-template-columns: minmax(160px, auto) 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(10, 16, 21, 0.68);
  backdrop-filter: blur(10px);
  z-index: 2;
  pointer-events: none;
}

.progress-copy {
  min-width: 0;
}

.progress-copy span,
.progress-copy strong {
  display: block;
  line-height: 1.1;
  white-space: nowrap;
}

.progress-copy span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.progress-copy strong {
  margin-top: 3px;
  font-size: 15px;
}

.progress-track {
  height: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--accent));
  transition: width 180ms ease;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: linear-gradient(90deg, rgba(8, 13, 17, 0.88), rgba(8, 13, 17, 0.36));
  z-index: 3;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.hidden,
.overlay.hidden {
  display: none;
}

.comic-bubble {
  position: absolute;
  top: 16%;
  left: 50%;
  z-index: 6;
  width: min(88vw, 640px);
  min-height: 180px;
  display: grid;
  place-items: center;
  padding: 38px 76px;
  color: #10161b;
  background: #ffcc4d;
  font-family: Impact, Haettenschweiler, "Arial Black", system-ui, sans-serif;
  font-size: clamp(44px, 10vw, 84px);
  font-weight: 900;
  line-height: 0.86;
  text-align: center;
  text-transform: uppercase;
  transform: translateX(-50%) rotate(-4deg);
  clip-path: polygon(50% 0%, 58% 12%, 72% 4%, 75% 20%, 95% 17%, 85% 35%, 100% 48%, 84% 59%, 94% 80%, 73% 76%, 68% 96%, 55% 83%, 43% 100%, 36% 80%, 16% 91%, 23% 69%, 2% 63%, 17% 49%, 0% 32%, 22% 29%, 18% 7%, 38% 17%);
  filter: drop-shadow(0 8px 0 #10161b) drop-shadow(0 16px 24px rgba(0, 0, 0, 0.42));
  opacity: 0;
  animation: bubbleFadeIn 1.45s ease-out forwards;
}

.comic-bubble.hidden {
  display: none;
}

.level-complete-bubble {
  position: absolute;
  top: 20%;
  left: 50%;
  z-index: 6;
  width: min(54vw, 280px);
  min-height: 68px;
  display: grid;
  place-items: center;
  padding: 14px 26px;
  border: 3px solid rgba(246, 243, 233, 0.92);
  border-radius: 999px;
  color: #102018;
  background: linear-gradient(135deg, #43d95b, #ffcc4d);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.34), inset 0 0 18px rgba(255, 255, 255, 0.28);
  font-size: clamp(22px, 4vw, 36px);
  font-weight: 900;
  line-height: 0.95;
  text-align: center;
  text-transform: uppercase;
  transform: translateX(-50%) scale(0.92);
  opacity: 0;
  animation: completeBubbleIn 1.1s ease-out forwards;
}

.level-complete-bubble.hidden {
  display: none;
}

@keyframes completeBubbleIn {
  0% {
    opacity: 0;
    transform: translateX(-50%) scale(0.84);
  }

  100% {
    opacity: 1;
    transform: translateX(-50%) scale(1);
  }
}

@keyframes bubbleFadeIn {
  0% {
    opacity: 0;
    transform: translateX(-50%) rotate(-4deg) scale(0.76);
  }

  70% {
    opacity: 1;
    transform: translateX(-50%) rotate(-4deg) scale(1.04);
  }

  100% {
    opacity: 1;
    transform: translateX(-50%) rotate(-4deg) scale(1);
  }
}

.panel {
  position: relative;
  z-index: 5;
  width: min(520px, 100%);
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  margin-right: auto;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(16px);
}

.kicker {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: 13ch;
  font-size: clamp(38px, 7vw, 76px);
  line-height: 0.92;
  letter-spacing: 0;
}

.panel p:not(.kicker) {
  max-width: 44ch;
  margin: 16px 0 18px;
  color: #d9e2e2;
  font-size: 16px;
  line-height: 1.5;
}

button {
  min-height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #17120a;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.08);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.actions.hidden {
  display: none;
}

button.secondary {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
}

.lesson-visual {
  display: grid;
  gap: 12px;
  width: min(100%, 390px);
  max-width: 100%;
  margin: 18px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.time-demo {
  position: relative;
  min-height: 112px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 12, 16, 0.55);
}

.mini-staff {
  position: absolute;
  inset: 20px 12px;
  display: grid;
  align-content: space-between;
}

.mini-staff span {
  display: block;
  height: 2px;
  background: rgba(246, 243, 233, 0.34);
}

.stacked-time {
  position: absolute;
  top: 12px;
  left: 28px;
  display: grid;
  place-items: center;
  width: 58px;
  min-height: 88px;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 46px;
  font-weight: 900;
  line-height: 0.78;
  text-align: center;
}

.stacked-time span {
  display: block;
}

.stacked-time.meter-set {
  inset: 10px 14px;
  display: flex;
  width: auto;
  min-height: 88px;
  align-items: center;
  justify-content: space-around;
  gap: 10px;
}

.meter-card {
  display: grid;
  place-items: center;
  width: 52px;
  min-height: 82px;
  font-size: 40px;
  line-height: 0.78;
}

.note-demo {
  display: grid;
  grid-template-columns: 92px 32px minmax(92px, auto);
  align-items: center;
  gap: 10px;
}

.note-picture,
.beat-picture {
  display: grid;
  place-items: center;
  min-height: 76px;
  border-radius: 8px;
  font-weight: 900;
}

.note-picture {
  align-content: center;
  gap: 2px;
  background: var(--teal);
  color: #10161b;
  font-family: Georgia, serif;
  font-size: 44px;
  line-height: 0.9;
}

.note-picture small {
  display: block;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
}

.equals {
  color: var(--accent);
  font-size: 34px;
  font-weight: 900;
  text-align: center;
}

.beat-picture {
  padding: 0 16px;
  background: var(--accent);
  color: #17120a;
  font-size: 22px;
  white-space: nowrap;
}

.keys {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
}

.keys span {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
}

@media (max-width: 700px) {
  .shell {
    padding: 0;
  }

  .game-wrap {
    width: 100vw;
    height: 100vh;
    max-height: none;
    aspect-ratio: auto;
    border: 0;
    border-radius: 0;
  }

  .hud {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    top: 10px;
    right: 10px;
    left: 10px;
  }

  .level-progress {
    top: 214px;
    right: 10px;
    left: 10px;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .panel {
    max-height: calc(100vh - 24px);
    padding: 18px;
  }

  .lesson-visual {
    width: 100%;
  }

  .note-demo {
    grid-template-columns: 76px 24px minmax(76px, auto);
  }

  .note-picture,
  .beat-picture {
    min-height: 64px;
  }
}
