:root {
  --bg: #f6f3ee;
  --card: #fff;
  --ink: #1f2430;
  --muted: #5c6573;
  --line: #e4ddd3;
  --accent: #1f5f8b;
  --ok: #1b7a4a;
  --ng: #b42318;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  line-height: 1.65;
}
body { min-height: 100vh; }
button, label, input { font: inherit; }

.wrap {
  max-width: 920px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}
.kicker { color: var(--muted); font-size: 0.9rem; margin: 0 0 8px; }
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.app-header .kicker { margin: 0; }
.app-header .nav-row { margin: 0; }
.logout-form { margin: 0; flex: 0 0 auto; }
.logout-btn {
  background: none;
  border: 0;
  color: var(--muted);
  padding: 10px 4px;
  min-height: 44px;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
h1, h2 { line-height: 1.3; margin: 0 0 12px; }
p { margin: 0 0 16px; }

.login-wrap { max-width: 28rem; }
.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 18px;
  display: grid;
  gap: 12px;
}
.login-label { font-weight: 700; }
.login-card input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.login-error { color: var(--ng); font-weight: 700; }
.login-card .primary { width: 100%; text-align: center; }

.home-title { font-size: 1.7rem; }
.prompt { font-size: 1.15rem; margin-bottom: 20px; }
.resume-section { margin-bottom: 36px; }
.home-other-section { margin-top: 4px; }
.home-section-heading {
  font-size: 1.05rem;
  color: var(--muted);
  margin: 0 0 8px;
}

.stack { display: grid; gap: 12px; }
.card-btn, .primary, .ghost, .choice {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  padding: 16px 18px;
  text-align: left;
  cursor: pointer;
}
.card-btn:hover, .ghost:hover, .choice:hover { border-color: var(--accent); }
.card-btn strong { display: block; font-size: 1.1rem; }
.card-btn span { color: var(--muted); font-size: 0.95rem; }

.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  text-align: center;
  font-weight: 700;
}
.primary:disabled { opacity: 0.45; cursor: not-allowed; }
.ghost { text-align: center; }

.nav-row { display: flex; gap: 8px; margin-bottom: 16px; }
.meta { color: var(--muted); margin-bottom: 12px; }

.images { display: grid; gap: 12px; margin: 12px 0 20px; }
.images img {
  width: 100%;
  height: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: zoom-in;
  display: block;
}

.choices { display: grid; gap: 10px; margin-bottom: 16px; }
.choice { display: flex; gap: 12px; align-items: flex-start; }
.choice.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(31, 95, 139, 0.15); }
.choice .mark {
  font-weight: 700;
  min-width: 1.8rem;
}

.result-summary {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.result-banner {
  border-radius: 12px;
  padding: 14px 16px;
  margin: 0 0 12px;
  font-weight: 700;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.result-mark { font-size: 1.4rem; line-height: 1; }
.result-banner.ok { background: #e8f6ee; color: var(--ok); }
.result-banner.ng { background: #fdecea; color: var(--ng); }
.correct-key { font-size: 1.15rem; margin: 0; font-weight: 700; }
.answer-summary { margin: 0 0 6px; font-weight: 700; }
.jump-question { color: var(--accent); font-weight: 700; }

.expl-block {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.expl-block h2 { font-size: 1.05rem; }
.wrong-item { margin-bottom: 10px; }
.wrong-item:last-child { margin-bottom: 0; }

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(12, 16, 22, 0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 20;
}
.lightbox.hidden, [hidden] { display: none !important; }
.lightbox img {
  max-width: 100%;
  max-height: calc(100vh - 80px);
  height: auto;
}
.lightbox-close {
  margin-bottom: 12px;
  background: #fff;
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
}

@media (max-width: 799px) {
  html, body {
    overflow-x: hidden;
  }
  .wrap {
    padding: 12px 8px 40px;
  }
  .player .images {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-left: -8px;
    margin-right: -8px;
    width: calc(100% + 16px);
    max-width: calc(100% + 16px);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }
  .player .images img {
    width: 125%;
    max-width: none;
    height: auto;
    flex-shrink: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
}

@media (min-width: 800px) {
  .home-title { font-size: 2rem; }
  .wrap { padding-top: 36px; }
}
