/* --- Shared screen parts --- */

.screen-title {
  margin: 0;
  font: 800 clamp(24px, 6vw, 34px)/1.1 'Nunito', system-ui, sans-serif;
  color: var(--ink);
}

.clay-button.small {
  min-height: 52px;
  padding: 8px 18px;
  font-size: 18px;
  border-radius: 18px;
}

.button-row,
.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  align-items: center;
}

.clay-button.choice {
  background: var(--cream);
  color: var(--ink);
  text-shadow: none;
  box-shadow: inset 0 -6px 0 #eadfd2, 0 6px 14px var(--shadow);
  font-size: 20px;
}

.clay-button.choice.selected {
  background: var(--mint);
  color: #fff;
  box-shadow: inset 0 -6px 0 var(--mint-deep), 0 6px 14px var(--shadow);
}

.clay-button.choice.locked {
  opacity: 0.55;
}

.card-top {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
}

.card-top.wide {
  max-width: 720px;
}

.note {
  font-size: 15px;
  color: var(--ink-soft);
  text-align: center;
}

/* --- HUD --- */

.hud {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none !important;
  visibility: hidden;
}

.hud.visible {
  visibility: visible;
}

.hud * {
  pointer-events: none;
}

.hud .top-bar-cluster {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  pointer-events: auto;
}

.hud .top-bar--kubopad .top-bar-cluster {
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  width: var(--tap);
}

.hud .top-bar-cluster > * {
  pointer-events: auto;
}

.top-bar-actions {
  display: flex;
  gap: 10px;
  margin-left: auto;
  pointer-events: auto;
}

.hud-balance-corner {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.hud-balance-corner.visible {
  opacity: 1;
  visibility: visible;
}

.hud-star-balance {
  padding: 8px 16px;
  border-radius: 18px;
  background: var(--sun);
  box-shadow: inset 0 -5px 0 var(--sun-deep);
  font: 800 clamp(18px, 4.5vw, 22px)/1 'Nunito', system-ui, sans-serif;
  color: var(--ink);
}

.note-balance {
  padding: 10px 16px;
  border-radius: 18px;
  background: var(--cream);
  box-shadow: 0 6px 16px var(--shadow);
  font: 800 clamp(16px, 4vw, 20px)/1.2 'Nunito', system-ui, sans-serif;
  color: var(--ink);
}

.note-gain-pop {
  position: absolute;
  top: calc(108px + var(--safe-top));
  right: calc(20px + var(--safe-right));
  font: 800 clamp(18px, 4.5vw, 24px)/1 'Nunito', system-ui, sans-serif;
  color: var(--sun-deep);
  text-shadow: 0 2px 0 #fff;
  animation: note-gain-rise 0.55s ease-out forwards;
  pointer-events: none;
}

@keyframes note-gain-rise {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-28px) scale(1.08);
  }
}

