:root {
  color-scheme: light;
  --navy: #35104f;
  --navy-2: #551268;
  --teal: #db176d;
  --teal-dark: #a80d5d;
  --teal-soft: #fff0f7;
  --gold: #f3ad2b;
  --ink: #2c183c;
  --muted: #71657c;
  --line: #e3d9e8;
  --surface: #ffffff;
  --page: #f8f4fa;
  --correct: #177245;
  --correct-soft: #e9f7ef;
  --wrong: #b42318;
  --wrong-soft: #fdefed;
  --shadow: 0 20px 55px rgba(53, 16, 79, 0.13);
  font-family: "Noto Sans JP", "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--page); }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 8%, rgba(219, 23, 109, 0.09), transparent 24rem),
    radial-gradient(circle at 92% 18%, rgba(243, 173, 43, 0.08), transparent 20rem),
    linear-gradient(180deg, #fdfbfe 0%, var(--page) 100%);
  min-height: 100vh;
}

button, select { font: inherit; }
button { touch-action: manipulation; }

.skip-link {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 10;
  padding: 0.7rem 1rem;
  background: white;
  color: var(--navy);
  border-radius: 0.6rem;
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

.topbar {
  min-height: 7.4rem;
  padding: 0.75rem clamp(1rem, 4vw, 3rem);
  display: grid;
  grid-template-columns: minmax(9rem, 1fr) auto minmax(9rem, 1fr);
  align-items: center;
  gap: 1rem;
  background: linear-gradient(118deg, #ffd9ec 0%, #f2dcff 50%, #dfd2ff 100%);
  color: var(--navy);
  border-bottom: 4px solid transparent;
  border-image: linear-gradient(90deg, #f3ad2b, #db176d, #7e43a7) 1;
  box-shadow: 0 7px 24px rgba(83, 34, 112, 0.14);
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--navy);
  text-decoration: none;
}
.brand-logo {
  width: 6.15rem;
  height: 6.15rem;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(64, 12, 83, 0.16));
}

.header-date {
  margin: 0;
  color: #54116f;
  font-size: 0.9rem;
  font-weight: 850;
  line-height: 1.4;
}

.topbar-stats {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem;
}

.menu-button {
  min-height: 2.55rem;
  padding: 0.5rem 0.8rem;
  border: 1px solid rgba(83,18,104,0.18);
  border-radius: 999px;
  background: #fff;
  color: var(--navy);
  font-weight: 850;
  cursor: pointer;
}
.account-menu {
  position: absolute;
  top: calc(100% + 0.65rem);
  right: 0;
  z-index: 50;
  width: min(18rem, calc(100vw - 2rem));
  padding: 0.6rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: white;
  box-shadow: var(--shadow);
}
.account-menu p { margin: 0; padding: 0.6rem 0.7rem; color: var(--muted); font-size: 0.78rem; overflow-wrap: anywhere; }
.account-menu a, .account-menu button {
  width: 100%; display: block; padding: 0.72rem; border: 0; border-radius: 0.65rem; background: transparent;
  color: var(--ink); text-align: left; text-decoration: none; font-weight: 750; cursor: pointer;
}
.account-menu a:hover, .account-menu button:hover { background: var(--teal-soft); color: var(--teal-dark); }

.visitor-chip {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  padding: 0.55rem 0.8rem;
  border: 1px solid rgba(83,18,104,0.16);
  border-radius: 999px;
  background: rgba(255,255,255,0.56);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
  white-space: nowrap;
}
.visitor-chip strong { font-size: 0.83rem; }
.visitor-chip span, .visitor-chip small { color: #704d7d; font-size: 0.75rem; }

.score-chip {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  padding: 0.55rem 0.85rem;
  border: 1px solid rgba(83,18,104,0.16);
  border-radius: 999px;
  background: rgba(255,255,255,0.56);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
}
.score-chip span { font-size: 0.78rem; color: #704d7d; }
.score-chip strong { font-size: 1rem; }

.shell {
  width: min(100% - 2rem, 900px);
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 4rem) 0 3rem;
}

.personal-greeting {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid #e4c5df;
  border-radius: 0.9rem;
  background: linear-gradient(135deg, #ffe7f2, #eee2ff);
  color: var(--navy);
  font-size: 1rem;
  font-weight: 850;
  text-align: center;
}
.level-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.7rem;
  margin-bottom: 1.75rem;
}
.level-tab {
  min-height: 3.25rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid #d9cbe1;
  border-radius: 0.85rem;
  background: white;
  color: var(--navy);
  font-size: 1rem;
  font-weight: 900;
  cursor: pointer;
}
.level-tab.active {
  border-color: var(--teal);
  background: linear-gradient(135deg, #ffdaeb, #e9d9ff);
  color: var(--teal-dark);
  box-shadow: inset 0 0 0 1px var(--teal), 0 8px 20px rgba(83,18,104,0.1);
}

.practice-overview {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.7rem;
  margin: -0.8rem 0 1.75rem;
}
.practice-overview div {
  display: grid;
  gap: 0.2rem;
  min-height: 5.25rem;
  align-content: center;
  padding: 0.85rem 1rem;
  border: 1px solid #e1d3e8;
  border-radius: 0.85rem;
  background: rgba(255,255,255,0.78);
  box-shadow: 0 8px 22px rgba(53,16,79,0.06);
}
.practice-overview strong { color: var(--navy); font-size: 0.92rem; }
.practice-overview span { color: var(--muted); font-size: 0.78rem; line-height: 1.4; }

.study-materials {
  margin: 0 0 2.2rem;
  padding: clamp(1.1rem, 3vw, 1.6rem);
  border: 1px solid #dfcbe9;
  border-radius: 1.2rem;
  background: linear-gradient(135deg, rgba(255,255,255,0.96), rgba(249,235,255,0.92));
  box-shadow: 0 14px 34px rgba(53,16,79,0.09);
}
.materials-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.materials-heading h2 { margin: 0; color: var(--navy); font-size: clamp(1.3rem, 3vw, 1.75rem); }
.materials-badge { padding: 0.45rem 0.75rem; border-radius: 999px; background: var(--navy); color: white; font-size: 0.78rem; font-weight: 850; white-space: nowrap; }
.materials-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.85rem; }
.material-card { display: grid; grid-template-columns: 3.4rem 1fr; gap: 0.9rem; min-width: 0; padding: 1rem; border: 1px solid #e6d9ec; border-radius: 0.95rem; background: white; }
.material-icon { width: 3.4rem; height: 3.4rem; display: grid; place-items: center; border-radius: 0.8rem; background: #ffe2ef; color: var(--teal-dark); font-size: 0.85rem; font-weight: 950; }
.cards-icon { background: #eee1ff; color: var(--navy-2); font-size: 1.65rem; }
.material-card h3 { margin: 0; color: var(--navy); font-size: 1rem; line-height: 1.35; }
.material-card p { margin: 0.4rem 0 0.85rem; color: var(--muted); font-size: 0.86rem; line-height: 1.55; }
.material-link { width: fit-content; min-height: 2.65rem; display: inline-flex; align-items: center; justify-content: center; padding: 0.58rem 0.9rem; text-decoration: none; font-size: 0.86rem; }
.locked-button { border: 1px solid #d5c8dc; border-radius: 0.7rem; background: #f2edf4; color: #6e6174; font-weight: 800; cursor: not-allowed; }
.materials-note { margin: 0.9rem 0 0; color: #644b70; font-size: 0.8rem; line-height: 1.5; }

.exam-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 1.5rem;
}
.eyebrow {
  margin: 0 0 0.4rem;
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}
h1 { margin: 0; font-size: clamp(1.65rem, 4vw, 2.45rem); line-height: 1.16; }
.exam-meta { margin: 0.65rem 0 0; color: var(--muted); font-size: 0.95rem; }

.day-picker { display: grid; gap: 0.35rem; min-width: 10rem; color: var(--muted); font-size: 0.8rem; font-weight: 700; }
.day-picker select {
  width: 100%;
  min-height: 2.8rem;
  padding: 0 2.3rem 0 0.85rem;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  background: white;
  color: var(--ink);
}

.category-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.55rem;
  margin: -0.25rem 0 1.15rem;
}
.category-tab {
  min-height: 2.8rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid #d9cbe1;
  border-radius: 0.75rem;
  background: rgba(255,255,255,0.86);
  color: var(--navy);
  font-weight: 850;
  cursor: pointer;
}
.category-tab.active { border-color: var(--teal); background: linear-gradient(135deg, #ffe5f1, #efe1ff); color: var(--teal-dark); box-shadow: inset 0 0 0 1px var(--teal); }

.share-panel {
  margin: -0.35rem 0 1.4rem;
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  background: rgba(255,255,255,0.78);
}
.share-panel summary {
  padding: 0.85rem 1rem;
  color: var(--navy);
  font-weight: 800;
  cursor: pointer;
}
.share-panel summary span {
  margin-left: 0.45rem;
  color: var(--teal-dark);
  font-size: 0.85rem;
  font-weight: 650;
}
.share-content {
  display: grid;
  grid-template-columns: 10rem 1fr;
  gap: 1.25rem;
  align-items: center;
  padding: 0 1rem 1rem;
}
.share-content img {
  width: 10rem;
  height: 10rem;
  padding: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  background: white;
}
.share-content a { color: var(--teal-dark); overflow-wrap: anywhere; }
.share-note { margin: 0.55rem 0 0; color: var(--muted); font-size: 0.88rem; line-height: 1.5; }
.share-actions { display: flex; flex-wrap: wrap; gap: 0.65rem; margin-top: 0.9rem; }
.secondary-link {
  min-height: 3rem;
  display: inline-flex;
  align-items: center;
  padding: 0.65rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: white;
  color: var(--ink) !important;
  font-weight: 800;
  text-decoration: none;
}
.share-status { min-height: 1.2rem; margin: 0.5rem 0 0; color: var(--teal-dark); font-size: 0.82rem; }

.security-strip {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: -0.35rem 0 1.35rem;
  padding: 0.72rem 0.9rem;
  border: 1px solid #edc8d9;
  border-radius: 0.8rem;
  background: #fff5f9;
  color: #6b1744;
  font-size: 0.84rem;
  line-height: 1.45;
}
.security-icon { color: var(--gold); font-size: 0.75rem; }
.welcome-security { margin: 1rem 0 0.75rem; text-align: left; }
.daily-bank-note { margin: 0.75rem 0; padding: 0.75rem 0.85rem; border-radius: 0.7rem; background: #f4eaff; color: #4d2a61; text-align: left; font-size: 0.88rem; }

.security-notice {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 30;
  width: min(26rem, calc(100% - 2rem));
  padding: 0.9rem 1rem;
  border: 1px solid #ff9fc4;
  border-left: 4px solid var(--teal);
  border-radius: 0.8rem;
  background: #35104f;
  color: white;
  box-shadow: 0 14px 35px rgba(53, 16, 79, 0.28);
  font-size: 0.88rem;
  line-height: 1.45;
}

.progress-panel { margin-bottom: 1rem; }
.progress-copy { display: flex; justify-content: space-between; margin-bottom: 0.5rem; color: var(--muted); font-size: 0.82rem; font-weight: 700; }
.progress-track { height: 0.55rem; overflow: hidden; border-radius: 99px; background: #dce6ed; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--navy-2), var(--teal), var(--gold)); transition: width 240ms ease; }

.quiz-card {
  position: relative;
  overflow: hidden;
  padding: clamp(1.25rem, 4vw, 2.4rem);
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.quiz-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 0.35rem;
  background: linear-gradient(var(--teal), var(--gold));
  z-index: 2;
}
.quiz-card::after {
  content: "JDEE JAPAN";
  position: absolute;
  right: -1.6rem;
  bottom: 2.5rem;
  z-index: 0;
  color: var(--navy);
  font-size: clamp(2.4rem, 9vw, 5rem);
  font-weight: 950;
  letter-spacing: 0.08em;
  opacity: 0.035;
  transform: rotate(-16deg);
  pointer-events: none;
  white-space: nowrap;
}
.quiz-card > * { position: relative; z-index: 1; }
.quiz-card h2,
.quiz-card .option-label,
.quiz-card .hint-panel,
.quiz-card .feedback {
  -webkit-user-select: none;
  user-select: none;
}
.question-topline { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.category-pill { display: inline-flex; padding: 0.4rem 0.7rem; border-radius: 999px; background: var(--teal-soft); color: var(--teal-dark); font-size: 0.75rem; font-weight: 900; letter-spacing: 0.09em; }
.text-button { padding: 0.45rem 0; border: 0; background: transparent; color: var(--teal-dark); font-size: 0.86rem; font-weight: 750; cursor: pointer; text-decoration: underline; text-underline-offset: 0.2rem; }
.question-number { margin: 1.6rem 0 0.55rem; color: var(--muted); font-size: 0.78rem; font-weight: 850; letter-spacing: 0.12em; }
h2 { margin: 0; font-size: clamp(1.2rem, 3vw, 1.65rem); line-height: 1.7; font-weight: 750; }

.hint-panel {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border-left: 3px solid var(--gold);
  background: #fff9e9;
  color: #68501a;
  border-radius: 0 0.65rem 0.65rem 0;
  font-size: 0.94rem;
  line-height: 1.55;
}

.options { display: grid; gap: 0.8rem; margin-top: 1.6rem; }
.option {
  width: 100%;
  min-height: 3.5rem;
  display: grid;
  grid-template-columns: 2.2rem 1fr auto;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--line);
  border-radius: 0.85rem;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}
.option:hover:not(:disabled) { border-color: var(--teal); transform: translateY(-1px); }
.option:focus-visible, button:focus-visible, select:focus-visible { outline: 3px solid rgba(219,23,109,0.3); outline-offset: 2px; }
.option:disabled { cursor: default; opacity: 1; }
.option-letter { width: 2.1rem; height: 2.1rem; display: grid; place-items: center; border-radius: 0.55rem; background: #edf2f6; font-weight: 850; }
.option-label { font-size: 1rem; line-height: 1.5; }
.option-reading { display: block; margin-top: 0.12rem; color: #6d4c7d; font-size: 0.78rem; font-weight: 650; }
.option-status { font-size: 0.78rem; font-weight: 800; }
.option.correct { border-color: var(--correct); background: var(--correct-soft); }
.option.correct .option-letter { background: var(--correct); color: white; }
.option.wrong { border-color: var(--wrong); background: var(--wrong-soft); }
.option.wrong .option-letter { background: var(--wrong); color: white; }

.feedback {
  margin-top: 1.25rem;
  padding: 1.15rem;
  border-radius: 0.9rem;
  border: 1px solid;
  line-height: 1.6;
}
.feedback.correct-feedback { background: var(--correct-soft); border-color: #9ad2b3; }
.feedback.wrong-feedback { background: var(--wrong-soft); border-color: #e8aaa3; }
.feedback h3 { margin: 0 0 0.45rem; font-size: 1.05rem; }
.feedback p { margin: 0.3rem 0; }
.feedback .correct-answer { font-weight: 800; }
.feedback .selected-note { color: var(--muted); font-size: 0.9rem; }
.translation { margin: 0.75rem 0; padding: 0.75rem 0.85rem; border-radius: 0.7rem; background: rgba(255,255,255,0.72); }
.translation strong { color: var(--teal-dark); font-size: 0.76rem; letter-spacing: 0.06em; text-transform: uppercase; }
.translation p { margin: 0.25rem 0 0; }
.answer-reading { color: #6d4c7d; font-weight: 650; }

.modal {
  width: min(36rem, calc(100% - 2rem));
  max-height: calc(100vh - 2rem);
  overflow: auto;
  padding: clamp(1.25rem, 4vw, 2rem);
  border: 1px solid #d7c2e3;
  border-radius: 1.15rem;
  background: linear-gradient(145deg, #fff, #fff7fb);
  color: var(--ink);
  box-shadow: 0 28px 80px rgba(53,16,79,0.28);
}
.modal::backdrop { background: rgba(35,15,47,0.58); backdrop-filter: blur(3px); }
.modal h1, .modal h2 { margin: 0 2rem 0.7rem 0; }
.modal p, .modal li { line-height: 1.6; }
.modal-close { position: absolute; top: 0.7rem; right: 0.8rem; width: 2.5rem; height: 2.5rem; border: 0; border-radius: 50%; background: #f2e5fa; color: var(--navy); font-size: 1.5rem; cursor: pointer; }
.welcome-modal { text-align: center; }
.welcome-modal ol { display: inline-block; margin: 0.5rem auto; padding-left: 1.35rem; text-align: left; }
.welcome-logo { width: 6rem; height: 6rem; object-fit: contain; }
.modal-note { color: var(--muted); font-size: 0.88rem; }
.modal-action { width: 100%; margin-top: 0.75rem; }
.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 0; }
.setting-row span, .setting-row small { display: block; }
.setting-row small { margin-top: 0.3rem; color: var(--muted); line-height: 1.4; }
.setting-row input { width: 2.8rem; height: 1.5rem; accent-color: var(--teal); }
#report-form { display: grid; gap: 1rem; }
#report-form label { display: grid; gap: 0.35rem; font-weight: 750; }
#report-form select, #report-form textarea { width: 100%; padding: 0.75rem; border: 1px solid var(--line); border-radius: 0.7rem; background: white; color: var(--ink); }

.quiz-actions { display: flex; justify-content: space-between; gap: 0.8rem; margin-top: 1.6rem; }
.primary-button, .secondary-button {
  min-height: 3rem;
  padding: 0.65rem 1.15rem;
  border-radius: 0.75rem;
  font-weight: 800;
  cursor: pointer;
}
.primary-button { border: 1px solid var(--teal); background: var(--teal); color: white; }
.primary-button:hover:not(:disabled) { background: var(--teal-dark); }
.primary-button:disabled { border-color: #cbd7df; background: #dfe7ec; color: #8292a0; cursor: not-allowed; }
.secondary-button { border: 1px solid var(--line); background: white; color: var(--ink); }
.secondary-button:disabled { opacity: 0.45; cursor: not-allowed; }
.keyboard-note { margin: 1rem 0 0; color: var(--muted); font-size: 0.8rem; text-align: center; }

.summary { text-align: center; }
.summary-score { width: 8rem; height: 8rem; margin: 1rem auto 1.3rem; display: grid; place-items: center; border: 0.65rem solid var(--teal-soft); outline: 0.2rem solid var(--teal); border-radius: 50%; color: var(--navy); }
.summary-score strong { display: block; font-size: 2rem; }
.summary-score span { display: block; color: var(--muted); font-size: 0.78rem; }
.breakdown { width: min(100%, 32rem); margin: 1.5rem auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.7rem; }
.breakdown div { padding: 0.8rem 0.5rem; border: 1px solid var(--line); border-radius: 0.75rem; background: var(--page); }
.breakdown strong, .breakdown span { display: block; }
.breakdown span { margin-top: 0.2rem; color: var(--muted); font-size: 0.78rem; }
.study-advice {
  width: min(100%, 38rem);
  margin: 1.35rem auto 0;
  padding: 1rem 1.1rem;
  border: 1px solid #ddc5eb;
  border-left: 4px solid var(--teal);
  border-radius: 0.85rem;
  background: linear-gradient(135deg, #fff5fa, #f5ebff);
  text-align: left;
}
.study-advice h3 { margin: 0 0 0.55rem; color: var(--navy); font-size: 1.08rem; }
.study-advice p { margin: 0.35rem 0; line-height: 1.55; }
.summary-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 0.8rem; margin-top: 1.3rem; }

footer { width: min(100% - 2rem, 900px); margin: 0 auto; padding: 0 0 2rem; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 1rem; color: var(--muted); font-size: 0.76rem; }

@media (max-width: 640px) {
  .practice-overview { grid-template-columns: 1fr; }
  .practice-overview div { min-height: 0; }
  .topbar {
    min-height: 6.5rem;
    grid-template-columns: 1fr auto 1fr;
    gap: 0.45rem;
    padding-inline: 0.7rem;
  }
  .brand-logo { width: 5rem; height: 5rem; }
  .header-date { font-size: 0.68rem; }
  .score-chip span { display: none; }
  .score-chip { display: none; }
  .visitor-chip { display: grid; gap: 0; padding: 0.42rem 0.65rem; }
  .visitor-chip span { display: none; }
  .visitor-chip strong, .visitor-chip small { font-size: 0.68rem; }
  .exam-header { display: grid; gap: 1.2rem; }
  .day-picker { width: 100%; }
  .menu-button { padding-inline: 0.65rem; font-size: 0.78rem; }
  .category-tabs { grid-template-columns: repeat(2, 1fr); }
  .level-tabs { gap: 0.45rem; }
  .level-tab { min-height: 2.9rem; padding-inline: 0.45rem; font-size: 0.88rem; }
  .quiz-card { border-radius: 1rem; }
  .keyboard-note { display: none; }
  footer { display: grid; text-align: center; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

@media print {
  body * { visibility: hidden !important; }
  body::before {
    content: "Jdee Japan exam content is protected and cannot be printed.";
    visibility: visible !important;
    position: fixed;
    inset: 2rem;
    display: grid;
    place-items: center;
    color: #35104f;
    font: 800 18pt/1.5 system-ui, sans-serif;
    text-align: center;
  }
}
