:root {
  --bg-app: #edf2f7;
  --bg-paper: #fcfaf5;
  --bg-card: #ffffff;
  --bg-omr: #fbf7f8;
  --ink-primary: #0f172a;
  --ink-secondary: #475569;
  --ink-muted: #64748b;
  --navy: #0f294a;
  --navy-light: #1e4976;
  --navy-tint: #eef5fc;
  --crimson: #b91c1c;
  --crimson-tint: #fef2f2;
  --emerald: #047857;
  --emerald-tint: #ecfdf5;
  --amber: #b45309;
  --amber-tint: #fffbeb;
  --border: #e2e8f0;
  --border-strong: #94a3b8;
  --omr-pink: #d45d6d;
  --omr-fill: #1e293b;
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 12px 32px rgba(15, 23, 42, 0.09);
  --font-sans: "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", sans-serif;
  --font-serif: "Noto Serif JP", "Yu Mincho", "Hiragino Mincho ProN", Georgia, serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: linear-gradient(180deg, #e8eef5 0%, #f1f5f9 100%);
  min-height: 100%;
  color: var(--ink-primary);
  font-family: var(--font-sans);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

/* ---------- Top Header / Portal ---------- */
.portal-header {
  background: linear-gradient(135deg, #0b1f3a 0%, #153e75 55%, #1d4ed8 100%);
  color: #fff;
  padding: 22px 24px;
  border-bottom: 4px solid transparent;
  border-image: linear-gradient(90deg, #b91c1c 0%, #e11d48 55%, #f59e0b 100%) 1;
  box-shadow: 0 6px 24px rgba(11, 31, 58, 0.22);
}

.portal-header-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-badge {
  background: linear-gradient(145deg, #ffffff 0%, #f1f5f9 100%);
  color: #0b1f3a;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 8px 14px;
  border-radius: 8px;
  letter-spacing: 0.1em;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.brand-text h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.brand-text p {
  margin: 3px 0 0;
  font-size: 0.82rem;
  opacity: 0.88;
}

.container {
  max-width: 1120px;
  margin: 28px auto;
  padding: 0 20px 48px;
}

/* ---------- Cards & Controls ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  padding: 26px 28px;
  margin-bottom: 24px;
}

.section-heading {
  margin: 0 0 16px;
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 2px solid var(--navy-tint);
  padding-bottom: 10px;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

@media (max-width: 820px) {
  .level-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.level-card {
  border: 1.5px solid var(--border);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border-radius: 12px;
  padding: 18px 12px;
  text-align: center;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  display: flex;
  flex-direction: column;
  gap: 5px;
  position: relative;
  overflow: hidden;
}

.level-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: transparent;
  transition: background 0.18s ease;
}

.level-card:hover {
  border-color: var(--navy-light);
  transform: translateY(-3px);
  box-shadow: 0 10px 20px rgba(15, 41, 74, 0.1);
}

.level-card.selected {
  border-color: var(--navy);
  background: linear-gradient(180deg, #eef5fc 0%, #ffffff 100%);
  box-shadow: 0 10px 24px rgba(15, 41, 74, 0.14);
}

.level-card.selected::before {
  background: linear-gradient(90deg, #0f294a, #2563eb);
}

.level-code {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: 0.05em;
}

.level-desc {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-secondary);
}

.level-meta {
  font-size: 0.73rem;
  color: var(--ink-muted);
  margin-top: 4px;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 680px) {
  .mode-grid {
    grid-template-columns: 1fr;
  }
}

.mode-card {
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  text-align: left;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.mode-card:hover {
  border-color: var(--navy-light);
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(15, 41, 74, 0.08);
}

.mode-card.selected {
  border-color: var(--navy);
  background: linear-gradient(180deg, #eef5fc 0%, #ffffff 100%);
  box-shadow: 0 8px 20px rgba(15, 41, 74, 0.12);
}

.mode-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--navy);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mode-tag {
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: 99px;
  background: linear-gradient(135deg, #0f294a, #1e4976);
  color: #fff;
}

.mode-card.practice .mode-tag {
  background: linear-gradient(135deg, #047857, #10b981);
}

.mode-desc {
  font-size: 0.84rem;
  color: var(--ink-secondary);
  margin: 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all 0.16s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #0f294a 0%, #1d4ed8 100%);
  color: #fff;
  box-shadow: 0 3px 10px rgba(15, 41, 74, 0.22);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(15, 41, 74, 0.3);
}

.btn-crimson {
  background: linear-gradient(135deg, #991b1b 0%, #dc2626 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(185, 28, 28, 0.28);
}

.btn-crimson:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(185, 28, 28, 0.36);
}

.btn-outline {
  background: #fff;
  color: var(--navy);
  border-color: var(--border-strong);
}

.btn-outline:hover {
  background: var(--navy-tint);
  border-color: var(--navy);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.82rem;
  border-radius: 6px;
}

.btn-lg {
  padding: 14px 34px;
  font-size: 1.04rem;
  border-radius: 10px;
}

/* ---------- Official Exam Notice Box ---------- */
.exam-rules {
  background: var(--bg-paper);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 18px 22px;
  font-family: var(--font-serif);
}

.exam-rules h3 {
  margin: 0 0 10px;
  font-size: 1rem;
  text-align: center;
  border-bottom: 1px solid var(--border-strong);
  padding-bottom: 6px;
}

.exam-rules ol {
  margin: 0;
  padding-left: 20px;
  font-size: 0.88rem;
  line-height: 1.75;
}

.section-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin-top: 12px;
}

.section-table th,
.section-table td {
  border: 1px solid var(--border);
  padding: 9px 12px;
  text-align: left;
}

.section-table th {
  background: var(--navy-tint);
  color: var(--navy);
  font-weight: 600;
}

/* ---------- Exam Room Layout ---------- */
.exam-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.exam-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(11, 31, 58, 0.95);
  backdrop-filter: blur(8px);
  color: #fff;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 4px 16px rgba(11, 31, 58, 0.22);
}

.exam-topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.exam-level-pill {
  background: #fff;
  color: var(--navy);
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 0.9rem;
}

.exam-section-name {
  font-weight: 600;
  font-size: 0.96rem;
}

.exam-mode-pill {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.18);
}

.exam-topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.timer-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.25);
  padding: 5px 12px;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.05rem;
}

.timer-box.warning {
  background: var(--amber);
  color: #fff;
}

.timer-box.danger {
  background: var(--crimson);
  color: #fff;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.78; }
}

.exam-workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
  align-items: start;
}

