:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --surface-strong: #ebe4d8;
  --surface-cool: #edf1ef;
  --ink: #241f1b;
  --muted: #6d675f;
  --line: #d8cfc2;
  --line-strong: #b9aa98;
  --accent: #8f2f24;
  --accent-strong: #6e211a;
  --accent-soft: #f4e3df;
  --gold: #b88a28;
  --gold-soft: #f3e8c9;
  --hall-green: #36544a;
  --ok: #2e7654;
  --bad: #a83232;
  --focus: #1e6bb8;
  --shadow: 0 18px 42px rgba(43, 35, 26, 0.13);
  --shadow-soft: 0 10px 24px rgba(43, 35, 26, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(rgba(54, 84, 74, 0.055) 1px, transparent 1px) 0 132px / 100% 22px,
    radial-gradient(ellipse at top, rgba(255, 253, 248, 0.98), rgba(244, 241, 234, 0.86) 58%, rgba(238, 235, 228, 0.98)),
    var(--bg);
  color: var(--ink);
  font-family:
    "Yu Gothic UI",
    "Yu Gothic",
    "Hiragino Sans",
    Meiryo,
    system-ui,
    sans-serif;
  line-height: 1.5;
}

button {
  font: inherit;
}

.app-shell {
  width: min(100%, 1180px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px 16px 28px;
}

.app-header {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 72px;
  gap: 14px;
  align-items: center;
  min-height: 76px;
  padding: 16px 0 10px;
  position: relative;
}

.app-header::after {
  background: linear-gradient(90deg, transparent, var(--line-strong), var(--gold), var(--line-strong), transparent);
  bottom: 0;
  content: "";
  height: 1px;
  left: 0;
  opacity: 0.68;
  position: absolute;
  right: 0;
}

.header-title {
  grid-column: 2;
  justify-self: center;
  text-align: center;
  width: min(100%, 900px);
}

.app-header .ghost-button {
  align-self: center;
  grid-column: 1;
  transform: translateY(13px);
}

.eyebrow {
  display: inline-flex;
  margin: 0 0 13px;
  color: var(--hall-green);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  line-height: 1.2;
  position: relative;
  text-transform: uppercase;
}

.eyebrow::after {
  background: linear-gradient(90deg, var(--gold), transparent);
  content: "";
  height: 1px;
  left: calc(100% + 10px);
  opacity: 0.86;
  position: absolute;
  top: 50%;
  width: min(120px, 22vw);
}

.eyebrow::before {
  background: linear-gradient(270deg, var(--gold), transparent);
  content: "";
  height: 1px;
  opacity: 0.86;
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  width: min(120px, 22vw);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-family:
    "Yu Mincho",
    "Hiragino Mincho ProN",
    "YuMincho",
    "MS PMincho",
    serif;
  margin-bottom: 0;
  font-size: clamp(1.32rem, 4.6vw, 2.18rem);
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.16;
  position: relative;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.82),
    0 10px 20px rgba(43, 35, 26, 0.1);
}

.title-subtitle {
  color: var(--accent);
  display: block;
  font-size: 0.52em;
  font-weight: 800;
  line-height: 1.1;
  margin: 0.04em 0 0;
  white-space: nowrap;
}

.title-subtitle::before,
.title-subtitle::after {
  color: var(--gold);
  content: "〜";
  padding: 0 0.18em;
}

.screen {
  padding-top: 10px;
}

.hidden {
  display: none !important;
}

.title-visual {
  align-items: center;
  display: flex;
  justify-content: center;
  margin: 2px auto 18px;
  max-width: 1040px;
  min-height: 92px;
  overflow: hidden;
  width: 100%;
}

.title-visual img {
  display: block;
  filter: drop-shadow(0 16px 28px rgba(43, 35, 26, 0.18));
  height: auto;
  max-height: clamp(120px, 26vw, 280px);
  max-width: min(100%, 1040px);
  object-fit: contain;
  width: 100%;
}

