:root {
  --pink: #c22a5f;
  --pink-dark: #9c1e4b;
  --cream: #f7ecd9;
  --cream-2: #efe0c6;
  --ink: #3a2e2a;
  --yellow: #f4c430;
  --sky: #a9dcef;
  --grass: #6cbf4a;
  --white: #fffdf7;
  --shadow: rgba(20, 12, 8, 0.35);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  background: #1b1712;
  font-family: "Pixelify Sans", "Courier New", monospace;
  color: var(--ink);
  overflow: hidden;
}

#app {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  background: var(--grass);
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
}
.screen.active { display: block; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

.hidden { display: none !important; }

/* ============ COVER ============ */

#screen-cover { background: var(--sky); overflow: hidden; }

.cover-sky {
  position: absolute;
  inset: 0 0 34% 0;
  background: linear-gradient(180deg, #8fd3ea 0%, #b3e4f2 100%);
  overflow: hidden;
}

.cover-sun {
  position: absolute;
  top: 7%;
  right: 10%;
  width: 44px;
  height: 44px;
  background: var(--yellow);
  border-radius: 8px;
  box-shadow: 0 0 0 6px rgba(244, 196, 48, 0.35);
}

.cloud {
  position: absolute;
  background: var(--white);
  border-radius: 6px;
  box-shadow: 12px 0 0 var(--white), 24px 0 0 var(--white), 6px -8px 0 var(--white), 18px -8px 0 var(--white);
  width: 18px;
  height: 12px;
}
.cloud-1 { top: 12%; left: 8%; }
.cloud-2 { top: 24%; left: 62%; transform: scale(0.8); }
.cloud-3 { top: 6%; left: 40%; transform: scale(0.6); }

.cover-grass {
  position: absolute;
  inset: 66% 0 0 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,0.14) 3px, transparent 4px),
    radial-gradient(circle at 70% 60%, rgba(255,255,255,0.12) 3px, transparent 4px),
    linear-gradient(180deg, #79c94f 0%, #5fb33e 100%);
}
.spark {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 1px;
}
.s1 { background: #ffb3c7; top: 30%; left: 15%; }
.s2 { background: var(--yellow); top: 60%; left: 70%; }
.s3 { background: #9fd8ff; top: 75%; left: 35%; }

.cover-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 7vh 22px 24px;
  gap: 12px;
  text-align: center;
  overflow-y: auto;
}

.welcome-pill {
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 8px;
  padding: 5px 14px;
  font-family: "Press Start 2P", monospace;
  font-size: 9px;
  box-shadow: 3px 3px 0 var(--shadow);
}

.couple-title {
  font-family: "Pixelify Sans", monospace;
  font-weight: 700;
  font-size: clamp(38px, 12vw, 54px);
  line-height: 0.95;
  color: var(--white);
  text-shadow: 3px 0 0 var(--ink), -3px 0 0 var(--ink), 0 3px 0 var(--ink), 0 -3px 0 var(--ink), 4px 5px 0 var(--shadow);
  letter-spacing: 1px;
}
.couple-title .amp { color: var(--yellow); }

.date-pill {
  background: var(--ink);
  color: var(--cream);
  border-radius: 6px;
  padding: 5px 16px;
  font-family: "Press Start 2P", monospace;
  font-size: 9px;
  box-shadow: 3px 3px 0 var(--shadow);
}

.guest-card {
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 10px;
  padding: 14px 16px 12px;
  width: 100%;
  max-width: 340px;
  box-shadow: 4px 4px 0 var(--shadow);
}
.guest-label {
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  letter-spacing: 1px;
  color: #8a7a70;
}
.guest-name {
  font-size: 30px;
  font-weight: 700;
  margin: 6px 0 4px;
}
.guest-note {
  font-size: 13px;
  color: #8a7a70;
  line-height: 1.2;
}

.char-select {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 340px;
}
.char-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 10px;
  padding: 12px 8px;
  font-family: "Pixelify Sans", monospace;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--shadow);
  transition: transform 0.08s ease;
}
.char-btn:active { transform: translate(2px, 2px); }
.char-btn.selected {
  background: var(--pink);
  color: var(--white);
  border-color: var(--yellow);
}

.btn-primary {
  width: 100%;
  max-width: 340px;
  background: var(--pink);
  color: var(--white);
  border: 3px solid var(--ink);
  border-radius: 10px;
  padding: 14px;
  font-family: "Pixelify Sans", monospace;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 1px;
  box-shadow: 5px 5px 0 var(--shadow);
  transition: transform 0.08s ease;
}
.btn-primary:active { transform: translate(2px, 2px); box-shadow: 3px 3px 0 var(--shadow); }