@media (max-width: 980px) {
  .exam-workspace {
    grid-template-columns: 1fr;
  }
}

/* ---------- Question Booklet (問題用紙) ---------- */
.booklet {
  background: var(--bg-paper);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  box-shadow: var(--shadow-md);
  padding: 32px 36px;
  font-family: var(--font-serif);
}

@media (max-width: 640px) {
  .booklet {
    padding: 20px 16px;
  }
}

.booklet-header {
  border-bottom: 2px solid var(--ink-primary);
  padding-bottom: 12px;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
}

.booklet-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.booklet-sub {
  font-size: 0.85rem;
  color: var(--ink-secondary);
}

.mondai-block {
  margin-bottom: 32px;
}

.mondai-header {
  background: #f0ece3;
  border-left: 5px solid var(--ink-primary);
  padding: 10px 14px;
  margin-bottom: 18px;
  font-size: 0.98rem;
  font-weight: 700;
}

.passage-box {
  background: #fff;
  border: 1px solid var(--border-strong);
  padding: 18px 22px;
  margin-bottom: 20px;
  line-height: 1.95;
  font-size: 1rem;
  white-space: pre-line;
}

.passage-title {
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--navy);
  font-family: var(--font-sans);
  font-size: 0.85rem;
}

.info-notice-box {
  background: #fff;
  border: 2px solid var(--ink-primary);
  padding: 18px 20px;
  margin-bottom: 20px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  line-height: 1.7;
}

.info-notice-box h4 {
  margin: 0 0 10px;
  text-align: center;
  font-size: 1.05rem;
  border-bottom: 1px solid var(--border-strong);
  padding-bottom: 6px;
}

.question-item {
  padding: 16px 0;
  border-bottom: 1px dashed var(--border);
  scroll-margin-top: 76px;
}

.question-item:last-child {
  border-bottom: none;
}

.question-item.active-focus {
  background: rgba(20, 54, 93, 0.035);
  margin: 0 -12px;
  padding: 16px 12px;
  border-radius: 6px;
}

.q-top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.q-number-badge {
  display: inline-block;
  border: 1.5px solid var(--ink-primary);
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 1px 8px;
  margin-right: 10px;
  background: #fff;
}

.q-prompt {
  font-size: 1.05rem;
  line-height: 1.85;
  flex: 1;
}

.q-prompt u {
  text-underline-offset: 4px;
  text-decoration-thickness: 1.5px;
}

.q-flag-btn {
  font-family: var(--font-sans);
  font-size: 0.76rem;
  padding: 3px 9px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--ink-secondary);
  white-space: nowrap;
}

.q-flag-btn.flagged {
  background: var(--amber-tint);
  border-color: var(--amber);
  color: var(--amber);
  font-weight: 600;
}

.choices-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 18px;
  margin-left: 34px;
  margin-top: 8px;
}

