:root {
  --blue: #33b5e5;
  --blue-deep: #1a9fd3;
  --text: #5c6166;
  --text-soft: #8b949b;
  --label: #8a9aa5;
  --green: #36c95a;
  --lime: #bde61c;
  --yellow: #f5e21a;
  --orange: #ffa62b;
  --red: #ff6448;
  --card: rgba(255, 255, 255, 0.94);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Roboto', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--text);
  background: #dff3fc;
  background-image: radial-gradient(ellipse 75% 70% at 50% 48%, #fdfeff 0%, #eef9fe 38%, #d3eefb 75%, #bfe5f8 100%);
  -webkit-font-smoothing: antialiased;
}

#app { position: fixed; inset: 0; }

#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hidden { display: none !important; }

/* ---------- Horní lišta ---------- */

.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: max(12px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 0 max(18px, env(safe-area-inset-left));
  pointer-events: none;
}

.time, .score {
  color: var(--blue);
  font-weight: 300;
  font-size: clamp(32px, 5.4vw, 56px);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.time .total {
  font-size: 0.36em;
  color: #86b9cf;
  margin-left: 1px;
}
.score .label {
  font-size: 0.36em;
  color: var(--label);
  margin-right: 0.3em;
  font-weight: 400;
}

.hud-mid {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 6px;
  pointer-events: auto;
}

.badge {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--blue-deep);
  background: rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  padding: 5px 10px;
}

.icon-btn {
  width: 34px; height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  opacity: 0.7;
}
.icon-btn:hover { opacity: 1; }
.icon-btn span { width: 3px; height: 12px; border-radius: 2px; background: var(--blue); }

/* ---------- Text písně ---------- */

.lyrics {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 0 16px max(18px, 4.5vh, env(safe-area-inset-bottom));
  text-align: center;
  pointer-events: none;
}
.lyrics .line {
  white-space: pre-wrap;
  line-height: 1.3;
  min-height: 1.3em;
}
.lyrics .now { font-size: clamp(21px, 3.5vw, 36px); color: var(--text); }
.lyrics .next { font-size: clamp(19px, 3.1vw, 31px); color: #6c7277; margin-top: 2px; }

.syl.sung { color: var(--blue); }
.syl.active {
  background-image: linear-gradient(90deg, var(--blue) var(--p, 0%), var(--text) var(--p, 0%));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- Panely rytmických nástrojů ---------- */

.rhythm {
  --rp-w: 160px;
  position: absolute;
  right: max(16px, 2.2vw);
  top: 90px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}
.rhythm.row {
  left: 16px;
  right: 16px;
  flex-direction: row;
  justify-content: center;
}

.rpanel {
  width: var(--rp-w);
  padding: 9px 10px 11px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 8px 26px rgba(30, 120, 170, 0.14), 0 1px 2px rgba(30, 120, 170, 0.08);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rp-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  font-size: clamp(11px, calc(var(--rp-w) * 0.082), 14px);
  line-height: 1.2;
  padding: 0 4px;
}
.rp-name { font-weight: 500; color: #6b7a84; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-word { font-weight: 700; color: var(--blue); opacity: 0; white-space: nowrap; }
.rp-word.pop { animation: rp-pop 0.55s ease-out; }
@keyframes rp-pop {
  0% { opacity: 0; transform: scale(0.6); }
  15% { opacity: 1; transform: scale(1.18); }
  65% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; }
}

.rp-stage {
  position: relative;
  height: calc(var(--rp-w) * 0.66);
  border-radius: 16px;
  background: radial-gradient(circle at 50% 45%, #ffffff 0%, #eef8fd 75%);
  display: flex;
  align-items: center;
  justify-content: center;
}
.rhythm.row .rp-stage { height: calc(var(--rp-w) * 0.5); }
.rp-stage .ico { position: relative; height: 92%; width: auto; aspect-ratio: 1; overflow: visible; }

/* Kroužek, který se stahuje k obrázku před úderem */
.rp-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  height: 86%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 3px solid var(--blue);
  transform: translate(-50%, -50%) scale(var(--ring-s, 1.55));
  opacity: var(--ring-o, 0);
}
.rpanel.fire .rp-stage::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 16px;
  background: radial-gradient(circle, rgba(54, 201, 90, 0.38), rgba(54, 201, 90, 0) 62%);
  animation: rp-flash 0.35s ease-out forwards;
}
@keyframes rp-flash { from { opacity: 1; } to { opacity: 0; } }

/* Paličky: rozmach řídí --swing (0 = od sebe, 1 = ťuk) */
.ico .stick { transform-box: fill-box; transform-origin: 50% 94%; }
.ico .stick-l { transform: rotate(calc(-14deg + 24deg * var(--swing, 0))); }
.ico .stick-r { transform: rotate(calc(14deg - 24deg * var(--swing, 0))); }
.ico .trail { opacity: 0.55; }
.ico .burst { opacity: 0; transform-box: fill-box; transform-origin: 50% 100%; }
.rpanel.fire .ico .burst { animation: rp-burst 0.32s ease-out; }
@keyframes rp-burst {
  0% { opacity: 1; transform: scale(0.6); }
  100% { opacity: 0; transform: scale(1.4); }
}

/* Tamburína: úder nakloní, třepání rozkmitá */
.ico .tamb {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  transform: rotate(calc(-12deg * var(--swing, 0))) scale(calc(1 + 0.07 * var(--swing, 0)));
}
.ico .tamb-shaker { transform-box: fill-box; transform-origin: 50% 50%; }
.rpanel.shaking .ico .tamb-shaker { animation: rp-shake 0.08s linear infinite alternate; }
@keyframes rp-shake { from { transform: rotate(-9deg); } to { transform: rotate(9deg); } }
.ico .waves { opacity: 0; }
.rpanel.fire .ico .waves { animation: rp-waves 0.4s ease-out; }
.rpanel.shaking .ico .waves { opacity: 0.75; animation: rp-blink 0.16s linear infinite alternate; }
@keyframes rp-waves { from { opacity: 0.9; } to { opacity: 0; } }
@keyframes rp-blink { from { opacity: 0.35; } to { opacity: 0.85; } }

/* Pruh s nadcházejícími údery */
.rp-lane {
  position: relative;
  height: max(20px, calc(var(--rp-w) * 0.15));
  border-radius: 999px;
  background: #eaf5fb;
  overflow: hidden;
}
.rp-marker {
  position: absolute;
  left: 20%;
  top: 3px;
  bottom: 3px;
  width: 3px;
  margin-left: -1.5px;
  border-radius: 2px;
  background: var(--blue);
}
.cue {
  position: absolute;
  left: 0;
  top: 50%;
  will-change: transform;
}
.cue.tap {
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: #e39a4f;
  box-shadow: 0 0 0 2px #fff;
}
.rp-tamburina .cue.tap { background: #dcab3a; }
.cue.shake {
  height: 10px;
  margin-top: -5px;
  border-radius: 5px;
  background: repeating-linear-gradient(90deg, #f2c75a 0 5px, #dca533 5px 10px);
  box-shadow: 0 0 0 2px #fff;
}
.cue.past { opacity: 0.25; }

@media (prefers-reduced-motion: reduce) {
  .rpanel.shaking .ico .tamb-shaker, .rpanel.shaking .ico .waves { animation: none; }
}

/* ---------- Překryvná okna ---------- */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(236, 248, 254, 0.45);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  overflow-y: auto;
}

.card {
  width: min(560px, 100%);
  max-height: 100%;
  overflow-y: auto;
  background: var(--card);
  border-radius: 20px;
  box-shadow: 0 12px 40px rgba(30, 120, 170, 0.16), 0 1px 3px rgba(30, 120, 170, 0.08);
  padding: 26px 26px 18px;
}
.card.small { width: min(400px, 100%); }
.card.center { text-align: center; }

h1 {
  margin: 0 0 4px;
  font-weight: 300;
  font-size: 34px;
  color: var(--blue);
  letter-spacing: -0.01em;
}
.card h2 { margin: 0 0 14px; font-weight: 400; color: var(--text); font-size: 24px; }
.lead { margin: 0 0 18px; color: var(--text-soft); line-height: 1.45; }

/* ---------- Hlavička menu: velký nápis a nástroje po stranách ---------- */

.hero {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 2.4vw, 18px);
  margin: -2px 0 12px;
}
.hero + .lead { text-align: center; }
.hero-ico {
  flex: none;
  width: clamp(62px, 19vw, 108px);
  aspect-ratio: 1;
  filter: drop-shadow(0 6px 10px rgba(30, 120, 170, 0.18));
}
.hero-left { transform: rotate(-10deg); }
.hero-right { transform: rotate(10deg); }
.hero-ico .ico { display: block; width: 100%; height: 100%; overflow: visible; }

.hero-title {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  font-family: 'Fredoka', 'Roboto', system-ui, sans-serif;
  text-align: center;
}
.hero-small {
  font-weight: 600;
  font-size: clamp(14px, 4.2vw, 22px);
  letter-spacing: 0.32em;
  margin: 0 0 4px 0.32em;
  text-transform: uppercase;
  color: #6cc3e8;
}
.hero-big {
  font-weight: 700;
  font-size: clamp(40px, 12.5vw, 66px);
  letter-spacing: -0.01em;
  padding: 0 0.04em 0.08em;
  background: linear-gradient(180deg, #52c9f3 0%, #1b97cf 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 rgba(255, 255, 255, 0.95)) drop-shadow(0 6px 14px rgba(30, 150, 210, 0.25));
}

/* Paličky ťukají v tempu písně (124 dob za minutu), tamburína se pohupuje. */
.hero-ico .stick-l { animation: hero-stick-l 0.968s ease-in-out infinite; }
.hero-ico .stick-r { animation: hero-stick-r 0.968s ease-in-out infinite; }
@keyframes hero-stick-l {
  0%, 30% { transform: rotate(-14deg); }
  48%, 52% { transform: rotate(10deg); }
  72%, 100% { transform: rotate(-14deg); }
}
@keyframes hero-stick-r {
  0%, 30% { transform: rotate(14deg); }
  48%, 52% { transform: rotate(-10deg); }
  72%, 100% { transform: rotate(14deg); }
}
.hero-ico .burst { animation: hero-burst 0.968s linear infinite; }
@keyframes hero-burst {
  0%, 47% { opacity: 0; transform: scale(0.6); }
  50% { opacity: 1; transform: scale(0.8); }
  75%, 100% { opacity: 0; transform: scale(1.4); }
}
.hero-ico .tamb { animation: hero-tamb 1.936s ease-in-out infinite; }
@keyframes hero-tamb {
  0%, 100% { transform: rotate(-8deg); }
  50% { transform: rotate(8deg); }
}
.hero-ico .waves { animation: hero-waves 0.968s ease-out infinite; }
@keyframes hero-waves {
  0% { opacity: 0.8; }
  60%, 100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .hero-ico * { animation: none !important; }
}

/* ---------- Rozklikávací nastavení ---------- */

.more {
  margin-top: 16px;
  border-radius: 14px;
  background: #f3f9fc;
}
.more > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  padding: 12px 16px;
  border-radius: 14px;
  font-weight: 500;
  color: var(--blue-deep);
}
.more > summary::-webkit-details-marker { display: none; }
.more > summary::before {
  content: '';
  align-self: center;
  width: 7px;
  height: 7px;
  margin: 0 2px 0 2px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s;
}
.more[open] > summary::before { transform: rotate(45deg); }
.more > summary small { font-size: 13px; font-weight: 400; color: var(--text-soft); }
.more > summary:focus-visible { outline: 2px solid var(--blue-deep); outline-offset: 2px; }
.more > .grid { padding: 2px 16px 0; }
.more > .checks { padding: 0 16px 16px; }
.more select { background: #fff; }

.sec {
  margin: 18px 0 8px !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--label) !important;
}

.songs { display: grid; gap: 8px; }
.song {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 14px;
  padding: 13px 16px;
  background: #f3f9fc;
  font: inherit;
  color: inherit;
  cursor: pointer;
  box-shadow: inset 0 0 0 1.5px transparent;
  transition: box-shadow 0.15s, background 0.15s;
}
.song:hover { background: #eaf6fc; }
.song.selected { background: #e6f5fc; box-shadow: inset 0 0 0 1.5px var(--blue); }
.song-title { font-size: 18px; color: #42484d; }
.song-meta { font-size: 13px; color: var(--text-soft); }

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
}
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--text-soft); }
.field output { color: var(--blue-deep); margin-left: 4px; }
select {
  font: inherit;
  font-size: 15px;
  color: #42484d;
  padding: 9px 10px;
  border-radius: 10px;
  border: 0;
  background: #f3f9fc;
  box-shadow: inset 0 0 0 1px #d6e6ee;
}
input[type="range"] { width: 100%; accent-color: var(--blue); margin: 8px 0 0; }

.checks { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-top: 14px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--blue); }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
  align-items: center;
}
.card.center .actions, .card.small .actions { justify-content: center; }

.btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 24px;
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  color: #fff;
  background: linear-gradient(180deg, #45c0ee, #26a6da);
  box-shadow: 0 4px 12px rgba(38, 166, 218, 0.3);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
}
.btn:hover { box-shadow: 0 6px 16px rgba(38, 166, 218, 0.38); }
.btn:active { transform: translateY(1px); }
.btn.secondary {
  background: #fff;
  color: var(--blue-deep);
  box-shadow: inset 0 0 0 1.5px var(--blue);
}
.btn.link {
  background: none;
  box-shadow: none;
  color: var(--blue-deep);
  padding-left: 10px;
  padding-right: 10px;
}
.btn:focus-visible, .song:focus-visible, select:focus-visible, .icon-btn:focus-visible {
  outline: 2px solid var(--blue-deep);
  outline-offset: 2px;
}

.msg { min-height: 1em; margin: 12px 0 0; color: #d4483a; font-size: 14px; }
.msg:empty { margin: 0; min-height: 0; }

/* ---------- Ladička ---------- */

.tuner {
  margin-top: 16px;
  padding: 14px 16px 16px;
  border-radius: 14px;
  background: #f3f9fc;
}
.tuner-top { display: flex; align-items: baseline; gap: 14px; }
.tuner-note { font-size: 34px; font-weight: 300; color: var(--blue); min-width: 70px; }
.tuner-info { font-size: 14px; color: var(--text-soft); font-variant-numeric: tabular-nums; white-space: pre; }
.tuner-scale {
  position: relative;
  height: 14px;
  margin-top: 10px;
  border-radius: 7px;
  background: linear-gradient(90deg, #ffe0d6, #f7f7c8 30%, #d8f5d8 45%, #d8f5d8 55%, #f7f7c8 70%, #ffe0d6);
}
.tuner-scale .tick { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: #8fd19e; }
.tuner-needle {
  position: absolute;
  top: -4px;
  width: 6px; height: 22px;
  margin-left: -3px;
  left: 50%;
  border-radius: 3px;
  background: var(--green);
  box-shadow: 0 0 0 2px #fff;
  transition: left 0.06s linear;
}
.tuner-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-soft); margin-top: 6px; }
.level { height: 4px; border-radius: 2px; background: #dfeef5; margin-top: 10px; overflow: hidden; }
.level div { height: 100%; width: 0; background: var(--blue); transition: width 0.05s linear; }

/* ---------- Nápověda ---------- */

.help { margin-top: 18px; font-size: 14px; color: var(--text-soft); }
.help summary { cursor: pointer; color: var(--blue-deep); font-weight: 500; }
.help ul { padding-left: 18px; margin: 10px 0 0; line-height: 1.5; }
.help li { margin-bottom: 4px; }
.chip { display: inline-block; width: 14px; height: 9px; border-radius: 3px; vertical-align: middle; margin: 0 1px; }
.chip.lime { background: var(--lime); }
.chip.yellow { background: var(--yellow); }
.chip.orange { background: var(--orange); }
.chip.red { background: var(--red); }

.source { font-size: 11px; color: #a3adb3; margin: 14px 0 0; line-height: 1.4; }

/* ---------- Výsledek ---------- */

.res-song { margin: 0 0 6px; color: var(--text-soft); font-size: 14px; }
.res-rating { color: var(--blue) !important; font-weight: 300 !important; font-size: 30px !important; }
.res-score { font-size: 64px; font-weight: 300; color: var(--blue); line-height: 1; font-variant-numeric: tabular-nums; }
.res-score .label { display: block; font-size: 13px; color: var(--label); font-weight: 400; margin-bottom: 4px; }
.res-stats { display: flex; justify-content: center; gap: 36px; margin-top: 18px; }
.res-stats strong { display: block; font-size: 22px; font-weight: 400; color: #42484d; }
.res-stats small { font-size: 12px; color: var(--text-soft); }

@media (max-width: 480px) {
  .card { padding: 20px 18px 14px; border-radius: 18px; }
  h1 { font-size: 28px; }
  .grid { grid-template-columns: 1fr; }
  .btn { padding: 11px 20px; }
}
