:root {
  color-scheme: dark;
  --space: #102333;
  --paper: #e9eef1;
  --muted: #adc2cd;
  --line: #75919e;
  --accent: #edc18c;
  --ink: #173344;
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  background: var(--space);
  color: var(--paper);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { min-width: 280px; }

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: radial-gradient(ellipse at 50% 38%, #244356 0%, var(--space) 75%);
  touch-action: manipulation;
}

.site {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  max-width: 1240px;
  margin-inline: auto;
  padding-inline: clamp(22px, 5vw, 62px);
  pointer-events: none;
}

.masthead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-block: 30px;
}

.masthead a { pointer-events: auto; }
.wordmark { grid-column: 1; grid-row: 1; justify-self: start; font-weight: 700; font-size: 1rem; letter-spacing: -0.025em; }
.masthead nav { grid-column: 3; grid-row: 1; justify-self: end; }
nav { display: flex; align-items: center; flex-wrap: wrap; gap: 16px 24px; }
.language-links { display: inline-flex; align-items: center; gap: 10px; padding-left: 0; color: var(--paper); font-size: 0.8rem; }
.language-links a { font-size: inherit; }
.language-links a[aria-current="page"] { color: var(--paper); }
a { color: inherit; text-decoration: none; }
nav a { color: var(--muted); font-size: 0.86rem; font-weight: 500; }
nav a:hover { color: white; }

