:root {
  --night: #070920;
  --ink: #1a1030;
  --panel: #1b1a46;
  --panel-2: #262463;
  --border: #fff3d6;
  --text: #fff3d6;
  --muted: #a9a6d9;
  --gold: #ffe7a0;
  --pink: #ff9ec4;
  --rose: #ff5c8a;
  --paper: #fff4e2;
  --paper-line: #f1dcc0;
  --paper-ink: #3b2a4a;
  --px: 4px;
  --title: 'Press Start 2P', monospace;
  --body: 'VT323', monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--night);
  color: var(--text);
  font-family: var(--body);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

img, canvas { image-rendering: pixelated; image-rendering: crisp-edges; }

#scene { position: fixed; inset: 0; display: block; touch-action: manipulation; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

.hidden { opacity: 0; pointer-events: none; }

/* Notched pixel border, like an old RPG text box */
.pixel-box {
  background: var(--panel);
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--border),
    0 var(--px) 0 0 var(--border),
    calc(var(--px) * -1) 0 0 0 var(--border),
    var(--px) 0 0 0 var(--border),
    inset 0 var(--px) 0 0 var(--panel-2);
}

/* ---- HUD ---------------------------------------------------------------- */
#hud {
  position: fixed; top: max(12px, env(safe-area-inset-top)); left: 14px;
  display: flex; gap: 16px;
  font-family: var(--title); font-size: 10px;
  transition: opacity .6s;
  text-shadow: 2px 2px 0 var(--ink);
}
.hud-item { display: flex; align-items: center; gap: 6px; }
.hud-item img { width: 15px; height: 15px; }
#hud b { font-weight: normal; }
.hud-btn {
  font-family: var(--title); font-size: 8px; color: var(--gold);
  padding: 6px 7px; margin: -6px 0; min-height: 28px;
  background: rgba(26, 16, 48, .6);
  box-shadow: 0 -2px 0 var(--panel-2), 0 2px 0 var(--panel-2), -2px 0 0 var(--panel-2), 2px 0 0 var(--panel-2);
}
.hud-btn:hover { color: var(--text); }
.hud-btn.confirm { color: var(--ink); background: var(--pink); }
.hud-btn[hidden] { display: none; }

#mute {
  position: fixed; top: max(8px, env(safe-area-inset-top)); right: 10px;
  width: 44px; height: 44px; display: grid; place-items: center;
  transition: opacity .6s;
}
#mute img { width: 27px; height: 21px; filter: drop-shadow(2px 2px 0 var(--ink)); }

/* ---- Tooltip, hint, toast ---------------------------------------------- */
#tooltip {
  position: fixed; pointer-events: none; z-index: 5;
  font-family: var(--title); font-size: 9px; line-height: 1.4;
  padding: 6px 8px; background: var(--ink); color: var(--gold);
  box-shadow: 0 -2px 0 var(--border), 0 2px 0 var(--border), -2px 0 0 var(--border), 2px 0 0 var(--border);
  transform: translate(-50%, -100%);
  opacity: 0; transition: opacity .15s; white-space: nowrap;
}
#tooltip.show { opacity: 1; }

#hint {
  position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  font-family: var(--title); font-size: 9px; color: var(--gold);
  text-shadow: 2px 2px 0 var(--ink); white-space: nowrap;
  animation: blink 1.2s steps(2) infinite; transition: opacity .8s;
}

#toast {
  position: fixed; left: 50%; top: 56px; transform: translate(-50%, -8px);
  max-width: min(90vw, 460px); text-align: center;
  font-size: 22px; line-height: 1.1; padding: 8px 14px;
  background: var(--ink); color: var(--text);
  box-shadow: 0 -2px 0 var(--pink), 0 2px 0 var(--pink), -2px 0 0 var(--pink), 2px 0 0 var(--pink);
  opacity: 0; pointer-events: none;
  transition: opacity .4s, transform .4s steps(4);
  z-index: 6;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

#flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 20; }
#flash.go { animation: flash .45s steps(5) forwards; }
@keyframes flash { 0% { opacity: .95; } 100% { opacity: 0; } }

@keyframes blink { 50% { opacity: 0; } }

