:root {
  color-scheme: dark;
  --bg: #111014;
  --panel: rgba(33, 29, 39, 0.86);
  --panel-strong: #2c2634;
  --text: #f8efe3;
  --muted: #b9aebf;
  --accent: #f1b75b;
  --accent-strong: #ff8c42;
  --cyan: #7be1ff;
  --green: #9be37d;
  --danger: #ff6c7f;
  --line: rgba(255, 255, 255, 0.12);
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.38);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 10%, rgba(241, 183, 91, 0.18), transparent 28rem),
    radial-gradient(circle at 88% 18%, rgba(123, 225, 255, 0.14), transparent 24rem),
    linear-gradient(135deg, #110f14 0%, #1c1721 55%, #100f13 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.58rem 0.78rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  font-size: 0.9rem;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.13);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.72rem;
  padding: 0.55rem 0.65rem;
  color: var(--text);
  background: rgba(5, 4, 8, 0.34);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(241, 183, 91, 0.7);
  box-shadow: 0 0 0 3px rgba(241, 183, 91, 0.12);
}

textarea {
  resize: vertical;
  min-height: 7rem;
  margin-top: 1rem;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.84rem;
}

label {
  display: grid;
  gap: 0.32rem;
  color: var(--muted);
  font-size: 0.84rem;
}

.app-shell {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: clamp(0.55rem, 1.5vw, 1rem);
}

.hero,
.instrument-panel,
.controls-panel,
.mode-tabs {
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
  padding: clamp(0.7rem, 1.6vw, 1rem);
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.67rem;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.35rem;
  font-size: clamp(1.8rem, 4.2vw, 2.8rem);
  line-height: 0.95;
}

h2 {
  margin-bottom: 0.18rem;
  font-size: clamp(1.05rem, 1.7vw, 1.35rem);
}

h3 {
  margin-bottom: 0.45rem;
  font-size: 0.98rem;
}

.hero-text,
.panel-heading p,
.hint-card p {
  color: var(--muted);
}

.hero-text {
  max-width: 68ch;
  margin-bottom: 0;
  line-height: 1.35;
  font-size: 0.86rem;
}

.version-card {
  display: grid;
  min-width: 5.8rem;
  gap: 0.12rem;
  border: 1px solid rgba(241, 183, 91, 0.25);
  border-radius: 0.85rem;
  padding: 0.62rem;
  background: linear-gradient(145deg, rgba(241, 183, 91, 0.16), rgba(255, 255, 255, 0.05));
  text-align: center;
}

.hero-actions {
  display: flex;
  align-items: stretch;
  gap: 0.45rem;
}

.fullscreen-button {
  min-width: 7.8rem;
  border-color: rgba(241, 183, 91, 0.22);
  background: rgba(255, 255, 255, 0.06);
  font-weight: 800;
}

.version-card span {
  color: var(--muted);
  font-size: 0.68rem;
}

.version-card strong {
  color: var(--accent);
  font-size: 1rem;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
  margin: 0.45rem 0;
  padding: 0.35rem;
}

.tab-button.active {
  color: #1a1010;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  font-weight: 800;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(340px, 1.05fr) minmax(320px, 0.95fr);
  gap: 0.6rem;
}

body[data-mode="freeplay"] .workspace-grid {
  grid-template-columns: 1fr;
}

body[data-mode="freeplay"] .controls-panel,
body[data-mode="freeplay"] .instrument-panel .panel-heading,
body[data-mode="freeplay"] .legend {
  display: none;
}

body[data-mode="freeplay"] .instrument-panel {
  min-height: calc(100vh - 6.2rem);
  display: grid;
  place-items: center;
}

body[data-mode="freeplay"] .drum-stage {
  width: min(96vmin, 980px);
  max-width: min(96vmin, 980px);
  border-radius: 1.8rem;
}

body.fullscreen-mode {
  overflow: hidden;
}

body.fullscreen-mode .app-shell {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0.45rem;
}

body.fullscreen-mode .hero {
  flex: 0 0 auto;
  padding: 0.55rem 0.75rem;
}

body.fullscreen-mode h1 {
  font-size: clamp(1.4rem, 3vw, 2.15rem);
}

body.fullscreen-mode .hero-text {
  display: none;
}

body.fullscreen-mode .mode-tabs {
  flex: 0 0 auto;
  margin: 0.35rem 0;
}

body.fullscreen-mode .workspace-grid {
  flex: 1 1 auto;
  min-height: 0;
}

body.fullscreen-mode .instrument-panel,
body.fullscreen-mode .controls-panel {
  min-height: 0;
  overflow: auto;
}

body.fullscreen-mode .drum-stage {
  max-height: calc(100vh - 9.8rem);
}

body.fullscreen-mode[data-mode="freeplay"] .instrument-panel {
  min-height: 0;
}

