/* =========================================================
   未完成の城 · Unfinished Castle — style.css
   ========================================================= */

/* ---------- Colours (lo-fi dusk palette) ----------
   Change these and the whole page follows. */
:root {
  --ink: #2b2d42; /* page background, text on paper */
  --ink-soft: #4a4c6a;
  --paper: #f4ecdc; /* windows, labels */
  --paper-dark: #e3d6bd;
  --teal: #4f7c86; /* buttons, train stripe */
  --hanko: #b5524b; /* red stamp colour */
  --nemophila: #9db8e8; /* blue flowers */
  --peach: #efbf9f; /* sunset */
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  background: var(--ink);
  color: var(--paper);
  font-family: "Pixelify Sans", system-ui, sans-serif;
  /* Pixelify Sans joins "fi" into one letter that looks like an "A"
     ("UnAnished Castle"), so keep every letter separate */
  font-variant-ligatures: no-common-ligatures;
}

/* Anything marked lang="ja" uses the Japanese font */
:lang(ja) {
  font-family: "Shippori Mincho", serif;
}

/* ---------- Title ---------- */
.site-header {
  text-align: center;
}

.site-header h1 {
  margin: 0;
  font-size: clamp(1.5rem, 4.5vw, 2.8rem);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.site-header h1 :lang(ja) {
  font-weight: 700;
}
.site-header .dot {
  color: var(--peach);
  padding: 0 0.15em;
}

.tagline {
  margin: 0.25rem 0 0;
  color: var(--nemophila);
  font-size: clamp(0.9rem, 2vw, 1.1rem);
}

main {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

/* ---------- The scene ---------- */
.scene {
  position: relative;
  /* As wide as possible, but short enough to fit on screen without scrolling */
  width: min(100%, max(320px, calc((100vh - 13rem) * 16 / 9)));
  aspect-ratio: 320 / 180;
  overflow: hidden; /* hides the train when it's off-screen */
  container-type: inline-size; /* lets text inside size itself with "cqw" units (1cqw = 1% of scene width) */
  box-shadow:
    0 0 0 4px var(--ink-soft),
    0 14px 30px rgba(0, 0, 0, 0.45);
}

/* Keep pixels sharp and blocky when the small canvas is scaled up */
.scene canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}
.scene canvas.placed {
  width: calc(var(--w) / 320 * 100%); /* placed canvases (the sign) use their own size */
  height: calc(var(--h) / 180 * 100%);
}

/* ---------- 2.5D layers ----------
   Each .layer fills the scene. script.js sets --mx and --my (from -1 to 1)
   based on where the mouse is. A layer slides by its --depth times that amount,
   so close layers move a lot and far ones barely move: parallax.
   scale(1.03) makes every layer a little bigger than the scene, so the edges
   never show a gap when they slide. */
.layer {
  --shift: calc(var(--depth) * 0.05cqw);
  position: absolute;
  inset: 0;
  pointer-events: none; /* clicks pass through to the layers underneath... */
  transform: translate(
      calc(var(--mx, 0) * var(--shift) * -1),
      calc(var(--my, 0) * var(--shift) * -0.5)
    )
    scale(1.03);
  transition: transform 0.9s ease-out, filter 2s ease;
}
.layer button {
  pointer-events: auto;
} /* ...except on buttons */
.layer > canvas:not(.placed) {
  position: absolute;
  inset: 0;
}

/* ---------- Camera effects ---------- */

/* Depth of field: the closest layer is out of focus, like a real lens */
#layer-foreground {
  filter: blur(3px);
}

/* Bloom: script.js copies only the brightest pixels here; blurring them
   and adding them on top makes lights and sunlit edges glow */
#bloom {
  filter: blur(6px);
  mix-blend-mode: screen;
  opacity: 0.55;
}

/* Rays of light fanning out from the sun */
.sunrays {
  position: absolute;
  inset: 0;
  pointer-events: none;
  mix-blend-mode: screen;
  background: repeating-conic-gradient(
    from 0deg at 94% 53%,
    rgba(253, 228, 191, 0.16) 0deg 2.5deg,
    transparent 2.5deg 8deg
  );
  -webkit-mask-image: radial-gradient(
    ellipse 75% 90% at 94% 53%,
    #000,
    transparent 75%
  );
  mask-image: radial-gradient(
    ellipse 75% 90% at 94% 53%,
    #000,
    transparent 75%
  );
  filter: blur(5px);
  animation: rays 9s ease-in-out infinite alternate;
}
@keyframes rays {
  from {
    opacity: 0.45;
  }
  to {
    opacity: 1;
  }
}

