* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 20px;
  font-family: "Segoe UI", "Hiragino Sans", "Meiryo", sans-serif;
  background: #f4f6f8;
  color: #1d2329;
}

.app {
  max-width: 780px;
  margin: 0 auto;
  padding: 20px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.subtitle {
  margin-top: 8px;
  color: #4b5563;
  line-height: 1.6;
}

.disclaimer {
  font-size: 12px;
  color: #6b7280;
  line-height: 1.5;
  margin-top: 12px;
  padding: 10px;
  background: #f9fafb;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

.mode-section {
  margin-top: 16px;
}

.mode-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mode-buttons button {
  border: 1px solid #cfd7df;
  background: #f8fafc;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
}

.mode-buttons button.primary {
  background: #2563eb;
  color: #fff;
  border-color: #1d4ed8;
}

.global-progress {
  margin-top: 10px;
  font-weight: 600;
  color: #1f2937;
}

.law-lock-banner {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: linear-gradient(90deg, #1d4ed8, #2563eb);
  color: #fff;
}

.law-lock-banner p {
  margin: 6px 0 0;
  font-size: 14px;
  line-height: 1.5;
  opacity: 0.95;
}

.hint {
  font-size: 13px;
  color: #6b7280;
  margin-top: 4px;
}

.unit-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.unit-button {
  border: 1px solid #cfd7df;
  background: #f8fafc;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
}

.unit-button.active {
  background: #0f766e;
  color: #fff;
  border-color: #0d9488;
}

.hidden {
  display: none;
}

.status {
  margin: 12px 0;
  display: flex;
  justify-content: space-between;
  color: #4b5563;
  font-size: 14px;
}

.progress-wrapper {
  margin-bottom: 16px;
}

.progress-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  margin-bottom: 6px;
}

.progress-bar-bg {
  width: 100%;
  height: 18px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-fill {
  width: 0;
  height: 100%;
  background: #ef4444;
  transition: width 0.28s ease, background-color 0.28s ease, filter 0.28s ease;
}

.progress-bar-fill.victory-pulse {
  animation: victoryPulse 0.9s ease-out 2;
}

@keyframes victoryPulse {
  0% {
    filter: brightness(1);
    transform: scaleX(1);
  }
  40% {
    filter: brightness(1.25);
    transform: scaleY(1.15);
  }
  100% {
    filter: brightness(1);
    transform: scaleX(1);
  }
}

.congrats {
  color: #16a34a;
  font-weight: 700;
  margin-top: 8px;
}

.question-card {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 16px;
}

.question-text {
  margin: 0 0 12px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.choices {
  display: grid;
  gap: 8px;
}

.choice-button {
  text-align: left;
  border: 1px solid #cfd7df;
  background: #fff;
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  font-size: 14px;
}

.choice-button.correct {
  border-color: #16a34a;
  background: #dcfce7;
}

.choice-button.wrong {
  border-color: #dc2626;
  background: #fee2e2;
}

.feedback {
  min-height: 24px;
  margin-top: 10px;
  font-weight: 600;
}

.toggle-row {
  margin-top: 16px;
}

body.focus {
  background: #000;
  color: #fff;
}

body.focus .app {
  background: #000;
  box-shadow: none;
  border: 1px solid #2f2f2f;
}

body.focus .subtitle,
body.focus .status,
body.focus .hint,
body.focus .disclaimer {
  color: #d1d5db;
}

body.focus .question-card {
  border-color: #2f2f2f;
}

body.focus .choice-button {
  background: #0e0e0e;
  color: #f8fafc;
  border-color: #374151;
}

body.focus .law-lock-banner {
  background: linear-gradient(90deg, #0f172a, #1e3a8a);
}

.app.celebrate-shake {
  animation: appShake 0.6s ease-out;
}

@keyframes appShake {
  0% {
    transform: translate(0, 0) rotate(0deg);
  }
  20% {
    transform: translate(-2px, 1px) rotate(-0.2deg);
  }
  40% {
    transform: translate(2px, -1px) rotate(0.2deg);
  }
  60% {
    transform: translate(-1px, 2px) rotate(-0.1deg);
  }
  100% {
    transform: translate(0, 0) rotate(0deg);
  }
}

.celebration-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
  pointer-events: auto;
}

/* .celebration-overlay の display:flex が .hidden より後で勝っていたため、
   非表示でも全面に透明レイヤーが残りクリックできなかった。これを確実に無効化する */
.celebration-overlay.hidden {
  display: none !important;
  pointer-events: none !important;
  visibility: hidden;
}

.celebration-overlay.show {
  animation: overlayFade 0.35s ease-out;
}

@keyframes overlayFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.celebration-card {
  position: relative;
  overflow: hidden;
  background: #fff;
  border-radius: 16px;
  padding: 28px 32px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  max-width: 90vw;
  animation: cardPop 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.confetti-piece {
  position: absolute;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  opacity: 0.95;
  pointer-events: none;
  animation: confettiFall 1.35s ease-in forwards;
}

@keyframes confettiFall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(110vh) rotate(720deg);
    opacity: 0.85;
  }
}

.progress-wrapper.victory-glow {
  filter: drop-shadow(0 0 12px rgba(34, 197, 94, 0.65));
}

@keyframes cardPop {
  0% {
    transform: scale(0.85) translateY(12px);
    opacity: 0;
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.celebration-stars {
  font-size: 42px;
  color: #f59e0b;
  animation: starSpin 1.2s ease-in-out infinite alternate;
}

@keyframes starSpin {
  from {
    transform: rotate(-8deg) scale(1);
  }
  to {
    transform: rotate(8deg) scale(1.08);
  }
}

.celebration-title {
  margin: 8px 0 0;
  font-size: 26px;
  font-weight: 800;
  color: #0f172a;
}

.celebration-sub {
  margin: 6px 0 0;
  font-size: 16px;
  color: #334155;
}

.celebration-hint {
  margin: 12px 0 0;
  font-size: 13px;
  color: #64748b;
}

.mock-summary {
  margin-top: 16px;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid #c7d2fe;
  background: #eef2ff;
  font-size: 14px;
  line-height: 1.6;
}

.mock-summary.hidden {
  display: none;
}