.course-character {
  display: block;
  filter: drop-shadow(0 16px 28px rgba(43, 35, 26, 0.18));
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.answer-content {
  display: grid;
  gap: 16px;
  min-width: 0;
  position: relative;
  z-index: 1;
}

.answer-character-stage {
  align-items: center;
  display: flex;
  inset: 0;
  justify-content: center;
  overflow: hidden;
  pointer-events: none;
  position: absolute;
  z-index: 0;
}

.answer-character {
  display: block;
  filter: drop-shadow(0 16px 28px rgba(43, 35, 26, 0.08));
  height: clamp(360px, 74vw, 620px);
  margin-bottom: 0;
  opacity: 0.2;
  max-width: none;
  object-fit: contain;
  width: auto;
}

.ghost-button,
.primary-button,
.secondary-button,
.option-button,
.mode-button,
.course-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  min-height: 44px;
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.15s ease;
}

.ghost-button {
  background: rgba(255, 253, 248, 0.9);
  color: var(--ink);
  padding: 9px 12px;
  box-shadow: var(--shadow-soft);
}

.primary-button {
  background: linear-gradient(180deg, #9b3b30, var(--accent-strong));
  border-color: color-mix(in srgb, var(--accent) 75%, black);
  box-shadow: 0 10px 22px rgba(111, 33, 26, 0.2);
  color: white;
  font-weight: 800;
  padding: 12px 18px;
}

.secondary-button {
  background: rgba(255, 253, 248, 0.94);
  color: var(--ink);
  padding: 12px 18px;
  font-weight: 700;
  box-shadow: var(--shadow-soft);
}

.primary-button:disabled,
.secondary-button:disabled,
.option-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.ghost-button:hover,
.secondary-button:hover,
.mode-button:hover,
.course-button:hover,
.option-button:hover {
  border-color: var(--gold);
  box-shadow: 0 14px 30px rgba(43, 35, 26, 0.12);
}

.primary-button:hover:not(:disabled) {
  background: linear-gradient(180deg, #a14539, #641c16);
  box-shadow: 0 14px 30px rgba(111, 33, 26, 0.26);
}

.ghost-button:focus-visible,
.primary-button:focus-visible,
.secondary-button:focus-visible,
.mode-button:focus-visible,
.course-button:focus-visible,
.option-button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 35%, transparent);
  outline-offset: 2px;
}

.menu-grid {
  display: grid;
  gap: 14px;
}

.course-grid {
  margin-inline: auto;
  width: min(100%, 920px);
}

.mode-button,
.course-button {
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(250, 246, 238, 0.96)),
    var(--surface);
  border-color: color-mix(in srgb, var(--line) 88%, var(--gold));
  box-shadow: var(--shadow-soft);
  color: var(--ink);
  display: grid;
  gap: 6px;
  grid-template-columns: auto minmax(0, 1fr);
  padding: 16px;
  position: relative;
  text-align: left;
}

.menu-icon {
  align-items: center;
  align-self: center;
  background: var(--surface-cool);
  border: 1px solid color-mix(in srgb, var(--hall-green) 22%, var(--line));
  border-radius: 50%;
  color: var(--hall-green);
  display: inline-flex;
  grid-column: 1;
  grid-row: 1 / span 2;
  height: 38px;
  justify-content: center;
  justify-self: start;
  position: relative;
  width: 38px;
}

.menu-icon::before {
  background: currentColor;
  content: "";
  height: 20px;
  mask: var(--icon-url) center / contain no-repeat;
  width: 20px;
}

.mode-button:hover .menu-icon {
  background: var(--gold-soft);
  border-color: color-mix(in srgb, var(--gold) 35%, var(--line));
  color: #7b5a16;
}

.course-button {
  grid-template-columns: minmax(0, 1fr);
}

.mode-button strong,
.course-button strong {
  font-size: 1.05rem;
  line-height: 1.25;
}

.mode-button span,
.course-button span,
.subtle {
  color: var(--muted);
  font-size: 0.9rem;
}

.mode-button > span:not(.menu-icon) {
  grid-column: 2;
}

.mode-button > strong {
  grid-column: 2;
}

.mode-button::after,
.course-button::after {
  background: linear-gradient(180deg, var(--gold), color-mix(in srgb, var(--gold) 38%, transparent));
  content: "";
  inset: 10px auto 10px 0;
  opacity: 0;
  position: absolute;
  transition: opacity 0.15s ease;
  width: 3px;
}

.mode-button:hover::after,
.course-button:hover::after {
  opacity: 1;
}

