/* Ink navy field, warm paper cards, one antique-gold accent.
   System fonts only. Motion is hover/focus and respects reduced motion. */

:root {
  --navy: #0c1220;
  --navy-2: #151d31;
  --ink: #1a1612;
  --muted: #4e463c;
  --paper: #f6f0e4;
  --paper-2: #fffaf2;
  --line: #e3d5c2;
  --gold: #c6a15a;
  --gold-deep: #6a4a12;
  --gold-soft: #f3e6c8;
  --cream: #f4efe6;
  --bad: #7c1e28;
  --bad-bg: #f8e7e3;
  --ok: #3f4a32;
  --ok-bg: #eef3e4;
  --shadow: 0 16px 40px rgba(4, 8, 18, 0.35);
  --sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", serif;
  --measure: 68ch;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--cream);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  background-color: var(--navy);
  background-image:
    radial-gradient(ellipse 70% 42% at 8% -8%, rgba(198, 161, 90, 0.18), transparent 55%),
    radial-gradient(ellipse 50% 36% at 100% 0%, rgba(198, 161, 90, 0.08), transparent 50%),
    linear-gradient(180deg, #141c30 0%, var(--navy) 38%, #0a101c 100%);
  color-scheme: dark;
}

body::before {
  content: "";
  position: fixed;
  inset: 12px;
  border: 1px solid rgba(198, 161, 90, 0.28);
  border-radius: 18px;
  pointer-events: none;
  z-index: 0;
}

::selection { background: #e7d3a2; color: var(--ink); }

a { color: var(--gold-deep); text-underline-offset: 3px; }

.site-header,
.shell { position: relative; z-index: 1; }

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px 24px;
  flex-wrap: wrap;
  padding: 18px 28px 14px;
  color: var(--cream);
  border-bottom: 1px solid rgba(198, 161, 90, 0.28);
}

.header-end {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px 16px;
  margin-left: auto;
  flex-wrap: wrap;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-decoration: none;
  color: var(--cream);
  background: transparent;
  border: 1px solid rgba(198, 161, 90, 0.75);
  border-radius: 999px;
  padding: 6px 14px;
  min-height: 36px;
  cursor: pointer;
  line-height: 1.2;
}


.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--cream);
  text-decoration: none;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: 0.08em;
}

.mark {
  width: 11px;
  height: 11px;
  background: var(--gold);
  transform: rotate(45deg);
  flex: none;
  box-shadow: 0 0 0 4px rgba(198, 161, 90, 0.15);
}

.site-nav {
  display: flex;
  gap: 6px 14px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.site-nav a,
.linkish {
  color: var(--cream);
  text-decoration: none;
  font-size: 15px;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 8px 2px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.site-nav form { margin: 0; }

.who {
  color: #d9d0c3;
  font-size: 14px;
  padding: 8px 0;
}

.shell {
  width: min(880px, 100%);
  margin: 0 auto;
  padding: 28px 22px 80px;
}

.shell-narrow { width: min(460px, 100%); }
.shell-portal { width: min(640px, 100%); }

h1, h2, h3, .score-hero, .brand, .q-head, .group-title {
  font-family: var(--serif);
}

h1 {
  font-size: clamp(1.7rem, 3vw, 2.15rem);
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin: 0 0 10px;
  color: var(--ink);
}

h2 {
  font-size: 1.28rem;
  line-height: 1.3;
  margin: 0 0 10px;
  color: var(--ink);
}

h2::after {
  content: "";
  display: block;
  width: 42px;
  height: 2px;
  margin-top: 8px;
  background: var(--gold);
}

h3 { font-size: 1.05rem; margin: 16px 0 8px; color: var(--ink); }

.card,
.entry {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid rgba(198, 161, 90, 0.38);
  border-radius: 18px;
  box-shadow: var(--shadow);
  color-scheme: light;
}

.card {
  position: relative;
  padding: 22px 22px 20px;
  margin-bottom: 16px;
}

.card::before {
  content: "";
  position: absolute;
  left: 22px;
  right: 22px;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.muted, .hint { color: var(--muted); }
.hint { margin: 0 0 8px; font-size: 0.95rem; line-height: 1.65; }

.meta {
  margin: 0 0 10px;
  color: var(--gold-deep);
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  font-weight: 700;
}

.flash {
  background: var(--paper-2);
  color: var(--ink);
  border: 1px solid var(--gold);
  border-left: 4px solid var(--gold);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
  color-scheme: light;
}

label.field {
  display: block;
  margin-bottom: 4px;
  font-weight: 700;
  color: var(--ink);
}

input[type="text"],
input[type="password"] {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  min-height: 48px;
  font-size: 16px;
  font-family: inherit;
  font-weight: 400;
  color: var(--ink);
  background: var(--paper-2);
  border: 1px solid #d5c6b0;
  border-radius: 12px;
  color-scheme: light;
}

input[type="text"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: var(--gold-deep);
  box-shadow: 0 0 0 3px rgba(198, 161, 90, 0.35);
}

.btn, button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  background: var(--gold);
  color: #1a140c;
  border-radius: 999px;
  padding: 12px 18px;
  min-height: 46px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
  cursor: pointer;
  text-align: center;
  line-height: 1.2;
}

.btn.secondary {
  background: var(--navy-2);
  color: var(--cream);
  border-color: #2a354c;
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border-color: #cbbba4;
}

.btn.danger {
  background: transparent;
  color: var(--bad);
  border-color: #e3b7b4;
}

.shell > .actions .btn.ghost,
.shell > .actions .btn.ghost:hover {
  color: var(--cream);
  border-color: rgba(198, 161, 90, 0.65);
  background: transparent;
}

.abandon {
  margin-top: 8px;
}

.shell > .abandon .btn.danger {
  color: #f6d7d4;
  border-color: rgba(246, 215, 212, 0.55);
}

.stack { display: flex; flex-direction: column; gap: 12px; }

.entries { display: flex; flex-direction: column; gap: 12px; }

.entry {
  display: block;
  padding: 18px 18px 18px 20px;
  text-decoration: none;
  color: inherit;
  border-left: 3px solid var(--gold);
}

.entry strong {
  display: block;
  font-family: var(--serif);
  font-size: 1.25rem;
  margin-bottom: 4px;
  color: var(--ink);
}

.score-hero {
  font-size: clamp(2.4rem, 6vw, 3.2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin: 12px 0 8px;
  color: var(--ink);
}

.score-hero span {
  font-size: 1.15rem;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 4px;
}

table { width: 100%; border-collapse: collapse; font-size: 15px; }

th, td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--gold-deep);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

tbody tr:last-child td { border-bottom: 0; }

#progress {
  display: inline-block;
  margin-top: 4px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--navy-2);
  color: var(--cream);
  font-size: 0.92rem;
  font-weight: 600;
}