body.fullscreen-mode[data-mode="freeplay"] .drum-stage {
  width: min(98vmin, calc(100vh - 4.8rem), 1100px);
  max-width: min(98vmin, calc(100vh - 4.8rem), 1100px);
  max-height: calc(100vh - 4.8rem);
}

.instrument-panel,
.controls-panel {
  min-width: 0;
  padding: clamp(0.65rem, 1.4vw, 0.9rem);
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.55rem;
  margin-bottom: 0.55rem;
}

.panel-heading p {
  margin-bottom: 0;
}

.drum-stage {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 1.1rem;
  max-width: min(100%, calc(100vh - 185px));
  margin: 0 auto;
  background:
    radial-gradient(circle at 46% 40%, rgba(255, 255, 255, 0.24), transparent 7rem),
    radial-gradient(circle, #625348 0%, #2c2930 56%, #131117 75%);
}

#visualCanvas,
#drumSvg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#visualCanvas {
  z-index: 1;
  pointer-events: none;
}

#drumSvg {
  z-index: 2;
}

.drum-shell {
  fill: url("#steelGradient");
  stroke: rgba(255, 255, 255, 0.34);
  stroke-width: 0.45;
  filter: drop-shadow(0 1.2px 2.2px rgba(0, 0, 0, 0.55));
}

.petal {
  cursor: pointer;
}

.petal-shape {
  fill: rgba(26, 22, 27, 0.28);
  stroke: rgba(0, 0, 0, 0.8);
  stroke-width: 0.55;
  transition:
    fill 160ms ease,
    stroke 160ms ease,
    filter 160ms ease;
}

.petal.selected .petal-shape {
  stroke: var(--accent);
  stroke-width: 0.85;
}

.petal.active .petal-shape {
  fill: rgba(241, 183, 91, 0.42);
  stroke: #ffe0a3;
  filter: drop-shadow(0 0 7px rgba(241, 183, 91, 0.9));
}

.petal.detected .petal-shape {
  fill: rgba(123, 225, 255, 0.4);
  stroke: var(--cyan);
  filter: drop-shadow(0 0 9px rgba(123, 225, 255, 0.9));
}

.petal text {
  pointer-events: none;
  text-anchor: middle;
  dominant-baseline: middle;
}

.petal-number {
  fill: #fff5e5;
  font-weight: 900;
  font-size: 4px;
  paint-order: stroke;
  stroke: rgba(0, 0, 0, 0.75);
  stroke-width: 0.55px;
}

.petal-note {
  fill: var(--muted);
  font-weight: 700;
  font-size: 2.2px;
}

.karaoke-overlay {
  pointer-events: none;
}

.karaoke-path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.1;
  stroke-dasharray: 2.2 1.5;
  marker-mid: url("#karaokeArrow");
  marker-end: url("#karaokeArrow");
  filter: drop-shadow(0 0 4px rgba(241, 183, 91, 0.9));
}

.stick-hit line {
  stroke: #f8efe3;
  stroke-width: 1.25;
  stroke-linecap: round;
  filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.65));
}

.stick-hit circle {
  fill: var(--accent);
  stroke: #fff1c4;
  stroke-width: 0.45;
}

.sequence-step circle {
  fill: rgba(15, 13, 18, 0.82);
  stroke: rgba(255, 255, 255, 0.72);
  stroke-width: 0.55;
}

.sequence-step.current-step circle {
  fill: var(--accent);
  stroke: #fff1c4;
  stroke-width: 0.85;
  filter: drop-shadow(0 0 5px rgba(241, 183, 91, 0.9));
}

.sequence-number,
.sequence-label {
  text-anchor: middle;
  dominant-baseline: middle;
  paint-order: stroke;
  stroke: rgba(0, 0, 0, 0.76);
}

.sequence-number {
  fill: #fff7eb;
  font-size: 4.2px;
  font-weight: 950;
  stroke-width: 0.55px;
}

.current-step .sequence-number {
  fill: #211306;
  stroke: rgba(255, 255, 255, 0.45);
}

.sequence-label {
  fill: var(--accent);
  font-size: 2.2px;
  font-weight: 900;
  stroke-width: 0.35px;
}

.legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(5.8rem, 1fr));
  gap: 0.35rem;
  margin-top: 0.55rem;
}

.legend-item {
  display: grid;
  gap: 0.15rem;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  padding: 0.48rem;
  background: rgba(255, 255, 255, 0.05);
}

.legend-item strong {
  color: var(--accent);
}

.legend-item small {
  color: var(--muted);
}

.mode-panel {
  display: none;
}

.mode-panel.active {
  display: block;
}

.primary-button {
  color: #1c1208;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  font-weight: 900;
}

.ghost-button {
  background: transparent;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem;
  margin: 0.55rem 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.quick-form {
  grid-template-columns: 0.7fr 1fr 1fr;
}

.toggle-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  margin: 0.6rem 0;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 0.78rem;
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.05);
}

.toggle-row input {
  width: auto;
  accent-color: var(--accent);
}