/* ---- Dialog box ---------------------------------------------------------- */
#dialog-layer {
  position: fixed; inset: 0; z-index: 8;
  display: none; align-items: flex-end; justify-content: center;
  padding: 0 16px max(28px, env(safe-area-inset-bottom));
  cursor: pointer;
}
#dialog-layer.open { display: flex; }
#dialog {
  width: min(560px, 100%); padding: 16px 20px 22px; position: relative;
  animation: rise .3s steps(4);
}
#dialog-title {
  font-family: var(--title); font-size: 10px; color: var(--gold); margin-bottom: 10px;
}
#dialog-text { font-size: 26px; line-height: 1.05; min-height: 2.1em; }
#dialog-next {
  position: absolute; right: 16px; bottom: 10px;
  width: 0; height: 0; border: 6px solid transparent; border-top: 7px solid var(--gold); border-bottom: 0;
  animation: blink .8s steps(2) infinite; opacity: 0;
}
#dialog.done #dialog-next { opacity: 1; }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }

/* ---- Modals -------------------------------------------------------------- */
.modal {
  position: fixed; inset: 0; z-index: 10;
  display: none; align-items: center; justify-content: center; padding: 16px;
}
.modal.open { display: flex; }
.backdrop { position: absolute; inset: 0; background: rgba(4, 5, 20, .72); }
.panel {
  position: relative; max-height: calc(100dvh - 40px); overflow: auto;
  animation: pop .35s steps(5);
}
@keyframes pop { from { transform: scale(.85); opacity: 0; } }

.close {
  position: absolute; top: 6px; right: 8px; z-index: 2;
  width: 36px; height: 36px;
  font-family: var(--title); font-size: 14px; color: var(--gold);
}
.panel h2 {
  font-family: var(--title); font-size: 13px; font-weight: normal; color: var(--gold);
  margin: 4px 40px 18px 0; line-height: 1.5;
}

/* Letter */
.panel.letter {
  width: min(560px, 100%); padding: 0; overflow: visible;
  animation: pull-out .7s steps(7);
}
@keyframes pull-out { from { transform: translateY(60vh); } }
.letter .close { color: var(--paper-ink); }
.paper {
  max-height: calc(100dvh - 40px); overflow: auto;
  padding: 38px 30px 34px;
  background:
    repeating-linear-gradient(to bottom, transparent 0 27px, var(--paper-line) 27px 29px),
    var(--paper);
  background-attachment: local;
  color: var(--paper-ink);
  font-size: 25px; line-height: 29px;
  box-shadow: 0 -4px 0 var(--paper), 0 4px 0 var(--paper), -4px 0 0 var(--paper), 4px 0 0 var(--paper),
              8px 8px 0 4px rgba(0, 0, 0, .35);
  user-select: text;
}
.paper p { margin: 0 0 29px; }
.paper .greeting { color: var(--rose); }
.paper .signoff { margin-bottom: 0; }
.paper .signature { color: var(--rose); margin: 0; }

/* Playlist */
.panel.playlist { width: min(520px, 100%); padding: 18px; }
#playlist-body iframe { display: block; width: 100%; height: 380px; border: 0; border-radius: 0; }
#playlist-body p { font-size: 24px; margin: 0 0 14px; }
.pixel-btn {
  display: inline-block; margin-top: 14px;
  font-family: var(--title); font-size: 10px; text-decoration: none;
  padding: 10px 14px; color: var(--ink); background: var(--gold);
  box-shadow: 0 -3px 0 var(--ink), 0 3px 0 var(--ink), -3px 0 0 var(--ink), 3px 0 0 var(--ink), 3px 6px 0 0 var(--rose);
}
.pixel-btn:active { transform: translateY(3px); box-shadow: 0 -3px 0 var(--ink), 0 3px 0 var(--ink), -3px 0 0 var(--ink), 3px 0 0 var(--ink); }