/* Tilt-shift: blurs the top and bottom edges of the picture so the castle
   in the middle looks like the thing the camera is focused on */
.tilt-shift {
  position: absolute;
  inset: 0;
  pointer-events: none;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  -webkit-mask-image: linear-gradient(
    to bottom,
    #000,
    transparent 28%,
    transparent 80%,
    #000
  );
  mask-image: linear-gradient(
    to bottom,
    #000,
    transparent 28%,
    transparent 80%,
    #000
  );
}

/* Lighting overlay: warm sunset glow on the right, darker corners */
.lighting {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(
      ellipse 45% 60% at 94% 53%,
      rgba(253, 228, 191, 0.22),
      transparent 70%
    ),
    radial-gradient(
      ellipse 75% 85% at 55% 50%,
      transparent 60%,
      rgba(43, 45, 66, 0.45) 100%
    );
}

/* Turns --x/--y/--w/--h (in the 320×180 pixel grid) into positions on screen */
.placed {
  position: absolute;
  left: calc(var(--x) / 320 * 100%);
  top: calc(var(--y) / 180 * 100%);
  width: calc(var(--w) / 320 * 100%);
  height: calc(var(--h) / 180 * 100%);
}

/* ---------- Clickable castle parts ---------- */
.hotspot {
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}
.hotspot:hover,
.hotspot:focus-visible {
  outline: 2px dashed rgba(244, 236, 220, 0.8);
  outline-offset: 2px;
}

/* The little name tag that appears above a hotspot */
.label {
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translate(-50%, -6px);
  white-space: nowrap;
  padding: 0.15em 0.5em;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  font-family: "Pixelify Sans", system-ui, sans-serif;
  font-size: clamp(11px, 1.4cqw, 18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.hotspot:hover .label,
.hotspot:focus-visible .label {
  opacity: 1;
}

/* On touch screens there's no hover, so always show the labels */
@media (hover: none) {
  .hotspot .label {
    opacity: 1;
  }
}

/* ---------- The train ---------- */
.train {
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  /* trains.js moves it by changing --x, and sets its size (--w, --h) to fit each train */
}
.train:disabled {
  cursor: default;
}

/* A tiny 1-pixel rattle while moving */
.train.moving canvas {
  animation: rattle 0.25s steps(2) infinite;
}
@keyframes rattle {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-3%);
  }
}

/* "Send me a message" tag: only shown while the train waits at the platform */
.train .label {
  font-size: clamp(11px, 1.5cqw, 19px);
}
.train.waiting .label {
  opacity: 1;
  animation: bob 1.2s steps(2) infinite;
}
.train.waiting:hover,
.train.waiting:focus-visible {
  outline: 2px dashed rgba(244, 236, 220, 0.8);
  outline-offset: 2px;
}
@keyframes bob {
  from {
    transform: translate(-50%, -6px);
  }
  to {
    transform: translate(-50%, -10px);
  }
}

/* ---------- Rooms (rooms.js) ---------- */

/* Everything outside: when you enter a room it zooms towards where you clicked
   (--zx, --zy, set by rooms.js) and fades away, then the room appears. */
.castle-view {
  position: absolute;
  inset: 0;
  transform-origin: var(--zx, 50%) var(--zy, 50%);
  transition:
    transform 0.65s ease-out,
    opacity 0.65s ease-out,
    visibility 0s;
}
.scene.in-room .castle-view {
  transform: scale(2.6);
  opacity: 0;
  visibility: hidden; /* also takes the castle's buttons out of the Tab order */
  transition:
    transform 0.65s ease-in,
    opacity 0.65s ease-in,
    visibility 0s 0.65s;
}

.room {
  position: absolute;
  inset: 0;
  outline: none;
  animation: room-in 0.5s ease-out;
}
.room > canvas:not(.placed) {
  position: absolute;
  inset: 0;
}
@keyframes room-in {
  from {
    opacity: 0;
    transform: scale(1.08);
  }
}

/* The room's name, on a little paper plaque in the corner */
.room-name {
  position: absolute;
  top: 3%;
  left: 2%;
  margin: 0;
  padding: 0.2em 0.6em;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  font-size: clamp(12px, 1.8cqw, 22px);
  font-weight: 600;
  pointer-events: none;
}

