* {
  box-sizing: border-box;
}

:root {
  --ink: #243044;
  --muted: #697386;
  --paper: #fffdf8;
  --panel: #ffffff;
  --line: #d9e2ef;
  --blue: #2457a6;
  --teal: #159a8f;
  --coral: #e35c45;
  --gold: #f3b33d;
  --green: #1f9d62;
  --red: #c83d3d;
  --shadow: 0 18px 45px rgba(42, 52, 70, 0.14);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(243, 179, 61, 0.22), transparent 34rem),
    linear-gradient(135deg, #f5fbff 0%, #fff8ee 48%, #f8fff6 100%);
  color: var(--ink);
}

button {
  font: inherit;
}

.app-shell {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px 16px;
  display: grid;
  place-items: center;
}

.quiz-panel {
  width: 100%;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid rgba(36, 48, 68, 0.1);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px;
  background: linear-gradient(90deg, #ffffff, #eef8ff);
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(24px, 5vw, 38px);
  line-height: 1.15;
}

h2 {
  margin-bottom: 10px;
  font-size: clamp(23px, 4.6vw, 32px);
  line-height: 1.2;
}

.set-badge {
  flex: 0 0 auto;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  font-size: 14px;
  font-weight: 900;
}

.dashboard-screen,
.start-screen,
.quiz-screen,
.result-screen {
  padding: 28px 24px 30px;
}

.dashboard-screen {
  text-align: center;
}

.start-screen {
  text-align: center;
}

.start-screen p,
#resultMessage {
  max-width: 520px;
  margin: 0 auto 22px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.8;
}

.dashboard-hero {
  display: grid;
  gap: 10px;
  justify-items: center;
  margin-bottom: 14px;
}

.dashboard-hero h2 {
  margin-bottom: 0;
}

.total-score {
  width: min(100%, 430px);
  padding: 14px 16px;
  border: 2px solid rgba(36, 87, 166, 0.18);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f4f9ff);
}

.total-score span,
.record-tile span,
.progress-head span,
.set-record-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.total-score span {
  display: block;
  margin-bottom: 4px;
}

.total-score strong {
  display: block;
  color: var(--blue);
  font-size: clamp(34px, 10vw, 52px);
  line-height: 1;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.record-tile {
  min-height: 64px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.record-tile strong {
  font-size: 19px;
}

.progress-panel {
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  text-align: left;
}

.progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.progress-head strong {
  color: var(--blue);
}

.progress-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f6;
}

.progress-track div {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--gold));
  transition: width 0.2s ease;
}

.progress-panel p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.set-record-list {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
  text-align: left;
}

.set-record-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.set-record-name {
  display: block;
  margin-bottom: 1px;
  font-weight: 900;
}

.set-record-score {
  color: var(--blue);
  font-size: 19px;
  font-weight: 900;
}

.cover-art {
  position: relative;
  height: 142px;
  margin: 0 auto 26px;
  max-width: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(36, 87, 166, 0.08) 0 22%, transparent 22%),
    repeating-linear-gradient(0deg, transparent 0 30px, rgba(36, 48, 68, 0.08) 30px 31px),
    var(--paper);
}

.tile {
  position: absolute;
  display: grid;
  place-items: center;
  width: 112px;
  height: 42px;
  border: 2px solid currentColor;
  border-radius: 8px;
  background: white;
  font-weight: 900;
  box-shadow: 0 8px 0 rgba(36, 48, 68, 0.08);
}

.tile-a {
  left: 44px;
  top: 22px;
  color: var(--blue);
  transform: rotate(-5deg);
}

.tile-b {
  right: 62px;
  top: 48px;
  color: var(--coral);
  transform: rotate(4deg);
}

.tile-c {
  left: 130px;
  bottom: 20px;
  color: var(--teal);
}

.set-picker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  max-width: 680px;
  margin: 0 auto 22px;
}

.set-option {
  min-height: 62px;
  padding: 10px 12px;
  border: 2px solid #cdd9ea;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
}

.set-option strong,
.set-option span {
  display: block;
}

.set-option strong {
  font-size: 17px;
}

.set-option span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.set-option.active {
  border-color: var(--blue);
  background: #eef6ff;
  color: var(--blue);
}

.set-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 180px;
  min-height: 48px;
  padding: 12px 22px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: white;
  font-size: 17px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 8px 0 #173b76;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 9px 0 #173b76;
}