/* Gallery */
.panel.gallery { width: min(760px, 100%); padding: 18px; }
#gallery-grid {
  display: grid; gap: 22px 18px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  padding: 6px 6px 12px;
}
.polaroid {
  margin: 0; padding: 8px 8px 0; background: #fbf7ef; color: var(--paper-ink);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, .4);
  cursor: pointer; transition: transform .15s steps(2);
}
.polaroid:nth-child(3n+1) { transform: rotate(-2deg); }
.polaroid:nth-child(3n+2) { transform: rotate(1.5deg); }
.polaroid:nth-child(3n) { transform: rotate(-.5deg); }
.polaroid:hover { transform: rotate(0) scale(1.04); }
.polaroid .ph {
  aspect-ratio: 1; width: 100%; object-fit: cover; display: block;
  background: #2a2860; image-rendering: auto;
}
.polaroid .missing {
  aspect-ratio: 1; display: grid; place-items: center; text-align: center;
  background: #2a2860; color: var(--muted); font-size: 18px; padding: 8px;
}
.polaroid figcaption { font-size: 20px; line-height: 1; padding: 8px 2px 10px; min-height: 36px; }

/* Wish */
.panel.wish { width: min(420px, 100%); padding: 18px 20px 22px; }
#wish-prompt { font-size: 22px; color: var(--muted); margin: -8px 0 12px; }
#wish-text {
  display: block; width: 100%; resize: none;
  font: inherit; font-size: 22px; line-height: 1.05;
  padding: 8px 10px; color: var(--text); background: var(--ink); border: 0; outline: 0;
  box-shadow: 0 0 0 3px var(--panel-2); user-select: text;
}
#wish-text:focus { box-shadow: 0 0 0 3px var(--gold); }
.wish-share { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 20px; color: var(--muted); cursor: pointer; }
.wish-share input { width: 18px; height: 18px; accent-color: var(--pink); }
#wish-msg { min-height: 20px; font-size: 19px; color: var(--pink); margin: 6px 0 0; }
.wish .pixel-btn { margin-top: 8px; }

/* The note behind the K: a small handwritten card */
.panel.k-card {
  width: min(380px, 100%); padding: 34px 26px 26px; text-align: center;
  background: var(--paper); color: var(--paper-ink);
  box-shadow: 0 -4px 0 var(--paper), 0 4px 0 var(--paper), -4px 0 0 var(--paper), 4px 0 0 var(--paper),
              8px 8px 0 4px rgba(0, 0, 0, .35);
  transform: rotate(-1.5deg);
}
.k-card .close { color: var(--paper-ink); }
#k-image { display: block; max-width: 100%; max-height: 50dvh; margin: 0 auto 14px; image-rendering: auto; }
#k-line { font-family: 'Caveat', cursive; font-size: 32px; line-height: 1.15; margin: 0; user-select: text; }
.k-card .pixel-btn { margin-top: 16px; }

/* Cassette */
.panel.tape { width: min(420px, 100%); padding: 18px 20px 20px; }
.cassette { position: relative; width: 100%; aspect-ratio: 64 / 40; }
#tape-canvas { width: 100%; height: 100%; display: block; }
#tape-label {
  position: absolute; left: 12%; right: 12%; top: 13%;
  text-align: center; font-size: clamp(16px, 5vw, 22px); color: var(--paper-ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tape-progress { height: 8px; margin: 16px 0 12px; background: var(--ink); box-shadow: 0 0 0 2px var(--panel-2); }
.tape-progress i { display: block; height: 100%; width: 0; background: var(--pink); }
.tape-row { display: flex; align-items: center; justify-content: space-between; }
.tape-row .pixel-btn { margin: 0; min-width: 96px; }
#tape-time { font-size: 22px; color: var(--muted); }
#tape-msg { font-size: 20px; color: var(--muted); margin: 12px 0 0; min-height: 20px; }

/* Plant a flower */
.panel.planter { width: min(460px, 100%); padding: 18px 20px 22px; }
#plant-preview {
  display: flex; justify-content: center; align-items: flex-end;
  height: 96px; margin: -6px 0 8px;
}
.pick-label { display: block; font-family: var(--title); font-size: 9px; color: var(--muted); margin: 0 0 8px; }
.pick-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.pick {
  width: 44px; height: 44px; display: grid; place-items: center;
  background: var(--ink); box-shadow: 0 0 0 2px var(--panel-2);
}
.pick.swatch { width: 34px; height: 34px; }
.pick[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--gold); }
#plant-note {
  display: block; width: 100%; resize: none;
  font: inherit; font-size: 22px; line-height: 1.05;
  padding: 8px 10px; color: var(--text); background: var(--ink); border: 0; outline: 0;
  box-shadow: 0 0 0 3px var(--panel-2);
  user-select: text;
}
#plant-note:focus { box-shadow: 0 0 0 3px var(--gold); }
.plant-foot { display: flex; justify-content: space-between; gap: 12px; font-size: 18px; margin-top: 8px; min-height: 20px; }
#plant-msg { color: var(--pink); }
#plant-count { color: var(--muted); }
.planter .pixel-btn { margin-top: 12px; }

