* {
  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);
  --level-accent: var(--green);
  --level-accent-rgb: 31, 157, 98;
  --level-soft: #f4fbf6;
  --level-soft-strong: #e8f7ee;
}

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);
}

body[data-level="intermediate"] {
  --level-accent: #237ec7;
  --level-accent-rgb: 35, 126, 199;
  --level-soft: #f0faff;
  --level-soft-strong: #e1f3ff;
  background:
    radial-gradient(circle at top left, rgba(97, 183, 230, 0.18), transparent 34rem),
    linear-gradient(135deg, #f5fbff 0%, #ffffff 48%, #eefaff 100%);
}

body[data-level="advanced"] {
  --level-accent: #c83d3d;
  --level-accent-rgb: 200, 61, 61;
  --level-soft: #fff5f4;
  --level-soft-strong: #ffe8e6;
  background:
    radial-gradient(circle at top left, rgba(227, 92, 69, 0.14), transparent 34rem),
    linear-gradient(135deg, #fff8f7 0%, #ffffff 48%, #fff1ef 100%);
}

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, var(--level-soft));
  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;
}

.app-header h1 .title-level {
  color: var(--level-accent);
}

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;
}

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

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

.level-cover-art {
  background:
    linear-gradient(90deg, rgba(35, 126, 199, 0.08) 0 24%, transparent 24%),
    repeating-linear-gradient(0deg, transparent 0 30px, rgba(36, 48, 68, 0.08) 30px 31px),
    var(--paper);
}

.level-picker {
  display: grid;
  gap: 12px;
  max-width: 560px;
  margin: 18px auto 0;
}

.level-option {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 14px;
  min-height: 72px;
  padding: 14px 16px;
  border: 2px solid #d7e2ef;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.level-option.completed {
  background: #fbfdfb;
  padding-right: 38px;
}

.level-option.completed::after {
  content: "🏅";
  position: absolute;
  top: 7px;
  right: 10px;
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  overflow: visible;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  font-size: 16px;
  line-height: 22px;
  opacity: 0.76;
}

.level-option:hover {
  border-color: var(--level-accent);
  background: var(--level-soft);
}

.level-option span {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.level-option strong {
  font-size: clamp(22px, 5vw, 30px);
  line-height: 1.1;
}

.level-option b {
  color: var(--level-accent);
}

.level-option em {
  justify-self: end;
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  font-weight: 900;
  white-space: nowrap;
}

.level-option.beginner {
  --level-accent: var(--green);
  border-color: rgba(31, 157, 98, 0.32);
}

.level-option.intermediate {
  --level-accent: #237ec7;
  border-color: rgba(35, 126, 199, 0.32);
}

.level-option.advanced {
  --level-accent: #c83d3d;
  border-color: rgba(200, 61, 61, 0.32);
}

.block-composition-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 14px;
  min-height: 58px;
  padding: 12px 16px;
  border: 2px solid rgba(224, 169, 40, 0.26);
  border-radius: 8px;
  background: linear-gradient(180deg, #fffefa, #fff8dc);
  color: var(--ink);
  text-align: left;
  text-decoration: none;
}

.block-composition-link:hover {
  border-color: rgba(224, 169, 40, 0.48);
  background: #fff5cf;
}

.block-composition-link span {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.block-composition-link strong {
  font-size: 22px;
  line-height: 1.1;
}

.block-composition-link em {
  justify-self: end;
  color: #9a7418;
  font-size: 13px;
  font-style: normal;
  font-weight: 900;
  white-space: nowrap;
}

.placement-test-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 12px;
  width: min(560px, 100%);
  min-height: 56px;
  margin: 14px auto 0;
  padding: 12px 14px;
  border: 2px solid rgba(224, 169, 40, 0.28);
  border-radius: 8px;
  background: linear-gradient(180deg, #fffdf5, #fff5cf);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.placement-test-button:hover {
  border-color: rgba(224, 169, 40, 0.48);
  background: linear-gradient(180deg, #fffbea, #fff0bb);
}

.placement-test-button span {
  font-size: 18px;
  font-weight: 950;
}

.placement-test-button strong {
  color: #9a6b06;
  font-size: 13px;
  white-space: nowrap;
}

.dashboard-level-tools {
  display: flex;
  justify-content: flex-end;
  max-width: 430px;
  margin: -6px auto 12px;
}

.compact-button {
  min-width: 0;
  min-height: 36px;
  padding: 7px 12px;
  font-size: 13px;
  line-height: 1;
}

.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;
}

.eiken-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: min(100%, 430px);
  margin: -2px auto 14px;
}

.eiken-summary > div {
  display: grid;
  gap: 3px;
  padding: 10px 12px 22px;
  border: 1px solid rgba(var(--level-accent-rgb), 0.18);
  border-radius: 8px;
  background: var(--level-soft);
  text-align: center;
}

.eiken-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.eiken-summary strong {
  color: var(--level-accent);
  font-size: 20px;
  line-height: 1.2;
}

.total-score {
  width: min(100%, 430px);
  padding: 14px 16px;
  border: 2px solid rgba(var(--level-accent-rgb), 0.18);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, var(--level-soft));
}