.room .room-exit {
  position: absolute;
  left: 2%;
  bottom: 4%;
  font-size: clamp(11px, 1.4cqw, 18px);
}

/* The ryokan's glow layer: the andon's light is added on top, like real light (screen blending) */
#ryokan-glow {
  mix-blend-mode: screen;
  pointer-events: none;
}
.room > canvas {
  pointer-events: none; /* clicks go to the hotspots, not the pictures */
}

/* ---------- Night mode (switched at the ryokan's futon, room-ryokan.js) ----------
   The castle scene repaints itself for night (script.js, "Night"): moon, stars, lit
   windows. Here: no sun rays, cool moonlight instead of the warm sunset glow, stronger
   bloom so every lamp and window glows. The genkan is simply dimmed. */
.scene canvas {
  transition: filter 1.5s ease;
}
body.night #genkan-canvas {
  filter: brightness(0.5) saturate(0.6) hue-rotate(-12deg);
}
body.night #station-sign {
  filter: brightness(0.55) saturate(0.7); /* the sign isn't a light, so it sits in the dark too */
}
body.night #bloom {
  opacity: 0.85;
}
body.night .sunrays {
  animation: none;
  opacity: 0;
}
body.night .lighting {
  background:
    radial-gradient(ellipse 35% 45% at 88% 40%, rgba(200, 210, 255, 0.1), transparent 70%),
    radial-gradient(ellipse 75% 85% at 55% 50%, transparent 55%, rgba(8, 10, 30, 0.55) 100%);
}

/* The business card flying into the box */
.flying-card {
  position: absolute;
  image-rendering: pixelated;
  pointer-events: none;
}

/* ---------- Business card pop-up (room-genkan.js) ---------- */
.privacy-note {
  padding: 0.4rem 0.6rem;
  border-left: 4px solid var(--teal);
  background: rgba(79, 124, 134, 0.1);
}
/* The real file input is hidden; the pixel button around it is what you click */
.file-button {
  display: inline-block;
}
.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.file-button:focus-within {
  outline: 2px dashed var(--ink);
  outline-offset: 2px;
}
.meishi-card {
  display: block;
  /* shown at its true size (every pixel exactly one pixel: sharpest small
     print); only shrunk when the screen is too narrow, like on a phone */
  width: auto;
  max-width: 100%;
  height: auto;
  margin: 0 auto 1rem; /* centred */
  image-rendering: pixelated;
}
#meishi-download,
#my-card-download {
  text-decoration: none;
}

/* Fitting the 4 corners to the card in the photo (room-genkan.js) */
.card-fit {
  position: relative;
  margin: 0 auto 0.8rem;
  touch-action: none; /* dragging a corner on a phone mustn't scroll the page */
  user-select: none;
}
.card-fit canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.fit-outline {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.fit-outline polygon {
  fill: rgba(79, 124, 134, 0.18);
  stroke: var(--teal);
  stroke-width: 3;
}
.fit-corner {
  position: absolute;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px; /* centred on its point */
  padding: 0;
  border: 3px solid var(--paper);
  border-radius: 50%;
  background: var(--hanko);
  box-shadow: 0 0 0 2px var(--ink);
  cursor: grab;
  touch-action: none;
}
.fit-corner:active {
  cursor: grabbing;
}
.fit-corner:focus-visible {
  outline: 3px dashed var(--ink);
  outline-offset: 3px;
}
.detail-choice {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 0.8rem;
}
.detail-choice .pixel-btn {
  font-size: 0.85em;
  padding: 0.3rem 0.7rem;
}
.detail-choice .pixel-btn[aria-pressed="true"] {
  background: var(--teal);
  color: var(--paper);
}
.link-button {
  padding: 0;
  border: none;
  background: none;
  color: var(--teal);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* ---------- Departure signal and conductor (station.js) ---------- */

/* Anything with the "hidden" attribute stays hidden, even if other rules give it a size */
[hidden] {
  display: none !important;
}

/* The signal sits at the very left edge, so its name tag starts at its left
   instead of being centred (which would push it off the scene) */
#signal .label {
  left: 0;
  transform: translate(0, -6px);
}
#signal:disabled {
  cursor: default;
}
#signal:disabled .label {
  display: none;
}

