:root {
  --cream: #fff6e5;
  --paper: #fffaf0;
  --ink: #3b2a20;
  --ink-soft: #6f5646;
  --barn: #b8402e;
  --barn-dark: #8f3024;
  --grass: #5f9e4a;
  --grass-light: #8fcc6b;
  --hay: #e8c15a;
  --sky: #a2d5ef;
  --pink: #f6b6c2;
  --px: 4px;
  --head: "Press Start 2P", monospace;  /* blocky heading font */
  --hs: 1;                              /* heading size multiplier */
}
/* Press Start 2P has no Vietnamese glyphs; Tiny5 does (and runs smaller) */
html[lang="vi"] { --head: "Tiny5", monospace; --hs: 1.55; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: "VT323", ui-monospace, monospace;
  font-size: 22px;
  line-height: 1.25;
  -webkit-font-smoothing: none;
  overflow-x: hidden;
}
img, canvas { image-rendering: pixelated; }
.tiny { font-family: var(--head); font-size: calc(10px * var(--hs)); letter-spacing: 1px; line-height: 1.8; }
.dim { opacity: .7; }
.center { text-align: center; }
.mt { margin-top: 30px; }

/* Pixel border helper */
.card, .box, .btn, .tabs button, .grid button, input, select, textarea {
  border: var(--px) solid var(--ink);
  box-shadow: var(--px) var(--px) 0 var(--ink);
}

/* ── Start screen ───────────────────────── */
.start {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,.06) 0 2px, transparent 2px 4px),
    linear-gradient(#78c2ec, #ffd49c 70%, #7cba5b 70%);
  text-align: center; padding: 16px;
  transition: opacity .5s steps(5), visibility .5s;
}
.start.gone { opacity: 0; visibility: hidden; }
.start-inner { display: grid; gap: 22px; justify-items: center; }
.start-names {
  margin: 0; font-weight: normal; font-size: clamp(48px, 12vw, 96px); line-height: .95;
  display: grid; color: var(--paper);
  text-shadow: 4px 4px 0 var(--ink), -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink);
}
.amp { color: var(--barn); font-size: .7em; }
.blink { animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .35; } }

/* ── Hero ───────────────────────────────── */
.hero { position: relative; background: #78c2ec; }
.hero-text {
  position: absolute; top: 0; left: 0; right: 0; z-index: 2;
  text-align: center; padding: 18px 16px 0; pointer-events: none;
}
.names {
  margin: 4px 0; font-weight: normal; font-size: clamp(40px, 8vw, 76px); line-height: 1;
  color: var(--paper);
  text-shadow: 3px 3px 0 var(--ink), -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink);
}
.date { margin: 0; font-size: 26px; color: var(--ink); }
.scene-wrap { display: flex; justify-content: center; overflow: hidden; }
#farm { display: block; cursor: pointer; touch-action: manipulation; }
.hint {
  position: absolute; bottom: 8px; left: 0; right: 0; text-align: center; margin: 0;
  color: var(--paper); text-shadow: 2px 2px 0 var(--ink);
  animation: bob 1.2s steps(2) infinite;
}
@keyframes bob { 50% { transform: translateY(3px); } }

/* ── Nav ────────────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: center; gap: 4px; flex-wrap: wrap;
  background: var(--barn); border-block: var(--px) solid var(--ink); padding: 8px;
}
.nav a {
  font-family: var(--head); font-size: calc(10px * var(--hs));
  color: var(--paper); text-decoration: none; padding: 8px 10px;
}
.nav a:hover, .nav a:focus-visible { background: var(--barn-dark); outline: none; }

/* ── Sections ───────────────────────────── */
.section { max-width: 960px; margin: 0 auto; padding: 56px 16px 24px; scroll-margin-top: 48px; }
.h2 {
  font-family: var(--head); font-weight: normal; font-size: calc(clamp(14px, 3.4vw, 20px) * var(--hs));
  text-align: center; margin: 0 0 28px; line-height: 1.6;
}
.h2::before, .h2::after { content: "♥"; color: var(--barn); margin: 0 12px; }
.h3 { font-family: var(--head); font-weight: normal; font-size: calc(11px * var(--hs)); margin: 0 0 10px; color: var(--barn); }
.big { font-size: 30px; margin: 0 0 8px; }

.count { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; }
.box { background: var(--paper); width: 92px; padding: 10px 0; text-align: center; }
.box b { display: block; font-size: 48px; line-height: 1; font-weight: normal; }
.box span { font-family: var(--head); font-size: calc(9px * var(--hs)); }

/* Details */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 22px; }
.card { background: var(--paper); padding: 20px; }