#place-bar {
  position: fixed; left: 50%; top: max(52px, env(safe-area-inset-top)); transform: translateX(-50%);
  z-index: 7; display: flex; align-items: center; gap: 14px; white-space: nowrap;
  font-family: var(--title); font-size: 9px; color: var(--gold); text-shadow: 2px 2px 0 var(--ink);
  transition: opacity .3s;
}
#place-bar .pixel-btn { margin: 0; font-size: 9px; padding: 7px 9px; }

#lightbox { z-index: 12; }
.lightbox-inner { position: relative; display: flex; align-items: center; gap: 8px; max-width: 100%; }
.polaroid.big { cursor: default; transform: none; animation: pop .3s steps(4); }
.polaroid.big img { display: block; max-width: min(80vw, 640px); max-height: 70dvh; image-rendering: auto; }
.polaroid.big figcaption { font-size: 26px; text-align: center; }
.lightbox-inner .close { top: -44px; right: 0; }
.nav { font-family: var(--title); font-size: 18px; color: var(--gold); width: 40px; height: 60px; flex: none; }

/* ---- Minigame ------------------------------------------------------------ */
#game {
  position: fixed; inset: 0; z-index: 25;
  display: grid; place-items: center;
  background: #03040f;
}
#game[hidden] { display: none; }
#game-frame {
  position: relative; overflow: hidden;
  box-shadow: 0 0 0 4px var(--panel-2), 0 0 0 8px var(--border);
}
#game-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
#game-close { position: fixed; top: max(8px, env(safe-area-inset-top)); right: 10px; width: 44px; height: 44px; z-index: 3; }

#game-hud {
  position: absolute; top: 2%; left: 3%; right: 3%;
  display: flex; justify-content: space-between; align-items: center;
  pointer-events: none;
}
#game-hearts { display: flex; gap: 3px; }
#game-score { font-family: var(--title); font-size: 10px; color: var(--gold); text-shadow: 2px 2px 0 var(--ink); }

#boss-bar {
  position: absolute; top: 8.5%; left: 6%; right: 6%; pointer-events: none;
  font-family: var(--title); font-size: 9px; color: #ff8a8a; text-shadow: 2px 2px 0 var(--ink);
}
#boss-bar[hidden] { display: none; }
#boss-bar .bar { height: 8px; margin-top: 5px; background: #2a1020; box-shadow: 0 0 0 2px var(--border); }
#boss-bar i { display: block; height: 100%; width: 100%; background: linear-gradient(#ff6b6b 0 50%, #c62f3a 50%); transition: width .15s steps(3); }

#game-warning {
  position: absolute; left: 0; right: 0; top: 40%; text-align: center; pointer-events: none;
  font-family: var(--title); font-size: 11px; line-height: 1.8; color: #ff5c5c; text-shadow: 2px 2px 0 var(--ink);
  animation: blink .5s steps(2) infinite;
}
#game-warning[hidden] { display: none; }

#game-fire {
  position: absolute; right: 4%; bottom: 3%; width: 64px; height: 64px; border-radius: 50%;
  font-family: var(--title); font-size: 9px; color: var(--ink);
  background: rgba(255, 92, 138, .55);
  box-shadow: 0 0 0 3px rgba(255, 243, 214, .7), 0 4px 0 3px rgba(26, 16, 48, .8);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