.q { padding: 18px 0 6px; border-top: 1px solid var(--line); }
.q:first-of-type { border-top: 0; padding-top: 8px; }

.q-head { font-weight: 700; color: #2a241c; font-size: 1.02rem; }

.q > .q-head::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 8px;
  background: var(--gold);
  transform: rotate(45deg);
  vertical-align: 2px;
}

.prompt {
  white-space: pre-wrap;
  overflow-wrap: break-word;
  max-width: var(--measure);
  margin: 8px 0 12px;
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.75;
  color: #1c1814;
}

.opt {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  margin: 6px 0;
  border: 1px solid #e0d2bf;
  border-radius: 12px;
  background: var(--paper-2);
  cursor: pointer;
}

.opt input {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  flex: none;
  accent-color: var(--gold-deep);
}

.opt:has(input:checked) {
  border-color: var(--gold-deep);
  background: var(--gold-soft);
  box-shadow: inset 3px 0 0 var(--gold);
}

.jump { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.jump a {
  background: var(--gold-soft);
  color: var(--ink);
  text-decoration: none;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 14px;
}

.submit-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0 12px;
}

.submit-bar.sticky {
  position: sticky;
  bottom: 16px;
  z-index: 2;
  background: var(--paper);
  border: 1px solid rgba(198, 161, 90, 0.45);
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 10px 28px rgba(4, 8, 18, 0.28);
  color-scheme: light;
}

.submit-bar .btn { flex: 1 1 132px; }

td .actions { margin-top: 0; }
td form, .actions form { display: inline; }

.wrong, .okline {
  border-radius: 12px;
  padding: 12px 14px;
  margin: 10px 0;
  border: 1px solid transparent;
}

.wrong {
  background: var(--bad-bg);
  border-color: #efc9c4;
  color: #3a1a1d;
}

.okline {
  background: var(--ok-bg);
  border-color: #d5e0c6;
  color: #24301c;
}

.tag { font-size: 13px; font-weight: 700; letter-spacing: 0.02em; }
.tag.bad { color: var(--bad); }
.tag.ok { color: #2f5a34; }

.break { list-style: none; padding: 0; margin: 12px 0 0; }

.break li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.break li:last-child { border-bottom: 0; }

.group-title {
  margin: 18px 0 8px;
  padding-left: 10px;
  border-left: 3px solid var(--gold);
  font-weight: 700;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.card .actions { margin-top: 16px; }

@media (min-width: 800px) {
  .submit-bar .btn { flex: 0 1 auto; min-width: 128px; }
}

@media (max-width: 720px) {
  body::before { display: none; }
  body { border-top: 3px solid var(--gold); }
  .site-header { padding: 14px 16px 10px; }
  .shell { padding: 18px 16px 64px; }
  .card { padding: 18px 16px 16px; border-radius: 16px; }
  .card::before { left: 16px; right: 16px; }
  .table-scroll.is-wide table { min-width: 640px; }
  .submit-bar.sticky { bottom: 8px; }
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .btn, .entry, .opt, .site-nav a, .linkish, .lang-switch {
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
  }
  .btn:hover { transform: translateY(-1px); background: #d4b36e; }
  .btn.secondary:hover { background: #243049; }
  .btn.ghost:hover { background: rgba(198, 161, 90, 0.12); }
  .btn.danger:hover { background: rgba(124, 30, 40, 0.06); }
  .shell > .actions .btn.ghost:hover { background: rgba(198, 161, 90, 0.12); }
  .shell > .abandon .btn.danger:hover { background: rgba(246, 215, 212, 0.08); }
  .entry:hover {
    transform: translateY(-2px);
    background: var(--paper-2);
    border-color: var(--gold);
  }
  .opt:hover { border-color: var(--gold); }
  .site-nav a:hover, .linkish:hover, .lang-switch:hover {
    color: #f0d9a4;
    border-color: var(--gold);
  }
}

.btn:focus-visible,
.entry:focus-visible,
.site-nav a:focus-visible,
.linkish:focus-visible,
.lang-switch:focus-visible,
.opt:focus-within {
  outline: 2px solid var(--gold-deep);
  outline-offset: 3px;
}

.shell > .actions .btn.ghost:focus-visible,
.site-nav a:focus-visible,
.linkish:focus-visible,
.lang-switch:focus-visible,
.brand:focus-visible {
  outline-color: #f0d9a4;
}

@media (prefers-reduced-motion: reduce) {
  .btn, .entry, .opt, .site-nav a, .linkish, .lang-switch { transition: none; }
}
