:root {
  --paper: #fcf8f2;
  --sheet: #fffdf9;
  --ink: #2e211b;
  --muted: #65564b;
  --line: #e8dbcc;
  --rust: #a54325;
  --game-ink: #4a3026;
  --game-accent: #a54325;
  --game-tint: #f8e9df;
  --serif: "YuMincho", "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif CJK JP", serif;
  font-family: "Hiragino Sans", "Yu Gothic", Meiryo, system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.65;
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 0; }
[hidden] { display: none !important; }
:where(h1, h2, h3, p, ul, ol, figure) { margin: 0; }
:where(button, input, select, textarea) { font: inherit; color: inherit; }
:where(button, a, select, input, textarea) { -webkit-tap-highlight-color: transparent; }
:where(button, a):focus-visible, :where(select, input, textarea):focus-visible {
  outline: 3px solid #176b61;
  outline-offset: 4px;
}
:where(h1, h2, h3)[tabindex="-1"]:focus { outline: none; }
a { color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
[data-theme="mission"] { --game-ink: #592958; --game-accent: #743575; --game-tint: #f7e7f5; }
[data-theme="match"] { --game-ink: #18483d; --game-accent: #206554; --game-tint: #e4f2e8; }

.site-header { background: var(--sheet); border-bottom: 1px solid var(--line); }
.header-inner {
  max-width: 1184px; min-height: 68px; margin-inline: auto;
  padding: 6px clamp(16px, 4vw, 36px); display: flex; align-items: center;
  justify-content: space-between; gap: 12px;
}
.lab-brand {
  text-decoration: none; display: inline-flex; align-items: center; gap: 10px;
  font-size: .93rem; font-weight: 800; min-height: 44px;
}
.lab-mark { display: inline-grid; place-items: center; width: 35px; height: 35px; flex: 0 0 35px; }
.lab-mark img { display: block; width: 100%; height: 100%; }
.sound-toggle {
  border: 1px solid var(--line); border-radius: 100px; background: transparent;
  padding: 6px 13px; display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; font-size: .79rem; font-weight: 700; color: var(--muted);
}
.sound-toggle[aria-pressed="true"] { background: var(--game-tint); color: var(--game-ink); }
.sound-toggle[aria-pressed="true"] .sound-off,
.sound-toggle[aria-pressed="false"] .sound-on { display: none; }
.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; }
.game-footer {
  width: min(100% - 32px, 740px); margin: 32px auto 0; padding: 15px 0 26px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 16px;
}
.game-footer a { display: inline-flex; min-height: 44px; align-items: center; text-underline-offset: 3px; }
.game-main { width: min(100% - 32px, 740px); margin: clamp(16px, 4vw, 40px) auto 0; }
.game-intro { display: grid; gap: 8px; margin-bottom: 20px; }
.game-intro h1 {
  color: var(--game-ink); font-size: clamp(1.65rem, 5.5vw, 2.6rem);
  font-weight: 850; letter-spacing: -.04em; line-height: 1.24; overflow-wrap: anywhere;
}
.game-kicker {
  color: var(--game-ink); font-size: .73rem; font-weight: 850;
  letter-spacing: .14em; text-transform: uppercase;
}
.game-panel {
  position: relative; border: 1px solid var(--line); border-radius: 22px;
  background: var(--sheet); padding: clamp(16px, 3.5vw, 30px);
  box-shadow: 0 3px 0 #ede4d9, 0 10px 28px #59331d0a;
}
.game-panel :where(h1, h2, h3) { overflow-wrap: anywhere; line-height: 1.35; }
.game-progress {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  font-size: .83rem; font-weight: 750; color: var(--game-ink); margin-bottom: 12px;
}
.badge {
  display: inline-flex; align-items: center; gap: 4px; background: var(--game-tint);
  color: var(--game-ink); border-radius: 30px; padding: 3px 10px;
  font-size: .77rem; font-weight: 800;
}
.stack { display: grid; gap: 16px; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); gap: 12px; }
.field { display: grid; min-width: 0; gap: 5px; font-weight: 750; }
.field :where(input, select), :where(input[type="text"], select) {
  min-width: 0; max-width: 100%; min-height: 46px; padding: 8px 11px;
  background: #fff; border: 1px solid #c6b8ab; border-radius: 10px; font-size: 1rem;
}
.btn {
  display: inline-flex; justify-content: center; align-items: center; gap: 8px;
  padding: 10px 18px; min-height: 48px; min-width: 44px;
  border: 1px solid transparent; border-radius: 12px;
  font-weight: 800; line-height: 1.45; text-align: center; text-decoration: none;
  transition: background-color .16s ease, color .16s ease, box-shadow .16s ease;
}
.btn-primary { color: #fff; background: var(--game-accent); box-shadow: 0 2px 0 var(--game-ink); }
.btn-primary:not(:disabled):hover { background: var(--game-ink); }
.btn-secondary { color: var(--game-ink); background: var(--game-tint); border-color: #0002; }
.btn-secondary:not(:disabled):hover { border-color: var(--game-accent); }
.btn-quiet { background: transparent; color: var(--muted); border-color: var(--line); }
.btn-quiet:not(:disabled):hover { background: var(--sheet); color: var(--ink); }
.btn:disabled { opacity: .6; box-shadow: none; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; }
.button-row > .btn { flex: 1 1 126px; }
.exit-dialog {
  max-width: 420px; width: calc(100% - 32px); padding: 22px; border-radius: 18px;
  border: 1px solid var(--line); color: var(--ink); background: var(--sheet);
}
.exit-dialog h2 { font-size: 1.22rem; }
.exit-dialog p { margin: 6px 0 18px; font-size: .9rem; }
.exit-dialog::backdrop { background: #2014109c; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0,0,0,0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.confetti { pointer-events: none; position: absolute; z-index: 5; inset: 0; overflow: hidden; border-radius: inherit; }
.confetti i {
  position: absolute; top: -12px; left: var(--x); width: 8px; height: 12px;
  background: #e6a74d; border-radius: 2px; animation: confetti-drop .8s var(--delay) ease-out both;
}
.confetti i:nth-child(3n) { background: #da7d9a; width: 6px; border-radius: 50%; }
.confetti i:nth-child(3n + 1) { background: #64a997; }
@keyframes confetti-drop {
  0% { transform: translateY(0); opacity: 1; }
  65% { opacity: 1; }
  100% { transform: translate(var(--drift), 200px) rotate(var(--spin)); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .confetti { display: none; }
}