.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(--level-accent);
  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(--level-accent);
  text-align: right;
  white-space: nowrap;
}

.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(--level-accent), var(--teal));
  transition: width 0.2s ease;
}

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

.progress-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.progress-foot p:last-child {
  text-align: right;
}

.dashboard-start-button {
  margin-bottom: 16px;
}

.special-test-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 8px;
}

.special-test-button {
  position: relative;
  min-height: 58px;
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 10px 12px;
  border: 2px solid rgba(45, 95, 160, 0.22);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, var(--level-soft) 100%);
  box-shadow: 0 8px 18px rgba(36, 48, 68, 0.08);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

#reviewTestButton {
  border-color: rgba(238, 116, 96, 0.42);
  background: linear-gradient(180deg, #ffffff 0%, #fff3ef 100%);
}

.special-test-button:hover {
  border-color: var(--level-accent);
  box-shadow: 0 10px 22px rgba(36, 48, 68, 0.12);
  transform: translateY(-1px);
}

#reviewTestButton:hover {
  border-color: var(--red);
}

.special-test-button span {
  font-size: 16px;
  font-weight: 950;
}

.special-test-button strong {
  color: var(--level-accent);
  font-size: 12px;
  line-height: 1.25;
}

.special-test-button em {
  position: absolute;
  right: 10px;
  bottom: 7px;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
  line-height: 1;
}

.special-test-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
  box-shadow: none;
}

.dashboard-section-title {
  display: block;
  width: 100%;
  margin: 0 0 14px;
  text-align: left;
}

.unit-section {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  text-align: left;
}

.unit-placeholder {
  padding: 18px;
  border: 1px dashed #cdd9ea;
  border-radius: 8px;
  background: var(--level-soft);
  color: var(--muted);
  font-weight: 900;
  text-align: center;
}

.unit-section h3 {
  margin: 0;
  font-size: 18px;
}

#unitSectionTitle {
  margin: 0;
  text-align: left;
}

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

.unit-option {
  position: relative;
  min-height: 64px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 4px 10px;
  padding: 12px 14px;
  border: 2px solid #cdd9ea;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.unit-option.completed,
.set-option.completed {
  border-color: rgba(31, 157, 98, 0.34);
  background: #f4fbf6;
  padding-right: 34px;
}

.unit-option.locked,
.set-option.locked {
  border-color: #d9dee7;
  background: #f5f6f8;
  color: #8b94a3;
  cursor: not-allowed;
  opacity: 0.72;
}

.unit-option.locked strong,
.unit-option.locked span,
.unit-option.locked b,
.unit-option.locked em,
.set-option.locked strong,
.set-option.locked span,
.set-option.locked b,
.set-option.locked em {
  color: #8b94a3;
}

.unit-option.locked:hover,
.set-option.locked:hover {
  border-color: #d9dee7;
  background: #f5f6f8;
}

.unit-option.completed::after,
.set-option.completed::after {
  content: "🏅";
  position: absolute;
  top: 4px;
  right: 8px;
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  overflow: visible;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  font-size: 15px;
  line-height: 22px;
  opacity: 0.78;
}

.unit-option strong {
  font-size: 22px;
  white-space: nowrap;
}

.unit-option span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-align: right;
  white-space: nowrap;
}