.link-plain {
  color: var(--ink);
  font-family: "Pixelify Sans", monospace;
  font-size: 16px;
  text-decoration: underline;
  padding: 4px;
}

/* ============ GAME ============ */

#screen-game { background: #000; }
#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#hud {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.hud-item {
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 8px;
  box-shadow: 3px 3px 0 var(--shadow);
  height: 40px;
}
.hud-hearts {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 10px;
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  flex: 1;
}
.hud-hearts .h { font-size: 15px; line-height: 1; }
.hud-hearts .h.on { color: var(--pink); }
.hud-hearts .h.off { color: #d9cfc2; }
.hud-hearts .count { margin-left: 6px; }
.hud-btn {
  width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Press Start 2P", monospace;
  font-size: 11px;
  color: var(--ink);
}
#hudSound, #hudMenu { font-size: 16px; }

.hint-interact {
  position: absolute;
  bottom: 26%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--yellow);
  border: 3px solid var(--ink);
  border-radius: 6px;
  padding: 2px 8px;
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  animation: bounce 0.7s infinite alternate;
}
@keyframes bounce { from { transform: translate(-50%, 0); } to { transform: translate(-50%, -5px); } }

/* Dialogue */
.dialogue {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 12px;
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 12px;
  box-shadow: 4px 4px 0 var(--shadow);
  padding: 22px 14px 12px;
  min-height: 110px;
}
.dialogue-name {
  position: absolute;
  top: -14px;
  left: 12px;
  background: var(--pink);
  color: var(--white);
  border: 3px solid var(--ink);
  border-radius: 8px;
  padding: 2px 12px;
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
}
.dialogue-close {
  position: absolute;
  top: -14px;
  right: 10px;
  width: 30px;
  height: 30px;
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 8px;
  font-family: "Press Start 2P", monospace;
  font-size: 11px;
  color: var(--ink);
}
#dlgPortrait {
  position: absolute;
  left: 14px;
  bottom: 40px;
  width: 56px;
  height: 56px;
  border: 3px solid var(--pink);
  border-radius: 8px;
  background: var(--cream);
  image-rendering: pixelated;
}
.dialogue-text {
  margin-left: 68px;
  font-family: "Pixelify Sans", monospace;
  font-size: 18px;
  line-height: 1.25;
  min-height: 52px;
}
.dialogue-next {
  position: absolute;
  right: 14px;
  bottom: 8px;
  color: var(--pink);
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  padding: 4px;
}

/* Touch controls */
.touch-controls {
  position: absolute;
  inset: auto 0 0 0;
  padding: 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
}
.dpad {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(3, 44px);
  pointer-events: auto;
}
.dpad-btn {
  background: rgba(255, 253, 247, 0.85);
  border: 3px solid var(--ink);
  border-radius: 8px;
  font-size: 14px;
  color: var(--ink);
}
.dpad-btn.up { grid-column: 2; grid-row: 1; }
.dpad-btn.left { grid-column: 1; grid-row: 2; }
.dpad-btn.right { grid-column: 3; grid-row: 2; }
.dpad-btn.down { grid-column: 2; grid-row: 3; }
.action-btn {
  pointer-events: auto;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--pink);
  border: 3px solid var(--ink);
  color: var(--white);
  font-family: "Press Start 2P", monospace;
  font-size: 16px;
  box-shadow: 3px 3px 0 var(--shadow);
}

/* Confetti */
.confetti-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti-piece {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 8px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(540deg); }
}

/* ============ OVERLAY / PANELS ============ */

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(27, 23, 18, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 20;
}
.panel {
  width: 100%;
  max-width: 400px;
  max-height: 86vh;
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 14px;
  box-shadow: 6px 6px 0 var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--cream-2);
  border-bottom: 3px solid var(--ink);
}
.panel-header-ico { font-size: 18px; }
.panel-header-title {
  flex: 1;
  font-family: "Pixelify Sans", monospace;
  font-size: 22px;
  font-weight: 700;
}
.panel-close {
  width: 32px;
  height: 32px;
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 8px;
  font-family: "Press Start 2P", monospace;
  font-size: 11px;
  color: var(--ink);
}

.menu-list {
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 10px;
  padding: 11px 14px;
  font-family: "Pixelify Sans", monospace;
  font-size: 19px;
  font-weight: 600;
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--shadow);
  transition: transform 0.08s ease;
}
.menu-item:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--shadow); }
.menu-item .mi-ico { font-size: 18px; }

