:root {
  --bg: #fffaf0;            /* cream */
  --panel: #ffffff;
  --fg: #222222;
  --ink: #111111;           /* the cartoon outline black */
  --muted: #6b6b6b;
  --line: #e9e2d2;
  --accent: #f8b040;        /* cheetah orange */
  --accent-dark: #e0901c;
  --accent-soft: #fff1d6;
  --ok: #2e9e5b;
  --bad: #d64545;
  --shadow: 0 10px 28px rgba(224, 144, 28, .14);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.4;
}
body {
  background-image:
    radial-gradient(55% 40% at 0% 0%, rgba(248, 176, 64, .22), transparent 70%),
    radial-gradient(45% 30% at 100% 5%, rgba(248, 176, 64, .12), transparent 70%);
  background-attachment: fixed;
}

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px clamp(16px, 4vw, 32px) 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0 12px;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.logo { width: 64px; height: 64px; flex: none; }
.brand-text { min-width: 0; }

h1 {
  margin: 0;
  font-size: clamp(22px, 4.2vw, 38px);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .05em;
  line-height: 1.05;
  color: #3a3a3a;
}
.tagline {
  margin: 4px 0 0;
  font-size: clamp(13px, 1.6vw, 16px);
  color: var(--muted);
  letter-spacing: .01em;
}

.icons { display: flex; gap: 8px; flex: none; }

/* Buttons: bold outlines, like the cartoon */
button {
  font: inherit;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 12px;
  border: 2px solid var(--ink);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 3px 0 var(--ink);
  transition: background .15s, transform .08s, box-shadow .08s, opacity .15s;
}
button:hover { background: var(--accent-soft); }
button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
button:disabled { opacity: .4; cursor: default; transform: none; }
button.primary {
  background: var(--accent);
  color: var(--ink);
  min-width: 128px;
}
button.primary:hover { background: #ffbb52; }
button.primary.stop { background: var(--ink); color: #fff; }
button.primary.stop:hover { background: #333; }

button.icon {
  width: 44px; height: 44px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: var(--accent);
}
button.icon:hover { background: #ffbb52; }
button.icon svg {
  width: 22px; height: 22px;
  fill: none; stroke: currentColor; stroke-width: 2.4;
  stroke-linecap: round; stroke-linejoin: round;
}
/* the close button inside a sheet is quieter */
.sheet-head button.icon { background: var(--panel); }

/* Fields */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
}
.field .val { color: var(--accent-dark); font-weight: 800; }
.field.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  align-self: end;
  padding-bottom: 8px;
  font-size: 14px;
  color: var(--fg);
}

select, input[type="range"] { width: 100%; font: inherit; color: var(--fg); }
select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23111111'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 8px 28px 8px 10px;
  font-weight: 600;
}
select:focus { outline: 3px solid var(--accent-soft); }
input[type="range"] { accent-color: var(--accent-dark); padding: 8px 0; margin: 0; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent-dark); margin: 0; }

