:root {
  --ink: #2a1a2e;
  --cream: #fffaf0;
  --paper: #fff0d9;
  --tan: #efd1a0;
  --brown: #8a5a3b;
  --gold: #ffc45c;
  --rose: #eb5078;
  --pink: #ff9bc5;
  --green: #54bd78;
  --shadow: 0 4px 0 var(--ink);
  --font-pixel: 'Press Start 2P', monospace;
  --font-body: 'VT323', monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: linear-gradient(180deg, #87d9f2 0%, #b8edf3 45%, #e4f7de 75%, #fff2d7 100%) fixed; color: var(--ink); font-family: var(--font-body); font-size: 20px; }
button { font-family: inherit; cursor: pointer; }
[hidden] { display: none !important; }

#game {
  position: fixed; inset: 0; display: block;
  image-rendering: auto;
  touch-action: none; user-select: none; -webkit-user-select: none;
}

/* ---------- pixel frame helpers ---------- */
.pix {
  background: var(--cream);
  border: 3px solid var(--ink);
  box-shadow: var(--shadow), inset 0 0 0 3px var(--paper);
  border-radius: 10px;
}

/* ---------- HUD ---------- */
.hud-top {
  position: fixed; top: max(10px, env(safe-area-inset-top)); left: 12px; right: 12px;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
  pointer-events: none; z-index: 5;
}
.hud-title {
  background: var(--cream); border: 3px solid var(--ink); border-radius: 10px;
  box-shadow: var(--shadow); padding: 6px 12px; display: flex; flex-direction: column; gap: 4px;
}
.hud-title b { font-family: var(--font-pixel); font-size: 11px; color: var(--rose); }
.hud-title span { font-size: 16px; color: var(--brown); line-height: 1; }
.icon-btn {
  pointer-events: auto;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--cream); border: 3px solid var(--ink); box-shadow: var(--shadow);
  font-family: var(--font-pixel); font-size: 14px; color: var(--ink);
  display: grid; place-items: center; transition: transform .1s;
}
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.icon-btn.small { width: 36px; height: 36px; font-size: 12px; box-shadow: 0 3px 0 var(--ink); }
#btn-music .note { font-size: 22px; line-height: 1; color: #999; }
#btn-music.on .note { color: var(--rose); animation: bob 1s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }

.prompt {
  position: fixed; left: 50%; top: 22%; transform: translateX(-50%);
  background: var(--ink); color: #ffe066; font-family: var(--font-pixel); font-size: 11px;
  padding: 10px 14px; border-radius: 8px; border: 3px solid #ffe066; z-index: 5; pointer-events: none;
  animation: pop .2s ease-out;
}
@keyframes pop { from { transform: translateX(-50%) scale(.8); opacity: 0; } }