.modal-body {
  padding: 16px;
  overflow-y: auto;
  font-family: "Pixelify Sans", monospace;
  font-size: 17px;
  line-height: 1.35;
}
.modal-body h3 {
  font-family: "Press Start 2P", monospace;
  font-size: 11px;
  color: var(--pink);
  margin: 14px 0 8px;
}
.modal-body p { margin-bottom: 10px; }

.std-head { text-align: center; margin-bottom: 14px; }
.std-head .std-label {
  font-family: "Press Start 2P", monospace;
  font-size: 9px;
  letter-spacing: 2px;
  color: #8a7a70;
}
.std-head .std-names {
  font-family: "Pixelify Sans", monospace;
  font-weight: 700;
  font-size: 34px;
  color: var(--pink);
  margin: 4px 0;
}
.std-head .std-amp { color: var(--yellow); }
.std-head .std-when { font-size: 17px; }
.std-head .std-where { font-size: 16px; color: #8a7a70; }

.countdown {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 14px;
}
.cd-box {
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 8px;
  padding: 8px 4px;
  min-width: 62px;
  text-align: center;
  box-shadow: 3px 3px 0 var(--shadow);
}
.cd-num {
  font-family: "Press Start 2P", monospace;
  font-size: 16px;
}
.cd-lbl {
  font-family: "Press Start 2P", monospace;
  font-size: 7px;
  color: #8a7a70;
  margin-top: 6px;
}

.timeline { list-style: none; }
.timeline li {
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  box-shadow: 3px 3px 0 var(--shadow);
}
.timeline .tl-year {
  font-family: "Press Start 2P", monospace;
  font-size: 9px;
  color: var(--pink);
}

.event-card, .gift-card, .person-card {
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 3px 3px 0 var(--shadow);
}
.event-card .ec-title { font-weight: 700; font-size: 20px; }
.event-card .ec-time { color: var(--pink); font-family: "Press Start 2P", monospace; font-size: 10px; margin: 6px 0; }

.btn-block {
  display: block;
  width: 100%;
  background: var(--pink);
  color: var(--white);
  border: 3px solid var(--ink);
  border-radius: 10px;
  padding: 11px;
  font-family: "Pixelify Sans", monospace;
  font-size: 19px;
  font-weight: 700;
  box-shadow: 4px 4px 0 var(--shadow);
  text-align: center;
  text-decoration: none;
  margin-top: 8px;
}
.btn-block:active { transform: translate(2px, 2px); }

.gallery-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.gallery-item {
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 3px 3px 0 var(--shadow);
}
.gallery-item canvas { width: 100%; display: block; image-rendering: pixelated; }
.gallery-item .gi-cap {
  padding: 6px 8px;
  font-family: "Press Start 2P", monospace;
  font-size: 7px;
  text-align: center;
  color: var(--ink);
}

.form-group { margin-bottom: 12px; }
.form-group label {
  display: block;
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  margin-bottom: 6px;
  color: #8a7a70;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 8px;
  padding: 10px;
  font-family: "Pixelify Sans", monospace;
  font-size: 18px;
  color: var(--ink);
}
.form-group textarea { min-height: 70px; resize: vertical; }
.radio-row { display: flex; gap: 10px; }
.radio-row label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 8px;
  padding: 10px;
  font-family: "Pixelify Sans", monospace;
  font-size: 17px;
  color: var(--ink);
  cursor: pointer;
}
.radio-row input { accent-color: var(--pink); }

.wish-item {
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  box-shadow: 3px 3px 0 var(--shadow);
}
.wish-item .wi-name { color: var(--pink); font-weight: 700; }

.gift-card .gc-bank {
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  color: var(--pink);
}
.gift-card .gc-num {
  font-family: "Press Start 2P", monospace;
  font-size: 12px;
  margin: 8px 0;
  user-select: all;
}
.btn-copy {
  background: var(--cream-2);
  border: 3px solid var(--ink);
  border-radius: 8px;
  padding: 6px 12px;
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  color: var(--ink);
}

.person-card { display: flex; gap: 12px; align-items: center; }
.person-card canvas {
  width: 72px;
  height: 72px;
  image-rendering: pixelated;
  border: 3px solid var(--pink);
  border-radius: 8px;
  background: var(--cream-2);
}
.person-card .pc-name { font-weight: 700; font-size: 22px; }
.person-card .pc-desc { font-size: 15px; color: #6f5f55; }

/* Toast */
.toast {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--cream);
  border: 3px solid var(--white);
  border-radius: 10px;
  padding: 10px 16px;
  font-family: "Pixelify Sans", monospace;
  font-size: 16px;
  z-index: 40;
  box-shadow: 4px 4px 0 var(--shadow);
  max-width: 86%;
  text-align: center;
}