.mode-button[disabled] {
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.58;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.next-button {
  box-shadow:
    0 12px 26px rgba(111, 33, 26, 0.24),
    inset 0 0 0 1px rgba(255, 255, 255, 0.16);
  min-width: 128px;
}

.quiz-layout {
  display: grid;
  gap: 14px;
}

.portrait-layout {
  display: grid;
  gap: 14px;
}

.quiz-status {
  align-items: center;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(249, 245, 237, 0.96)),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 10px;
  padding: 14px;
}

.portrait-card {
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(249, 245, 237, 0.96)),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 14px;
  justify-items: center;
  padding: 14px;
}

.portrait-image {
  aspect-ratio: 5 / 7;
  background: var(--surface-cool);
  border: 6px solid var(--surface);
  border-radius: 8px;
  box-shadow:
    0 0 0 1px var(--line),
    var(--shadow);
  object-fit: cover;
  width: min(100%, 260px);
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
}

.pill {
  background: color-mix(in srgb, var(--surface-cool) 82%, white);
  border: 1px solid color-mix(in srgb, var(--hall-green) 18%, var(--line));
  border-radius: 999px;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 800;
  padding: 6px 10px;
}

.play-area {
  align-items: center;
  display: grid;
  gap: 12px;
  justify-items: center;
}

.play-button {
  align-items: center;
  aspect-ratio: 1;
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.18), transparent 26%),
    linear-gradient(145deg, #a94337, #671e18);
  border: 1px solid color-mix(in srgb, var(--accent-strong) 72%, black);
  border-radius: 50%;
  box-shadow:
    0 14px 30px rgba(111, 33, 26, 0.24),
    0 0 0 7px rgba(184, 138, 40, 0.12);
  color: white;
  cursor: pointer;
  display: grid;
  gap: 3px;
  height: 112px;
  justify-items: center;
  padding: 0;
  place-content: center;
  text-align: center;
  transition:
    background 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.15s ease;
  width: 112px;
}

.play-button:hover:not(:disabled) {
  box-shadow:
    0 18px 36px rgba(111, 33, 26, 0.28),
    0 0 0 7px rgba(184, 138, 40, 0.18);
  transform: translateY(-1px);
}

.play-button:disabled {
  background: #b9aa9a;
  border-color: #a49483;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 1;
}

.play-icon {
  font-size: 2rem;
  line-height: 1;
  transform: translateX(2px);
}

.play-button:disabled .play-icon {
  transform: none;
}

.play-label {
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1.1;
}

.timer-track {
  background: #e1d7c8;
  border-radius: 999px;
  box-shadow: inset 0 1px 2px rgba(43, 35, 26, 0.12);
  height: 12px;
  overflow: hidden;
}

.timer-fill {
  background: linear-gradient(90deg, var(--accent), var(--gold));
  height: 100%;
  transform-origin: left center;
  width: 100%;
}

.answer-panel {
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(250, 246, 238, 0.96)),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 16px;
  padding: 14px;
  position: relative;
}

.choice-section {
  display: grid;
  gap: 10px;
}

.choice-section h2 {
  color: var(--hall-green);
  font-size: 1rem;
  font-weight: 900;
  margin-bottom: 0;
}

.option-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.option-button {
  background: rgba(255, 255, 255, 0.92);
  border-color: color-mix(in srgb, var(--line) 84%, white);
  color: var(--ink);
  min-height: 58px;
  padding: 10px;
  text-align: center;
  width: 100%;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.option-button.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
  font-weight: 800;
}

.option-button.correct {
  background: #dff0e7;
  border-color: var(--ok);
  color: #174832;
}

.option-button.wrong {
  background: #f4dddd;
  border-color: var(--bad);
  color: #731f1f;
}

.confidence-toggle {
  align-items: center;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  font-weight: 800;
  gap: 8px;
  justify-self: start;
  min-height: 42px;
  padding: 8px 12px;
}

.feedback {
  align-content: center;
  background: rgba(255, 253, 248, 0.82);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(43, 35, 26, 0.18);
  display: grid;
  gap: 8px;
  inset: 50% auto auto 50%;
  margin: 0;
  max-width: calc(100% - 28px);
  min-height: 132px;
  padding: 18px;
  position: absolute;
  text-align: center;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100% - 28px));
  z-index: 2;
}

.feedback strong {
  display: block;
  font-size: 1.8rem;
  line-height: 1.2;
}

.feedback span {
  display: block;
  overflow-wrap: anywhere;
}