/* ---------- controls ---------- */
.joystick, .btn-a {
  position: fixed; bottom: calc(150px + env(safe-area-inset-bottom)); z-index: 6;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.joystick { left: 18px; width: 120px; height: 120px; }
.joy-ring {
  position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle, #5a4a3a 0 30%, #2a1a2e 31%);
  border: 4px solid var(--ink); box-shadow: 0 0 0 3px var(--gold), 0 5px 0 3px var(--ink);
}
.stick {
  position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px;
  border-radius: 50%; background: var(--gold); border: 4px solid var(--ink);
  display: grid; place-items: center; font-size: 20px; color: var(--ink); pointer-events: none;
  box-shadow: inset 0 -4px 0 #b8862c;
}
.joystick label, .btn-a label {
  position: absolute; left: 50%; bottom: -24px; transform: translateX(-50%);
  font-family: var(--font-pixel); font-size: 9px; color: var(--cream); text-shadow: 2px 2px 0 var(--ink);
  letter-spacing: 1px; pointer-events: none;
}
.btn-a {
  right: 22px; width: 84px; height: 84px; border-radius: 50%;
  background: var(--cream); border: 4px solid var(--ink); box-shadow: 0 0 0 3px var(--gold), 0 5px 0 3px var(--ink);
  display: grid; place-items: center; font-family: var(--font-pixel); font-size: 26px; color: var(--ink);
  transition: transform .08s;
}
.btn-a:active { transform: translateY(4px); box-shadow: 0 0 0 3px var(--gold), 0 1px 0 3px var(--ink); }

@media (pointer: fine) and (min-width: 900px) {
  .joystick, .btn-a { display: none; }
}

/* ---------- bottom menu ---------- */
.menu {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 7;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 0 10px calc(10px + env(safe-area-inset-bottom));
  pointer-events: none;
}
.sapa {
  pointer-events: auto;
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--cream); border: 3px solid var(--ink); border-radius: 12px; box-shadow: var(--shadow);
  font-family: var(--font-pixel); font-size: 11px; padding: 12px 18px; color: var(--ink);
  transition: transform .1s, background .2s;
}
.sapa.ready { background: #ffe9a8; animation: wiggle .6s ease-in-out infinite; }
.sapa:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
@keyframes wiggle { 0%, 100% { transform: rotate(-1deg); } 50% { transform: rotate(1deg); } }
.menu-items {
  pointer-events: auto;
  width: 100%; max-width: 760px;
  background: var(--cream); border: 3px solid var(--ink); border-radius: 14px;
  box-shadow: var(--shadow), inset 0 0 0 3px var(--paper);
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; padding: 8px 6px;
}
.menu-item {
  background: transparent; border: 0; border-radius: 8px; padding: 6px 2px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-family: var(--font-pixel); font-size: 7px; color: var(--brown); text-transform: uppercase; letter-spacing: .5px;
  line-height: 1.2; text-align: center; transition: background .15s, transform .1s;
}
.menu-item svg, .menu-item .pixicon { width: 44px; height: 44px; filter: drop-shadow(1px 1px 0 rgba(0,0,0,.15)); }
.pixicon { image-rendering: pixelated; image-rendering: crisp-edges; display: block; }
.menu-item:hover, .menu-item.active { background: var(--paper); transform: translateY(-2px); }
.menu-item:active { transform: translateY(1px); }
@media (max-width: 480px) {
  .menu-item { font-size: 6px; }
  .menu-item svg, .menu-item .pixicon { width: 30px; height: 30px; }
  .joystick { width: 100px; height: 100px; left: 12px; }
  .btn-a { width: 70px; height: 70px; right: 14px; font-size: 22px; }
  .joystick, .btn-a { bottom: calc(140px + env(safe-area-inset-bottom)); }
}

/* ---------- dialogue ---------- */
.dialog {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(126px + env(safe-area-inset-bottom));
  width: min(640px, calc(100% - 24px)); z-index: 8;
  background: var(--cream); border: 3px solid var(--ink); border-radius: 14px;
  box-shadow: var(--shadow), inset 0 0 0 3px var(--paper);
  display: flex; gap: 12px; padding: 12px; cursor: pointer;
  animation: pop-up .18s ease-out;
}
@keyframes pop-up { from { transform: translate(-50%, 12px); opacity: 0; } }
.dlg-portrait-wrap {
  flex: 0 0 auto; width: 84px; height: 84px; border: 3px solid var(--ink); border-radius: 10px;
  background: var(--paper); overflow: hidden; display: grid; place-items: center;
}
#dlg-portrait { width: 80px; height: 80px; image-rendering: pixelated; }
.dlg-main { flex: 1; min-width: 0; position: relative; }
.dlg-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.dlg-head b { font-family: var(--font-pixel); font-size: 12px; color: var(--rose); }
.dlg-role { font-size: 15px; color: var(--brown); }
#dlg-text { margin: 0; font-size: 21px; line-height: 1.2; min-height: 2.4em; color: var(--ink); }
.dlg-hint { position: absolute; right: 2px; bottom: -2px; font-family: var(--font-pixel); font-size: 10px; color: var(--brown); animation: bob 1s infinite; }
.dlg-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-radius: 10px;
  box-shadow: 0 3px 0 var(--ink); padding: 8px 14px;
  font-family: var(--font-pixel); font-size: 10px; text-decoration: none; line-height: 1.4;
  transition: transform .08s;
}
.btn:active { transform: translateY(3px); box-shadow: none; }
.btn-gold { background: var(--gold); }
.btn.big { font-size: 13px; padding: 14px 22px; }
.btn svg, .btn .pixicon { width: 20px; height: 20px; }
.sapa .pixicon { width: 22px; height: 22px; }