.primary-button:active {
  transform: translateY(5px);
  box-shadow: 0 3px 0 #173b76;
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 150px;
  min-height: 46px;
  padding: 11px 18px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.secondary-button:hover {
  border-color: var(--blue);
  background: #f4f9ff;
  transform: translateY(-1px);
}

.status-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.status-row > div {
  min-height: 64px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.status-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.status-row strong {
  font-size: 20px;
}

.timer-box.warning strong {
  color: var(--red);
}

.timer-track {
  height: 10px;
  overflow: hidden;
  margin-bottom: 20px;
  border-radius: 999px;
  background: #edf1f6;
}

.timer-fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--gold), var(--coral));
  transition: width 0.25s linear;
}

.question-card {
  position: relative;
  min-height: 180px;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 26px 56px;
  margin-bottom: 18px;
  border: 2px solid rgba(36, 87, 166, 0.16);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 253, 248, 0.96)),
    repeating-linear-gradient(0deg, transparent 0 35px, rgba(36, 48, 68, 0.08) 35px 36px);
}

.sound-button {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 42px;
  height: 42px;
  border: 2px solid var(--blue);
  border-radius: 50%;
  background: white;
  color: var(--blue);
  font-size: 22px;
  font-weight: 900;
  cursor: pointer;
}

.prompt {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
}

.word {
  overflow-wrap: anywhere;
  text-align: center;
  color: var(--ink);
  font-size: clamp(42px, 12vw, 82px);
  font-weight: 900;
  line-height: 1;
}

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

.choice-button {
  min-height: 68px;
  padding: 14px 12px;
  border: 2px solid #cdd9ea;
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-size: clamp(16px, 4vw, 21px);
  font-weight: 900;
  line-height: 1.25;
  cursor: pointer;
  transition: border-color 0.12s ease, transform 0.12s ease, background 0.12s ease;
}

@media (hover: hover) and (pointer: fine) {
  .choice-button:hover:not(:disabled) {
    border-color: var(--blue);
    transform: translateY(-1px);
  }
}

.choice-button:focus {
  outline: none;
}

.choice-button:focus-visible {
  outline: 3px solid rgba(36, 87, 166, 0.28);
  outline-offset: 2px;
}

.choice-button:disabled {
  cursor: default;
}

.choice-button.correct {
  border-color: var(--green);
  background: #eaf8f0;
  color: #12643f;
}

.choice-button.wrong {
  border-color: var(--red);
  background: #fff0ef;
  color: #9d2828;
}

.feedback {
  min-height: 32px;
  margin-top: 14px;
  text-align: center;
  font-size: 17px;
  font-weight: 900;
}

.feedback.good {
  color: var(--green);
}

.feedback.bad {
  color: var(--red);
}

.quiz-actions {
  display: flex;
  justify-content: center;
  margin-top: 6px;
}

.result-screen {
  text-align: center;
}

.score-ring {
  width: min(72vw, 230px);
  height: min(72vw, 230px);
  margin: 10px auto 22px;
  display: grid;
  place-items: center;
  align-content: center;
  border: 12px solid #e9f3ff;
  border-top-color: var(--blue);
  border-right-color: var(--teal);
  border-bottom-color: var(--gold);
  border-radius: 50%;
  background: white;
}

.score-ring strong {
  display: block;
  font-size: 30px;
}

.score-ring span {
  color: var(--muted);
  font-weight: 900;
}

.score-breakdown {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-width: 420px;
  margin: 0 auto 18px;
}