#game-fire.down { background: rgba(255, 92, 138, .9); transform: translateY(3px); box-shadow: 0 0 0 3px rgba(255, 243, 214, .9); }
#game-fire[hidden] { display: none; }

.floater {
  position: absolute; transform: translate(-50%, -100%); white-space: nowrap; pointer-events: none;
  font-size: 20px; color: var(--gold); text-shadow: 2px 2px 0 var(--ink);
  animation: float-up 1.1s steps(8) forwards;
}
.floater.sad { color: var(--pink); }
@keyframes float-up { to { transform: translate(-50%, -260%); opacity: 0; } }

#game-screen {
  position: absolute; inset: 0; overflow: auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 12px; text-align: center;
  background: rgba(7, 9, 32, .88);
}
#game-screen[hidden] { display: none; }
#game-screen .game-title {
  font-family: var(--title); font-weight: normal; font-size: 16px; margin: 0 0 4px;
  color: var(--text); text-shadow: 3px 3px 0 var(--rose);
}
#game-screen .label { font-family: var(--title); font-size: 8px; color: #ff8a8a; margin: 6px 0 0; }
#game-screen .label.good { color: #9be89b; }
#game-screen .hint, #game-screen .line { font-size: 19px; color: var(--muted); margin: 4px 0; }
#game-screen .pixel-btn { margin-top: 6px; font-size: 9px; }
.food-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 8px; max-width: 100%; }
.food { margin: 0; width: 58px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.food img { image-rendering: pixelated; }
.food figcaption { font-size: 15px; line-height: 1; color: var(--text); }
.win-note {
  font-size: 22px; line-height: 1.1; color: var(--text); min-height: 3em; max-width: 30ch;
  margin: 6px 0 4px; user-select: text;
}

/* Afterparty snack */
#game-screen .snack-pic { image-rendering: pixelated; max-height: 45%; width: auto; }
#game-screen .snack-name { font-family: var(--title); font-size: 10px; line-height: 1.7; color: var(--gold); margin: 4px 0; max-width: 90%; }

/* ---- Cozy minigames (paper planes, fireflies) ---------------------------- */
#mini {
  position: fixed; inset: 0; z-index: 25;
  display: grid; place-items: center; background: #03040f;
}
#mini-frame { position: relative; overflow: hidden; box-shadow: 0 0 0 4px var(--panel-2), 0 0 0 8px var(--border); }
#mini-canvas { display: block; width: 100%; height: 100%; touch-action: none; image-rendering: pixelated; cursor: pointer; }
#mini-close { position: fixed; top: max(8px, env(safe-area-inset-top)); right: 10px; width: 44px; height: 44px; z-index: 3; }
#mini-hud {
  position: absolute; top: 3%; left: 4%; right: 4%; pointer-events: none;
  font-size: 18px; line-height: 1; color: var(--gold); text-shadow: 2px 2px 0 var(--ink);
}
#mini-screen {
  position: absolute; inset: 0; overflow: auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 16px; text-align: center; background: rgba(7, 9, 32, .88);
}
#mini-screen.soft {
  justify-content: flex-start; padding-top: 9%;
  background: linear-gradient(rgba(7, 9, 32, .92) 0 48%, rgba(7, 9, 32, 0) 72%);
}
#mini-screen .game-title { font-family: var(--title); font-weight: normal; font-size: 14px; line-height: 1.6; margin: 0 0 4px; color: var(--text); text-shadow: 3px 3px 0 var(--rose); }
#mini-screen .line { font-size: 20px; color: var(--muted); margin: 2px 0 6px; max-width: 32ch; }
#mini-screen .pixel-btn { font-size: 9px; margin-top: 4px; }