/* ---------- panel ---------- */
.panel { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 14px; }
.panel-backdrop { position: absolute; inset: 0; background: rgba(42, 26, 46, .55); opacity: 0; transition: opacity .2s; }
.panel.open .panel-backdrop { opacity: 1; }
.panel-box {
  position: relative; width: min(560px, 100%); max-height: min(86vh, 820px);
  background: var(--cream); border: 3px solid var(--ink); border-radius: 16px;
  box-shadow: 0 6px 0 var(--ink), inset 0 0 0 3px var(--paper);
  display: flex; flex-direction: column; overflow: hidden;
  transform: translateY(20px) scale(.96); opacity: 0; transition: transform .2s, opacity .2s;
}
.panel.open .panel-box { transform: none; opacity: 1; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; background: var(--paper); border-bottom: 3px solid var(--ink);
}
.panel-head h2 { margin: 0; font-family: var(--font-pixel); font-size: 12px; display: flex; align-items: center; gap: 10px; color: var(--ink); }
.panel-head h2 svg, .panel-head h2 .pixicon { width: 26px; height: 26px; }
.panel-body { padding: 14px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.panel-body p { margin: 0 0 8px; line-height: 1.25; }
.panel-body h3 { margin: 6px 0 6px; font-family: var(--font-pixel); font-size: 11px; color: var(--rose); }
.panel-body h3.sub { margin-top: 18px; }
.lead { font-size: 21px; text-align: center; color: var(--brown); }
.muted { color: var(--brown); font-size: 18px; }
.center { text-align: center; }
.note { color: var(--green); }
.card {
  background: #fff; border: 3px solid var(--ink); border-radius: 12px; padding: 14px; margin-bottom: 12px;
  box-shadow: 0 3px 0 var(--ink);
}
.card.center { text-align: center; }
.card.center .portrait { margin: 0 auto 8px; display: block; }
.portrait { image-rendering: pixelated; border: 3px solid var(--ink); border-radius: 10px; background: var(--paper); }
.amp { text-align: center; font-family: var(--font-pixel); font-size: 22px; color: var(--gold); margin: -4px 0 8px; text-shadow: 2px 2px 0 var(--ink); }
.tag { display: inline-block; background: var(--paper); border: 2px solid var(--ink); border-radius: 6px; padding: 2px 8px; font-size: 16px; color: var(--ink); text-decoration: none; }
.tag.ok { background: #cfeec4; }
.tag.no { background: #f7d1d1; }
.row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }

.countdown { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.countdown div { background: var(--ink); color: #ffe066; border-radius: 10px; padding: 10px 4px; text-align: center; border: 3px solid var(--gold); }
.countdown b { display: block; font-family: var(--font-pixel); font-size: 18px; }
.countdown span { font-size: 15px; color: var(--cream); }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.gallery figure { margin: 0; background: #fff; border: 3px solid var(--ink); border-radius: 10px; padding: 8px 8px 6px; box-shadow: 0 3px 0 var(--ink); }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; border: 2px solid var(--ink); }
.gallery img:not(.pixel-photo) { image-rendering: auto; }
.gallery figcaption { font-size: 16px; text-align: center; margin-top: 6px; color: var(--brown); }

.timeline { list-style: none; margin: 0; padding: 0 0 0 22px; border-left: 4px dotted var(--tan); }
.timeline li { position: relative; margin-bottom: 18px; }
.timeline li::before { content: ''; position: absolute; left: -32px; top: 4px; width: 14px; height: 14px; background: var(--rose); border: 3px solid var(--ink); }
.timeline .year { font-family: var(--font-pixel); font-size: 9px; color: var(--gold); background: var(--ink); padding: 3px 6px; border-radius: 4px; }
.timeline h3 { margin-top: 6px; }

.form { display: grid; gap: 10px; }
.form label { display: grid; gap: 4px; font-size: 17px; color: var(--brown); }
.form input, .form select, .form textarea {
  font-family: var(--font-body); font-size: 20px; padding: 8px 10px; border: 3px solid var(--ink); border-radius: 8px; background: var(--cream); color: var(--ink);
}
.form textarea { resize: vertical; }
.wishes { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.wish { background: #fff; border: 3px solid var(--ink); border-radius: 10px; padding: 10px 12px; }
.wish-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.wish-head b { font-family: var(--font-pixel); font-size: 10px; }
.wish p { margin: 0; }

.bank { display: grid; gap: 4px; }
.bank-name { font-family: var(--font-pixel); font-size: 10px; color: var(--brown); }
.mono { font-family: var(--font-pixel); font-size: 14px; letter-spacing: 1px; }
.bank .btn { justify-self: start; margin-top: 6px; }

.snap-out img { width: 100%; max-width: 360px; border: 3px solid var(--ink); border-radius: 8px; margin-top: 10px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; top: 14%; transform: translate(-50%, -10px); z-index: 30;
  background: var(--ink); color: var(--cream); border: 3px solid var(--gold); border-radius: 10px;
  padding: 10px 16px; font-size: 19px; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none;
  max-width: calc(100% - 40px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- cover ---------- */
.cover {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: safe center; padding: 20px; overflow-y: auto;
  background: radial-gradient(ellipse at 50% 20%, #e4f7de 0%, #b8edf3 55%, #87d9f2 100%);
  transition: opacity .6s, transform .6s;
}
.cover.hide { opacity: 0; transform: scale(1.06); pointer-events: none; }
.cover-box {
  width: min(560px, 100%); text-align: center;
  background: var(--cream); border: 4px solid var(--ink); border-radius: 18px;
  box-shadow: 0 8px 0 var(--ink), inset 0 0 0 4px var(--paper);
  padding: 28px 22px 24px;
}
.cover-kicker { font-family: var(--font-pixel); font-size: 10px; color: var(--brown); margin: 0 0 12px; letter-spacing: 1px; }
.cover-box h1 { font-family: var(--font-pixel); font-size: clamp(18px, 6vw, 28px); margin: 0 0 8px; color: var(--rose); line-height: 1.4; text-shadow: 3px 3px 0 var(--tan); }
.amp-sm { display: block; font-size: .6em; color: var(--gold); }
.cover-date { margin: 0 0 18px; font-size: 22px; color: var(--ink); }
.cover-to { background: var(--paper); border: 3px solid var(--ink); border-radius: 12px; padding: 10px 14px; margin: 0 0 18px; display: grid; gap: 4px; }
.cover-to span { font-size: 17px; color: var(--brown); }
.cover-to b { font-family: var(--font-pixel); font-size: 13px; color: var(--ink); word-break: break-word; }
.cover-hint { margin: 14px 0 0; font-size: 17px; color: var(--brown); }

body.is-locked .menu, body.is-locked .joystick, body.is-locked .btn-a, body.is-locked .hud-top { visibility: hidden; }

/* Playable guest selection and nearby music cue. */
.guest-picker { margin: 0 0 18px; }
.guest-picker h2 { font-family: var(--font-pixel); font-size: 11px; margin: 0 0 12px; }
.guest-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.guest-option { display: flex; flex-direction: column; align-items: center; padding: 4px 3px 8px; border: 2px solid var(--tan); border-radius: 12px; background: #f1f6e9; color: var(--ink); }
.guest-option img { display: block; width: 100%; max-width: 95px; height: auto; }
.guest-option b { font-size: 20px; }
.guest-option span { font-size: 14px; line-height: 1.1; }
.guest-option[aria-pressed="true"] { border-color: var(--rose); background: #ffe1ed; box-shadow: 0 0 0 2px var(--rose); }
.guest-option:focus-visible { outline: 3px solid #438fd1; outline-offset: 4px; }
#guest-selected { font-size: 17px; line-height: 1.2; margin: 12px 0 0; }
.dance-status { position: fixed; top: 105px; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); padding: 8px 14px; border: 2px solid var(--rose); border-radius: 18px; background: var(--cream); color: var(--ink); z-index: 5; pointer-events: none; text-align: center; font-size: 18px; }
@media (max-width: 440px) {
  .cover { padding: 12px; }
  .cover-box { padding: 20px 14px; }
  .guest-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .guest-option img { max-width: 68px; }
  .cover-date, .cover-to { margin-bottom: 12px; }
}

/* Midnight rooftop palette */
:root { --ink: #e7eaff; --cream: #161e38; --paper: #232c4b; --tan: #485079; --brown: #b4bddd; --gold: #70e3ed; --rose: #ff79cf; --pink: #d793ff; --shadow: 0 4px 0 #070b1c; }
html, body { background: radial-gradient(ellipse at 65% 20%, #293456 0%, #111831 45%, #060a1b 100%) fixed; }
.hud-title, .menu, .dialog, .panel-box { border-color: #515b88; box-shadow: 0 5px 24px #05081780, 0 0 18px #715dff18; }
.cover { background: radial-gradient(ellipse at 20% 20%, #66306470, transparent 50%), radial-gradient(ellipse at 80% 75%, #12687660, transparent 50%), #0b1028ed; }
.cover-box { border-color: #626c99; box-shadow: 0 0 65px #9c4be32b; }
.cover-kicker { color: #7de8f2; font-size: 8px; line-height: 1.8; }
.guest-option { background: #202944; }
.guest-option[aria-pressed="true"] { background: #4c2d55; }
.btn-gold { color: #101c35; border-color: #a5f9ff; box-shadow: 0 0 18px #54d8ee40; }
.card, .wish, .gallery figure { background: #232c4b; }
.tag.ok { background: #255545; } .tag.no { background: #66394d; }
.joy-ring, .btn-a { border-color: #8791c8; }
.dance-status { box-shadow: 0 0 24px #ff43c74d; }

.lift-overlay { position:fixed; inset:0; z-index:100; display:grid; place-items:center; padding:20px; background:#070b1bf5; }
.lift-cabin { width:min(100%,440px); text-align:center; padding:24px; border:2px solid #7482a8; border-radius:18px; background:linear-gradient(110deg,#27334b,#11192c); box-shadow:0 0 70px #5dbfe52b; }
.lift-kicker { color:#8fe6ed; font-size:14px; letter-spacing:2px; }
.lift-cabin h2 { margin:12px 0; font-size:28px; }
.lift-display { margin:16px auto; padding:10px; width:130px; color:#8ff6ed; background:#080e20; font:24px var(--font-pixel); border:1px solid #637896; }
.lift-doors { position:relative; height:220px; overflow:hidden; border:5px solid #77879b; background:linear-gradient(#ad996d,#343f58); display:grid; place-items:center; }
.lift-doors>div { position:absolute; width:50%; height:100%; z-index:1; background:linear-gradient(90deg,#4a5b75,#93a1b1,#46556d); transition:transform 1s; }
.lift-doors>div:first-child { left:0; border-right:2px solid #25314a; }.lift-doors>div:nth-child(2){right:0;}
.arrived .lift-doors>div:first-child { transform:translateX(-95%); }.arrived .lift-doors>div:nth-child(2) { transform:translateX(95%); }
.lift-doors span { color:#fff0cf; letter-spacing:3px; font-size:30px; }.lift-doors small { font-size:14px; }
.lift-status { min-height:56px; color:#d8e2f4; }.lift-cabin button { margin:5px; }
@media(prefers-reduced-motion:reduce) { .lift-doors>div { transition:none; } }

.prompt { background:#18213b; color:#ffe9a8; }
.sapa.ready { color:#18213b; }