@media (max-width: 600px) {
  .choices-grid {
    grid-template-columns: 1fr;
    margin-left: 8px;
  }
}

.choice-btn {
  display: flex;
  align-items: baseline;
  gap: 8px;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 10px;
  font-family: var(--font-serif);
  font-size: 0.98rem;
  color: var(--ink-primary);
  transition: background 0.12s;
}

.choice-btn:hover {
  background: rgba(20, 54, 93, 0.06);
}

.choice-btn.selected {
  background: var(--navy-tint);
  border-color: var(--navy);
  font-weight: 600;
}

.choice-num {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.85rem;
  min-width: 20px;
}

/* ---------- Listening Player ---------- */
.listening-player {
  background: #fff;
  border: 1.5px solid var(--navy);
  border-radius: 8px;
  padding: 14px 16px;
  margin: 10px 0 12px 34px;
  font-family: var(--font-sans);
}

@media (max-width: 600px) {
  .listening-player {
    margin-left: 0;
  }
}

.listening-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.listening-status {
  font-size: 0.84rem;
  color: var(--ink-secondary);
}

.listening-wave {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 16px;
}

.listening-wave span {
  display: inline-block;
  width: 3px;
  height: 6px;
  background: var(--navy);
  border-radius: 2px;
}

.listening-wave.playing span {
  animation: wave 0.8s ease-in-out infinite;
}

.listening-wave.playing span:nth-child(2) { animation-delay: 0.15s; }
.listening-wave.playing span:nth-child(3) { animation-delay: 0.3s; }
.listening-wave.playing span:nth-child(4) { animation-delay: 0.45s; }

@keyframes wave {
  0%, 100% { height: 5px; }
  50% { height: 16px; }
}

.script-toggle-box {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--bg-app);
  border-radius: 6px;
  font-size: 0.85rem;
  white-space: pre-line;
  color: var(--ink-primary);
}

