/* Road to Nagoya. A 1-bit look: black, white, two grays, and hinomaru red as the only color. */

:root {
  --black: #06060e;
  --white: #f0f0f0;
  --gray-lt: #a9a9b3;
  --gray-dk: #3a3a48;
  --red: #BC002D;

  /* Ink and paper swap on the white Las Vegas band, so art, borders and buttons recolor themselves. */
  --ink: var(--white);
  --paper: var(--black);

  --u: 4px;
  --gutter: 16px;
  --font-head: "Press Start 2P", "DotGothic16", monospace;
  --font-body: "DotGothic16", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--black);
  color: var(--white);
  /* No scroll-behavior here: a link to /#wall must land at once. app.js animates in-page moves itself. */
  scroll-padding-top: 76px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font: 16px/1.75 var(--font-body);
  font-synthesis: none;
  overflow-wrap: anywhere;
  line-break: strict;
  -webkit-font-smoothing: none;
}

/* Pixel fonts are only crisp at whole multiples of their grid (8px for Press Start 2P, 16px for
   DotGothic16), so sizes step at breakpoints instead of scaling fluidly. */

h1,
h2,
h3,
p {
  margin: 0;
  font-weight: 400;
}

.px {
  display: block;
  height: auto;
  shape-rendering: crispEdges;
}

.pi { fill: var(--ink); }
.pp { fill: var(--paper); }
.pg { fill: var(--gray-lt); }
.pd { fill: var(--gray-dk); }
.pr { fill: var(--red); }

.sprite {
  position: absolute;
  overflow: hidden;
}

:focus-visible {
  outline: var(--u) solid var(--ink);
  outline-offset: var(--u);
}

/* Bordered controls keep a gap between border and ring, so the ring still reads on a filled or selected one. */
.btn:focus-visible,
.input:focus-visible {
  outline-offset: calc(var(--u) * 2);
}

/* Japanese arrives a beat after first paint; keep the English from flashing in its place. */
.lang-pending [data-i18n] {
  visibility: hidden;
}

.text-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 8px;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

/* Four hard shadows draw a border with the corner pixels left out. The color is resolved on each
   element, so a box on the white band or one marked with --edge picks up the right one. */
.btn,
.lang-toggle,
.dialog,
.panel,
.choice-face,
.chip span,
.input,
.form-error,
.saved {
  box-shadow:
    0 calc(var(--u) * -1) 0 0 var(--edge, var(--ink)),
    0 var(--u) 0 0 var(--edge, var(--ink)),
    calc(var(--u) * -1) 0 0 0 var(--edge, var(--ink)),
    var(--u) 0 0 0 var(--edge, var(--ink));
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  margin: var(--u);
  padding: 12px 20px;
  border: 0;
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 var(--font-head);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  background: var(--ink);
  color: var(--paper);
  transform: translateY(var(--u));
}

.btn-primary {
  width: calc(100% - var(--u) * 2);
  background: var(--red);
  color: var(--white);
}

.btn-primary:active {
  background: var(--white);
  color: var(--red);
}

.btn-solid {
  background: var(--ink);
  color: var(--paper);
}

.btn-solid:active {
  --edge: var(--red);
  background: var(--red);
  color: var(--white);
}

.btn[disabled] {
  background: var(--gray-dk);
  color: var(--gray-lt);
  cursor: wait;
  transform: none;
}

@media (hover: hover) {
  .btn:hover:not([disabled]) {
    background: var(--ink);
    color: var(--paper);
  }

  .btn-primary:hover:not([disabled]) {
    background: var(--white);
    color: var(--red);
  }

  .btn-solid:hover:not([disabled]) {
    --edge: var(--red);
    background: var(--red);
    color: var(--white);
  }
}

/* Language toggle, pinned top right. The strip behind it is solid so content never shows beside or under the control. */

.topbar {
  position: fixed;
  z-index: 10;
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  justify-content: flex-end;
  padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px 12px;
  background: var(--black);
}

.lang-toggle {
  display: flex;
  margin: var(--u);
}

.lang-toggle button {
  min-width: 48px;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--white);
  font: 16px/1 var(--font-body);
  cursor: pointer;
}

.lang-toggle button[aria-pressed="true"] {
  background: var(--white);
  color: var(--black);
}

.lang-toggle button:focus-visible {
  outline-offset: calc(var(--u) * 2);
}

/* Screens */

.screen {
  padding: 48px var(--gutter);
}

/* 1. Title card */

.title-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100svh;
  padding-top: 80px;
}

.marquee {
  position: relative;
  width: min(100%, 560px);
  padding: 40px 20px 36px;
  text-align: center;
}