.feedback.ok {
  border-color: var(--ok);
  color: #174832;
}

.feedback.bad {
  border-color: var(--bad);
  color: #731f1f;
}

.result-summary {
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(250, 246, 238, 0.96)),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  padding: 18px;
}

.exam-result,
.trophy-result {
  overflow: hidden;
  position: relative;
}

.exam-result.is-passed,
.trophy-result.is-passed {
  border-color: #d6a11e;
  box-shadow: 0 20px 46px rgba(143, 102, 16, 0.18);
}

.exam-result.is-failed {
  border-color: color-mix(in srgb, var(--bad) 45%, var(--line));
}

.result-kicker {
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 900;
  letter-spacing: 0;
  margin-bottom: 8px;
}

.result-popup-layer {
  align-items: center;
  background: rgba(24, 20, 16, 0.38);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: fixed;
  z-index: 20;
}

.result-popup {
  align-items: center;
  animation: popup-in 0.28s ease-out both;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid #d6a11e;
  border-radius: 8px;
  box-shadow: 0 22px 56px rgba(45, 35, 22, 0.2);
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
  justify-items: center;
  max-width: 560px;
  overflow: hidden;
  padding: 22px 18px 18px;
  position: relative;
  text-align: center;
  width: min(100%, 560px);
  z-index: 2;
}

.result-popup.is-trophy {
  border-color: #d6a11e;
}

.result-popup strong,
.result-popup span {
  display: block;
}

.result-popup strong {
  font-size: 1.45rem;
  line-height: 1.2;
}

.result-popup span {
  color: var(--muted);
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.popup-trophy .trophy-svg {
  height: 118px;
  width: 106px;
}

.popup-close {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: 900;
  height: 36px;
  line-height: 1;
  position: absolute;
  right: 10px;
  top: 10px;
  width: 36px;
}

.popup-close:hover,
.popup-close:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  outline: none;
}

.popup-confetti {
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  position: absolute;
  z-index: 1;
}

.popup-confetti span {
  animation: confetti-drop 1.5s ease-out both;
  background: hsl(calc(var(--i) * 29deg), 78%, 58%);
  border-radius: 2px;
  height: 12px;
  left: calc(4% + (var(--i) * 4%));
  position: absolute;
  top: -18px;
  transform: rotate(calc(var(--i) * 21deg));
  width: 7px;
}

@keyframes popup-in {
  0% {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes confetti-drop {
  0% {
    opacity: 0;
    transform: translateY(0) rotate(0deg);
  }

  12% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translateY(260px) translateX(calc((var(--i) - 12) * 4px)) rotate(calc(var(--i) * 52deg));
  }
}

.score-number {
  font-size: 2.6rem;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 8px;
}

.history-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.history-item {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 10px;
}

.history-item.is-correct {
  border-left: 4px solid var(--ok);
}

.history-item.is-wrong {
  border-left: 4px solid var(--bad);
}

.review-panel {
  display: grid;
  gap: 14px;
}

.review-actions {
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(249, 245, 237, 0.96)),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 8px;
  padding: 12px;
}

.review-list {
  display: grid;
  gap: 8px;
}

.review-item {
  align-items: center;
  background: rgba(255, 253, 248, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: auto minmax(0, 1fr);
  padding: 10px;
}

.review-item strong,
.review-item .subtle {
  overflow-wrap: anywhere;
}

.review-item .subtle {
  grid-column: 2;
}

.trophy-board {
  display: grid;
  gap: 14px;
}

.trophy-list {
  display: grid;
  gap: 12px;
}

.trophy-row-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 12px;
  padding: 14px;
}

.trophy-label {
  color: var(--ink);
  font-size: 1.02rem;
  font-weight: 900;
  letter-spacing: 0;
  margin: 0;
}