/* ---------- OMR Mark Sheet (マークシート) ---------- */
.omr-panel {
  position: sticky;
  top: 68px;
  background: var(--bg-omr);
  border: 2px solid var(--omr-pink);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.omr-header {
  background: linear-gradient(135deg, #d45d6d 0%, #be4052 100%);
  color: #fff;
  padding: 11px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 0.92rem;
}

.omr-progress {
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.22);
  padding: 2px 8px;
  border-radius: 99px;
}

.omr-legend {
  padding: 8px 14px;
  font-size: 0.74rem;
  color: var(--ink-secondary);
  border-bottom: 1px solid #e7cfd3;
  display: flex;
  justify-content: space-between;
}

.omr-rows {
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  padding: 8px 10px;
}

.omr-group {
  border: 1px solid #eccfd4;
  border-radius: 6px;
  margin-bottom: 10px;
  overflow: hidden;
  background: #fff;
}

.omr-group:last-child {
  margin-bottom: 0;
}

.omr-group-header {
  background: #fbecef;
  color: #9e3141;
  font-weight: 700;
  font-size: 0.78rem;
  padding: 5px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #eccfd4;
}

.omr-group-count {
  font-weight: 600;
  font-size: 0.72rem;
  opacity: 0.85;
}

.omr-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.omr-row:nth-child(even) {
  background: rgba(217, 107, 120, 0.06);
}

.omr-row.flagged {
  background: var(--amber-tint);
}

.omr-q-num {
  font-weight: 700;
  font-size: 0.82rem;
  min-width: 44px;
  color: var(--ink-primary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.omr-bubbles {
  display: flex;
  gap: 10px;
}

.omr-bubble {
  width: 24px;
  height: 30px;
  border-radius: 12px;
  border: 1.5px solid var(--omr-pink);
  background: #fff;
  color: var(--omr-pink);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.1s ease;
}

.omr-bubble:hover {
  border-color: var(--ink-primary);
}

.omr-bubble.marked {
  background: var(--omr-fill);
  border-color: var(--omr-fill);
  color: var(--omr-fill);
  box-shadow: inset 0 0 0 2px #fff;
}

.omr-footer {
  padding: 12px 14px;
  border-top: 1px solid #e7cfd3;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ---------- Score Report (合否結果通知書) ---------- */
.certificate-card {
  background: #fff;
  border: 3px double var(--navy);
  border-radius: 8px;
  padding: 28px 32px;
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
}

.cert-header {
  text-align: center;
  border-bottom: 2px solid var(--navy);
  padding-bottom: 14px;
  margin-bottom: 20px;
}

.cert-header h2 {
  margin: 0;
  color: var(--navy);
  font-size: 1.4rem;
  letter-spacing: 0.08em;
}

.cert-header p {
  margin: 4px 0 0;
  color: var(--ink-secondary);
  font-size: 0.88rem;
}

.result-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 18px 22px;
  border-radius: 8px;
  margin-bottom: 22px;
}

.result-banner.passed {
  background: var(--emerald-tint);
  border: 2px solid var(--emerald);
}

.result-banner.failed {
  background: var(--crimson-tint);
  border: 2px solid var(--crimson);
}

.result-verdict {
  font-size: 1.6rem;
  font-weight: 700;
}

.result-banner.passed .result-verdict { color: var(--emerald); }
.result-banner.failed .result-verdict { color: var(--crimson); }

.total-score-box {
  text-align: right;
}

.total-score-num {
  font-size: 2.1rem;
  font-weight: 700;
  color: var(--navy);
}

.score-bars {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.score-bar-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
  background: var(--bg-paper);
}

.progress-track {
  height: 10px;
  background: #e2e8f0;
  border-radius: 99px;
  overflow: hidden;
  margin: 8px 0;
}

.progress-fill {
  height: 100%;
  background: var(--navy);
  border-radius: 99px;
}

.progress-fill.fail {
  background: var(--crimson);
}

/* ---------- Review List ---------- */
.review-item {
  border: 1px solid var(--border);
  border-left: 5px solid var(--emerald);
  border-radius: 6px;
  padding: 16px 18px;
  margin-bottom: 14px;
  background: #fff;
}

.review-item.wrong {
  border-left-color: var(--crimson);
}

.explanation-box {
  margin-top: 10px;
  padding: 10px 14px;
  background: var(--navy-tint);
  border-radius: 6px;
  font-size: 0.88rem;
  color: var(--ink-primary);
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-box {
  background: #fff;
  border-radius: 8px;
  max-width: 480px;
  width: 100%;
  padding: 24px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
}

.modal-box h3 {
  margin: 0 0 10px;
  color: var(--navy);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* ---------- JLPT Listening Illustrations ---------- */
.jlpt-illus-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 12px 0 14px 34px;
  max-width: 480px;
}

@media (max-width: 600px) {
  .jlpt-illus-grid {
    margin-left: 0;
  }
}

.jlpt-illus-panel {
  border: 1.5px solid var(--ink-primary);
  background: #fff;
  border-radius: 4px;
  padding: 6px 8px 8px;
  position: relative;
  text-align: center;
}

.jlpt-illus-num {
  position: absolute;
  top: 4px;
  left: 6px;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.82rem;
  border: 1px solid var(--ink-primary);
  width: 20px;
  height: 20px;
  line-height: 18px;
  background: #fff;
}

.jlpt-svg {
  width: 100%;
  max-width: 150px;
  height: auto;
  display: block;
  margin: 0 auto;
}

.jlpt-scene-box {
  border: 1.5px solid var(--ink-primary);
  background: #fff;
  border-radius: 4px;
  padding: 10px 12px;
  margin: 12px 0 14px 34px;
  max-width: 360px;
  text-align: center;
}

@media (max-width: 600px) {
  .jlpt-scene-box {
    margin-left: 0;
  }
}

.jlpt-svg-scene {
  width: 100%;
  max-width: 300px;
  height: auto;
  display: block;
  margin: 0 auto;
}

.jlpt-illus-caption {
  font-family: var(--font-sans);
  font-size: 0.76rem;
  color: var(--ink-secondary);
  margin-top: 4px;
}

/* ---------- Mobile Split View (Top: Questions 50% / Bottom: Mark Sheet 50%) ---------- */
.mobile-omr-bar,
.mobile-omr-close,
.mobile-omr-backdrop {
  display: none !important;
}

@media (max-width: 980px) {
  .exam-shell {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .exam-topbar {
    padding: 8px 12px;
    gap: 8px;
  }

  .exam-workspace {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 8px;
    padding: 8px;
    overflow: hidden;
    align-items: stretch;
  }

  .booklet {
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 14px;
    -webkit-overflow-scrolling: touch;
  }

  .omr-panel {
    position: static;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .omr-panel .omr-rows {
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .omr-footer {
    padding: 8px 12px;
  }
}

@media (max-width: 980px) and (orientation: landscape) {
  .exam-workspace {
    grid-template-columns: 1fr 270px;
    grid-template-rows: 1fr;
    gap: 10px;
    padding: 8px 12px;
  }

  .omr-header {
    padding: 8px 12px;
    font-size: 0.85rem;
  }

  .omr-legend {
    padding: 5px 10px;
    font-size: 0.7rem;
  }
}

/* ---------- Print Support ---------- */
@media print {
  .no-print {
    display: none !important;
  }
  body {
    background: #fff;
  }
  .certificate-card {
    box-shadow: none;
  }
}