/* The conductor has no name tag on purpose: clicking him is an easter egg */
.conductor {
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}
.conductor:hover,
.conductor:focus-visible {
  outline: 2px dashed rgba(244, 236, 220, 0.8);
  outline-offset: 2px;
}

/* The certificate picture inside its pop-up */
.certificate {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 0 1rem;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.25);
}
#certificate-download {
  text-decoration: none;
}

/* ---------- Under the scene ---------- */
.hint {
  margin: 0;
  color: var(--paper-dark);
  font-size: 0.95rem;
  text-align: center;
}

.map-legend ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.map-legend button {
  padding: 0.35rem 0.8rem;
  border: 2px solid var(--paper);
  background: transparent;
  color: var(--paper);
  font: inherit;
  cursor: pointer;
}
.map-legend button:hover,
.map-legend button:focus-visible {
  background: var(--paper);
  color: var(--ink);
}
.map-legend button:disabled {
  opacity: 0.4;
  cursor: default;
  background: transparent;
  color: var(--paper);
}

/* The Résumé button stands out from the castle buttons, so it's easy to spot */
.map-legend .glance-button {
  border-color: var(--peach);
  background: var(--peach);
  color: var(--ink);
  font-weight: 600;
}
.map-legend .glance-button:hover,
.map-legend .glance-button:focus-visible {
  background: var(--paper);
  border-color: var(--paper);
}

.site-footer {
  margin-top: auto;
  color: #8a8cab;
  font-size: 0.85rem;
}

/* ---------- Pop-up windows ---------- */
dialog {
  width: min(560px, 92vw);
  padding: 0;
  border: none;
  background: transparent;
  color: var(--ink);
}
dialog::backdrop {
  background: rgba(30, 31, 48, 0.65);
}

.window {
  position: relative;
  padding: 1.25rem 1.5rem 1.5rem;
  background: var(--paper);
  border: 4px solid var(--ink);
  box-shadow:
    inset 0 0 0 3px var(--paper-dark),
    6px 6px 0 rgba(0, 0, 0, 0.4);
  font-family: "Pixelify Sans", system-ui, sans-serif;
  line-height: 1.5;
}
.window h2 {
  margin: 0;
  font-size: 1.6rem;
}
.window .romaji {
  margin: 0 0 1rem;
  color: var(--teal);
}

.cards {
  display: grid;
  gap: 0.5rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}
.cards li {
  padding: 0.6rem 0.8rem;
  border: 2px dashed var(--ink-soft);
}

/* ---------- The theatre's playbill (room-theatre.js) ---------- */
.playbill-list {
  display: grid;
  gap: 0.5rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}
.playbill-play {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 0.7rem;
  width: 100%;
  padding: 0.6rem 0.8rem;
  font: inherit;
  text-align: left;
  color: var(--ink);
  background: #fffaf0;
  border: 2px solid var(--ink);
  cursor: pointer;
}
.playbill-play:hover,
.playbill-play:focus-visible {
  background: var(--paper-dark);
}
.playbill-number {
  grid-row: span 2;
  align-self: center;
  min-width: 1.6em;
  text-align: center;
  color: var(--paper);
  background: var(--hanko);
}
.playbill-summary {
  color: var(--ink-soft);
}
.playbill-empty {
  color: var(--ink-soft);
}
/* the act being played: a little stage with a curtain that sweeps across between acts */
.act-stage {
  position: relative;
  overflow: hidden;
  min-height: 8rem;
  margin: 0.8rem 0;
  padding: 0.8rem 1rem;
  background: #fffaf0;
  border: 2px solid var(--ink);
  border-top: 6px solid #3f2a1c;
}
.act-stage h3 {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
  color: var(--hanko);
}
.act-stage p {
  margin: 0;
  white-space: pre-wrap; /* keep the line breaks I typed */
  font-family: system-ui, sans-serif;
}
.act-stage.curtain-sweep::after {
  content: "";
  position: absolute;
  inset: 0;
  /* the 定式幕 curtain: black, persimmon, green */
  background: repeating-linear-gradient(90deg, #1e1a1e 0 24px, #b5562e 24px 48px, #3f6a40 48px 72px);
  animation: curtain-open 0.7s ease-in forwards;
}
@keyframes curtain-open {
  to {
    transform: translateX(101%);
  }
}
.act-buttons {
  align-items: center;
  justify-content: space-between;
}
.act-count {
  color: var(--ink-soft);
}
.kuroko-toggle {
  margin-top: 0.8rem;
}
.kuroko-toggle[aria-pressed="true"] {
  color: var(--paper);
  background: #1e1a1e;
}
.kuroko-box {
  margin: 0.6rem 0;
  padding: 0.7rem 0.9rem;
  color: var(--paper);
  background: #1e1a1e;
}
.kuroko-box p {
  margin: 0 0 0.4rem;
}
.kuroko-box a.pixel-btn {
  text-decoration: none;
}
.kuroko-tech {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.6rem;
  padding: 0;
  list-style: none;
}
.kuroko-tech li {
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--paper);
}
#to-playbill {
  margin: 0.6rem 0.6rem 0.8rem 0;
}

