/* 画面全体の基本設定 */
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans JP", sans-serif;
  background: #ffffff;
  color: #222;
}
/* アプリ本体の枠 */
.app {
  max-width: 640px;
  margin: 24px auto;
  padding: 16px;
}
.hidden {
  display: none !important;
}
.level-select {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.title-screen-title {
  margin: 0 0 8px;
  font-family: "Zen Old Mincho", serif;
  font-size: clamp(2.2rem, 8vw, 3rem);
  font-weight: 900;
  line-height: 1.3;
  text-align: center;
}
.title-screen-subtitle {
  margin: 0 0 16px;
  font-family: "Zen Old Mincho", serif;
  font-size: clamp(0.9rem, 3.5vw, 1.1rem);
  font-weight: 400;
  color: #555;
  line-height: 1.5;
  text-align: center;
}
.title-master-image {
  display: block;
  width: 100%;
  max-width: 900px;
  height: auto;
  margin: 0 auto 20px;
}
.level-buttons {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (min-width: 520px) {
  .level-buttons {
    grid-template-columns: repeat(2, 1fr);
  }
}
.level-btn {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #ccc;
  border-radius: 12px;
  background: #fff;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s;
}
.level-btn:hover {
  border-color: #888;
  background: #fafafa;
}
.level-btn:active {
  transform: scale(0.995);
}
.level-btn--locked {
  cursor: not-allowed;
  opacity: 0.55;
  background: #f5f5f5;
}
.level-btn--locked:hover,
.level-btn--locked:active {
  border-color: #ccc;
  background: #f5f5f5;
  transform: none;
}
.level-buttons--selecting .level-btn:not(.level-btn--selecting) {
  opacity: 0.55;
  cursor: not-allowed;
}
.level-btn--selecting {
  animation: level-btn-blink 2s linear forwards;
  pointer-events: none;
}
@keyframes level-btn-blink {
  0%,
  19.9% {
    opacity: 1;
  }
  20%,
  39.9% {
    opacity: 0.35;
  }
  40%,
  59.9% {
    opacity: 1;
  }
  60%,
  79.9% {
    opacity: 0.35;
  }
  80%,
  100% {
    opacity: 1;
  }
}
.level-name {
  font-size: clamp(0.82rem, 3.2vw, 1.05rem);
  font-weight: 700;
  line-height: 1.35;
}
.game-panel {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 48px);
}
.ramen-wrap {
  margin: 0 0 14px;
}
.ramen-image {
  display: block;
  width: 100%;
  max-width: 600px;
  height: auto;
  margin: 10px auto;
}
.ramen-complete-message {
  margin: 0 0 8px;
  font-family: "Zen Old Mincho", serif;
  font-size: clamp(1.15rem, 4.2vw, 1.5rem);
  font-weight: 900;
  line-height: 1.3;
  color: #c45c00;
  text-align: center;
}
.game-panel-footer {
  margin-top: auto;
  padding-top: 16px;
}
.change-level-btn {
  display: block;
  width: 100%;
  margin: 0;
  padding: 12px 14px;
  font-size: 1rem;
  border: 1px solid #bbb;
  border-radius: 8px;
  background: #f5f5f5;
  cursor: pointer;
  font-weight: 600;
}
.change-level-btn:hover {
  background: #ebebeb;
}
.status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.timer-display {
  margin: 0;
  font-size: clamp(3rem, 14vw, 4.5rem);
  font-weight: 800;
  line-height: 1;
  color: #d4380d;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.timer-display.timer-warning {
  color: #cf1322;
  animation: timer-pulse 0.8s ease-in-out infinite;
}
@keyframes timer-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}
.question-progress {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: #555;
}
.result-panel {
  text-align: center;
  padding: 0 8px 0;
  width: 100%;
  overflow-x: hidden;
}
.result-hero {
  width: 100%;
  max-width: min(100%, 600px);
  margin: 0 auto 14px;
}
.result-hero-stage {
  display: grid;
  place-items: center;
  width: 100%;
  position: relative;
}
.result-hero-ramen,
.result-confetti {
  grid-area: 1 / 1;
  height: auto;
  object-fit: contain;
}
.result-hero-character {
  grid-area: 1 / 1;
  object-fit: contain;
}
.result-hero-ramen {
  width: min(100%, 585px);
  z-index: 1;
  transition: opacity 0.6s ease;
}
.result-hero-ramen--fade-out {
  opacity: 0;
}
.result-confetti {
  width: 100%;
  min-height: 200px;
  height: 100%;
  z-index: 3;
  pointer-events: none;
}
.result-hero-character {
  height: clamp(220px, 42vh, 300px);
  width: auto;
  max-width: 100%;
  z-index: 2;
  pointer-events: none;
}
.result-hero-character--reveal {
  animation: result-character-reveal 0.5s ease forwards;
}
@keyframes result-character-reveal {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
.result-clear-body {
  position: relative;
  z-index: 3;
  width: 100%;
  margin-top: 4px;
}
.result-summary {
  margin: 0 0 10px;
  padding: 0 4px;
  font-size: clamp(0.82rem, 3.2vw, 1rem);
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  color: #222;
}
.master-comment {
  display: flex;
  justify-content: center;
  margin: 0 auto 8px;
  max-width: 100%;
  padding: 0 12px;
}
.master-comment-box {
  width: 100%;
  max-width: min(100%, 320px);
  padding: 10px 14px;
  border-radius: 12px;
  background: #fff8f0;
  border: 2px solid #e8c9a0;
}
.master-comment-text {
  margin: 0;
  font-size: clamp(0.88rem, 3.2vw, 1rem);
  font-weight: 600;
  line-height: 1.45;
  color: #333;
  white-space: pre-line;
  text-align: center;
}
.level-title-highlight {
  font-family: "Zen Old Mincho", serif;
  font-size: clamp(1.15rem, 4.5vw, 1.55rem);
  font-weight: 900;
  color: #b8860b;
  line-height: 1.3;
}
.answer-review-toggle {
  display: block;
  width: 100%;
  max-width: 320px;
  margin: 0 auto 12px;
  padding: 10px 14px;
  font-size: 0.95rem;
  font-weight: 600;
  border: 1px solid #bbb;
  border-radius: 10px;
  background: #f5f5f5;
  cursor: pointer;
  text-align: center;
}
.answer-review-toggle:hover {
  background: #ebebeb;
}
.answer-review {
  margin: 0 0 20px;
  text-align: left;
}
.answer-review-title {
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
  color: #333;
}
.answer-review-scroll {
  max-height: min(50vh, 420px);
  overflow: auto;
  border: 1px solid #ddd;
  border-radius: 10px;
  background: #fafafa;
}
.answer-review-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.answer-review-table th,
.answer-review-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #e5e5e5;
  vertical-align: top;
}
.answer-review-table th {
  position: sticky;
  top: 0;
  background: #f0f0f0;
  font-weight: 700;
  text-align: left;
  z-index: 1;
}
.answer-review-table tr:last-child td {
  border-bottom: none;
}
.answer-review-table td.num {
  width: 2rem;
  text-align: right;
  color: #666;
  white-space: nowrap;
}
.answer-review-table td.q {
  word-break: break-word;
}
.answer-review-table .cell-wrong {
  color: #b42318;
  font-weight: 600;
}
.answer-review-table .cell-ok {
  color: #1a7f37;
  font-weight: 600;
}
.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 320px;
  margin: 0 auto 16px;
}
.result-btn {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  border-radius: 10px;
  border: 1px solid #bbb;
  background: #f5f5f5;
  cursor: pointer;
  font-weight: 600;
}
.result-btn.primary {
  background: #1a5f2a;
  border-color: #1a5f2a;
  color: #fff;
}
.result-btn:hover {
  filter: brightness(0.97);
}
.result-btn.primary:hover {
  filter: brightness(1.08);
}
.question {
  font-size: 1.2rem;
  margin: 0 0 16px;
  min-height: 2.5em;
}
.choices {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.choice-btn {
  width: 100%;
  padding: 20px 12px;
  min-height: 72px;
  border: 1px solid #ccc;
  border-radius: 12px;
  background: #fff;
  font-size: clamp(1.05rem, 4vw, 1.25rem);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.choice-btn:active {
  transform: scale(0.98);
}
.choice-btn:disabled {
  cursor: default;
  opacity: 0.8;
}
.feedback {
  margin-top: 14px;
  min-height: 1.5em;
  font-weight: 600;
}
.correct {
  color: #1a7f37;
}
.wrong {
  color: #b42318;
}
/* スマホ向け: 文字と余白を少し調整 */
@media (max-width: 480px) {
  .app {
    margin: 12px auto;
    padding: 12px;
  }
  .game-panel {
    min-height: calc(100dvh - 24px);
  }
  .question {
    font-size: 1.05rem;
  }
  .choice-btn {
    min-height: 64px;
    padding: 16px 10px;
  }
  .title-master-image {
    width: 100%;
    max-width: 100%;
  }
  .result-hero {
    max-width: 100%;
    margin-bottom: 8px;
  }
  .result-hero-ramen {
    width: min(100%, 585px);
  }
  .result-hero-character {
    height: clamp(200px, 40vh, 280px);
    width: auto;
    max-width: 100%;
  }
  .result-summary {
    margin-bottom: 8px;
    font-size: clamp(0.78rem, 3.1vw, 0.92rem);
  }
  .master-comment {
    margin-bottom: 6px;
  }
  .master-comment-box {
    max-width: 100%;
    padding: 8px 12px;
  }
  .master-comment-text {
    font-size: clamp(0.82rem, 3vw, 0.92rem);
    line-height: 1.4;
  }
  .level-title-highlight {
    font-size: clamp(1.05rem, 4.2vw, 1.35rem);
  }
  .ramen-complete-message {
    margin-bottom: 6px;
    font-size: clamp(1.05rem, 4vw, 1.25rem);
  }
}
@media (max-height: 700px) {
  .master-comment-box {
    padding: 8px 12px;
  }
}
.sound-toggle-btn {
  position: fixed;
  top: max(10px, env(safe-area-inset-top, 0px));
  right: max(10px, env(safe-area-inset-right, 0px));
  z-index: 1100;
  pointer-events: auto;
  margin: 0;
  padding: 6px 10px;
  border: 1px solid #bbb;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  color: #222;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}
.sound-toggle-btn:hover {
  background: #fff;
  border-color: #888;
}
.sound-toggle-btn:active {
  transform: scale(0.97);
}
.sound-toggle-btn[aria-pressed="false"] {
  color: #666;
}
/* クイズ開始前カウントダウン */
.countdown-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
}
.countdown-text {
  margin: 0;
  font-family: "Zen Old Mincho", serif;
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
  color: #fff;
  -webkit-text-stroke: 3px #000;
  paint-order: stroke fill;
  text-shadow:
    2px 2px 0 #000,
    -2px 2px 0 #000,
    2px -2px 0 #000,
    -2px -2px 0 #000;
}
.countdown-text--number {
  font-size: 150px;
}
.countdown-text--start {
  font-size: 130px;
  color: #e87878;
}
.countdown-pop {
  animation: countdown-pop 0.45s cubic-bezier(0.22, 1.15, 0.36, 1);
}
@keyframes countdown-pop {
  0% {
    transform: scale(0.35);
    opacity: 0.7;
  }
  45% {
    transform: scale(1.18);
    opacity: 1;
  }
  70% {
    transform: scale(0.92);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}
@media (max-width: 480px) {
  .countdown-text--number {
    font-size: 80px;
  }
  .countdown-text--start {
    font-size: 68px;
  }
  .countdown-text {
    -webkit-text-stroke: 2px #000;
  }
}