.pause-banner {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 16px 28px;
  border-radius: 24px;
  background: var(--cream);
  box-shadow: 0 10px 28px var(--shadow);
  font: 800 clamp(22px, 5vw, 32px)/1.2 'Nunito', system-ui, sans-serif;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.pause-banner.visible {
  opacity: 1;
  visibility: visible;
}

.subtitle {
  position: absolute;
  left: 50%;
  bottom: 4.2%;
  max-width: min(88vw, 620px);
  transform: translate(-50%, calc(50% + 20px));
  padding: 12px 20px;
  border-radius: 22px;
  background: var(--cream);
  box-shadow: 0 8px 20px var(--shadow);
  font-size: clamp(17px, 4.2vw, 22px);
  text-align: center;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.subtitle.visible {
  opacity: 1;
  transform: translate(-50%, 50%);
}

@media (pointer: coarse) {
  .subtitle {
    width: min(calc(100vw - 16px), 720px);
    max-width: none;
    padding: 10px 14px;
    line-height: 1.25;
  }
}

.notyk-hero-tag {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, calc(-100% - 8px));
  padding: 8px 16px;
  border-radius: 18px;
  background: var(--cream);
  box-shadow: 0 6px 16px var(--shadow);
  font: 800 clamp(15px, 3.8vw, 20px)/1.15 'Nunito', system-ui, sans-serif;
  color: var(--ink);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.notyk-hero-tag.visible {
  opacity: 1;
  visibility: visible;
}

.hit-label {
  position: absolute;
  bottom: 30%;
  transform: translateX(-50%);
  font: 800 28px/1 'Nunito', system-ui, sans-serif;
  color: #fff;
  text-shadow: 0 3px 0 var(--coral-deep), 0 6px 12px var(--shadow);
  animation: hit-rise 0.65s ease-out forwards;
}

.hit-label.good {
  text-shadow: 0 3px 0 var(--sky-deep), 0 6px 12px var(--shadow);
}

@keyframes hit-rise {
  from { opacity: 1; transform: translate(-50%, 0) scale(0.7); }
  30% { transform: translate(-50%, -12px) scale(1.15); }
  to { opacity: 0; transform: translate(-50%, -60px) scale(1); }
}

.countdown {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%);
  font: 800 120px/1 'Nunito', system-ui, sans-serif;
  color: #fff;
  text-shadow: 0 6px 0 var(--lilac-deep), 0 10px 24px var(--shadow);
  opacity: 0;
}

.countdown.visible {
  opacity: 1;
}

.countdown.pop {
  animation: count-pop 0.8s ease-out;
}

@keyframes count-pop {
  from { transform: translate(-50%, -50%) scale(1.6); opacity: 0; }
  30% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  to { transform: translate(-50%, -50%) scale(0.9); opacity: 0.2; }
}

/* --- Map --- */

.map-screen {
  justify-content: flex-start;
  gap: 12px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.map-header {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 900px;
  flex-shrink: 0;
}

.map-header .screen-title {
  flex: 1;
}

.star-count {
  padding: 8px 16px;
  border-radius: 18px;
  background: var(--sun);
  box-shadow: inset 0 -5px 0 var(--sun-deep);
  font: 800 22px/1 'Nunito', system-ui, sans-serif;
}

.map-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: auto;
  gap: 14px;
  width: 100%;
  max-width: 900px;
  flex: none;
  padding-bottom: calc(12px + var(--safe-bottom));
}

@media (max-aspect-ratio: 1/1) {
  .map-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .map-screen {
    gap: 10px;
  }

  .world-card {
    padding: 10px 8px;
    border-radius: 22px;
    gap: 6px;
  }

  .world-number {
    font-size: 28px;
  }

  .world-name {
    font-size: clamp(13px, 3.2vw, 17px);
  }

  .clay-button.level-button {
    min-width: 52px;
    min-height: 48px;
    padding: 4px 8px;
    font-size: 16px;
  }

  .map-header .star-count {
    padding: 6px 12px;
    font-size: 18px;
  }

  .hud:has(.top-bar--kubopad) .note-balance,
  .hud:has(.top-bar--level) .note-balance {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
  }

  .hud:has(.top-bar--kubopad) .hud-balance-corner,
  .hud:has(.top-bar--level) .hud-balance-corner {
    gap: 0;
  }

  .hud:has(.top-bar--kubopad) .note-gain-pop,
  .hud:has(.top-bar--level) .note-gain-pop {
    top: calc(56px + var(--safe-top));
    left: 50%;
    right: auto;
    transform: translateX(-50%);
  }
}

.world-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border-radius: 26px;
  color: #fff;
  box-shadow: inset 0 -8px 0 rgba(0, 0, 0, 0.12), 0 10px 20px var(--shadow);
  text-align: center;
}

.world-card.coral { background: var(--coral); }
.world-card.sun { background: var(--sun); color: var(--ink); }
.world-card.lilac { background: var(--lilac); }
.world-card.sky { background: var(--sky); }
.world-card.mint { background: var(--mint); }
.world-card.kubopad-card { background: linear-gradient(135deg, var(--lilac), var(--sky)); }

.top-mark {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 5px 8px;
  border-radius: 12px;
  background: var(--sun);
  color: var(--ink);
  font: 800 13px/1 'Nunito', system-ui, sans-serif;
  box-shadow: inset 0 -3px 0 var(--sun-deep);
}