.unit-option b,
.set-option b {
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.unit-option em {
  grid-column: 1 / -1;
  color: var(--blue);
  font-size: 13px;
  font-style: normal;
  font-weight: 900;
}

.unit-option:hover {
  border-color: var(--blue);
  background: #f4f9ff;
}

.ranking-section {
  display: grid;
  gap: 12px;
  margin: 8px 0 18px;
  text-align: left;
}

.ranking-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.ranking-section-head h1 {
  flex: 0 0 auto;
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  white-space: nowrap;
}

.ranking-section-head h1 b {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.ranking-section h3 {
  margin: 0;
  font-size: 18px;
}

.ranking-section-head p {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: right;
}

.ranking-section-head p.warning {
  color: var(--red);
}

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

.ranking-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.challenge-ranking-card {
  grid-column: 1 / -1;
  background: #ffffff;
  border-color: #cdd9ea;
}

.ranking-card h4 {
  margin: 0 0 10px;
  color: var(--blue);
  font-size: 14px;
}

.ranking-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.ranking-card-head h4 {
  margin-bottom: 0;
}

.ranking-card-head label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.ranking-card-head select {
  min-width: 80px;
  padding: 6px 24px 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  font: inherit;
  font-weight: 900;
}

.ranking-card ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ranking-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px;
  border: 1px solid rgba(36, 48, 68, 0.08);
  border-radius: 8px;
  background: #ffffff;
}

.ranking-rank {
  color: var(--coral);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.ranking-profile {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.ranking-profile strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-profile small {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-value {
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.ranking-empty {
  padding: 10px;
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.challenge-chart-card {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.challenge-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.challenge-chart-head h4 {
  margin: 0;
  color: var(--blue);
  font-size: 14px;
}

.challenge-chart-head label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.challenge-chart-head select {
  min-width: 94px;
  padding: 6px 26px 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  font: inherit;
  font-weight: 900;
}

.challenge-score-chart {
  min-height: 170px;
  overflow: hidden;
  border: 1px solid rgba(36, 48, 68, 0.08);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}

.challenge-score-chart svg {
  display: block;
  width: 100%;
  height: 170px;
}

.chart-grid-line {
  stroke: rgba(36, 48, 68, 0.12);
  stroke-width: 1;
}

.chart-grid-line.is-major {
  stroke: rgba(36, 48, 68, 0.28);
  stroke-width: 1.25;
}

.chart-axis-label,
.chart-point-label {
  fill: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.chart-line {
  fill: none;
  stroke: var(--blue);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.chart-line.is-review {
  stroke: var(--red);
}

.chart-point {
  fill: #ffffff;
  stroke: var(--blue);
  stroke-width: 2;
}

.chart-point.is-review {
  stroke: var(--red);
}

.chart-bar {
  fill: var(--blue);
  opacity: 0.86;
}

.chart-bar.is-review {
  fill: var(--red);
}

.chart-legend {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.chart-empty-message {
  display: grid;
  min-height: 170px;
  place-items: center;
  padding: 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  text-align: center;
}

.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);
}

.dashboard-cover-art {
  height: 118px;
  margin-bottom: 14px;
}

.dashboard-cover-art .tile {
  transform-origin: center;
}

.dashboard-cover-art .tile-a {
  top: 18px;
}

.dashboard-cover-art .tile-b {
  top: 38px;
}

.dashboard-cover-art .tile-c {
  bottom: 14px;
}

.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: 1fr;
  gap: 10px;
  max-width: 680px;
  margin: 0 auto 22px;
}

.set-option {
  position: relative;
  min-height: 48px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border: 2px solid #cdd9ea;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
}

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

.set-option span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.set-option em {
  color: var(--blue);
  font-size: 13px;
  font-style: normal;
  font-weight: 900;
  text-align: right;
  white-space: nowrap;
}

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

.set-option.completed.active {
  border-color: var(--blue);
  background: linear-gradient(180deg, #eef6ff, #f4fbf6);
}

.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);
}

.primary-button:disabled,
.primary-button.disabled {
  background: #aeb8c7;
  box-shadow: 0 8px 0 #808b99;
  cursor: not-allowed;
  transform: none;
}

.empty-unit-message {
  margin-top: -4px;
  color: var(--muted);
  font-weight: 900;
}

.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 {
  width: 100%;
  overflow-wrap: normal;
  word-break: normal;
  white-space: nowrap;
  text-align: center;
  color: var(--ink);
  font-size: clamp(38px, 8vw, 68px);
  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(52vw, 178px);
  height: min(52vw, 178px);
  margin: 6px auto 12px;
  display: grid;
  place-items: center;
  align-content: center;
  border: 10px 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: 28px;
}

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

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

.score-breakdown div {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.score-breakdown span {
  display: inline;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.score-breakdown strong {
  color: var(--ink);
  font-size: 18px;
  white-space: nowrap;
}

.save-status {
  min-height: 18px;
  margin: 0 auto 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.save-status.saved {
  color: var(--green);
}

.save-status.warning {
  color: var(--red);
}

.result-screen #resultMessage {
  margin-bottom: 12px;
  font-size: 15px;
  line-height: 1.55;
}

.review-list {
  display: grid;
  gap: 6px;
  max-width: 520px;
  max-height: 132px;
  overflow-y: auto;
  margin: 0 auto 12px;
  text-align: left;
}

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

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

.result-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  justify-content: center;
  gap: 8px;
  max-width: 520px;
  margin: 0 auto;
}

.result-actions .primary-button,
.result-actions .secondary-button {
  min-width: 0;
  min-height: 42px;
  padding: 9px 10px;
  font-size: 14px;
  line-height: 1.2;
}

.result-actions .primary-button {
  box-shadow: none;
}

.result-actions .primary-button:hover,
.result-actions .primary-button:active {
  box-shadow: none;
  transform: none;
}

.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,
  .level-screen,
  .dashboard-screen,
  .start-screen,
  .quiz-screen,
  .result-screen {
    padding-left: 18px;
    padding-right: 18px;
  }

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

  .level-option {
    min-height: 64px;
    padding: 12px;
  }

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

  .eiken-summary {
    gap: 8px;
    margin-bottom: 10px;
  }

  .eiken-summary > div {
    padding: 8px 9px;
  }

  .eiken-summary strong {
    font-size: 17px;
  }

  .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;
  }

  .ranking-section-head {
    display: grid;
    gap: 4px;
    text-align: left;
  }

  .ranking-section-head p {
    text-align: left;
  }

  .ranking-grid {
    grid-template-columns: 1fr;
  }

  .challenge-chart-head {
    align-items: stretch;
    flex-direction: column;
  }

  .challenge-chart-head label {
    justify-content: space-between;
  }

  .challenge-chart-head select {
    min-width: 118px;
  }

  .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(30px, 8.5vw, 42px);
  }

  .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;
  }

  .set-option {
    min-height: 44px;
    grid-template-columns: auto minmax(54px, 1fr) auto auto;
    gap: 6px;
    padding: 8px 9px;
  }

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

  .set-option span {
    font-size: 11px;
  }

  .set-option em {
    font-size: 12px;
  }

  .unit-option b,
  .set-option b {
    font-size: 12px;
  }

  .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;
  }

  .dashboard-start-button {
    margin-bottom: 10px;
  }

  .special-test-panel {
    gap: 7px;
    margin-bottom: 6px;
  }

  .special-test-button {
    min-height: 50px;
    padding: 8px 9px 20px;
  }

  .special-test-button span {
    font-size: 13px;
  }

  .special-test-button strong {
    font-size: 11px;
  }

  .unit-section {
    gap: 8px;
    margin-bottom: 12px;
  }

  .unit-section h3 {
    font-size: 16px;
  }

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

  .unit-option {
    min-height: 54px;
    padding: 9px 11px;
  }

  .unit-option strong {
    font-size: 20px;
  }

  .unit-option em {
    font-size: 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: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .score-breakdown div {
    min-height: 38px;
    padding: 7px 8px;
  }

  .score-breakdown span {
    font-size: 11px;
  }

  .score-breakdown strong {
    font-size: 16px;
  }

  .result-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .result-actions .primary-button,
  .result-actions .secondary-button {
    width: 100%;
    min-height: 38px;
    padding: 8px 6px;
    font-size: 12px;
  }
}

@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;
  }

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

  .result-screen .eyebrow {
    margin-bottom: 2px;
  }

  .result-screen h2 {
    margin-bottom: 6px;
    font-size: 20px;
  }

  .score-ring {
    width: min(40vw, 122px);
    height: min(40vw, 122px);
    margin-bottom: 8px;
    border-width: 8px;
  }

  .score-ring strong {
    font-size: 22px;
  }

  .score-ring span {
    font-size: 12px;
  }

  .result-screen #resultMessage {
    margin-bottom: 8px;
    font-size: 13px;
    line-height: 1.45;
  }

  .review-list {
    max-height: 92px;
    margin-bottom: 8px;
  }

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

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

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

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

  .dashboard-start-button {
    margin-bottom: 8px;
  }

  .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;
  }
}