.score-breakdown div {
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.score-breakdown span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.score-breakdown strong {
  color: var(--ink);
  font-size: 20px;
}

.review-list {
  display: grid;
  gap: 8px;
  max-width: 520px;
  margin: 0 auto 22px;
  text-align: left;
}

.review-item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.review-item strong {
  color: var(--blue);
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.result-actions .primary-button,
.result-actions .secondary-button {
  min-width: 150px;
}

.hidden {
  display: none;
}

@media (max-width: 560px) {
  .app-shell {
    padding: 0;
    align-items: stretch;
  }

  .quiz-panel {
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .app-header,
  .dashboard-screen,
  .start-screen,
  .quiz-screen,
  .result-screen {
    padding-left: 18px;
    padding-right: 18px;
  }

  .dashboard-screen {
    padding-top: 18px;
    padding-bottom: 20px;
  }

  .dashboard-hero {
    gap: 8px;
    margin-bottom: 10px;
  }

  .dashboard-hero h2 {
    font-size: 22px;
  }

  .total-score {
    padding: 11px 12px;
  }

  .total-score span {
    margin-bottom: 2px;
    font-size: 11px;
  }

  .total-score strong {
    font-size: 38px;
  }

  .quiz-screen {
    padding-top: 14px;
    padding-bottom: 16px;
  }

  .app-header {
    align-items: flex-start;
  }

  .quiz-screen .status-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 7px;
  }

  .quiz-screen .status-row > div {
    min-height: 42px;
    padding: 6px 7px;
    text-align: center;
  }

  .quiz-screen .status-label {
    margin-bottom: 1px;
    font-size: 10px;
    line-height: 1.1;
  }

  .quiz-screen .status-row strong {
    font-size: 16px;
    line-height: 1.1;
  }

  .quiz-screen .timer-box {
    grid-column: auto;
  }

  .quiz-screen .timer-track {
    height: 7px;
    margin-bottom: 12px;
  }

  .quiz-screen .question-card {
    min-height: 126px;
    padding: 18px 48px 18px 18px;
    margin-bottom: 12px;
  }

  .quiz-screen .sound-button {
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    font-size: 19px;
  }

  .quiz-screen .prompt {
    margin-bottom: 5px;
    font-size: 13px;
  }

  .quiz-screen .word {
    font-size: clamp(34px, 11vw, 54px);
  }

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

  .quiz-screen .choice-button {
    min-height: 54px;
    padding: 10px 12px;
    font-size: 18px;
  }

  .quiz-screen .feedback {
    min-height: 24px;
    margin-top: 8px;
    font-size: 15px;
  }

  .quiz-screen .quiz-actions {
    margin-top: 4px;
  }

  .quiz-screen .secondary-button {
    min-width: 118px;
    min-height: 38px;
    padding: 8px 14px;
  }

  .set-picker {
    grid-template-columns: 1fr;
  }

  .dashboard-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 9px;
  }

  .record-tile {
    min-height: 50px;
    padding: 7px 4px;
  }

  .record-tile span {
    font-size: 10px;
  }

  .record-tile strong {
    font-size: 16px;
  }

  .progress-panel {
    padding: 10px;
    margin-bottom: 9px;
  }

  .progress-head {
    margin-bottom: 6px;
  }

  .progress-track {
    height: 9px;
  }

  .progress-panel p {
    margin-top: 6px;
    font-size: 12px;
  }

  .set-record-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    margin-bottom: 12px;
  }

  .set-record-item {
    grid-template-columns: 1fr;
    gap: 5px;
    padding: 8px 9px;
  }

  .set-record-score {
    font-size: 17px;
  }

  .set-record-name {
    margin-bottom: 0;
  }

  .set-record-meta {
    font-size: 11px;
  }

  .set-actions {
    display: grid;
  }

  .set-actions .primary-button,
  .set-actions .secondary-button {
    width: 100%;
  }

  .score-breakdown {
    grid-template-columns: 1fr;
  }

  .result-actions {
    display: grid;
  }

  .result-actions .primary-button,
  .result-actions .secondary-button {
    width: 100%;
  }
}

@media (max-width: 390px), (max-height: 760px) {
  .app-header {
    padding: 10px 18px;
  }

  .app-header .eyebrow {
    font-size: 11px;
  }

  .app-header h1 {
    font-size: 22px;
  }

  .set-badge {
    padding: 7px 10px;
    font-size: 12px;
  }

  .dashboard-screen {
    padding-top: 12px;
    padding-bottom: 14px;
  }

  .dashboard-hero {
    gap: 6px;
    margin-bottom: 8px;
  }

  .dashboard-hero h2 {
    font-size: 20px;
  }

  .total-score {
    padding: 9px 10px;
  }

  .total-score strong {
    font-size: 34px;
  }

  .dashboard-grid {
    margin-bottom: 7px;
  }

  .record-tile {
    min-height: 46px;
  }

  .progress-panel {
    margin-bottom: 7px;
  }

  .set-record-list {
    gap: 6px;
    margin-bottom: 9px;
  }

  .set-record-item {
    padding: 7px 8px;
  }

  .primary-button {
    min-height: 44px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .quiz-screen {
    padding-top: 10px;
  }

  .quiz-screen .question-card {
    min-height: 112px;
  }

  .quiz-screen .choice-button {
    min-height: 50px;
  }
}