/* ---- Developing polaroid --------------------------------------------------- */
.polaroid.big { position: relative; }
#lb-film { position: absolute; image-rendering: pixelated; touch-action: none; cursor: grab; }
.polaroid.undeveloped .ph { filter: brightness(.08) sepia(1) contrast(.8); }
.polaroid.undeveloped figcaption { color: #a99f93; }

/* ---- Letter: paper plane button ------------------------------------------- */
#letter-plane { margin-top: 26px; font-size: 9px; }

/* ---- Notebook -------------------------------------------------------------- */
.panel.notebook { width: min(520px, 100%); padding: 0; overflow: visible; animation: pull-out .6s steps(6); }
.notebook .close { color: var(--paper-ink); }
#nb-text {
  display: block; width: 100%; resize: vertical; min-height: 116px;
  font: inherit; font-size: 24px; line-height: 29px; color: var(--paper-ink);
  background: transparent; border: 0; outline: 0; padding: 0; margin: 0 0 8px;
  user-select: text;
}
#nb-text::placeholder { color: #b9a58c; }
.nb-row { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.nb-row .pixel-btn { margin: 0; font-size: 9px; }
#nb-msg { font-size: 20px; color: var(--rose); }
.nb-page { margin: 0 0 22px; }
.nb-date { display: flex; justify-content: space-between; align-items: baseline; font-size: 19px; color: var(--rose); }
.nb-body { white-space: pre-wrap; margin: 0; }
.nb-del { font-family: var(--body); font-size: 18px; color: #a0896f; padding: 0 4px; }
.nb-del.confirm { color: var(--rose); }
.nb-privacy { font-size: 19px; color: #9c8a73; margin: 10px 0 2px !important; }
.nb-link { font-family: var(--body); font-size: 19px; color: var(--rose); text-decoration: underline; padding: 0; }

/* ---- Title screen -------------------------------------------------------- */
#title-screen {
  position: fixed; inset: 0; z-index: 30;
  display: grid; place-items: center; padding: 24px;
  background: rgba(7, 9, 32, .55);
  transition: opacity 1.2s;
  cursor: pointer;
}
#title-screen.gone { opacity: 0; pointer-events: none; }
.title-inner { text-align: center; }
#title-heart-btn { padding: 6px; display: inline-block; }
#title-heart { width: 56px; height: 48px; animation: beat 1.1s steps(2) infinite; display: block; }
#title-heart.squish { animation: squish .25s steps(3); }
@keyframes squish { 50% { transform: scale(1.3, .75); } }
#title-secret {
  min-height: 0; margin: 8px 0 -8px; font-size: 22px; color: var(--pink);
  opacity: 0; transform: translateY(6px); transition: opacity .6s, transform .6s steps(4);
}
#title-secret.show { opacity: 1; transform: none; }
@keyframes beat { 50% { transform: scale(1.12); } }
#title-text {
  font-family: var(--title); font-weight: normal;
  font-size: clamp(18px, 5vw, 38px); line-height: 1.4; margin: 22px 0 10px;
  color: var(--text);
  text-shadow: 4px 4px 0 var(--rose), 8px 8px 0 var(--ink);
}
#title-sub { font-size: clamp(20px, 3.4vw, 28px); color: var(--muted); margin: 0 0 40px; }
#start {
  font-family: var(--title); font-size: clamp(11px, 2.4vw, 15px); color: var(--gold);
  padding: 12px 18px;
}
.blink { animation: blink 1.1s steps(2) infinite; }
.sound-note { font-size: 18px; color: var(--muted); margin-top: 10px; opacity: .7; }

#gate { margin: -12px 0 26px; }
#gate label { display: block; font-size: 24px; margin-bottom: 12px; }
#gate input {
  font: inherit; font-size: 24px; text-align: center; width: min(280px, 80vw);
  padding: 6px 10px; color: var(--text); background: var(--ink); border: 0; outline: 0;
  box-shadow: 0 -3px 0 var(--border), 0 3px 0 var(--border), -3px 0 0 var(--border), 3px 0 0 var(--border);
  user-select: text;
}
#gate-msg { min-height: 24px; font-size: 20px; color: var(--pink); margin: 10px 0 0; }
#gate.shake { animation: shake .4s steps(6); }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

@media (max-width: 480px) {
  #dialog-text { font-size: 23px; }
  .paper { padding: 34px 20px 28px; font-size: 22px; line-height: 26px;
    background: repeating-linear-gradient(to bottom, transparent 0 24px, var(--paper-line) 24px 26px), var(--paper); background-attachment: local; }
  .paper p { margin-bottom: 26px; }
  #gallery-grid { grid-template-columns: repeat(2, 1fr); gap: 16px 12px; }
  .nav { width: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
