* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  background: #ffffff;
  min-height: 100vh;
  color: #1a202c;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 1.5rem 1rem;
}

.app {
  width: 100%;
  max-width: 680px;
}

.header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #1a202c;
}

.title ruby rt {
  font-size: 0.45em;
  font-weight: 600;
  letter-spacing: 0;
}

.subtitle {
  margin-top: 0.6rem;
  color: #718096;
  font-size: 0.92rem;
  line-height: 1.5;
}

.panel {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 1.25rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.panel.hidden {
  display: none;
}

.panel-title {
  text-align: center;
  font-size: 1.2rem;
  margin-bottom: 1rem;
  color: #2d3748;
}

.course-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.btn {
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-course {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  padding: 1rem 1.25rem;
  text-align: left;
  color: #fff;
}

.btn-course:hover {
  transform: translateY(-2px);
}

.course-name {
  font-size: 1.05rem;
  font-weight: 700;
}

.course-desc {
  font-size: 0.82rem;
  opacity: 0.9;
}

.btn-normal {
  background: linear-gradient(135deg, #4299e1, #3182ce);
}

.btn-normal:hover {
  box-shadow: 0 6px 20px rgba(66, 153, 225, 0.35);
}

.btn-hard {
  background: linear-gradient(135deg, #e53e3e, #c53030);
}

.btn-hard:hover {
  box-shadow: 0 6px 20px rgba(229, 62, 62, 0.35);
}

.btn-ranking-view {
  display: block;
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.65rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #4a5568;
  background: transparent;
  border: 1.5px solid #cbd5e0;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}

.btn-ranking-view:hover {
  background: #f7fafc;
  border-color: #a0aec0;
}

.btn-primary {
  display: block;
  width: 100%;
  margin-top: 1.25rem;
  padding: 0.85rem 1.5rem;
  font-size: 1rem;
  font-weight: 700;
  color: #1a202c;
  background: #ffffff;
  border: 2px solid #1a202c;
  border-radius: 999px;
}

.btn-primary:hover {
  background: #f7fafc;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.stat {
  background: #f7fafc;
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
  text-align: center;
  border: 1px solid #e2e8f0;
}

.stat-label {
  display: block;
  font-size: 0.7rem;
  color: #718096;
}

.stat-value {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
  margin-top: 0.15rem;
  color: #2d3748;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.stat-value-sm {
  font-size: 0.95rem;
}

.chart-section {
  margin-bottom: 1rem;
}

.chart-title {
  font-size: 0.8rem;
  color: #718096;
  margin-bottom: 0.5rem;
  letter-spacing: 0.06em;
}

.chart {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-height: 160px;
  padding: 0.75rem;
  background: #f7fafc;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}

.chart-row {
  display: grid;
  grid-template-columns: 3.2rem 1fr minmax(4rem, auto);
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.chart-row.pending .chart-bar-wrap {
  opacity: 0.35;
}

.chart-subject {
  font-weight: 600;
  text-align: right;
  color: #4a5568;
}

.chart-bar-wrap {
  position: relative;
  height: 22px;
  background: #edf2f7;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
}

.chart-bar {
  height: 100%;
  border-radius: 5px;
  transition: width 0.4s ease-out;
  min-width: 0;
}

.chart-bar.empty {
  width: 0 !important;
}

.chart-points {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #718096;
  font-size: 0.8rem;
  white-space: nowrap;
}

.chart-row.active .chart-subject {
  color: #F2BA05;
  font-weight: 800;
}

.play-area {
  position: relative;
  padding: 1.25rem 1rem 1rem;
  background: #f7fafc;
  border-radius: 14px;
  border: 2px solid #e2e8f0;
  cursor: pointer;
  user-select: none;
}

.play-area.stopped {
  cursor: default;
}

.subject-badge {
  display: inline-block;
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.85rem;
}

.bar-track {
  position: relative;
  width: 100%;
  height: 48px;
  background: #edf2f7;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #cbd5e0;
}

.bar-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0%;
  border-radius: 8px 0 0 8px;
  transition: none;
  box-shadow: inset 0 -2px 6px rgba(0, 0, 0, 0.1);
}

.bar-edge-marker {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #2d3748;
  z-index: 2;
}

.hint {
  margin-top: 0.75rem;
  text-align: center;
  font-size: 0.88rem;
  color: #718096;
}

.round-score {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: #F2BA05;
  white-space: nowrap;
}

.round-score.hidden {
  visibility: hidden;
}

.result-total {
  text-align: center;
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
  color: #4a5568;
}

.result-total strong {
  font-size: 2rem;
  color: #F2BA05;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ===== ランキング登録 ===== */
.ranking-entry {
  margin-top: 1rem;
  margin-bottom: 0.25rem;
}

.name-input-wrap {
  display: flex;
  gap: 0.5rem;
}

.name-input {
  flex: 1;
  padding: 0.6rem 0.85rem;
  font-size: 0.95rem;
  font-family: inherit;
  border: 1.5px solid #cbd5e0;
  border-radius: 10px;
  outline: none;
  color: #1a202c;
  transition: border-color 0.15s;
}

.name-input:focus {
  border-color: #4299e1;
}

.name-input:disabled {
  background: #f7fafc;
  color: #a0aec0;
}

.btn-register {
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  color: #fff;
  background: #4299e1;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.btn-register:hover {
  background: #3182ce;
}

.btn-register:disabled {
  background: #a0aec0;
  cursor: default;
}

.rank-msg {
  margin-top: 0.5rem;
  text-align: center;
  font-size: 0.92rem;
  font-weight: 700;
  color: #2d3748;
}

.rank-msg.hidden {
  display: none;
}

/* ===== ランキング画面 ===== */
.ranking-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.ranking-tab {
  flex: 1;
  padding: 0.55rem;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  color: #718096;
  background: #f7fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.ranking-tab.active {
  color: #fff;
  background: #4299e1;
  border-color: #4299e1;
}

.ranking-list {
  min-height: 160px;
  padding: 0.5rem 0;
}

.ranking-loading,
.ranking-empty {
  text-align: center;
  color: #718096;
  font-size: 0.88rem;
  padding: 2rem 0;
}

.ranking-item {
  display: grid;
  grid-template-columns: 2.4rem 1fr auto auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.25rem;
  border-bottom: 1px solid #f0f0f0;
  font-size: 0.88rem;
}

.ranking-rank {
  font-weight: 700;
  color: #718096;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.ranking-item:nth-child(1) .ranking-rank { color: #d69e2e; font-size: 1rem; }
.ranking-item:nth-child(2) .ranking-rank { color: #718096; }
.ranking-item:nth-child(3) .ranking-rank { color: #c05621; }

.ranking-name {
  font-weight: 600;
  color: #2d3748;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-course {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  white-space: nowrap;
}

.ranking-course-normal {
  background: #ebf8ff;
  color: #3182ce;
}

.ranking-course-hard {
  background: #fff5f5;
  color: #e53e3e;
}

.ranking-score {
  font-weight: 700;
  color: #2d3748;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chart-result {
  min-height: auto;
}

/* ===== おまけコース ===== */

.btn-bonus {
  background: linear-gradient(135deg, #FF5F94, #40B3F5);
}

.btn-bonus:hover {
  box-shadow: 0 6px 20px rgba(64, 179, 245, 0.4);
}

.bonus-logo-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.bonus-logo-img {
  height: 140px;
  object-fit: contain;
}

.bonus-logo-caption {
  font-size: 0.82rem;
  color: #718096;
}

.bonus-charts-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.bonus-chart-title {
  font-size: 0.78rem;
  color: #718096;
  text-align: center;
  letter-spacing: 0.06em;
  margin-bottom: 0.4rem;
}

.bonus-chart {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.6rem;
  background: #f7fafc;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  min-height: 108px;
}

.bonus-bar-row {
  display: block;
}

.bonus-bar-wrap {
  flex: 1;
  height: 18px;
  background: #edf2f7;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
}

.bonus-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.35s ease-out;
  min-width: 0;
}

/* おまけ結果 */
.bonus-result-rows {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-bottom: 1.25rem;
}

.bonus-result-row {
  display: grid;
  grid-template-columns: 1fr 4.2rem;
  align-items: center;
  gap: 0.5rem;
}

.bonus-compare-track {
  position: relative;
  height: 30px;
  background: #edf2f7;
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
}

.bonus-result-target-bar,
.bonus-result-player-bar {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  border-radius: 6px;
  opacity: 0.5;
}

.bonus-result-pct {
  text-align: right;
  font-size: 0.92rem;
  font-weight: 700;
  color: #2d3748;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.bonus-total-score {
  text-align: center;
  font-size: 1.1rem;
  color: #4a5568;
  margin-bottom: 0.25rem;
}

.bonus-total-score.hidden {
  display: none;
}

.bonus-total-score strong {
  font-size: 2rem;
  color: #e53e3e;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 480px) {
  .title {
    font-size: 1.55rem;
  }

  .stat-value {
    font-size: 1.1rem;
  }

  .chart-row {
    grid-template-columns: 2.8rem 1fr minmax(3.6rem, auto);
    font-size: 0.78rem;
  }

  .chart-points {
    font-size: 0.72rem;
  }
}
