/* 県庁所在地クイズ */
:root {
  --bg: #f3f8ff;
  --surface: #ffffff;
  --ink: #1a2744;
  --muted: #5c6b82;
  --header-border: #d6e4ff;
  --header-util-bg: #e8eef8;
  --accent: #3d7dd6;
  --accent-2: #5cb88a;
  --danger: #e85a5a;
  --ok: #43a047;
  --radius: 16px;
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP",
    system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

body {
  max-width: 480px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.app-header:not(.app-header--unified) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface);
  border-bottom: 2px solid #d6e4ff;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-quit {
  font: inherit;
  font-size: 0.72rem;
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px solid #ffcdd2;
  background: #fff8f8;
  color: #c62828;
  cursor: pointer;
}

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

select.mode-select {
  font: inherit;
  font-size: 0.72rem;
  padding: 5px 6px;
  border-radius: 8px;
  border: 1px solid #d0d9e8;
  background: var(--surface);
  color: var(--ink);
  max-width: 7.5rem;
}

.app-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  min-width: 0;
}

.app-title-link {
  color: inherit;
  text-decoration: none;
}

.app-title-link:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.app-title-link:active {
  opacity: 0.85;
}

.btn-home {
  font: inherit;
  font-size: 0.78rem;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #d0d9e8;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

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

.stats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 8px 12px;
  background: linear-gradient(180deg, #e8f1ff, #dce9ff);
  border-bottom: 1px solid #c5d8f5;
  font-size: 0.72rem;
  color: var(--muted);
}

.stats-bar strong {
  color: var(--ink);
  font-weight: 800;
}

.stat-pill {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid #d0d9e8;
}

.master-progress {
  flex: 1 1 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  overflow: hidden;
  margin-top: 2px;
}

.master-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #64b5f6, #3d7dd6);
  transition: width 0.35s ease;
}

.session-progress {
  flex: 1 1 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  overflow: hidden;
  margin-top: 2px;
}

.session-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #81c784, #43a047);
  transition: width 0.35s ease;
}

.character-panel {
  flex: 0 0 auto;
  padding: 8px 12px 10px;
  background: linear-gradient(180deg, #fff, #e8f1ff);
  border-bottom: 2px solid #c5d8f5;
  text-align: center;
}

.char-single {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.char-img-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 88px;
}

.char-single img,
.squad-item img {
  display: block;
  max-height: 88px;
  max-width: min(42vw, 140px);
  width: auto;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.1));
}

.char-label {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}

.char-squad .squad-caption {
  margin-top: 6px;
}

.squad-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  max-width: 320px;
  margin: 0 auto;
}

.squad-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 10px;
  background: var(--surface);
  border: 2px solid #d6e4ff;
}

.squad-item img {
  max-height: 56px;
  max-width: 100%;
}

.squad-item span {
  font-size: 1rem;
  line-height: 1;
}

.character-panel.fx-bounce .char-img-wrap img {
  animation: charBounce 0.5s ease 3;
}

.character-panel.fx-swap .char-img-wrap img {
  animation: charSwapIn 0.55s ease;
}

.character-panel.fx-squad-pop .squad-item {
  animation: squadPop 0.45s ease backwards;
}

.character-panel.fx-squad-pop .squad-item:nth-child(1) {
  animation-delay: 0s;
}
.character-panel.fx-squad-pop .squad-item:nth-child(2) {
  animation-delay: 0.08s;
}
.character-panel.fx-squad-pop .squad-item:nth-child(3) {
  animation-delay: 0.16s;
}
.character-panel.fx-squad-pop .squad-item:nth-child(4) {
  animation-delay: 0.24s;
}

.character-panel.fx-squad-glow .squad-item {
  animation: squadGlow 0.9s ease-in-out infinite;
}

@keyframes charBounce {
  0%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-12px);
  }
}

@keyframes charSwapIn {
  0% {
    opacity: 0;
    transform: scale(0.7) rotate(-8deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0);
  }
}