/* Marquee bulbs: one lit, one dark, repeated. `space` spreads whole bulbs along each edge so no bulb is cut. */
.marquee::before {
  --row: linear-gradient(90deg, transparent 4px, var(--white) 4px 8px, transparent 8px 16px, var(--gray-dk) 16px 20px, transparent 20px);
  --col: linear-gradient(180deg, transparent 4px, var(--white) 4px 8px, transparent 8px 16px, var(--gray-dk) 16px 20px, transparent 20px);
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    var(--row) left top / 24px 4px space no-repeat,
    var(--row) left bottom / 24px 4px space no-repeat,
    var(--col) left top / 4px 24px no-repeat space,
    var(--col) right top / 4px 24px no-repeat space;
}

.game-title {
  font: 32px/1.25 var(--font-head);
}

.game-title span {
  display: block;
}

.team {
  margin-top: 16px;
  font: 12px/1.5 var(--font-head);
}

.scene {
  width: 192px;
  margin: 24px auto 28px;
}

/* Blinks five times to mark the one control on the card, then holds steady. */
.btn-start span {
  animation: blink 1s linear 5;
}

@keyframes blink {
  0%, 49.9% { visibility: visible; }
  50%, 100% { visibility: hidden; }
}

/* 2. Story dialog */

.dialog {
  position: relative;
  margin: var(--u);
  background: var(--paper);
}

.story-screen {
  padding-top: 24px;
}

.story-box {
  max-width: 552px;
  margin-inline: auto;
  padding: 32px 16px 8px;
}

.js .story-box {
  cursor: pointer;
}

.speaker {
  position: absolute;
  top: -14px;
  left: 12px;
  padding: 8px 8px 6px;
  background: var(--ink);
  color: var(--paper);
  font: 12px/1 var(--font-head);
}

.story-lines {
  margin: 0;
  padding: 0;
  list-style: none;
}

.story-lines li + li {
  margin-top: 16px;
}

/* With scripts on, one line shows at a time. The fixed height stops the box jumping between lines. */
.js .story-lines li {
  display: none;
  margin: 0;
  min-height: 10.5em;
}

.js .story-lines li.is-current {
  display: block;
}

.dialog-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.story-count {
  margin-right: auto;
  color: var(--gray-lt);
}

