* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", Arial, sans-serif;
  background: #f4f4f4;
  color: #333;
}

.container {
  margin: 20px auto;
  width: 95%;
  max-width: 1100px;
  background: #fff;
  padding: 24px 28px;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

/* ---------- Controls ---------- */
.controls {
  margin-bottom: 16px;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.control-row label {
  font-weight: 600;
  font-size: 14px;
}

.control-row select {
  padding: 6px 10px;
  font-size: 14px;
  border: 1px solid #bbb;
  border-radius: 5px;
  background: #fafafa;
  cursor: pointer;
}

.button-row {
  display: flex;
  gap: 10px;
}

button {
  padding: 10px 28px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  border-radius: 6px;
  background: #3a6ea5;
  color: #fff;
  transition: background 0.2s;
}

button:hover {
  background: #2c5580;
}

button:active {
  background: #1f3f5e;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- Record button ---------- */
.record-btn {
  background: #c0392b;
}

.record-btn:hover {
  background: #a93226;
}

.record-btn:active {
  background: #922b21;
}

/* ---------- Play button ---------- */
.play-btn {
  background: #27ae60;
}

.play-btn:hover {
  background: #219150;
}

.play-btn:active {
  background: #1a7a42;
}

/* ---------- Share button ---------- */
.share-btn {
  background: #8e44ad;
}

.share-btn:hover {
  background: #7d3c98;
}

.share-btn:active {
  background: #6c3483;
}

/* ---------- Share Recording button ---------- */
.share-recording-btn {
  background: #2c3e50;
}

.share-recording-btn:hover {
  background: #1a252f;
}

.share-recording-btn:active {
  background: #141d26;
}

/* ---------- Daily banner ---------- */
.daily-banner {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  color: #8e44ad;
  padding: 6px 0;
}

/* ---------- Status display ---------- */
.status {
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  color: #c0392b;
  min-height: 30px;
  margin-bottom: 6px;
}

/* ---------- Notation area ---------- */
#notation {
  margin-top: 8px;
  min-height: 200px;
}

#notation svg {
  width: 100%;
  height: auto;
}

/* ---------- Score display ---------- */
.score-display {
  margin-top: 20px;
  text-align: center;
}

.score-card {
  display: inline-block;
  padding: 20px 40px;
  border-radius: 12px;
  color: #fff;
}

.score-pct {
  font-size: 48px;
  font-weight: 800;
  line-height: 1.1;
}

.score-grade {
  font-size: 22px;
  font-weight: 600;
  margin-top: 4px;
}

.score-detail {
  font-size: 14px;
  margin-top: 6px;
  opacity: 0.9;
}

.grade-s { background: #ffd000; color: #333; }
.grade-dnf { background: #777; color: #fff; }
.grade-a { background: #27ae60; }
.grade-b { background: #2980b9; }
.grade-c { background: #e8a317; }
.grade-d { background: #c0392b; }

/* ---------- Attempts bar ---------- */
.attempts-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 8px 12px;
  background: #f0f0f0;
  border-radius: 8px;
}

.attempts-label {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}

.attempt-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.attempt-btn {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  border: 2px solid #3a6ea5;
  border-radius: 5px;
  background: #fff;
  color: #3a6ea5;
  cursor: pointer;
  transition: all 0.15s;
}

.attempt-btn:hover {
  background: #e8f0fa;
}

.attempt-btn.active {
  background: #3a6ea5;
  color: #fff;
}

.attempt-btn .attempt-score {
  font-size: 11px;
  opacity: 0.8;
  margin-left: 4px;
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  .container {
    padding: 14px;
  }

  .control-row {
    align-items: center;
  }

  button {
    width: 100%;
  }

  .score-pct {
    font-size: 36px;
  }
}

/* ---------- Daily Challenge button ---------- */
.daily-challenge-btn {
  background: #8e44ad;
  font-size: 14px;
  padding: 6px 14px;
  white-space: nowrap;
}

.daily-challenge-btn:hover {
  background: #7d3c98;
}

.daily-challenge-btn:active {
  background: #6c3483;
}

/* ---------- History button ---------- */
.history-btn {
  background: #e67e22;
  font-size: 14px;
  padding: 10px 16px;
}

.history-btn:hover {
  background: #cf6d17;
}

.history-btn:active {
  background: #b35f14;
}

/* ---------- Modal overlay ---------- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: #fff;
  border-radius: 12px;
  padding: 30px;
  max-width: 520px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  font-size: 28px;
  color: #888;
  cursor: pointer;
  padding: 0 6px;
  line-height: 1;
}

.modal-close:hover {
  color: #333;
  background: none;
}

/* ---------- History content ---------- */
.history-title {
  font-size: 22px;
  margin-bottom: 6px;
  color: #333;
}

.history-total {
  font-size: 15px;
  color: #555;
  margin-bottom: 18px;
}

.history-chart {
  margin-bottom: 22px;
}

.history-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.history-label {
  font-size: 13px;
  font-weight: 600;
  width: 110px;
  text-align: right;
  flex-shrink: 0;
}

.history-bar-bg {
  flex: 1;
  height: 22px;
  background: #eee;
  border-radius: 4px;
  overflow: hidden;
}

.history-bar {
  height: 100%;
  border-radius: 4px;
  min-width: 2px;
  transition: width 0.3s;
}

.history-count {
  font-size: 14px;
  font-weight: 700;
  width: 30px;
  text-align: left;
  color: #333;
}

.history-subtitle {
  font-size: 16px;
  color: #555;
  margin-bottom: 10px;
  border-top: 1px solid #eee;
  padding-top: 14px;
}

.history-recent {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #f8f8f8;
  border-radius: 6px;
  font-size: 13px;
}

.history-entry-score {
  font-weight: 700;
  font-size: 15px;
  width: 48px;
  flex-shrink: 0;
}

.history-entry-detail {
  flex: 1;
  color: #555;
}

.history-entry-seed {
  color: #888;
  font-size: 12px;
}

.history-entry-date {
  color: #aaa;
  font-size: 12px;
  flex-shrink: 0;
}

/* ---------- Mode Selection Overlay ---------- */
.mode-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.mode-select-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px 48px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
  max-width: 520px;
  width: 90%;
}

.mode-select-card h1 {
  font-size: 24px;
  margin-bottom: 6px;
  color: #333;
}

.mode-subtitle {
  font-size: 14px;
  color: #888;
  margin-bottom: 28px;
}

.mode-buttons {
  display: flex;
  gap: 16px;
  justify-content: center;
}

.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 24px 32px;
  min-width: 180px;
  border: 2px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s, box-shadow 0.15s;
}

.mode-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}

.mode-btn .mode-name {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
}

.mode-btn .mode-desc {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
}

.practice-mode-btn {
  background: #27ae60;
}

.practice-mode-btn:hover {
  background: #219150;
}

.challenge-mode-btn {
  background: #2b4ec0;
}

.challenge-mode-btn:hover {
  background: #243a8a;
}

/* ---------- Mode Label ---------- */
.mode-label {
  font-size: 13px;
  font-weight: 600;
  color: #888;
  white-space: nowrap;
}

/* ---------- Play button active (red when Stop shown) ---------- */
.play-btn.playing {
  background: #c0392b;
}

.play-btn.playing:hover {
  background: #a93226;
}

.play-btn.playing:active {
  background: #922b21;
}

/* ---------- Hide challenge-only elements in practice mode ---------- */
body[data-mode="practice"] .challenge-only {
  display: none !important;
}

/* ---------- Mode Switch Button ---------- */
.mode-switch-container {
  display: flex;
  justify-content: center;
  margin: 20px 0 10px;
}

.mode-switch-btn {
  padding: 10px 28px;
  font-size: 15px;
  font-weight: 600;
  border: 2px solid #888;
  border-radius: 8px;
  background: #f5f5f5;
  color: #333;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-switch-btn.active-practice {
  background: #27ae60;
  border-color: #27ae60;
  color: #fff;
}

.mode-switch-btn.active-practice:hover {
  background: #219150;
  border-color: #219150;
}

.mode-switch-btn.active-challenge {
  background: #2b4ec0;
  border-color: #2b4ec0;
  color: #fff;
}

.mode-switch-btn.active-challenge:hover {
  background: #243a8a;
  border-color: #243a8a;
}

.mode-switch-btn:hover {
  background: #e0e0e0;
  border-color: #555;
}

.mode-switch-btn:active {
  transform: scale(0.97);
}

@media (max-width: 600px) {
  .mode-buttons {
    flex-direction: column;
  }

  .mode-btn {
    min-width: unset;
    width: 100%;
  }
}