@keyframes squadPop {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  70% {
    transform: scale(1.06);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes squadGlow {
  0%,
  100% {
    filter: drop-shadow(0 0 0 transparent);
    border-color: #d6e4ff;
  }
  50% {
    filter: drop-shadow(0 0 8px rgba(255, 193, 7, 0.8));
    border-color: #ffd54f;
  }
}

.btn-secondary {
  width: 100%;
  padding: 10px;
  margin-top: 6px;
  border: none;
  border-radius: 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: #eceff1;
  color: var(--ink);
}

.quiz-main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 12px;
}

.speech-bubble {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff;
  border: 2px solid #c5d8f5;
  font-size: 0.88rem;
  line-height: 1.4;
  text-align: center;
}

.question-card {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 16px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 2px solid #d6e4ff;
  box-shadow: 0 8px 24px rgba(61, 125, 214, 0.1);
  min-height: 140px;
}

.question-label {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.prefecture-name {
  margin: 0;
  font-size: clamp(1.6rem, 7vw, 2.2rem);
  font-weight: 800;
  letter-spacing: 0.06em;
}

.question-card.flash-ok {
  animation: flashOk 0.5s ease;
}

.question-card.flash-ng {
  animation: flashNg 0.5s ease;
}

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.choice-btn {
  font: inherit;
  cursor: pointer;
  min-height: 52px;
  padding: 10px 8px;
  border-radius: 12px;
  border: 2px solid #d0d9e8;
  background: var(--surface);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
  transition:
    transform 0.12s ease,
    background 0.12s ease,
    border-color 0.12s ease;
}

.choice-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.choice-btn:disabled {
  cursor: default;
  opacity: 0.85;
}

.choice-btn.correct {
  border-color: var(--ok);
  background: #e8f5e9;
  color: #2e7d32;
}

.choice-btn.wrong {
  border-color: var(--danger);
  background: #ffebee;
  color: #c62828;
}

.choice-btn.dim {
  opacity: 0.45;
}

.celebrate-banner {
  position: fixed;
  left: 50%;
  top: 22%;
  transform: translate(-50%, -16px) scale(0.92);
  opacity: 0;
  pointer-events: none;
  z-index: 40;
  max-width: 90%;
  padding: 14px 20px;
  border-radius: 999px;
  background: linear-gradient(135deg, #81d4fa, #4fc3f7);
  color: #01579b;
  font-weight: 800;
  font-size: 0.95rem;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  transition:
    opacity 0.25s ease,
    transform 0.25s ease;
}

.celebrate-banner.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 39, 68, 0.5);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}

.modal-backdrop[hidden] {
  display: none;
}

.celebrate-modal-card {
  position: relative;
  width: min(100%, 360px);
  max-height: 92vh;
  overflow: auto;
  background: linear-gradient(180deg, #e3f2fd, #fff);
  border-radius: 20px;
  padding: 18px 16px;
  text-align: center;
  border: 3px solid #64b5f6;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}

.celebrate-modal-card.record-burst {
  animation: recordShake 0.45s ease, recordGlow 1.2s ease 2;
}

.celebrate-modal-title {
  margin: 0 0 8px;
  font-size: 1.2rem;
  font-weight: 800;
  color: #1565c0;
}

.celebrate-modal-msg {
  margin: 0 0 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-line;
}

.celebrate-modal-img {
  display: block;
  width: min(100%, 280px);
  margin: 0 auto 12px;
  border-radius: 12px;
  animation: popIn 0.5s ease;
}

.celebrate-modal-actions {
  margin-top: 8px;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 12px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), #2563b8);
  color: #fff;
}

@keyframes flashOk {
  0% {
    box-shadow: 0 0 0 0 rgba(67, 160, 71, 0.45);
  }
  100% {
    box-shadow: none;
  }
}

@keyframes flashNg {
  0% {
    box-shadow: 0 0 0 0 rgba(232, 90, 90, 0.4);
  }
  100% {
    box-shadow: none;
  }
}

@keyframes popIn {
  0% {
    opacity: 0;
    transform: scale(0.88);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes recordShake {
  0%,
  100% {
    transform: rotate(0deg) scale(1);
  }
  25% {
    transform: rotate(-2deg) scale(1.02);
  }
  75% {
    transform: rotate(2deg) scale(1.02);
  }
}

@keyframes recordGlow {
  50% {
    box-shadow:
      0 0 0 4px rgba(100, 181, 246, 0.5),
      0 20px 50px rgba(61, 125, 214, 0.35);
  }
}

@media (prefers-reduced-motion: reduce) {
  .question-card.flash-ok,
  .question-card.flash-ng,
  .celebrate-modal-card.record-burst,
  .celebrate-modal-img,
  .character-panel.fx-bounce .char-img-wrap img,
  .character-panel.fx-swap .char-img-wrap img,
  .character-panel.fx-squad-pop .squad-item,
  .character-panel.fx-squad-glow .squad-item {
    animation: none !important;
  }
}