.trophy-slots {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.trophy-cell {
  align-items: center;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  justify-items: center;
  min-height: 112px;
  padding: 10px 8px;
  text-align: center;
}

.trophy-cell.is-earned {
  background: white;
  border-color: color-mix(in srgb, var(--gold) 48%, var(--line));
}

.trophy-course {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 900;
  line-height: 1.2;
}

.trophy-mark {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 78px;
}

.trophy-empty {
  border: 1px solid var(--line);
  border-radius: 50%;
  display: block;
  height: 34px;
  opacity: 0.72;
  width: 34px;
}

.trophy-svg {
  color: #b8722d;
  display: block;
  filter: drop-shadow(0 10px 14px rgba(45, 35, 22, 0.18));
  height: 78px;
  overflow: visible;
  width: 70px;
}

.trophy-svg .trophy-glow {
  display: none;
}

.trophy-svg .trophy-wing {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 8;
}

.trophy-svg .trophy-body,
.trophy-svg .trophy-stem,
.trophy-svg .trophy-base,
.trophy-svg .trophy-plinth {
  fill: currentColor;
  stroke: rgba(58, 41, 18, 0.32);
  stroke-linejoin: round;
  stroke-width: 2;
}

.trophy-svg .trophy-face {
  fill: rgba(255, 255, 255, 0.36);
}

.trophy-svg .trophy-star {
  fill: rgba(255, 255, 255, 0.88);
  stroke: rgba(58, 41, 18, 0.16);
  stroke-linejoin: round;
  stroke-width: 1;
}

.trophy-beginner {
  color: #b96f31;
  transform: scale(0.9);
}

.trophy-intermediate {
  color: #9aa7b1;
}

.trophy-advanced {
  color: #d6a11e;
  transform: scale(1.08);
}

.trophy-advanced .trophy-glow {
  opacity: 0.68;
}

.stats-grid {
  display: grid;
  gap: 10px;
}

.sound-panel {
  display: grid;
  gap: 14px;
}

.sound-player {
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(249, 245, 237, 0.96)),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
  padding: 12px;
  position: sticky;
  top: 8px;
  z-index: 3;
}

.sound-now {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: auto minmax(0, 1fr);
}

.sound-now strong,
.sound-now span {
  display: block;
  overflow-wrap: anywhere;
}

