:root {
  color-scheme: dark;
  --bg: #12161b;
  --panel: #1b2027;
  --text: #e6e3df;
  --muted: #abaeb4;
  --line: #353b43;
  --accent: #e9b3bb;
  --ink: #18191b;
  --green: #8bb7a4;
}
* {
  box-sizing: border-box;
}
body.light {
  color-scheme: light;
  --bg: #f5f2ec;
  --panel: #fffdf8;
  --text: #272b32;
  --muted: #626974;
  --line: #d8d2c8;
  --accent: #9b4f62;
  --ink: #fff;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    15px/1.85 system-ui,
    -apple-system,
    "Hiragino Kaku Gothic ProN",
    sans-serif;
}
header {
  max-width: 1120px;
  margin: auto;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
header a {
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
  letter-spacing: 0.08em;
}
nav {
  display: flex;
  gap: 8px;
}
main {
  max-width: 1080px;
  margin: auto;
  padding: 40px 24px 70px;
  min-height: 65vh;
}
h1,
h2,
h3,
.serif {
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-weight: 500;
}
h1 {
  font-size: clamp(42px, 10vw, 92px);
  line-height: 1.4;
  letter-spacing: 0.12em;
  margin: 24px 0;
}
h2 {
  font-size: 25px;
  margin: 0 0 24px;
  line-height: 1.6;
}
h3 {
  font-size: 19px;
  margin: 0 0 14px;
}
p {
  margin: 0 0 16px;
}
a {
  color: var(--accent);
  overflow-wrap: anywhere;
}
button,
select,
input,
textarea {
  font: inherit;
  max-width: 100%;
  color: inherit;
}
button {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 7px 13px;
  cursor: pointer;
  line-height: 1.65;
}
button:hover,
button.selected {
  border-color: var(--accent);
  color: var(--accent);
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--ink);
  padding: 13px 30px;
  min-height: 48px;
}
.primary:hover {
  color: var(--ink);
  filter: brightness(1.08);
}
select,
input,
textarea {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
  padding: 9px;
  min-width: 0;
}
input:not([type="checkbox"]),
textarea {
  width: 100%;
}
textarea {
  min-height: 80px;
}
label {
  display: block;
  margin-bottom: 14px;
}
label > span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 5px;
}
button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
.hero {
  max-width: 730px;
  margin: 20px auto 48px;
  text-align: center;
}
.eyebrow {
  font:
    12px/1.5 ui-monospace,
    monospace;
  letter-spacing: 0.18em;
  color: var(--muted);
}
.accent {
  color: var(--accent);
}
.lead {
  line-height: 2.3;
  text-align: left;
  max-width: 610px;
  margin: 22px auto 30px;
}
.muted,
small {
  color: var(--muted);
}
.small {
  font-size: 12px;
}
.section {
  border-top: 1px solid var(--line);
  padding-top: 35px;
  margin-top: 45px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  min-width: 0;
}
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}
.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.columns {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 25px;
  align-items: start;
}
.stack {
  display: grid;
  gap: 22px;
}
.row {
  display: flex;
  gap: 9px;
  align-items: center;
  flex-wrap: wrap;
}
.spread {
  justify-content: space-between;
}
.counters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin: 25px 0;
}
.counter {
  display: block;
  color: var(--accent);
  font:
    32px/1.6 ui-monospace,
    monospace;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th,
td {
  text-align: left;
  padding: 9px 7px;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
  vertical-align: top;
}
th {
  font-weight: 400;
  color: var(--muted);
}
.scroll {
  overflow: auto;
}
.sharebar {
  display: grid;
  grid-template-columns: 120px 1fr 65px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
  margin: 12px 0;
}
.track {
  background: var(--line);
  height: 5px;
  border-radius: 5px;
  overflow: hidden;
}
.track i {
  display: block;
  background: var(--accent);
  height: 100%;
}
.trivia {
  border-left: 2px solid var(--accent);
  text-align: left;
  padding: 16px 20px;
  background: var(--panel);
  margin: 22px 0;
}
.trivia p {
  margin-bottom: 7px;
}
.certificate {
  max-width: 780px;
  margin: auto;
  border: 1px solid var(--accent);
  padding: 35px;
  background: var(--panel);
}
.certificate h1 {
  font-size: 34px;
}
.certificate .name {
  font-size: 44px;
}
.passport {
  border: 1px solid var(--accent);
}
.passport h2 {
  font-size: 17px;
}
.passport canvas {
  width: 96px;
  height: 96px;
  float: right;
}
.mrz {
  font: 11px/1.6 monospace;
  word-break: break-all;
  padding-top: 20px;
  color: var(--muted);
}
canvas {
  display: block;
  max-width: 100%;
  image-rendering: pixelated;
}
.scene {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: 5px;
}
.scene-caption {
  padding-top: 10px;
  font-size: 12px;
  color: var(--muted);
}
.bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-top: 12px;
}
.controls {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 25px;
}
.controls h2 {
  margin: 0;
  font-size: 22px;
}
.controls button {
  font-size: 12px;
  padding: 5px 9px;
}
.logs {
  max-height: 400px;
  overflow: auto;
}
.log {
  display: flex;
  align-items: start;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 12px 0;
}
.log time {
  flex: 0 0 66px;
  font-size: 11px;
  color: var(--muted);
}
.log span {
  flex: 1;
}
.life-map {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12px, 1fr));
  gap: 4px;
  margin: 15px 0;
}
.life-map i {
  display: block;
  aspect-ratio: 1;
  background: var(--accent);
  min-width: 0;
}
.life-map .expected {
  outline: 1px solid var(--text);
  outline-offset: 1px;
}
.chart {
  width: 100%;
  height: auto;
}
.chart text {
  fill: var(--muted);
  font: 10px system-ui;
}
.ending {
  max-width: 760px;
  margin: 35px auto;
}
.ending h1 {
  font-size: 44px;
}
.ending canvas {
  margin-bottom: 30px;
}
.horizontal {
  display: flex;
  gap: 16px;
  overflow: auto;
  padding-bottom: 12px;
}
.horizontal > .card {
  flex: 0 0 260px;
}
.lottery {
  text-align: center;
  min-height: 55vh;
  display: grid;
  align-content: center;
}
.lottery h1 {
  font-size: clamp(32px, 8vw, 65px);
}
.lottery p {
  color: var(--muted);
}
.thought {
  border-left: 2px solid var(--accent);
  padding-left: 15px;
  margin: 12px 0;
}
dialog {
  width: min(620px, calc(100% - 28px));
  max-height: 85vh;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
}
dialog::backdrop {
  background: #000b;
}
dialog h2 {
  margin-right: 20px;
}
.modal-close {
  float: right;
}
.actions {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.danger {
  color: #e8a0a0;
}
#notice {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 12px 20px;
  border-radius: 6px;
  max-width: calc(100% - 24px);
  z-index: 100;
  display: none;
}
#notice.visible {
  display: block;
}
footer {
  border-top: 1px solid var(--line);
  padding: 30px 20px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
}
footer p {
  margin: 4px;
}
.empty {
  color: var(--muted);
  font-size: 13px;
  padding: 15px 0;
}
.room {
  width: 100%;
  max-width: 700px;
  aspect-ratio: 16/9;
}
.badge {
  border: 1px solid var(--line);
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 20px;
}
.spinner {
  animation: breathe 1.2s ease-in-out infinite;
}
@keyframes breathe {
  50% {
    opacity: 0.35;
  }
}
@media (max-width: 700px) {
  header {
    padding: 14px 16px;
  }
  main {
    padding: 24px 16px 45px;
  }
  .columns,
  .grid,
  .cards {
    grid-template-columns: 1fr;
  }
  .hero {
    margin-top: 8px;
  }
  .card {
    padding: 19px;
  }
  .certificate {
    padding: 22px;
  }
  .sharebar {
    grid-template-columns: 90px 1fr 60px;
  }
  .controls {
    position: relative;
  }
  .counters {
    gap: 10px;
  }
  .counters small {
    font-size: 10px;
  }
  .counter {
    font-size: 27px;
  }
  .lead {
    font-size: 14px;
  }
  .ending h1 {
    font-size: 32px;
  }
  h2 {
    font-size: 22px;
  }
  .scroll table {
    min-width: 470px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

/* Each logical scene pixel occupies an integer number of screen pixels. */
.scene,
.room {
  width: calc(160px * var(--pixel-scale, 1));
  height: auto;
  aspect-ratio: 16 / 9;
  margin: 0 auto;
  border-radius: 0;
}
.cat-portrait {
  width: 100px;
  height: 90px;
  margin: 0;
}
.scene-card {
  text-align: center;
}
.capture-moment {
  font-size: 12px;
  margin-top: 12px;
  border-color: #80616e;
  color: var(--accent);
}
.estimate {
  margin-left: 6px;
  font-size: 10px;
  white-space: nowrap;
}
.sources {
  padding-left: 22px;
}
.sources li {
  padding: 7px 0;
  font-size: 12px;
  overflow-wrap: anywhere;
}
.memory-preview {
  padding: 30px 20px;
  margin: 38px 0;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(145deg, var(--panel), var(--bg));
}
.memory-preview h2 {
  font-size: 24px;
}
.memory-gallery {
  max-width: 540px;
  margin: auto auto 22px;
}
.photo-preview {
  width: 280px;
  height: auto;
  margin: 0 auto 20px !important;
  border-radius: 6px;
  box-shadow: 0 10px 30px #0003;
  image-rendering: auto;
}
.photo-thumbnails {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 6px;
}
.photo-thumbnail {
  overflow: hidden;
  border-radius: 4px;
  background: #e6d5ce;
}
.photo-thumbnail canvas {
  width: 100%;
  height: auto;
  margin: 0;
  filter: blur(3px);
  image-rendering: auto;
  transform: scale(1.08);
}
.memory-cta {
  width: 100%;
  max-width: 520px;
}
.memory-preview.compact {
  border: 0;
  margin: 0;
  padding: 12px 0;
  background: none;
}
.film-preview {
  width: 180px;
  height: auto;
  margin: 10px auto;
  image-rendering: auto;
}
@media (max-width: 700px) {
  .scene-card {
    padding: 10px;
  }
  .certificate .name {
    font-size: 28px;
    overflow-wrap: anywhere;
  }
  .memory-preview {
    padding: 24px 12px;
  }
  .memory-cta {
    padding: 13px 12px;
    font-size: 14px;
  }
  .photo-thumbnails {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
  }
}

/* 見出しの最後の1〜2字だけが次の行に落ちないよう、行の長さをそろえる */
h1, h2, h3, .modal-title { text-wrap: balance; }