/* Tempo and note-name hint sliders on the main screen */
.tempo-row { display: flex; flex-wrap: wrap; gap: 8px 32px; padding: 2px 0 6px; }
.tempo-row .field { flex: 1 1 240px; max-width: 360px; font-size: 13px; }
.tempo-row .field > span:first-child { display: flex; justify-content: space-between; }
.field.dim { opacity: .45; }
.hint-text { font-size: 11px; color: var(--muted); line-height: 1.3; }
.tempo-row .instrument-field { flex: 0 1 auto; max-width: none; }
/* the instrument picker looks like a button and opens a native list when tapped */
.instrument-btn {
  width: auto;
  min-width: 180px;
  padding: 9px 36px 9px 14px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M0 0l6 8 6-8z' fill='%23111111'/%3E%3C/svg%3E") no-repeat right 12px center;
  box-shadow: 0 3px 0 var(--ink);
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
}
.instrument-btn:hover { background-color: #ffbb52; }

/* Score */
.score {
  background: var(--panel);
  border: 2px solid var(--ink);
  border-radius: 16px;
  padding: 6px 4px;
  margin: 8px 0;
  min-height: 140px;
  box-shadow: var(--shadow);
}
#score svg { display: block; width: 100%; height: auto; }

.summary {
  margin: 4px 0 8px;
  padding: 14px 16px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: var(--accent-soft);
  text-align: center;
}
.summary h2 { margin: 0 0 6px; font-size: 17px; font-weight: 900; text-transform: uppercase; letter-spacing: .04em; color: #3a3a3a; }
.summary p { margin: 4px 0; color: #555; }
.summary strong { color: var(--ink); }
.summary .legend { font-size: 12px; color: var(--muted); margin-top: 8px; }

.note { color: var(--muted); font-size: 13px; text-align: center; }

/* Controls pinned to the bottom, centred */
.bottom {
  margin-top: auto;
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, rgba(255, 250, 240, 0), var(--bg) 30%);
  padding: 10px 0 max(18px, env(safe-area-inset-bottom));
  text-align: center;
}
.beat { display: inline-block; color: var(--accent-dark); font-size: 10px; margin-right: 6px; transition: opacity .1s; }
.heard {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  min-height: 18px;
}
.status {
  color: var(--muted);
  font-size: 14px;
  min-height: 22px;
  margin-bottom: 12px;
}
.status.big { font-size: 28px; font-weight: 900; color: var(--accent-dark); }
.controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Key mode checks */
.checks { display: flex; gap: 16px; padding-top: 6px; }
.check-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--fg); }

/* Key chips */
.field.keys { grid-column: 1 / -1; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 2px; }
.chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; padding: 8px 12px;
  border: 2px solid var(--ink); border-radius: 999px;
  background: var(--panel); color: var(--ink);
  font-size: 14px; font-weight: 700; cursor: pointer; user-select: none;
}
.chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip:has(input:checked) { background: var(--accent); }

/* Pop-up sheets */
dialog.sheet {
  border: 2px solid var(--ink);
  border-radius: 20px;
  padding: 0;
  width: min(600px, calc(100% - 32px));
  background: var(--panel);
  color: var(--fg);
  box-shadow: 0 20px 50px rgba(40, 30, 0, .22);
}
dialog.sheet::backdrop { background: rgba(60, 40, 0, .32); }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 6px 20px;
}
.version { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: 0; text-transform: none; margin-left: 6px; }
.sheet-head h2 { margin: 0; font-size: 17px; font-weight: 900; text-transform: uppercase; letter-spacing: .04em; color: #3a3a3a; }
.sheet .grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px 16px;
  padding: 8px 20px 22px;
}

/* Tuner */
.tuner { text-align: center; }
.tuner-note {
  font-size: 88px;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1;
  padding: 8px 0 4px;
  min-height: 96px;
  color: #3a3a3a;
}
.tuner.intune .tuner-note { color: var(--ok); }
.tuner-bar-wrap {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 20px 10px;
}
.tuner-end { color: var(--muted); font-size: 18px; width: 16px; }
.tuner-bar { flex: 1; display: flex; align-items: center; gap: 3px; height: 44px; }
.seg {
  flex: 1; height: 24px; border-radius: 3px;
  background: var(--c, #ccc);
  opacity: .18;
  transition: opacity .18s ease;
}
.seg.center { height: 44px; opacity: .35; }
.seg.lit { opacity: .6; }
.seg.on { opacity: 1; }
.tuner-sub { color: var(--muted); font-size: 14px; min-height: 20px; padding: 0 20px 22px; }

@media (max-width: 480px) {
  header { padding-top: 8px; }
  .brand { gap: 10px; }
  .logo { width: 52px; height: 52px; }
  h1 { font-size: 19px; letter-spacing: .04em; }
  .tagline { font-size: 12px; }
  .controls { gap: 8px; }
  .controls button { padding: 12px 14px; }
  .controls .primary { min-width: 108px; }
  dialog.sheet {
    width: 100%;
    max-width: none;
    margin: auto 0 0;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
  }
  .sheet .grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .tuner-note { font-size: 72px; min-height: 80px; }
  .seg { border-radius: 2px; }
}
