/* ===================================================
   リセット・基本設定
=================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-main:        #2E7D32;
  --color-main-dark:   #1B5E20;
  --color-main-light:  #A5D6A7;
  --color-main-pale:   #E8F5E9;
  --color-accent:      #AEEA00;
  --color-bg:          #F9FBF9;
  --color-text:        #212121;
  --color-text-sub:    #616161;
  --color-white:       #FFFFFF;
  --color-correct:     #388E3C;
  --color-incorrect:   #D32F2F;
  --color-border:      #C8E6C9;
  --color-disabled:    #BDBDBD;
  --radius:            10px;
  --shadow:            0 4px 20px rgba(0,0,0,0.18);
  --transition:        0.2s ease;
}

html, body {
  height: 100%;
  font-family: 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 16px;
  line-height: 1.6;
}

/* ===================================================
   ユーティリティ
=================================================== */
.hidden {
  display: none !important;
}

/* ===================================================
   画面切り替え
=================================================== */
.screen {
  width: 100%;
  min-height: 100vh;
}

/* ===================================================
   ボタン共通
=================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 22px;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: bold;
  transition: background var(--transition), transform var(--transition), opacity var(--transition);
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: var(--color-main);
  color: var(--color-white);
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-main-dark);
}

.btn-secondary {
  background: var(--color-main-pale);
  color: var(--color-main);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-main-light);
}

.btn:disabled {
  background: var(--color-disabled);
  color: var(--color-white);
  cursor: not-allowed;
  opacity: 0.6;
}

.btn-large {
  padding: 14px 40px;
  font-size: 1.1rem;
}

/* ===================================================
   スタート画面
=================================================== */
#start-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-main-pale) 0%, #DCEDC8 100%);
}

.start-card {
  background: var(--color-white);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 60px 50px;
  text-align: center;
  max-width: 480px;
  width: 90%;
  animation: fadeInUp 0.5s ease;
}

.start-logo {
  font-size: 4rem;
  margin-bottom: 16px;
}

.start-title {
  font-size: 2rem;
  font-weight: bold;
  color: var(--color-main);
  line-height: 1.3;
  margin-bottom: 16px;
}

.start-desc {
  color: var(--color-text-sub);
  font-size: 0.95rem;
  margin-bottom: 36px;
  line-height: 1.8;
}

/* ===================================================
   動画画面
=================================================== */
#video-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: #111;
  position: relative;
}

#video-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#video-player {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

/* クイズ表示中のクリックブロック用オーバーレイ */
#video-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 10;
}

/* 動画タイトル・進行状況バー */
#video-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 20px;
  background: var(--color-main-dark);
  color: var(--color-white);
  font-size: 0.9rem;
}

#quiz-progress {
  font-weight: bold;
  color: var(--color-accent);
}

/* ===================================================
   クイズ フローティングウィンドウ
=================================================== */
#quiz-window {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 420px;
  min-width: 300px;
  max-width: 90vw;
  background: var(--color-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 100;
  overflow: hidden;
  animation: windowIn 0.3s ease;
  border: 2px solid var(--color-main-light);
}

/* ウィンドウ アニメーション */
@keyframes windowIn {
  from {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 20px));
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

/* タイトルバー */
#quiz-titlebar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--color-main);
  color: var(--color-white);
  padding: 10px 14px;
  cursor: grab;
  user-select: none;
}

#quiz-titlebar:active {
  cursor: grabbing;
}

#quiz-titlebar-text {
  font-weight: bold;
  font-size: 0.95rem;
}

#btn-minimize {
  background: rgba(255,255,255,0.25);
  border: none;
  color: var(--color-white);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background var(--transition);
}

#btn-minimize:hover {
  background: rgba(255,255,255,0.45);
}

/* クイズ本体 */
#quiz-body {
  padding: 20px;
  overflow-y: auto;
  max-height: 75vh;
}

