/* =========================================================
   Theme variables
   ========================================================= */

:root {
  /* Dark theme (default) */
  --app-height: 100vh; /* fallback; JS will overwrite on iOS */
  --bg-main: #0e0e11;
  --bg-panel: #15151a;
  --bg-stage: #0b0b0f;

  --text-main: #eee;
  --text-muted: rgba(255,255,255,0.75);

  --button-bg: #242430;
  --button-accent: #3a6cff;
  --button-stop: #8a2b2b;

  --tonic-ring: rgba(255,255,255,0.35);
}
html, body {
  height: 100%;

body.theme-light {
  --bg-main: #eef2ea;        /* bone with green tint */
  --bg-panel: #e4eadf;
  --bg-stage: #f6f8f3;

  --text-main: #111;
  --text-muted: rgba(0,0,0,0.65);

  --button-bg: #d8ddd3;
  --button-accent: #3a6cff;
  --button-stop: #c85d5d;

  --tonic-ring: rgba(0,0,0,0.35);
}

/* =========================================================
   Base layout
   ========================================================= */

* { box-sizing: border-box; }

body {
  /* replace min-height:100vh */
  height: var(--app-height);
  margin: 0;

  background: var(--bg-main);
  color: var(--text-main);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;

  display: flex;
  justify-content: center;
  align-items: flex-start;

  /* IMPORTANT: once height is correct, you do not want Safari page scrolling */
  overflow: hidden;
}

.app {
  width: 100%;
  max-width: 1100px;
  padding: 1rem;

  height: 100%;
  min-height: 0;

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

/* Header */
.topbar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;

  padding: 0.75rem 1rem;
  background: var(--bg-panel);
  border-radius: 10px;
}

.status {
  font-size: 0.95rem;
  font-weight: 500;
  opacity: 0.8;
  white-space: nowrap;
}

/* =========================================================
   Note board
   ========================================================= */

.stage {
  width: 100%;
  display: flex;
  justify-content: center;
}

.board {
  width: 100%;
  max-width: 1000px;
  /* keep your current height as a desktop fallback */
  height: min(62vh, 520px);
  /* IMPORTANT: remove the hard minimum that breaks iPhone/iPad fitting */
  min-height: 0;
  background: var(--bg-stage);
  border-radius: 12px;
  padding: 1rem;

  position: relative;
}

/* Positioning surface */
.notes {
  position: absolute;
  inset: 1rem;

  width: auto;
  height: auto;
}

/* =========================================================
   Controls strip
   ========================================================= */

.controls {
  width: 100%;
  max-width: 1000px;
  margin-top: auto;

  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.9rem;

  background: var(--bg-panel);
  padding: 1rem 1.25rem;
  border-radius: 12px;
}

.controls section {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  white-space: nowrap;
}

.controls h3 {
  margin: 0 0.25rem 0 0;
  font-size: 0.95rem;
  font-weight: 600;
  opacity: 0.9;
}

button {
  background: var(--button-bg);
  color: var(--text-main);
  border: none;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
}

button.start {
  background: var(--button-accent);
  padding: 0.6rem 1.1rem;
  font-weight: 700;
}

button.stop {
  background: var(--button-stop);
  padding: 0.6rem 1.1rem;
  font-weight: 700;
}

button:disabled,
select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* =========================================================
   Notes (now vertical bars)
   ========================================================= */

.note {
  position: absolute;

  /* Defaults; JS sets actual width/height */
  width: 18px;
  height: 54px;

  border-radius: 999px;
  transform: translate(-50%, -50%);

  border: none;
  padding: 0;

  opacity: 0.2; /* out-of-scale default (dimmed) */
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;

  box-shadow: 0 0 0 2px rgba(0,0,0,0.15);
}

.note.in-scale {
  opacity: 0.95;
}

.note.glow {
  opacity: 1;
  filter: saturate(1.25) brightness(1.08);
  box-shadow:
    0 0 34px currentColor,
    0 0 70px currentColor,
    0 0 0 3px rgba(255,255,255,0.70);
}

body.theme-light .note.glow {
  box-shadow:
    0 0 34px currentColor,
    0 0 70px currentColor,
    0 0 0 3px rgba(0,0,0,0.50);
}

/* Mark C as tonic (ring) */
.note.tonic {
  overflow: visible;
}

.note.tonic::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 999px;
  border: 2px solid var(--tonic-ring);
  pointer-events: none;
}

.note.tonic-main::after {
  inset: -7px;
  border-width: 3px;
}

.note:focus-visible {
  outline: 3px solid rgba(255,255,255,0.35);
  outline-offset: 2px;
}

body.theme-light .note:focus-visible {
  outline-color: rgba(0,0,0,0.35);
}