:root {
  color-scheme: light;
  --bg: #ffffff;
  --ink: #1c1b19;
  --ink-2: #5d5b56;
  --ink-3: #8d8a83;
  --line: #e4e2dd;
  --line-strong: #1c1b19;
  --field: #f5f4f1;
  --accent: #c2412b;
  --accent-soft: #fbeeea;
  --hit: #fdf6e3;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #161615;
    --ink: #eeece7;
    --ink-2: #b4b1a9;
    --ink-3: #85827b;
    --line: #2e2d2a;
    --line-strong: #eeece7;
    --field: #22211f;
    --accent: #ec7a62;
    --accent-soft: #3a211b;
    --hit: #2c2715;
  }
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #161615;
  --ink: #eeece7;
  --ink-2: #b4b1a9;
  --ink-3: #85827b;
  --line: #2e2d2a;
  --line-strong: #eeece7;
  --field: #22211f;
  --accent: #ec7a62;
  --accent-soft: #3a211b;
  --hit: #2c2715;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', Meiryo, sans-serif;
  font-size: 15px;
  line-height: 1.7;
}
a {
  color: inherit;
}
h1,
h2 {
  margin: 0;
  line-height: 1.4;
}
button,
input {
  font: inherit;
  color: inherit;
}

.page {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 16px;
}
.site-header {
  padding: 28px 0 24px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 28px;
}
.site-header h1 {
  font-size: 1.35rem;
  font-weight: 700;
}
.site-header a {
  text-decoration: none;
}
.site-header p {
  margin: 4px 0 0;
  color: var(--ink-2);
  font-size: 0.9rem;
}

/* 2カラム：左が入力、右が結果（スマホでは縦に並べる） */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
  gap: 48px;
  align-items: start;
}
.outputs {
  position: sticky;
  top: 16px;
}

/* 参加人数・景品数 */
.stepper-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
}
.stepper-row + .stepper-row {
  border-top: 1px solid var(--line);
}
.stepper-row label {
  font-weight: 700;
}
.stepper-row small {
  display: block;
  font-weight: 400;
  font-size: 0.76rem;
  color: var(--ink-3);
  line-height: 1.4;
}
.stepper {
  display: flex;
  align-items: center;
  gap: 6px;
}
.stepper button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 6px;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.stepper button:hover:not(:disabled) {
  border-color: var(--ink-3);
}
.stepper button:disabled {
  opacity: 0.35;
  cursor: default;
}
.stepper input {
  width: 72px;
  height: 40px;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
}
.stepper .unit {
  width: 1.2em;
  color: var(--ink-2);
}
input:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* 結果 */
.stale {
  opacity: 0.55;
  transition: opacity 0.15s;
}
.headline {
  padding-bottom: 24px;
  border-bottom: 2px solid var(--line-strong);
}
.headline p {
  margin: 0;
}
.headline-label {
  font-weight: 700;
}
.headline-value {
  font-size: clamp(2.4rem, 7.5vw, 3.6rem);
  white-space: nowrap;
  font-weight: 800;
  line-height: 1.1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.headline-sub {
  color: var(--ink-2);
}

.block {
  margin-top: 32px;
}
.block h2 {
  font-size: 1rem;
  margin-bottom: 8px;
}
.block-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.fine {
  font-size: 0.82rem;
  color: var(--ink-3);
  margin: 8px 0 0;
}
.footnote {
  margin-top: 32px;
}
.text-btn {
  border: 0;
  background: none;
  padding: 0;
  margin-left: 6px;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  font-size: inherit;
}
.error {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  padding: 12px 14px;
  margin: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
th {
  font-weight: 400;
  text-align: left;
}
.sample summary {
  font-weight: 700;
  cursor: pointer;
}
.sample summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.sample .block-head {
  margin-top: 8px;
}
.sample .block-head .fine {
  margin: 0;
}
.timeline-wrap {
  margin-top: 8px;
  max-height: 360px;
  overflow: auto;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.timeline {
  font-size: 0.86rem;
}
.timeline th {
  position: sticky;
  top: 0;
  background: var(--bg);
  color: var(--ink-3);
  font-size: 0.78rem;
}
.timeline th,
.timeline td {
  padding: 4px 8px 4px 0;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
.timeline td:last-child {
  white-space: normal;
  width: 100%;
}
.timeline tr.hit td {
  background: var(--hit);
  font-weight: 700;
}

.mobile-bar {
  display: none;
}

/* ページ下部 */
.notes {
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 0.88rem;
}
.notes h2 {
  font-size: 0.95rem;
  color: var(--ink);
  margin-bottom: 4px;
}
.notes ul {
  margin: 0 0 20px;
  padding-left: 1.2em;
}
.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-top: 40px;
  padding: 20px 0 32px;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
  color: var(--ink-3);
}
.site-footer a {
  text-decoration: none;
}
.prose {
  max-width: 680px;
}
.prose h1 {
  font-size: 1.3rem;
  margin-bottom: 12px;
}
.prose h2 {
  font-size: 1rem;
  margin-top: 24px;
}
.prose li {
  margin: 4px 0;
}

@media (max-width: 800px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 36px;
  }
  .outputs {
    position: static;
  }
  .mobile-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: var(--bg);
    border-top: 1px solid var(--line-strong);
    font-size: 0.85rem;
    z-index: 10;
  }
  .mobile-bar b {
    font-size: 1.4rem;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
  }
  body {
    padding-bottom: 64px;
  }
}