/* ---------- At a glance (résumé panel) ---------- */
dialog.wide {
  width: min(760px, 94vw);
}
.glance-name {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 600;
}
#glance-content h3 {
  margin: 1.1rem 0 0.4rem;
  font-size: 1.05rem;
  color: var(--teal);
}
#glance-content p {
  margin: 0.2rem 0;
}
#glance-content a {
  color: var(--ink);
}

/* Little label tags for skills */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.tags li {
  padding: 0.1rem 0.55rem;
  border: 2px solid var(--ink);
  background: var(--paper-dark);
}
.tags.small li {
  border-width: 1px;
  font-size: 0.85rem;
}

.glance-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.2rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
#glance-content .glance-links .pixel-btn {
  display: inline-block;
  color: var(--paper);
  text-decoration: none;
}
#glance-content .glance-links .pixel-btn.secondary {
  color: var(--ink);
  cursor: default;
}

/* Project cards: as many per row as fit */
.glance-projects {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.6rem;
  margin: 0 0 1.2rem;
  padding: 0;
  list-style: none;
}
.glance-projects > li {
  padding: 0.6rem 0.8rem;
  border: 2px dashed var(--ink-soft);
}
.glance-projects > li.glance-note {
  grid-column: 1 / -1; /* "Loading…" and friends use the whole row */
  border: none;
  padding: 0;
  color: var(--ink-soft);
}

/* 工事日誌 The construction log: dated entries, newest first */
.construction-log {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  max-height: 55vh;
  overflow-y: auto;
}
.construction-log li {
  padding: 0.45rem 0;
  border-bottom: 1px dashed rgba(43, 45, 66, 0.25);
}
.construction-log time {
  font-family: "Pixelify Sans", monospace;
  color: var(--ink-soft, #5a5670);
  margin-right: 0.3rem;
}

.progress {
  font-family: monospace;
  color: var(--teal);
}

/* Chunky game-style button */
.pixel-btn {
  padding: 0.45rem 1rem;
  border: 3px solid var(--ink);
  background: var(--teal);
  color: var(--paper);
  box-shadow: 3px 3px 0 var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.pixel-btn:hover {
  filter: brightness(1.1);
}
.pixel-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}
.pixel-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}
.pixel-btn.secondary {
  background: var(--paper-dark);
  color: var(--ink);
}

/* ---------- Ticket (contact form) ---------- */
.ticket {
  /* dashed "tear here" line down the left side */
  border-left: 4px dashed var(--ink);
  background:
    repeating-linear-gradient(
      0deg,
      transparent 0 22px,
      rgba(79, 124, 134, 0.08) 22px 23px
    ),
    var(--paper);
}
.stamp {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  width: 3rem;
  height: 3rem;
  display: grid;
  place-items: center;
  border: 3px solid var(--hanko);
  border-radius: 50%;
  color: var(--hanko);
  font-size: 1.5rem;
  font-weight: 700;
  transform: rotate(-12deg);
  opacity: 0.85;
}

#contact-form label,
#friend-form label {
  display: block;
  margin-bottom: 0.8rem;
  font-weight: 600;
}
#contact-form label span,
#friend-form label span {
  font-weight: 500;
  color: var(--teal);
  margin-left: 0.3em;
}
#contact-form input,
#contact-form textarea,
#friend-form input,
#friend-form textarea {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem;
  border: 2px solid var(--ink);
  background: #fffaf0;
  color: var(--ink);
  font: inherit;
  font-weight: 400;
}
#contact-form textarea,
#friend-form textarea {
  resize: vertical;
}
#contact-form input:focus,
#contact-form textarea:focus,
#friend-form input:focus,
#friend-form textarea:focus {
  outline: 3px solid var(--teal);
  outline-offset: 1px;
}