.world-card.locked {
  filter: grayscale(0.55) opacity(0.7);
}

.world-number {
  font: 800 34px/1 'Nunito', system-ui, sans-serif;
}

.world-name {
  font: 800 clamp(15px, 3.4vw, 20px)/1.15 'Nunito', system-ui, sans-serif;
}

.world-card .lock svg {
  width: 30px;
  height: 30px;
}

.level-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.clay-button.level-button {
  min-width: 64px;
  min-height: 56px;
  padding: 6px 12px;
  font-size: 18px;
  background: var(--cream);
  color: var(--ink);
  text-shadow: none;
  box-shadow: inset 0 -6px 0 #eadfd2, 0 6px 12px var(--shadow);
}

.clay-button.level-button.done {
  background: #fff6d6;
}

/* --- Results --- */

.result-stars {
  display: flex;
  gap: 14px;
}

.result-star {
  font-size: clamp(60px, 16vw, 96px);
  line-height: 1;
  color: rgba(59, 47, 74, 0.15);
  transition: transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1), color 0.2s ease;
  transform: scale(0.8);
}

.result-star.earned {
  color: var(--sun);
  text-shadow: 0 4px 0 var(--sun-deep), 0 8px 20px var(--shadow);
  transform: scale(1.1);
}

/* --- Settings and credits --- */

.settings-screen {
  justify-content: flex-start;
  overflow: hidden;
}

.settings-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: min(92vw, 520px);
  max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 28px);
  margin-top: 4px;
  overflow: hidden;
  border-radius: 30px;
  background: var(--cream);
  box-shadow: 0 14px 34px var(--shadow);
}

.settings-card-head {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 20px 20px 10px;
}

.settings-card-head .card-top {
  width: 100%;
}

.settings-scroll {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 4px 20px 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--coral) rgba(59, 47, 74, 0.12);
}

.settings-scroll::-webkit-scrollbar {
  width: 10px;
}

.settings-scroll::-webkit-scrollbar-track {
  margin: 6px 0;
  border-radius: 999px;
  background: rgba(59, 47, 74, 0.08);
}

.settings-scroll::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: var(--coral);
  border: 2px solid var(--cream);
}

.settings-scroll-hint {
  flex-shrink: 0;
  padding: 10px 16px 18px;
  text-align: center;
  font: 800 clamp(14px, 3.6vw, 16px)/1.3 'Nunito', system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(to bottom, rgba(255, 248, 239, 0), var(--cream) 45%);
  transition: opacity 0.25s ease, max-height 0.25s ease, padding 0.25s ease;
  max-height: 56px;
}

.settings-scroll-hint.hidden {
  opacity: 0;
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
  pointer-events: none;
}

.setting-label {
  align-self: flex-start;
  font-weight: 800;
}

.slider-row {
  display: grid;
  grid-template-columns: 8.5em 1fr;
  align-items: center;
  gap: 12px;
  width: 100%;
  font-weight: 800;
}

.slider-row input[type='range'] {
  width: 100%;
  height: 44px;
  accent-color: var(--coral);
  touch-action: pan-x;
}

.hold-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.credits-authors {
  margin: 0;
  font: 800 22px/1.3 'Nunito', system-ui, sans-serif;
  text-align: center;
}

a.clay-button {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

/* --- Kubopad select --- */

.kubopad-select {
  justify-content: flex-start;
  overflow: hidden;
}

.kubopad-select-panel {
  display: flex;
  flex-direction: column;
  width: min(92vw, 720px);
  max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 24px);
  overflow: hidden;
  border-radius: 30px;
  background: rgba(255, 248, 239, 0.92);
  box-shadow: 0 14px 34px var(--shadow);
}

.kubopad-select-head {
  flex-shrink: 0;
  padding: 16px 16px 8px;
}

.kubopad-select-head .clay-button.big {
  width: 100%;
  margin-top: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.kubopad-select-head .button-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: none;
}

.kubopad-select-head .button-icon svg {
  width: 100%;
  height: 100%;
}