/* Buttons */
.btn {
  display: inline-block; font-family: var(--head); font-size: calc(11px * var(--hs));
  background: var(--hay); color: var(--ink); padding: 12px 16px; cursor: pointer; text-decoration: none;
  transition: transform .05s, box-shadow .05s;
}
.btn:hover { background: #f6d77e; }
.btn:active { transform: translate(var(--px), var(--px)); box-shadow: 0 0 0 var(--ink); }
.btn:focus-visible { outline: 3px dashed var(--barn); outline-offset: 4px; }
.btn-big { font-size: calc(14px * var(--hs)); padding: 16px 22px; }
.btn[disabled] { opacity: .6; cursor: wait; }

/* Gallery */
.tabs { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-bottom: 24px; }
.tabs button {
  font-family: "VT323", monospace; font-size: 22px; background: var(--paper); color: var(--ink);
  padding: 4px 12px; cursor: pointer; box-shadow: 3px 3px 0 var(--ink); border-width: 3px;
}
.tabs button[aria-selected="true"] { background: var(--grass); color: var(--paper); }
.grid { columns: 3 220px; column-gap: 14px; }
.grid button {
  display: block; width: 100%; padding: 0; margin: 0 0 14px; background: var(--paper);
  cursor: zoom-in; break-inside: avoid; border-width: 3px; box-shadow: 3px 3px 0 var(--ink);
}
.grid img { display: block; width: 100%; height: auto; image-rendering: auto; transition: filter .2s; }
.grid button:hover img { filter: brightness(1.08) saturate(1.1); }

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 60; background: rgba(30, 20, 14, .94);
  display: grid; place-items: center; padding: 56px 12px;
}
.lightbox[hidden] { display: none; }
.lightbox img {
  max-width: 100%; max-height: calc(100vh - 120px); image-rendering: auto;
  border: var(--px) solid var(--paper); box-shadow: 6px 6px 0 #000;
}
.lb-close { position: absolute; top: 12px; right: 12px; }
.lb-prev, .lb-next { position: absolute; top: 50%; transform: translateY(-50%); }
.lb-prev { left: 12px; } .lb-next { right: 12px; }
.lb-prev:active, .lb-next:active { transform: translateY(-50%) translate(4px, 4px); }
.lb-count { position: absolute; bottom: 12px; left: 0; right: 0; text-align: center; color: var(--paper); margin: 0; }