/* The spam trap box: moved far off-screen, so people never see it */
.honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
/* The Turnstile check box */
.human-check {
  margin: 0.25rem 0 0.5rem;
}

.form-status {
  min-height: 1.2em;
  margin: 0 0 0.5rem;
  color: var(--hanko);
}
.ticket-buttons {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ---------- Toast message ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  max-width: 90vw;
  margin: 0;
  padding: 0.6rem 1rem;
  background: var(--paper);
  color: var(--ink);
  border: 3px solid var(--ink);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.4);
  text-align: center;
  transform: translate(-50%, 200%);
  transition: transform 0.3s;
}
.toast.show {
  transform: translate(-50%, 0);
}

/* ---------- ⚙ Settings (settings.js) ----------
   A see-through gear in the top right corner of the scene: faint until you
   point at it, so it doesn't spoil the picture. */
.settings-btn {
  position: absolute;
  top: 2.5%;
  right: 1.5%;
  z-index: 20; /* above the castle view and the rooms */
  width: clamp(26px, 3.4cqw, 42px);
  aspect-ratio: 1;
  padding: 0.3em;
  border: 2px solid rgba(244, 236, 220, 0.45);
  background: rgba(43, 45, 66, 0.3);
  color: var(--paper);
  opacity: 0.55;
  cursor: pointer;
  transition:
    opacity 0.2s,
    background 0.2s;
}
.settings-btn:hover,
.settings-btn:focus-visible {
  opacity: 1;
  background: rgba(43, 45, 66, 0.75);
}
.settings-btn svg {
  display: block;
  width: 100%;
  height: 100%;
  shape-rendering: crispEdges; /* keep the pixel gear blocky */
}
.settings-group {
  margin: 0 0 1rem;
  padding: 0.4rem 0.9rem 0.7rem;
  border: 2px solid var(--ink-soft);
}
.settings-group legend {
  padding: 0 0.3rem;
  font-weight: 600;
}
.settings-choice {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.2rem 0;
  cursor: pointer;
}
.settings-choice input {
  width: 1.1em;
  height: 1.1em;
  margin: 0;
  accent-color: var(--teal);
}
.settings-note {
  margin: 0.3rem 0 0;
  font-size: 0.85em;
  color: var(--ink-soft);
}

/* ---------- Train gallery (index.html?gallery) ---------- */
.train-gallery {
  position: fixed;
  inset: 0;
  z-index: 50;
  overflow: auto;
  padding: 1.5rem;
  background: #8e9aa8;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.train-gallery figure {
  margin: 0;
}
.train-gallery figcaption {
  margin-bottom: 0.3rem;
  color: var(--ink);
  font-size: 1rem;
}
.train-gallery code {
  margin-left: 0.5em;
  color: var(--paper);
  font-size: 0.85em;
}
.train-gallery canvas {
  display: block;
  image-rendering: pixelated;
  background: linear-gradient(to bottom, transparent 85%, #77707a 85%); /* a strip of track */
}

/* ---------- Seattle weather (when the Sounder visits) ----------
   script.js adds class="rainy" to <body> while the Sounder is in town. */
body {
  transition: background-color 2s;
}
body.rainy {
  --ink: #3a3f47;
  --ink-soft: #5b626c;
  --nemophila: #aeb8c4;
  --peach: #c2cad3;
}
body.rainy .layer {
  filter: saturate(0.35) brightness(0.85); /* drain the colour out of everything */
}
.gloom {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 2s;
  background: linear-gradient(to bottom,
    rgba(84, 92, 104, 0.85), rgba(110, 118, 130, 0.55) 45%,
    rgba(100, 108, 120, 0.5) 58%, rgba(70, 78, 90, 0.2) 70%);
}
body.rainy .gloom { opacity: 1; }
.sunrays, #bloom, .lighting { transition: opacity 2s; }
body.rainy .sunrays { animation: none; opacity: 0; }
body.rainy #bloom { opacity: 0.08; }
body.rainy .lighting { opacity: 0.5; }

/* ---------- Respect "reduce motion" settings ----------
   Some people turn off animations in their computer settings (it can cause
   dizziness). Then every CSS animation and transition on the site is switched
   off: things simply appear in their final place. script.js and trains.js do
   the same for the canvas: one still frame, no parallax, trains just appear. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  /* without its animation the theatre's act curtain would never open */
  .act-stage.curtain-sweep::after {
    display: none;
  }
}