.kubopad-select-scroll {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 4px 16px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--coral) rgba(59, 47, 74, 0.12);
}

.kubopad-select-scroll::-webkit-scrollbar {
  width: 10px;
}

.kubopad-select-scroll::-webkit-scrollbar-track {
  margin: 6px 0;
  border-radius: 999px;
  background: rgba(59, 47, 74, 0.08);
}

.kubopad-select-scroll::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: var(--coral);
  border: 2px solid rgba(255, 248, 239, 0.92);
}

.kubopad-select-scroll-hint {
  flex-shrink: 0;
  padding: 10px 16px 16px;
  text-align: center;
  font: 800 clamp(14px, 3.6vw, 16px)/1.3 'Nunito', system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(to bottom, rgba(255, 248, 239, 0), rgba(255, 248, 239, 0.92) 45%);
  transition: opacity 0.25s ease, max-height 0.25s ease, padding 0.25s ease;
  max-height: 56px;
}

.kubopad-select-scroll-hint.hidden {
  opacity: 0;
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
  pointer-events: none;
}

.kubopad-mode-label {
  margin: 0;
  width: min(92vw, 520px);
  max-width: 100%;
  text-align: center;
  font: 800 clamp(15px, 3.6vw, 18px)/1.2 'Nunito', system-ui, sans-serif;
  color: var(--ink);
}

.song-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 720px;
}

.clay-button.song-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 64px;
  padding: 8px 14px;
  border-radius: 18px;
  font-size: 16px;
  text-align: left;
}

.song-row-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
}

.song-row-title {
  font-size: 17px;
  line-height: 1.15;
}

.song-row-style,
.song-row-time {
  font-size: 13px;
  font-weight: 700;
  opacity: 0.85;
}

.song-row-time {
  font-variant-numeric: tabular-nums;
}

.song-row-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.song-mark {
  font-size: 22px;
  line-height: 1;
}

.song-row.color-0 { background: var(--coral); }
.song-row.color-1 { background: var(--sky); box-shadow: inset 0 -6px 0 var(--sky-deep), 0 6px 14px var(--shadow); }
.song-row.color-2 { background: var(--lilac); box-shadow: inset 0 -6px 0 var(--lilac-deep), 0 6px 14px var(--shadow); }
.song-row.color-3 { background: var(--mint); box-shadow: inset 0 -6px 0 var(--mint-deep), 0 6px 14px var(--shadow); }
.song-row.color-4 { background: var(--sun); color: var(--ink); box-shadow: inset 0 -6px 0 var(--sun-deep), 0 6px 14px var(--shadow); }

.song-row.playing {
  outline: 4px solid var(--ink);
  outline-offset: 2px;
}

.song-row.paused {
  outline-style: dashed;
}

.city-transport-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.clay-button.city-transport {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 64px;
  min-height: 68px;
  padding: 6px 8px;
  font-size: 13px;
}

.city-transport-icon {
  display: flex;
  width: 28px;
  height: 28px;
}

.city-transport-icon svg {
  width: 28px;
  height: 28px;
}

.clay-button.city-transport:disabled {
  opacity: 0.4;
}

.city-timeline {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.city-time {
  min-width: 2.6em;
  font: 800 14px/1 'Nunito', system-ui, sans-serif;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.city-time:last-child {
  text-align: right;
}

.city-timeline-range {
  width: 100%;
  height: 28px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
  touch-action: none;
}

.city-timeline-range:disabled {
  opacity: 0.4;
  cursor: default;
}

.city-timeline-range::-webkit-slider-runnable-track {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--ink) var(--city-progress, 0%), rgba(59, 47, 74, 0.18) var(--city-progress, 0%));
}

.city-timeline-range::-webkit-slider-thumb {
  appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -6px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
}

.city-timeline-range::-moz-range-track {
  height: 10px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--ink) var(--city-progress, 0%), rgba(59, 47, 74, 0.18) var(--city-progress, 0%));
}

.city-timeline-range::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
}

.song-cover {
  font-size: 44px;
  line-height: 1;
}

.song-stars {
  min-height: 1em;
  color: #fff6c2;
}