/* RSVP form */
.form { max-width: 560px; margin: 18px auto 0; display: grid; gap: 16px; }
.form label, .form legend { font-family: var(--head); font-size: calc(10px * var(--hs)); display: grid; gap: 8px; }
.form fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
input, select, textarea {
  font: inherit; font-family: "VT323", monospace; font-size: 22px; color: var(--ink);
  background: #fff; padding: 8px 10px; border-width: 3px; box-shadow: 3px 3px 0 var(--ink); border-radius: 0;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 3px dashed var(--grass); outline-offset: 2px; }
.choice {
  display: flex !important; align-items: center; gap: 10px; cursor: pointer;
  font-family: "VT323", monospace !important; font-size: 24px !important;
}
.choice input { width: 22px; height: 22px; box-shadow: none; accent-color: var(--barn); }
.hp { position: absolute; left: -9999px; }
.msg { margin: 0; min-height: 1.2em; text-align: center; font-size: 24px; }
.msg.ok { color: var(--grass); }
.msg.err { color: var(--barn); }

.footer { text-align: center; padding: 40px 16px 56px; background: var(--grass); color: var(--paper); border-top: var(--px) solid var(--ink); margin-top: 48px; }
.footer p { margin: 4px 0; font-size: 28px; }

@media (max-width: 520px) {
  body { font-size: 20px; }
  .form .row { grid-template-columns: 1fr; }
  .box { width: 72px; }
  .box b { font-size: 38px; }
  .lb-prev, .lb-next { top: auto; bottom: 8px; transform: none; }
  .lb-prev:active, .lb-next:active { transform: translate(4px, 4px); }
}
@media (prefers-reduced-motion: reduce) {
  .blink, .hint { animation: none; }
  html { scroll-behavior: auto; }
}

/* Dress code card */
.dress-card {
  --rivet: radial-gradient(circle, #a8d2ee 0 3px, var(--ink) 3px 5px, transparent 5.5px);
  max-width: 460px; margin: 0 auto; padding: 34px 24px 30px; text-align: center;
  background:
    var(--rivet) 6px 6px / 16px 16px no-repeat,
    var(--rivet) calc(100% - 6px) 6px / 16px 16px no-repeat,
    var(--rivet) 6px calc(100% - 6px) / 16px 16px no-repeat,
    var(--rivet) calc(100% - 6px) calc(100% - 6px) / 16px 16px no-repeat,
    #f7ecd6;
  border: var(--px) solid var(--ink);
  box-shadow: var(--px) var(--px) 0 var(--ink), inset 0 0 0 4px #e6d4b0;
}
.dress-title { font-family: var(--head); font-weight: normal; font-size: calc(clamp(16px, 4.6vw, 22px) * var(--hs)); margin: 0 0 18px; }
.dress-sub { margin: 0 0 10px; font-size: 26px; }
.dress-colors { margin: 0 0 20px; font-size: 26px; }
.outfits { display: flex; justify-content: center; align-items: flex-end; gap: 22px; margin-bottom: 22px; }
.outfits canvas { height: 220px; width: auto; }
.swatches { display: flex; justify-content: center; gap: 16px; }
.swatches span { width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); }
.dress-tip { margin: 20px 0 0; color: var(--ink-soft); font-size: 22px; }
@media (max-width: 520px) { .outfits canvas { height: 170px; } }

/* Scene player (story + wedding day timelines) */
.player { max-width: 780px; margin: 0 auto; outline: none; }
.screen {
  position: relative; cursor: pointer; background: #1a120d;
  border: var(--px) solid var(--ink); box-shadow: var(--px) var(--px) 0 var(--ink);
}
.screen canvas { display: block; width: 100%; height: auto; aspect-ratio: 192 / 108; }
.hud { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; justify-content: space-between; gap: 8px; pointer-events: none; }
.chip {
  font-family: "VT323", monospace; font-size: 20px; line-height: 1; padding: 4px 8px 3px;
  background: var(--paper); border: 3px solid var(--ink); box-shadow: 2px 2px 0 var(--ink);
}
.chip[hidden] { display: none; }
.chip-a { background: var(--hay); }
.dialog {
  position: relative; margin-top: 14px; padding: 12px 16px 14px; min-height: 112px;
  background: var(--paper); border: var(--px) solid var(--ink); box-shadow: var(--px) var(--px) 0 var(--ink);
}
.dialog h3 { margin: 0 0 6px; font-family: var(--head); font-weight: normal; font-size: calc(12px * var(--hs)); color: var(--barn); line-height: 1.6; }
.dialog p { margin: 0; font-size: 24px; }
.dialog .more { position: absolute; right: 10px; bottom: 6px; font-size: 18px; color: var(--barn); }
.controls { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 16px; }
.controls .btn { min-width: 52px; font-size: 14px; padding: 10px 14px; }
.controls .btn[disabled] { opacity: .35; cursor: default; }
.dots { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.dots button {
  width: 14px; height: 14px; padding: 0; background: var(--paper); cursor: pointer;
  border: 3px solid var(--ink); box-shadow: none;
}
.dots button[aria-current="step"] { background: var(--barn); }
.suntrack { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-family: var(--head); font-size: calc(8px * var(--hs)); }
.suntrack .track { position: relative; flex: 1; height: 6px; background: repeating-linear-gradient(90deg, var(--ink) 0 6px, transparent 6px 10px); }
.sun-dot {
  position: absolute; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px;
  background: #ffd84a; border: 3px solid var(--ink); box-shadow: 0 0 0 3px #fff1c4;
  transition: left .8s steps(8);
}
@media (max-width: 520px) {
  .dialog { min-height: 140px; }
  .dialog p { font-size: 21px; }
  .chip { font-size: 17px; }
}

/* Gallery minigame */
.game-intro { margin: -10px 0 18px; }
.game { max-width: 960px; margin: 0 auto; }
.game-screen { display: flex; justify-content: center; background: #e9dcc4; overflow: hidden; cursor: pointer; touch-action: manipulation; }
.game-screen canvas { display: block; aspect-ratio: auto; image-rendering: pixelated; }
.gamepad { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 16px; user-select: none; -webkit-user-select: none; }
.gamepad .pad { width: 72px; height: 56px; font-size: 18px; touch-action: none; }
.gamepad .view { min-width: 140px; background: var(--grass-light); }
.gamepad .view:not([disabled]) { animation: pulse 1s steps(2) infinite; }
.gamepad .view[disabled] { opacity: .45; cursor: default; animation: none; }
@keyframes pulse { 50% { background: #b6e69a; } }
.keys { text-align: center; margin: 12px 0 0; }
.who { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.who .btn { font-family: "VT323", monospace; font-size: 22px; padding: 4px 12px; background: var(--paper); }
.who .btn[aria-pressed="true"] { background: var(--barn); color: var(--paper); }
.linkish {
  font: inherit; font-size: 22px; background: none; border: 0; color: var(--ink-soft); cursor: pointer;
  text-decoration: underline dotted; text-underline-offset: 4px; margin-top: 18px;
}
.grid { margin-top: 8px; }
@media (hover: none) { .keys { display: none; } }

/* Language switch */
.lang-switch {
  position: absolute; top: 10px; right: 10px; z-index: 70; display: flex;
  border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); background: var(--paper);
}
.lang-switch button {
  font-family: "VT323", monospace; font-size: 20px; line-height: 1; padding: 5px 9px 4px;
  border: 0; background: var(--paper); color: var(--ink); cursor: pointer;
}
.lang-switch button + button { border-left: 3px solid var(--ink); }
.lang-switch button[aria-pressed="true"] { background: var(--barn); color: var(--paper); }
.lang-switch button:focus-visible { outline: 3px dashed var(--grass); outline-offset: -5px; }
html[lang="vi"] .tiny { letter-spacing: 0; }
@media (max-width: 420px) {
  .nav { gap: 0; padding: 6px 4px; }
  .nav a { padding: 8px 6px; }
  html[lang="vi"] .nav a { font-size: 14px; }
}

/* ── Mobile polish ───────────────────────── */
/* comfortable tap targets */
.lang-switch button { min-width: 42px; min-height: 36px; }
.choice input { flex-shrink: 0; }
.linkish { min-height: 44px; padding: 8px 12px; }
@media (pointer: coarse) {
  .dots { gap: 6px; }
  .dots button { width: 22px; height: 22px; }
}
/* players never taller than the screen (landscape phones) */
.player { max-width: min(780px, max(300px, calc((100svh - 250px) * 1.78))); }
/* start screen fits short landscape screens */
.start { overflow-y: auto; }
.start-names { font-size: clamp(40px, min(12vw, 13svh), 96px); }
.start-inner { gap: min(22px, 3svh); }

@media (max-width: 480px) {
  .hero-text { padding-top: 50px; }   /* clear the language switch */
  .hud { top: 5px; left: 5px; right: 5px; }
  .chip { font-size: 15px; padding: 2px 5px 1px; border-width: 2px; box-shadow: 1px 1px 0 var(--ink); }
  .section { padding-top: 44px; }
}
@media (max-width: 380px) {
  .count { gap: 8px; }
  .box { width: 62px; }
  .box b { font-size: 32px; }
  .controls { gap: 8px; }
  .gamepad { gap: 8px; }
  .gamepad .pad { width: 60px; }
  .gamepad .view { min-width: 110px; }
  .dialog p { font-size: 20px; }
}
.footer .lang-switch { position: static; display: inline-flex; margin-top: 14px; }
.footer p.tiny { font-size: calc(10px * var(--hs)); margin-top: 8px; }

/* Peeking cats */
.peeker { position: absolute; z-index: 3; pointer-events: none; image-rendering: pixelated; will-change: transform; }
.peeker.flying { z-index: 45; }

/* Music toggle */
.music-btn {
  position: fixed; right: 14px; bottom: 14px; z-index: 55;
  width: 54px; height: 54px; padding: 0; cursor: pointer;
  display: grid; place-items: center;
  background: var(--paper); color: var(--ink);
  border: var(--px) solid var(--ink); box-shadow: var(--px) var(--px) 0 var(--ink);
  font-family: "VT323", monospace; font-size: 30px; line-height: 1;
}
.music-btn:active { transform: translate(var(--px), var(--px)); box-shadow: none; }
.music-btn:focus-visible { outline: 3px dashed var(--barn); outline-offset: 4px; }
.music-btn .note { grid-area: 1 / 1; position: relative; }
.music-btn:not(.on) .note::after { /* slash = muted */
  content: ""; position: absolute; left: -4px; right: -4px; top: 50%; height: 3px;
  background: var(--barn); transform: rotate(-45deg);
}
.music-btn .eq { grid-area: 1 / 1; display: none; gap: 3px; align-items: flex-end; height: 22px; }
.music-btn.on { background: var(--hay); }
.music-btn.on .note { display: none; }
.music-btn.on .eq { display: flex; }
.music-btn .eq i { width: 6px; background: var(--ink); animation: eq .9s steps(4) infinite; }
.music-btn .eq i:nth-child(2) { animation-delay: -.3s; }
.music-btn .eq i:nth-child(3) { animation-delay: -.6s; }
@keyframes eq { 0% { height: 6px; } 25% { height: 20px; } 50% { height: 10px; } 75% { height: 16px; } 100% { height: 6px; } }
.music-toast {
  position: fixed; right: 80px; bottom: 22px; z-index: 55; margin: 0; max-width: calc(100vw - 100px);
  background: var(--paper); border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink);
  padding: 6px 10px; font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.music-toast.show { animation: toastIn .25s steps(3); }
@keyframes toastIn { from { transform: translateX(20px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .music-btn .eq i { animation: none; height: 14px; } }