/* 最小化時 */
#quiz-window.minimized #quiz-body,
#quiz-window.minimized #resize-handle {
  display: none;
}

/* 問題番号 */
#quiz-number {
  font-size: 0.8rem;
  color: var(--color-main);
  font-weight: bold;
  margin-bottom: 8px;
  letter-spacing: 0.05em;
}

/* 問題文 */
#quiz-question {
  font-size: 1.05rem;
  font-weight: bold;
  color: var(--color-text);
  margin-bottom: 14px;
  line-height: 1.7;
}

/* 画像 */
#quiz-image-wrap {
  margin-bottom: 14px;
}

#quiz-image {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

/* 選択肢 */
#quiz-choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.choice-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border: 2px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  font-size: 0.95rem;
}

.choice-item:hover {
  border-color: var(--color-main);
  background: var(--color-main-pale);
}

.choice-item.selected {
  border-color: var(--color-main);
  background: var(--color-main-pale);
}

.choice-item input[type="radio"] {
  accent-color: var(--color-main);
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  cursor: pointer;
}

/* 回答後の色分け */
.choice-item.correct {
  border-color: var(--color-correct);
  background: #E8F5E9;
}

.choice-item.incorrect {
  border-color: var(--color-incorrect);
  background: #FFEBEE;
}

/* ボタンエリア */
#quiz-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

#quiz-buttons .btn {
  flex: 1;
  min-width: 80px;
  max-width: 160px;
}

/* リサイズハンドル */
#resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 18px;
  height: 18px;
  cursor: se-resize;
  background: linear-gradient(
    135deg,
    transparent 50%,
    var(--color-main-light) 50%
  );
  border-bottom-right-radius: var(--radius);
}

/* ===================================================
   スコア画面
=================================================== */
#score-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-main-pale) 0%, #DCEDC8 100%);
  min-height: 100vh;
  padding: 40px 20px;
}

.score-card {
  background: var(--color-white);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 50px 40px;
  text-align: center;
  max-width: 520px;
  width: 100%;
  animation: fadeInUp 0.5s ease;
}

#score-header {
  margin-bottom: 24px;
}

#score-header .score-emoji {
  font-size: 3.5rem;
  display: block;
  margin-bottom: 8px;
}

#score-header h2 {
  font-size: 1.6rem;
  color: var(--color-main);
  font-weight: bold;
}

#score-summary {
  background: var(--color-main-pale);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 28px;
}

#score-summary .score-count {
  font-size: 1.1rem;
  color: var(--color-text-sub);
  margin-bottom: 6px;
}

#score-summary .score-point {
  font-size: 3rem;
  font-weight: bold;
  color: var(--color-main);
  line-height: 1.1;
}

#score-summary .score-point span {
  font-size: 1.2rem;
  color: var(--color-text-sub);
}

/* 問題別一覧 */
#score-list {
  text-align: left;
  margin-bottom: 30px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  overflow: hidden;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9rem;
}

.score-row:last-child {
  border-bottom: none;
}

.score-row:nth-child(even) {
  background: var(--color-main-pale);
}

.score-row-num {
  font-weight: bold;
  color: var(--color-main);
  flex-shrink: 0;
  width: 28px;
}

.score-row-question {
  flex: 1;
  color: var(--color-text);
}

.score-row-result {
  font-size: 1.3rem;
  flex-shrink: 0;
}

/* ===================================================
   アニメーション
=================================================== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

@keyframes flash-correct {
  0%   { background: var(--color-white); }
  40%  { background: #C8E6C9; }
  100% { background: var(--color-white); }
}

.animate-shake {
  animation: shake 0.4s ease;
}

.animate-correct {
  animation: flash-correct 0.6s ease;
}

/* ===================================================
   レスポンシブ（タブレット対応）
=================================================== */
@media (max-width: 1023px) {
  #quiz-window {
    width: min(80vw, 400px);
  }

  .start-card,
  .score-card {
    padding: 40px 24px;
  }
}
