:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color-scheme: light dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: radial-gradient(circle at 15% 0%, rgba(103, 80, 164, 0.13), transparent 28rem), var(--mdui-color-surface, #fffbfe);
  color: var(--mdui-color-on-surface, #1d1b20);
}

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 72px;
}

.hero-card,
.detail-hero {
  display: block;
  overflow: hidden;
  --shape-corner: 28px;
}

.hero-content {
  padding: clamp(28px, 6vw, 72px);
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  opacity: 0.7;
}

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

h1 {
  max-width: 800px;
  margin-bottom: 16px;
  font-size: clamp(2rem, 5vw, 4.2rem);
  line-height: 1.02;
  letter-spacing: -0.045em;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.5rem, 3vw, 2.2rem);
}

.hero-copy {
  max-width: 760px;
  margin-bottom: 28px;
  font-size: 1.02rem;
  line-height: 1.7;
  opacity: 0.78;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.search-row mdui-button {
  min-height: 56px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin: 46px 4px 20px;
}

.muted {
  margin-bottom: 0;
  opacity: 0.66;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.beatmap-card {
  display: block;
  overflow: hidden;
  min-width: 0;
  --shape-corner: 22px;
}

.beatmap-cover {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 8.5;
  object-fit: cover;
  background: rgba(127, 127, 127, 0.16);
}

.beatmap-cover.cover-missing {
  visibility: hidden;
}

.beatmap-card-body {
  padding: 18px 18px 20px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 14px;
}

.beatmap-title {
  margin-bottom: 6px;
  overflow-wrap: anywhere;
  font-size: 1.16rem;
  line-height: 1.35;
}

.beatmap-artist {
  margin-bottom: 8px;
  font-weight: 600;
}

.beatmap-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 18px;
  font-size: 0.82rem;
  opacity: 0.68;
}

.state-panel,
.state-card-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 150px;
}

.prepare-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  min-height: min(520px, calc(100vh - 104px));
  padding: clamp(32px, 8vw, 96px);
  text-align: left;
  --shape-corner: 28px;
}

.prepare-card mdui-circular-progress {
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
}

.prepare-card h1 {
  margin-bottom: 14px;
}

.state-card {
  display: block;
  --shape-corner: 22px;
}

.state-card-content {
  flex-direction: column;
  padding: 24px;
  text-align: center;
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  padding-top: 28px;
}

.hidden {
  display: none !important;
}

.detail-hero {
  display: grid;
  grid-template-columns: minmax(260px, 40%) 1fr;
}

.detail-cover {
  width: 100%;
  height: 100%;
  min-height: 390px;
  object-fit: cover;
  background: rgba(127, 127, 127, 0.16);
}

.detail-copy {
  padding: clamp(26px, 5vw, 52px);
}

.detail-copy h1 {
  margin-bottom: 10px;
  font-size: clamp(2rem, 4vw, 3.5rem);
}

.detail-artist {
  margin-bottom: 8px;
  font-size: 1.25rem;
  font-weight: 700;
}

.preview-player {
  display: grid;
  gap: 10px;
  margin-top: 24px;
  padding: 14px 16px 16px;
  border-radius: 18px;
  background: rgba(127, 127, 127, 0.09);
}

.preview-heading {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.9rem;
}

.preview-icon {
  font-size: 1.2rem;
  color: var(--mdui-color-primary, #6750a4);
}

.preview-player audio {
  display: block;
  width: 100%;
  height: 42px;
}

.back-to-top {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 30;
}

.stats-grid,
.difficulty-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 26px 0;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(127, 127, 127, 0.09);
}

.stat-label {
  font-size: 0.78rem;
  opacity: 0.62;
}

.stat-value {
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 1rem;
}

.difficulty-list {
  display: grid;
  gap: 14px;
}

.difficulty-card {
  display: block;
  padding: 20px;
  --shape-corner: 20px;
}

.difficulty-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
}

.difficulty-head h3 {
  margin-bottom: 5px;
  font-size: 1.15rem;
}

.difficulty-actions {
  display: flex;
  flex-shrink: 0;
  gap: 8px;
}

.difficulty-stats {
  grid-template-columns: repeat(2, minmax(0, 180px));
  margin-bottom: 0;
}

#entry-confirm-dialog {
  --shape-corner: 24px;
}

.entry-confirm-content {
  width: min(480px, calc(100vw - 72px));
}

.entry-confirm-info {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.entry-confirm-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(127, 127, 127, 0.09);
}

.entry-confirm-chart-row {
  grid-column: 1 / -1;
}

.entry-confirm-row span {
  font-size: 0.78rem;
  opacity: 0.62;
}

.entry-confirm-row strong {
  overflow-wrap: anywhere;
}

@media (max-width: 900px) {
  .results-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .detail-cover {
    min-height: 0;
    aspect-ratio: 16 / 8;
  }
}

@media (max-width: 620px) {
  .page-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 16px;
  }

  .search-row,
  .results-grid {
    grid-template-columns: 1fr;
  }

  .search-row mdui-button {
    width: 100%;
  }

  .section-heading {
    align-items: start;
    flex-direction: column;
  }

  .stats-grid,
  .difficulty-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .prepare-card {
    flex-direction: column;
    text-align: center;
  }

  .entry-confirm-content {
    width: calc(100vw - 56px);
  }

  .entry-confirm-info {
    grid-template-columns: 1fr;
  }

  .entry-confirm-chart-row {
    grid-column: auto;
  }
}