.sound-controls {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.loop-toggle,
.volume-control {
  align-items: center;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 8px;
  min-height: 42px;
  padding: 8px 10px;
}

.loop-toggle {
  cursor: pointer;
  font-weight: 800;
  justify-content: center;
}

.volume-control {
  display: grid;
  font-weight: 800;
  grid-template-columns: auto minmax(0, 1fr);
}

.volume-control input {
  width: 100%;
}

.sound-list {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.sound-row {
  align-items: center;
  background: rgba(255, 253, 248, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  display: grid;
  gap: 8px;
  min-height: 96px;
  padding: 10px;
  text-align: left;
}

.sound-row.is-playing {
  background: linear-gradient(180deg, #fffdfa, #fbf0dc);
  border-color: var(--accent);
  box-shadow: inset 4px 0 0 var(--accent);
}

.sound-meta {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: auto minmax(0, 1fr);
}

.sound-meta strong,
.sound-meta span {
  display: block;
  overflow-wrap: anywhere;
}

.track-number {
  background: color-mix(in srgb, var(--surface-cool) 78%, white);
  border: 1px solid color-mix(in srgb, var(--hall-green) 18%, var(--line));
  border-radius: 999px;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 900;
  padding: 6px 8px;
}

.sound-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.playing-badge {
  background: linear-gradient(180deg, #9b3b30, var(--accent-strong));
  border-radius: 999px;
  color: white;
  font-size: 0.82rem;
  font-weight: 900;
  grid-column: 1 / -1;
  justify-self: start;
  padding: 4px 9px;
}

.compact-button {
  align-items: center;
  display: inline-flex;
  justify-content: center;
  min-height: 42px;
  padding: 8px 10px;
  text-align: center;
}

.stat-row {
  align-items: center;
  background: rgba(255, 253, 248, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 12px;
}

.empty-state {
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.96), rgba(249, 245, 237, 0.94)),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.empty-state + .empty-state {
  margin-top: 12px;
}

.credits-panel {
  display: grid;
  gap: 12px;
}

.credit-section {
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(249, 245, 237, 0.96)),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.credit-section summary {
  cursor: pointer;
  font-weight: 900;
  padding: 14px 16px;
  color: var(--hall-green);
}

.credit-section pre {
  background: rgba(255, 255, 255, 0.86);
  border-top: 1px solid var(--line);
  font-family:
    "Yu Gothic UI",
    "Yu Gothic",
    Meiryo,
    system-ui,
    sans-serif;
  font-size: 0.84rem;
  line-height: 1.55;
  margin: 0;
  max-height: 56vh;
  overflow: auto;
  padding: 14px 16px;
  white-space: pre-wrap;
  word-break: break-word;
}

.switch-control {
  align-items: center;
  cursor: pointer;
  display: inline-flex;
  font-weight: 800;
  gap: 10px;
  min-height: 44px;
}

.switch-control input {
  height: 1px;
  opacity: 0;
  position: absolute;
  width: 1px;
}

.switch-track {
  background: #c9beb0;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  height: 32px;
  padding: 3px;
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
  width: 58px;
}

.switch-thumb {
  background: white;
  border-radius: 50%;
  box-shadow: 0 3px 8px rgba(45, 35, 22, 0.24);
  height: 24px;
  transform: translateX(0);
  transition: transform 0.15s ease;
  width: 24px;
}

.switch-control input:checked + .switch-track {
  background: linear-gradient(180deg, #9b3b30, var(--accent-strong));
  border-color: var(--accent-strong);
}

.switch-control input:checked + .switch-track .switch-thumb {
  transform: translateX(26px);
}

.switch-control input:focus-visible + .switch-track {
  outline: 3px solid color-mix(in srgb, var(--focus) 35%, transparent);
  outline-offset: 2px;
}

.confirm-layer {
  align-items: center;
  background: rgba(24, 20, 16, 0.38);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: fixed;
  z-index: 30;
}

.confirm-dialog {
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.99), rgba(249, 245, 237, 0.98)),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 22px 56px rgba(45, 35, 22, 0.2);
  display: grid;
  gap: 10px;
  max-width: 420px;
  padding: 18px;
  width: min(100%, 420px);
}

.confirm-dialog strong,
.confirm-dialog span {
  display: block;
}

.confirm-dialog strong {
  font-size: 1.2rem;
}

.confirm-dialog span {
  color: var(--muted);
}

.confirm-actions {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 6px;
}

@media (min-width: 768px) {
  .app-shell {
    padding: 28px 28px 36px;
  }

  h1 {
    font-size: 2.05rem;
  }

  .menu-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .course-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .quiz-layout {
    grid-template-columns: minmax(260px, 0.85fr) minmax(0, 1.15fr);
    align-items: start;
  }

  .portrait-layout {
    grid-template-columns: minmax(260px, 0.85fr) minmax(0, 1.15fr);
    align-items: start;
  }

  .quiz-status,
  .portrait-card,
  .answer-panel,
  .result-summary {
    padding: 18px;
  }

  .portrait-image {
    width: min(100%, 320px);
  }

  .option-grid {
    gap: 10px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .review-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sound-player {
    grid-template-columns: minmax(220px, 1fr) minmax(340px, 1.5fr);
    align-items: center;
  }

  .volume-control {
    grid-column: 1 / -1;
  }

  .sound-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sound-row {
    align-content: start;
  }
}

@media (max-width: 520px) {
  .app-header {
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    gap: 8px;
  }

  .app-header:has(.ghost-button.hidden) .header-title {
    grid-column: 1 / -1;
  }

  .app-header .ghost-button {
    align-items: center;
    display: inline-flex;
    font-size: 0;
    height: 40px;
    justify-content: center;
    min-height: 40px;
    padding: 0;
    transform: translateY(10px);
    width: 40px;
  }

  .app-header .ghost-button::before {
    content: "←";
    font-size: 1.25rem;
    font-weight: 900;
    line-height: 1;
  }

  h1 {
    font-size: clamp(1.06rem, 5.1vw, 1.32rem);
    line-height: 1.12;
  }

  #screenTitle {
    overflow-wrap: normal;
    word-break: keep-all;
  }

  .title-subtitle {
    font-size: 0.46em;
    margin-top: 0;
  }
}

@media (min-width: 1200px) {
  .app-shell {
    padding-inline: 34px;
  }

  .menu-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .course-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .quiz-layout {
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 20px;
  }

  .portrait-layout {
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 20px;
  }

  .option-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .answer-character {
    height: min(640px, 50vw);
  }

  .sound-player {
    grid-template-columns: minmax(260px, 1fr) minmax(520px, 2fr) minmax(220px, 0.8fr);
  }

  .volume-control {
    grid-column: auto;
  }

  .sound-controls {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .sound-list {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .choice-section h2 {
    font-size: 1.05rem;
  }
}