/* ---------- Mini-games (shoin-games.js) ---------- */
.game-canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  border: 3px solid var(--ink);
  cursor: crosshair;
  touch-action: none; /* so dragging on a phone moves the poi instead of scrolling */
}
.game-canvas:focus-visible {
  outline: 2px dashed var(--teal);
  outline-offset: 3px;
}
.game-status {
  min-height: 3em;
  margin: 0.6rem 0;
}
.game-best {
  align-self: center;
  color: var(--teal);
  font-weight: 600;
}

/* 番付 Leaderboard under each game */
.score-form {
  margin-top: 1rem;
  padding: 0.7rem 0.8rem;
  border: 2px dashed var(--ink-soft);
}
.score-form label {
  display: block;
}
.score-form input {
  display: block;
  width: min(100%, 16rem);
  margin-top: 0.2rem;
  padding: 0.4rem;
  font: inherit;
  border: 2px solid var(--ink);
  background: #fffaf0;
}
.leaderboard h3 {
  margin: 1rem 0 0.3rem;
  font-size: 1.1rem;
}
.leaderboard-list {
  margin: 0;
  padding-left: 2rem;
  columns: 2 12rem; /* two columns when there's room */
}
.leaderboard-list li {
  break-inside: avoid;
}
.leaderboard-list .who {
  font-weight: 600;
}
.leaderboard-list .note {
  list-style: none;
  margin-left: -2rem;
  color: var(--ink-soft);
}

/* ---------- 個人情報 The privacy note ---------- */
.privacy-body {
  max-height: 60vh;
  overflow-y: auto;
  margin-bottom: 1rem;
  padding-right: 0.5rem;
}
.privacy-body:focus-visible {
  outline: 2px dashed var(--teal);
}
.privacy-body h3 {
  margin: 1.1rem 0 0.2rem;
  font-size: 1.05rem;
}
.privacy-body p {
  margin: 0.2rem 0 0.5rem;
}
/* The short "who sees this" line under a form, with its Privacy link */
.form-note {
  margin: 0.3rem 0;
  font-size: 0.9rem;
  color: var(--teal);
}

/* ---------- 書庫 Writing: musings + friends of the castle (writing.js) ---------- */
.writing-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.writing-tabs .pixel-btn[aria-pressed="false"] {
  background: var(--paper-dark);
  color: var(--ink);
}
.writing-tabs .pixel-btn[aria-pressed="true"] {
  background: var(--teal);
  color: var(--paper);
}
#writing-musings,
#writing-friends {
  max-height: 58vh;
  overflow-y: auto;
  margin-bottom: 1rem;
  padding-right: 0.5rem;
}
.musing-list,
.friend-notes {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}
.writing-note {
  color: var(--teal);
}
/* each post title is a button that opens the post */
.musing-link {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  padding: 0.5rem 0;
  border: none;
  border-bottom: 1px dashed rgba(43, 45, 66, 0.25);
  background: none;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.musing-link:hover .musing-link-title,
.musing-link:focus-visible .musing-link-title {
  color: var(--teal);
  text-decoration: underline;
}
.musing-link-title {
  font-weight: 600;
}
.musing-date {
  color: var(--teal);
  white-space: nowrap;
}
.musing h3 {
  margin: 0.6rem 0 0;
  font-size: 1.3rem;
}
.musing .musing-date {
  margin: 0 0 0.6rem;
}
/* a post keeps its own line breaks (blank lines become paragraphs) */
.musing-body p {
  margin: 0 0 0.8rem;
  white-space: pre-line;
}
/* friends' notes: their words in a quote, then who they are */
.friend-notes li {
  margin-bottom: 1rem;
}
.friend-notes blockquote {
  margin: 0;
  padding: 0.5rem 0.75rem;
  border-left: 4px solid var(--hanko);
  background: rgba(181, 82, 75, 0.08);
  white-space: pre-line;
}
.friend-who {
  margin: 0.25rem 0 0 0.75rem;
  color: var(--teal);
}
#friend-form {
  padding-top: 0.5rem;
  border-top: 2px dashed rgba(43, 45, 66, 0.3);
}
#friend-form h3 {
  margin: 0.4rem 0 0.2rem;
}