.dialog-next {
  display: none;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.js .dialog-next {
  display: grid;
}

.divider {
  display: flex;
  justify-content: center;
  padding: 8px 0 0;
}

.suits {
  width: 129px;
}

/* 5. Sign: a save-game panel */

.panel {
  max-width: 552px;
  margin: var(--u) auto;
  background: var(--paper);
}

.panel-title {
  --ink: var(--black);
  --paper: var(--white);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 12px;
  background: var(--white);
  color: var(--black);
  font: 16px/1.5 var(--font-head);
}

.panel-title .px {
  flex: none;
}

.choices {
  display: grid;
  gap: 16px;
  padding: 20px 16px;
}

.choice,
.chip {
  position: relative;
  display: block;
}

.choice input,
.chip input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.choice-face {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  margin: var(--u);
  padding: 12px 16px;
}

.choice-face .px {
  flex: none;
}

.choice input:checked + .choice-face,
.chip input:checked + span {
  background: var(--ink);
  color: var(--paper);
}

.choice input:focus-visible + .choice-face,
.chip input:focus-visible + span {
  outline: var(--u) solid var(--ink);
  outline-offset: calc(var(--u) * 2);
}

.fields {
  display: grid;
  gap: 20px;
  padding: 4px 16px 20px;
}

.side-line {
  padding-bottom: 20px;
  border-bottom: var(--u) dotted var(--gray-dk);
}

.field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.field label,
.field legend {
  display: block;
  margin-bottom: 12px;
  padding: 0;
}

.input {
  display: block;
  width: calc(100% - var(--u) * 2);
  min-height: 48px;
  margin: var(--u);
  padding: 10px 12px;
  border: 0;
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.75 var(--font-body);
  -webkit-appearance: none;
  appearance: none;
}

textarea.input {
  min-height: 132px;
  resize: vertical;
}

.count {
  display: block;
  margin-top: 4px;
  color: var(--gray-lt);
  text-align: right;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.chip span {
  display: flex;
  align-items: center;
  min-height: 44px;
  margin: var(--u);
  padding: 0 12px;
}

/* Honeypot. Off-screen rather than display:none, which some bots skip. */
.trap {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.notice {
  color: var(--gray-lt);
}

.turnstile:empty {
  display: none;
}

.form-error {
  --edge: var(--red);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: var(--u);
  padding: 12px;
}

.form-error::before {
  content: "!";
  flex: none;
  padding: 6px 10px 4px;
  background: var(--red);
  color: var(--white);
  font: 16px/1 var(--font-head);
}

/* 6. Saved */

.saved {
  --edge: var(--red);
  display: grid;
  justify-items: center;
  gap: 20px;
  max-width: 552px;
  margin: var(--u) auto;
  padding: 40px 16px;
  font: 16px/1.75 var(--font-head);
  text-align: center;
}

/* 7. Wall: every entry is a dialog box with the signer's name on the speaker tab */

.wall-screen {
  max-width: 688px;
  margin: 0 auto;
}

.wall-title {
  margin-bottom: 32px;
}

.wall-title span {
  display: block;
}

.wall-main[lang="en"] { font: 24px/1.3 var(--font-head); }
.wall-main[lang="ja"] { font: 32px/1.3 var(--font-body); }

.wall-title-alt {
  margin-top: 8px;
  color: var(--gray-lt);
}

.wall-title-alt[lang="en"] { font: 16px/1.5 var(--font-head); }
.wall-title-alt[lang="ja"] { font: 24px/1.3 var(--font-body); }

.wall-state {
  color: var(--gray-lt);
}

.wall-state + .btn {
  margin-top: 16px;
}

.entries {
  display: grid;
  gap: 32px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.entries:not(:empty) {
  margin-top: 14px;
}

/* Japan signers sit left, friends cheering from afar sit right, like two sides of a conversation. */
.entry {
  width: calc(100% - 24px);
}

.entry-afar {
  margin-left: auto;
}

.entry .dialog {
  padding: 0 16px 12px;
}

.entry-name {
  display: inline-block;
  max-width: 100%;
  margin: -14px 0 0 -4px;
  padding: 2px 8px;
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  vertical-align: top;
}

.entry-origin {
  margin-top: 8px;
  color: var(--gray-lt);
}

.entry-message {
  margin-top: 8px;
  white-space: pre-wrap;
}

.entry-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 16px;
  margin-top: 12px;
  color: var(--gray-lt);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.badge .px {
  flex: none;
}

/* The visitor's own message, just saved. */
.entry-mine .dialog {
  --edge: var(--red);
}

#more {
  display: flex;
  margin: 32px auto 0;
}

/* 8. Bonus stage: the skyline stands on a white band, and the page inverts for Las Vegas */

.bonus-screen {
  margin-top: 40px;
}

.bonus-sky {
  display: flex;
  justify-content: center;
}

.skyline {
  width: 240px;
}

.bonus-ground {
  --ink: var(--black);
  --paper: var(--white);
  background: var(--white);
  color: var(--black);
}

.bonus-inner {
  position: relative;
  max-width: 624px;
  margin: 0 auto;
  padding: 32px var(--gutter) 48px;
}

.dice {
  width: 63px;
  margin-bottom: 20px;
}

.bonus-title {
  margin-bottom: 16px;
  font: 16px/1.6 var(--font-head);
  text-wrap: balance;
}

.bonus-inner .btn {
  margin-top: 28px;
}

/* 9. Footer */

.footer {
  padding: 40px var(--gutter) calc(40px + env(safe-area-inset-bottom));
  color: var(--gray-lt);
  text-align: center;
}

.footer-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0 12px;
  color: var(--white);
}

.footer-note {
  max-width: 480px;
  margin: 12px auto 0;
}

.noscript {
  padding: 16px;
  background: var(--white);
  color: var(--black);
  text-align: center;
}

/* Japanese: DotGothic16 carries the headings, and words stay whole where a line breaks. */

html[lang="ja"] .btn,
html[lang="ja"] .panel-title,
html[lang="ja"] .bonus-title,
html[lang="ja"] .saved {
  font: 24px/1.5 var(--font-body);
  word-break: keep-all;
}

/* Wider screens */

@media (min-width: 360px) {
  .game-title { font-size: 40px; }
  .team { font-size: 16px; }
  .scene { width: 288px; }
  .skyline { width: 360px; }
}

@media (min-width: 560px) {
  :root { --gutter: 24px; }
  .screen { padding-block: 64px; }
  .title-screen { padding-top: 80px; }
  .story-screen { padding-top: 24px; }
  .game-title { font-size: 48px; }
  .scene { width: 384px; }
  .suits { width: 172px; }
  .skyline { width: 480px; }
  .js .story-lines li { min-height: 7em; }
  .choices { grid-template-columns: 1fr 1fr; padding-inline: 16px; }
  .fields { padding-inline: 24px; }
  .entry { width: min(100% - 96px, 520px); }
  .dice { position: absolute; top: 20px; right: var(--gutter); width: 84px; margin: 0; }
  .bonus-title { min-height: 40px; padding-right: 112px; }
}

@media (min-width: 760px) {
  .game-title { font-size: 56px; }
  .scene { width: 480px; }
  .skyline { width: 600px; }
  .marquee { padding-block: 52px 48px; }
}

@media (prefers-reduced-motion: reduce) {
  .btn-start span { animation: none; }
  .btn:active { transform: none; }
}