.status-card,
.count-card,
.editor-card,
.hint-card {
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  padding: 0.65rem;
  background: rgba(255, 255, 255, 0.055);
}

.status-card,
.count-card {
  display: grid;
  gap: 0.25rem;
}

.status-card strong,
.count-card strong {
  color: var(--green);
  font-size: 1.05rem;
}

.status-card small,
.count-card small,
.status-label {
  color: var(--muted);
}

.editor-card {
  margin-top: 0.55rem;
}

.compact-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.compact-status small {
  text-align: right;
}

.editor-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.editor-title-row h3,
.inline-buttons {
  margin: 0;
}

.inline-buttons button {
  padding-inline: 0.62rem;
}

.danger-button {
  color: #ffd9de;
  border-color: rgba(255, 108, 127, 0.28);
}

.advanced-editor {
  border-top: 1px solid var(--line);
  margin-top: 0.6rem;
  padding-top: 0.55rem;
}

.advanced-editor summary {
  color: var(--accent);
  cursor: pointer;
  font-weight: 800;
}

.advanced-editor p {
  margin: 0.4rem 0 0.6rem;
  color: var(--muted);
  font-size: 0.84rem;
}

.karaoke-focus {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin: 0.65rem 0;
}

.focus-card,
.focus-upcoming {
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.06);
}

.focus-card {
  display: grid;
  min-height: 6.2rem;
  place-items: center;
  padding: 0.75rem;
  text-align: center;
}

.focus-card.current {
  color: #211306;
  border-color: rgba(255, 232, 178, 0.8);
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.focus-card.next {
  border-color: rgba(123, 225, 255, 0.3);
}

.focus-card span,
.focus-card small {
  font-weight: 800;
  opacity: 0.78;
}

.focus-card strong {
  font-size: clamp(2.6rem, 6vw, 4.4rem);
  line-height: 0.85;
}

.focus-upcoming {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  overflow-x: auto;
  padding: 0.55rem;
}

.upcoming-hit {
  display: grid;
  place-items: center;
  min-width: 4.4rem;
  border: 1px solid var(--line);
  border-radius: 0.78rem;
  padding: 0.45rem 0.6rem;
  background: rgba(0, 0, 0, 0.18);
}

.upcoming-hit.current {
  color: #211306;
  background: var(--accent);
}

.upcoming-hit span,
.upcoming-hit small {
  font-size: 0.72rem;
  opacity: 0.78;
}

.upcoming-hit strong {
  font-size: 1.4rem;
  line-height: 1;
}

.upcoming-arrow {
  color: var(--accent);
  font-size: 1.15rem;
  font-weight: 900;
}

.note-tape-wrap {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 1.2rem;
  min-height: 8rem;
  background: rgba(0, 0, 0, 0.22);
}

.note-tape {
  display: flex;
  align-items: stretch;
  gap: 0.45rem;
  min-height: 8rem;
  padding: 0.75rem;
  transition: transform 180ms linear;
}

.tape-note {
  display: grid;
  place-items: center;
  gap: 0.15rem;
  min-width: var(--note-width, 4.5rem);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 1rem;
  padding: 0.7rem 0.8rem;
  background: rgba(255, 255, 255, 0.07);
}

.tape-note.active {
  color: #160f07;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  transform: scale(1.04);
}

.tape-note.upcoming {
  border-color: rgba(123, 225, 255, 0.42);
  box-shadow: inset 0 0 0 1px rgba(123, 225, 255, 0.18);
}

.tape-note strong {
  font-size: 1.9rem;
}

.tape-note small {
  color: inherit;
  opacity: 0.74;
}

@media (max-width: 980px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .controls-panel {
    order: -1;
  }
}

@media (max-width: 680px) {
  .hero,
  .panel-heading {
    display: grid;
  }

  .hero-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .mode-tabs,
  .toggle-grid {
    grid-template-columns: 1fr;
  }

  .form-grid,
  .quick-form {
    grid-template-columns: 1fr;
  }

  .app-shell {
    padding: 0.45rem;
  }

  .instrument-panel,
  .controls-panel,
  .hero,
  .mode-tabs {
    border-radius: 1.1rem;
  }

  .legend {
    display: flex;
    overflow-x: auto;
    padding-bottom: 0.25rem;
  }

  .legend-item {
    min-width: 5.4rem;
  }

  .compact-status,
  .editor-title-row {
    align-items: stretch;
    display: grid;
  }

  .compact-status small {
    text-align: left;
  }

  .karaoke-focus {
    grid-template-columns: 1fr;
  }

  .focus-upcoming {
    grid-column: auto;
  }
}

@media (orientation: landscape) and (max-height: 620px) {
  .hero {
    padding-block: 0.45rem;
  }

  .eyebrow,
  .hero-text {
    display: none;
  }

  .mode-tabs {
    margin-block: 0.3rem;
  }

  .instrument-panel,
  .controls-panel {
    padding: 0.5rem;
  }

  .drum-stage {
    max-height: calc(100vh - 7rem);
  }
}
