/* Base & Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary-color: #3498db;
  --primary-dark: #2980b9;
  --secondary-color: #ecf0f1;
  --text-main: #2c3e50;
  --text-light: #7f8c8d;
  --bg-color: #f7f9fc;
  --accent-color: #e74c3c;

  --gold: #f1c40f;
  --silver: #bdc3c7;
  --bronze: #cd7f32;
  --none: #95a5a6;

  --correct-bg: #d4edda;
  --correct-border: #c3e6cb;
  --correct-text: #155724;
  --wrong-bg: #f8d7da;
  --wrong-border: #f5c6cb;
  --wrong-text: #721c24;

  --timer-color: #2ecc71;
  --timer-warning: #f39c12;
  --timer-danger: #e74c3c;
}

body {
  font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.6;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

#app {
  width: 100%;
  max-width: 600px;
  /* モバイルファースト、PCでも中央表示で見やすい最大幅 */
  height: 100vh;
  max-height: 850px;
  background: #ffffff;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

@media (min-width: 601px) {
  #app {
    height: 90vh;
    border-radius: 12px;
  }
}

/* Screen Management */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  overflow-y: auto;
}

.screen.active {
  opacity: 1;
  visibility: visible;
  z-index: 10;
}

.content-wrapper {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

/* Typography & specific elements */
.mt-2 {
  margin-top: 10px;
}

.mt-3 {
  margin-top: 15px;
}

.mt-4 {
  margin-top: 20px;
}

h1,
h2,
h3 {
  margin-bottom: 15px;
}

/* Buttons */
.btn {
  display: block;
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.1s, filter 0.2s, background-color 0.2s;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.1);
}

.btn:active {
  transform: translateY(4px);
  box-shadow: none;
}

.primary-btn {
  background-color: var(--primary-color);
  color: white;
  box-shadow: 0 4px 0 var(--primary-dark);
}

.primary-btn:hover {
  background-color: var(--primary-dark);
}

.primary-btn:active {
  box-shadow: none;
}

.secondary-btn {
  background-color: var(--secondary-color);
  color: var(--text-main);
  box-shadow: 0 4px 0 #bdc3c7;
}

.secondary-btn:hover {
  filter: brightness(0.95);
}

.secondary-btn:active {
  box-shadow: none;
}

/* Title Screen */
.title {
  font-size: 32px;
  color: var(--primary-color);
  margin-bottom: 10px;
  line-height: 1.2;
}

.subtitle {
  font-size: 20px;
  color: var(--gold);
}

.description {
  margin-bottom: 30px;
  font-size: 14px;
  color: var(--text-light);
}

/* Difficulty Screen */
.difficulty-buttons {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 20px;
}

.diff-btn {
  background-color: white;
  border: 2px solid var(--primary-color);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
  box-shadow: 0 4px 0 var(--primary-color);
}

.diff-title {
  font-size: 18px;
  color: var(--primary-dark);
}

.diff-desc {
  font-size: 12px;
  color: var(--text-light);
  font-weight: normal;
  margin-top: 5px;
}

/* Quiz Screen */
.quiz-header {
  margin-bottom: 20px;
}

.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  font-weight: bold;
}

.badge {
  background-color: var(--primary-color);
  color: white;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
}

.timer-container {
  width: 100%;
  height: 8px;
  background-color: var(--secondary-color);
  border-radius: 4px;
  overflow: hidden;
}

.timer-bar {
  height: 100%;
  width: 100%;
  background-color: var(--timer-color);
  transition: width 0.1s linear, background-color 0.3s;
}

.question-container {
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 25px;
  padding: 15px;
  background: var(--bg-color);
  border-radius: 8px;
  border-left: 5px solid var(--primary-color);
}

.question-container h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.5;
}

.options-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-btn {
  background-color: white;
  border: 2px solid var(--secondary-color);
  color: var(--text-main);
  text-align: left;
  padding: 15px 20px;
  box-shadow: 0 4px 0 var(--secondary-color);
  font-weight: normal;
}

/* Answer Feedback States */
.option-btn.correct {
  background-color: var(--correct-bg);
  border-color: var(--correct-border);
  color: var(--correct-text);
  box-shadow: 0 4px 0 var(--correct-border);
  font-weight: bold;
}

.option-btn.wrong {
  background-color: var(--wrong-bg);
  border-color: var(--wrong-border);
  color: var(--wrong-text);
  box-shadow: 0 4px 0 var(--wrong-border);
}

.option-btn:disabled {
  cursor: not-allowed;
  opacity: 0.8;
}

/* Result Screen */
.medal-container {
  margin: 20px 0;
}

.medal {
  width: 120px;
  height: 120px;
  margin: 0 auto 10px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.5), 0 5px 15px rgba(0, 0, 0, 0.2);
  position: relative;
}

.medal::after {
  content: "★";
  font-size: 50px;
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.gold-medal {
  background: radial-gradient(ellipse at top left, #f1c40f, #d35400);
}

.silver-medal {
  background: radial-gradient(ellipse at top left, #bdc3c7, #7f8c8d);
}

.bronze-medal {
  background: radial-gradient(ellipse at top left, #cd7f32, #8e44ad);
}

.none-medal {
  background: var(--none);
  box-shadow: none;
}

.none-medal::after {
  content: "×";
}

.score-board {
  width: 100%;
  background: var(--bg-color);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 25px;
}

.score-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 14px;
}

.total-score {
  font-size: 24px;
  font-weight: bold;
  color: var(--primary-color);
  border-bottom: 2px solid var(--secondary-color);
  padding-bottom: 10px;
  margin-bottom: 15px;
}

.action-buttons {
  width: 100%;
}