.home { min-height: calc(100svh - 80px); display: flex; flex-direction: column; justify-content: center; padding-block: 40px 34px; }
.introduction {
  width: min(100%, 720px);
  padding: clamp(22px, 3vw, 36px);
  background: #10233380;
  border: 1px solid #75919e38;
  border-radius: 4px;
  pointer-events: auto;
}
h1 {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: clamp(3.35rem, 7vw, 6rem);
  line-height: 1.04;
  letter-spacing: -0.045em;
  font-weight: 500;
  margin: 0;
  text-wrap: balance;
}
.intro-lead { color: var(--accent); font-size: clamp(1rem, 1.7vw, 1.25rem); line-height: 1.5; margin: 16px 0 0; }
.intro-copy { max-width: 59ch; color: #d3e0e5; font-size: clamp(1rem, 1.5vw, 1.12rem); line-height: 1.7; margin: 25px 0 0; }
.game-intro { margin-top: clamp(30px, 5vh, 55px); max-width: 59ch; }
.game-intro h2 { color: var(--paper); font-size: 1rem; margin: 0 0 8px; }
.game-intro p { color: var(--muted); font-size: 0.95rem; line-height: 1.65; margin: 0; }
.intro-copy a, .game-intro p a { color: var(--paper); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.game-controls { margin-top: 24px; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 16px 28px; }
.learn-link { font-size: 0.9rem; font-weight: 600; color: var(--paper); border-bottom: 1px solid var(--line); padding-block: 10px; }
.learn-link span { margin-left: 5px; color: var(--accent); }
.learn-link:hover { color: var(--accent); }
button {
  border: 0;
  border-radius: 4px;
  padding: 13px 19px;
  background: var(--accent);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  pointer-events: auto;
}
button:hover { background: #f8d4a6; }
button[hidden] { display: none; }
a:focus-visible, button:focus-visible { outline: 3px solid white; outline-offset: 4px; }
#status { color: var(--muted); font-size: 0.8rem; line-height: 1.5; min-height: 1.5em; margin: 13px 0 0; }
.scroll-hint { color: var(--muted); font-size: 0.76rem; margin: auto 0 0; padding-top: 45px; }
.about { padding-block: clamp(85px, 13vh, 145px); pointer-events: auto; }
.about-inner, .post-card { max-width: 920px; padding: clamp(28px, 5vw, 64px); background: #142f40b8; border: 1px solid #75919e45; }
#about, #blog { scroll-margin-top: 24px; }
.stream { padding-block: 0 clamp(70px, 10vh, 120px); pointer-events: auto; }
.post-card h2 { font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; font-size: clamp(1.65rem, 3vw, 2.4rem); font-weight: 500; line-height: 1.25; letter-spacing: -0.025em; margin: 0; }
.post-card p { max-width: 65ch; margin: 20px 0 0; color: #d3e0e5; line-height: 1.75; }
.post-card .post-kind { margin: 0 0 18px; color: var(--accent); font-size: 0.85rem; font-weight: 600; }
.post-card h2 a, .article-body a, .article-back { text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px; }
.post-card h2 a:hover, .article-body a:hover, .article-back:hover { color: var(--accent); }
.article-page { background: radial-gradient(ellipse at 50% 0%, #244356 0%, var(--space) 65%) fixed; }
.article-reading { max-width: 920px; margin-block: 40px 90px; padding: clamp(24px, 5vw, 64px); background: #142f40b8; border: 1px solid #75919e45; pointer-events: auto; }
.article-body { font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif; color: #d3e0e5; font-size: clamp(1rem, 1.5vw, 1.12rem); line-height: 1.85; overflow-wrap: anywhere; }
.article-body h1 { color: var(--paper); font-size: clamp(2.1rem, 4.8vw, 3.8rem); line-height: 1.16; margin-bottom: 36px; }
.article-body h2 { color: var(--paper); font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; font-size: clamp(1.65rem, 3vw, 2.2rem); font-weight: 500; line-height: 1.25; margin: 48px 0 22px; }
.article-body p { margin: 0 0 24px; }
.article-body img { max-width: 100%; }
.article-body pre { overflow: auto; }
.article-back { display: inline-block; margin-top: 34px; font-size: 0.95rem; }
section[tabindex="-1"]:focus-visible { outline: 2px solid var(--line); outline-offset: 8px; }
.section-label { color: var(--accent); font-size: 0.85rem; font-weight: 600; margin: 0 0 18px; }
.about h2 { font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; font-size: clamp(2rem, 4vw, 3.4rem); line-height: 1.15; font-weight: 500; letter-spacing: -0.025em; max-width: 24ch; margin: 0; }
.about-copy { max-width: 65ch; margin-top: 28px; color: #d3e0e5; line-height: 1.75; }
.about-links { display: flex; flex-wrap: wrap; gap: 16px 30px; margin: 12px 0 28px; }
.about-links:last-child { margin-bottom: 0; }
.about-links a { border-bottom: 1px solid var(--line); padding-bottom: 5px; font-weight: 600; font-size: 0.9rem; }
.about-links a:hover { color: var(--accent); }
:lang(ja) { font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif; }
:lang(ja) h1, :lang(ja) .about h2, :lang(ja) .post-card h2, :lang(ja) .article-body h2 { font-family: "Hiragino Mincho ProN", "Yu Mincho", serif; line-height: 1.3; letter-spacing: 0; }
:lang(ja) .about h2 { max-width: 25ch; }

@media (max-width: 480px) {
  .site { padding-inline: 16px; }
  .masthead { gap: 8px; padding-block: 22px; }
  .wordmark { font-size: 0.9rem; }
  nav { gap: 12px 15px; }
  nav a { font-size: 0.8rem; }
  .language-links { padding-left: 0; }
  .home { min-height: calc(100svh - 64px); padding-block: 24px 28px; }
  .introduction { padding: 20px; }
  h1 { font-size: clamp(2.3rem, 11vw, 3.35rem); }
  .game-intro { margin-top: 28px; }
  .actions { gap: 10px 20px; }
  .about { padding-block: 45px 70px; }
  .about-inner, .post-card { padding: 24px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}


/* Playing keeps the field unobstructed and the exit within reach. */
.game-leader { grid-column: 2; grid-row: 1; justify-self: center; color: var(--accent); font-size: .8rem; white-space: nowrap; }
.game-leader:empty { display: none; }
.game-board { position: fixed; right: 20px; top: 86px; z-index: 3; white-space: pre-line; color: var(--paper); background: #102333c9; border: 1px solid #75919e45; padding: 12px 16px; font-size: .8rem; line-height: 1.65; pointer-events: none; }
.game-board[hidden] { display: none; }
body[data-playing] { overflow: hidden; }
body[data-playing] .site main, body[data-playing] .wordmark, body[data-playing] .masthead nav, body[data-playing] .game-leader { display: none; }
body[data-playing] .site { min-height: 0; }
body[data-playing] #leave { grid-column: 2; grid-row: 1; justify-self: center; position: relative; z-index: 4; }
@media (max-width: 480px) { .game-board { top: 80px; right: 12px; } .game-leader { grid-row: 2; font-size: .7rem; } }

/* Accessible multi-touch controls appear only during play on touch devices. */
.touch-controls { display: none; position: fixed; z-index: 4; inset: auto 0 max(16px, env(safe-area-inset-bottom)); padding-inline: max(16px, env(safe-area-inset-left)); pointer-events: none; grid-template-columns: repeat(3, 48px) 1fr 66px; grid-template-rows: repeat(3, 48px); gap: 6px; }
.touch-controls button { pointer-events: auto; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; padding: 0; min-width: 48px; min-height: 48px; color: var(--paper); background: #142f40dd; border: 1px solid #adc2cda0; border-radius: 8px; font-size: 1.05rem; }
.touch-controls button:active { background: #416176; }
.touch-controls .touch-forward { grid-column: 2; grid-row: 1; }
.touch-controls .touch-left { grid-column: 1; grid-row: 2; }
.touch-controls .touch-right { grid-column: 3; grid-row: 2; }
.touch-controls .touch-reverse { grid-column: 2; grid-row: 3; }
.touch-controls .touch-fire { grid-column: 5; grid-row: 2 / 4; font-size: .8rem; }
@media (any-pointer: coarse) { body[data-playing] .touch-controls { display: grid; } }
@media (max-height: 450px) and (orientation: landscape) { .touch-controls { grid-template-rows: repeat(3, 40px); gap: 4px; } .touch-controls button { min-height: 40px; } }

.play-instructions { display: none; position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 3; margin: 0; color: var(--muted); font-size: .75rem; white-space: nowrap; pointer-events: none; }
body[data-playing] .play-instructions { display: block; }
.touch-instructions { display: none; }
@media (any-pointer: coarse) { body[data-playing] .play-instructions { bottom: max(4px, env(safe-area-inset-bottom)); font-size: .68rem; } .keyboard-instructions { display: none; } .touch-instructions { display: inline; } }
