:root {
  --ink: #4d2844;
  --berry: #783c65;
  --rose: #d96b9d;
  --pink: #f8bdd4;
  --cream: #fff7eb;
  --gold: #ecc070;
  --gold-light: #fce09b;
  --step: polygon(0 12px, 4px 12px, 4px 8px, 8px 8px, 8px 4px, 12px 4px, 12px 0,
    calc(100% - 12px) 0, calc(100% - 12px) 4px, calc(100% - 8px) 4px,
    calc(100% - 8px) 8px, calc(100% - 4px) 8px, calc(100% - 4px) 12px, 100% 12px,
    100% calc(100% - 12px), calc(100% - 4px) calc(100% - 12px), calc(100% - 4px) calc(100% - 8px),
    calc(100% - 8px) calc(100% - 8px), calc(100% - 8px) calc(100% - 4px), calc(100% - 12px) calc(100% - 4px),
    calc(100% - 12px) 100%, 12px 100%, 12px calc(100% - 4px), 8px calc(100% - 4px),
    8px calc(100% - 8px), 4px calc(100% - 8px), 4px calc(100% - 12px), 0 calc(100% - 12px));
  --step-sm: polygon(0 8px, 4px 8px, 4px 4px, 8px 4px, 8px 0,
    calc(100% - 8px) 0, calc(100% - 8px) 4px, calc(100% - 4px) 4px, calc(100% - 4px) 8px, 100% 8px,
    100% calc(100% - 8px), calc(100% - 4px) calc(100% - 8px), calc(100% - 4px) calc(100% - 4px),
    calc(100% - 8px) calc(100% - 4px), calc(100% - 8px) 100%, 8px 100%, 8px calc(100% - 4px),
    4px calc(100% - 4px), 4px calc(100% - 8px), 0 calc(100% - 8px));
  --px-heart: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 10' shape-rendering='crispEdges'%3E%3Cpath fill='%235a2f4e' d='M2 0h2v1h-2zM7 0h2v1h-2zM1 1h1v1h-1zM4 1h1v1h-1zM6 1h1v1h-1zM9 1h1v1h-1zM0 2h1v3h-1zM5 2h1v1h-1zM10 2h1v3h-1zM1 5h1v1h-1zM9 5h1v1h-1zM2 6h1v1h-1zM8 6h1v1h-1zM3 7h1v1h-1zM7 7h1v1h-1zM4 8h1v1h-1zM6 8h1v1h-1zM5 9h1v1h-1z'/%3E%3Cpath fill='%23ff95be' d='M2 1h2v1h1v1h-4v-1h1zM7 1h2v1h1v1h-4v-1h1zM1 3h9v2h-1v1h-1v1h-1v1h-1v1h-1v-1h-1v-1h-1v-1h-1v-1h-1z'/%3E%3Cpath fill='%23ffe2ef' d='M2 1h1v1h1v1h-2zM7 2h1v1h-1zM2 3h1v1h-1z'/%3E%3Cpath fill='%23ffffff' d='M2 2h1v1h-1z'/%3E%3Cpath fill='%23df5f95' d='M9 4h1v1h-1zM2 5h1v1h-1zM8 5h1v1h-1zM3 6h1v1h-1zM7 6h1v1h-1zM4 7h3v1h-3zM5 8h1v1h-1z'/%3E%3C/svg%3E");
  --px-ribbon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 21 11' shape-rendering='crispEdges'%3E%3Cpath fill='%235a2f4e' d='M2 0h4v1h-4zM15 0h4v1h-4zM1 1h1v1h-1zM6 1h2v1h-2zM9 1h3v1h-3zM13 1h2v1h-2zM19 1h1v1h-1zM0 2h1v3h-1zM7 2h2v1h-2zM12 2h2v1h-2zM20 2h1v3h-1zM8 3h1v2h-1zM12 3h1v2h-1zM1 5h1v1h-1zM6 5h9v1h-9zM19 5h1v1h-1zM2 6h5v1h-5zM9 6h1v2h-1zM11 6h1v2h-1zM14 6h5v1h-5zM6 7h1v1h-1zM14 7h1v1h-1zM5 8h1v3h-1zM8 8h1v1h-1zM12 8h1v1h-1zM15 8h1v3h-1zM7 9h1v1h-1zM13 9h1v1h-1zM6 10h1v1h-1zM14 10h1v1h-1z'/%3E%3Cpath fill='%23ffa1c6' d='M4 1h2v1h-2zM15 1h2v1h-2zM2 2h5v1h-5zM14 2h5v1h-5zM1 3h7v2h-7zM13 3h7v2h-7zM2 5h4v1h-4zM15 5h4v1h-4zM7 6h2v1h-2zM12 6h2v1h-2zM7 7h1v1h-1zM13 7h1v1h-1zM6 8h2v1h-2zM13 8h2v1h-2z'/%3E%3Cpath fill='%23ffd9eb' d='M2 1h2v1h-2zM17 1h2v1h-2zM1 2h1v1h-1zM19 2h1v1h-1z'/%3E%3Cpath fill='%23df6b9b' d='M4 3h1v1h-1zM16 3h1v1h-1zM3 4h2v1h-2zM16 4h2v1h-2zM2 5h1v1h-1zM18 5h1v1h-1zM8 7h1v1h-1zM12 7h1v1h-1zM6 9h1v1h-1zM14 9h1v1h-1z'/%3E%3Cpath fill='%23f7c86b' d='M9 2h3v3h-3z'/%3E%3Cpath fill='%23fff2bc' d='M10 3h1v1h-1z'/%3E%3C/svg%3E");
  --px-rose: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 10' shape-rendering='crispEdges'%3E%3Cpath fill='%235a2f4e' d='M4 0h4v1h-4zM3 1h1v1h-1zM8 1h1v1h-1zM2 2h1v3h-1zM9 2h1v3h-1zM10 3h1v1h-1zM1 4h1v1h-1zM11 4h1v2h-1zM0 5h1v2h-1zM8 5h1v1h-1zM3 6h1v1h-1zM7 6h1v1h-1zM10 6h1v1h-1zM1 7h1v1h-1zM4 7h4v1h-4zM9 7h1v1h-1zM2 8h2v1h-2zM7 8h2v1h-2zM4 9h3v1h-3z'/%3E%3Cpath fill='%23ff9ac2' d='M6 1h2v1h-2zM4 2h5v1h-5zM3 3h6v2h-6zM4 5h3v2h-3z'/%3E%3Cpath fill='%23ffe0ee' d='M4 1h2v1h-2zM3 2h1v1h-1zM5 3h1v1h-1z'/%3E%3Cpath fill='%23dc6396' d='M6 2h1v1h-1zM4 3h1v1h-1zM7 3h1v1h-1zM6 4h1v1h-1zM3 5h1v1h-1zM5 5h1v1h-1zM7 5h1v1h-1zM4 6h1v1h-1z'/%3E%3Cpath fill='%23fff0b3' d='M5 4h1v1h-1z'/%3E%3Cpath fill='%23a8d988' d='M10 4h1v2h-1zM1 5h1v1h-1zM2 6h1v1h-1zM9 6h1v1h-1zM3 7h1v1h-1zM5 8h1v1h-1z'/%3E%3Cpath fill='%236da665' d='M9 5h1v1h-1zM1 6h1v1h-1zM8 6h1v2h-1zM2 7h1v1h-1zM4 8h1v1h-1zM6 8h1v1h-1z'/%3E%3C/svg%3E");
  color: var(--ink);
  font-family: 'Galmuri11', system-ui, 'Malgun Gothic', sans-serif;
  font-synthesis: none;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
dialog:not([open]) { display: none; }
.image-unavailable { visibility: hidden; }
body {
  margin: 0;
  background: radial-gradient(#d4a7c023 1px, transparent 1px) 0 0 / 12px 12px, #f9edf4;
}
button, input, a { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px dashed #863964;
  outline-offset: 3px;
}
button { -webkit-tap-highlight-color: #f6b3ce66; }
h1, h2, h3, p { margin: 0; }
.app { max-width: 430px; min-height: 100vh; min-height: 100svh; margin-inline: auto; }
.pixel { image-rendering: pixelated; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.copy-buffer { position: fixed; top: 0; left: 0; opacity: 0; font-size: 16px; pointer-events: none; }

.frame { position: relative; isolation: isolate; }
.frame::before, .frame::after {
  content: ''; position: absolute; pointer-events: none; clip-path: var(--step);
}
.frame::before { z-index: -2; inset: 0; background: var(--ink); }
.frame::after {
  z-index: -1; inset: 3px; background: var(--cream);
  box-shadow: inset 0 0 0 3px var(--gold), inset 0 0 0 5px #e59cb6, inset 0 0 0 7px #fff0d8;
}
.ribbon {
  position: absolute; z-index: 2; left: 50%; top: -10px; width: 32px; height: 18px;
  transform: translateX(-50%); background: #ed9cbb; filter: drop-shadow(0 2px #713a62);
  clip-path: polygon(0 0, 25% 0, 25% 17%, 41% 33%, 59% 33%, 75% 17%, 75% 0, 100% 0,
    100% 100%, 76% 100%, 64% 80%, 36% 80%, 24% 100%, 0 100%);
  border-block: 2px solid var(--berry);
}
.ribbon::after {
  content: ''; position: absolute; inset: 4px 11px 2px; background: #ffe198;
  border: 2px solid var(--berry);
}
.heart {
  display: inline-block; width: 15px; height: 14px;
  background: #f197b8; box-shadow: inset 0 -4px #d46496, inset 0 4px #ffc6db;
  clip-path: polygon(0 14%, 14% 14%, 14% 0, 42% 0, 42% 14%, 57% 14%, 57% 0, 86% 0, 86% 14%,
    100% 14%, 100% 57%, 86% 57%, 86% 71%, 71% 71%, 71% 86%, 57% 86%, 57% 100%, 43% 100%,
    43% 86%, 29% 86%, 29% 71%, 14% 71%, 14% 57%, 0 57%);
}
.hearts { display: flex; justify-content: center; gap: 5px; filter: drop-shadow(0 1px #7f3c69); }
.blink { animation: blink 1.35s steps(1, end) infinite; }
@keyframes blink { 0%, 66%, 100% { opacity: 1; } 67%, 99% { opacity: .33; } }

:is(.battle, .reveal) .frame::before {
  background: #5a2f4e;
}
:is(.battle, .reveal) .frame::after {
  inset: 3px;
  background: linear-gradient(180deg, #fffaf0 0%, #fff4e4 100%);
  box-shadow:
    inset 0 3px 0 0 var(--gold-light),
    inset 0 -3px 0 0 #d9a056,
    inset 3px 0 0 0 var(--gold),
    inset -3px 0 0 0 var(--gold),
    inset 0 0 0 5px #f2b1c9,
    inset 0 0 0 7px #fff3df;
}
:is(.battle, .reveal) .ribbon {
  top: -13px; width: 42px; height: 22px;
  border: 0; clip-path: none;
  background: var(--px-ribbon) center / contain no-repeat;
  image-rendering: pixelated;
  filter: drop-shadow(0 2px 0 #5a2f4e55);
}
:is(.battle, .reveal) .ribbon::after { display: none; }
:is(.battle, .reveal) .ribbon-sm {
  top: -11px; width: 34px; height: 18px;
}
:is(.battle, .reveal) .corner-rose {
  position: absolute; z-index: 3; left: -6px; bottom: -5px; width: 22px; height: 18px;
  pointer-events: none;
  background: var(--px-rose) center / contain no-repeat;
  image-rendering: pixelated;
  filter: drop-shadow(0 1px 0 #5a2f4e45);
}
:is(.battle, .reveal) .heart {
  width: 17px; height: 16px;
  clip-path: none; box-shadow: none;
  background: var(--px-heart) center / contain no-repeat;
  image-rendering: pixelated;
}
:is(.battle, .reveal) .hearts { gap: 4px; filter: drop-shadow(0 1px 0 #5a2f4e40); }

.battle {
  --command-bottom: max(8px, env(safe-area-inset-bottom, 0px));
  position: relative; isolation: isolate;
  height: 640px; height: clamp(510px, 100vh, 820px); height: clamp(510px, 100svh, 820px);
  overflow: hidden;
  border: 4px solid #5a2f4e;
  background:
    radial-gradient(#f5bfd655 1.5px, transparent 1.5px) 0 0 / 10px 10px,
    linear-gradient(180deg, #ccb0e6 0%, #dfc2ea 72%, #ecc6dc 100%);
  box-shadow: 0 4px 0 #9a638a, 0 10px 24px #5a2f4e28;
}
.battle::after {
  content: ''; position: absolute; pointer-events: none; z-index: 8; inset: 0;
  box-shadow: inset 0 0 0 2px #f8c6db, inset 0 0 0 4px #fce3bc88, inset 0 0 0 6px #d896b850;
}
.arena {
  position: absolute; inset: 0 0 86px; overflow: hidden;
  bottom: calc(86px + var(--command-bottom) - 8px);
  background: url('assets/bg.png') center / 100% 100% no-repeat, #cdb0e5;
  image-rendering: pixelated;
}
.battle-top {
  position: absolute; z-index: 7; top: max(10px, env(safe-area-inset-top)); inset-inline: 12px;
  display: flex; align-items: center; justify-content: space-between; pointer-events: none;
}
.chapter, .skip {
  border: 2px solid #5a2f4e; border-radius: 0; background: #fff6ea;
  box-shadow: inset 0 0 0 2px #f3c87b, 2px 2px 0 #5a2f4e66;
}
.chapter {
  font: 800 10px/1.2 ui-monospace, monospace; letter-spacing: .12em;
  padding: 6px 9px; color: var(--berry);
}
.skip {
  pointer-events: auto; min-height: 38px; padding: 4px 11px;
  font-size: 12px; font-weight: 850; color: #fff; background: #69254f;
  transition: background-color .12s steps(2), transform .08s steps(2);
}
.skip:hover { background: #833461; }
.skip:active { transform: translate(1px, 1px); box-shadow: inset 0 0 0 2px #f3c87b, 1px 1px 0 #5a2f4e66; }

.sprite { position: absolute; display: block; user-select: none; pointer-events: none; }
.bride-sprite {
  left: 51%; top: 20%; width: 46%; height: 43%;
  object-fit: contain; object-position: center bottom; z-index: 2;
  filter: drop-shadow(0 5px 0 #6b3d6644);
}
.groom-sprite {
  left: 0; bottom: 0; width: 59%; height: 44%;
  object-fit: contain; object-position: left bottom; z-index: 3;
  filter: drop-shadow(0 3px 0 #5a2f4e38);
}
.ball-sprite {
  left: 39%; top: 71%; width: 15%; z-index: 5; transform: translate(-50%, -50%);
  filter: drop-shadow(0 3px 0 #5a2f4e48);
}

.badge {
  position: absolute; z-index: 4; min-width: 39%; padding: 11px 14px 11px;
  text-align: center; font-size: 18px; font-weight: 900; letter-spacing: .04em;
  filter: drop-shadow(0 3px 0 #5a2f4e52);
}
.badge::before, .badge::after { clip-path: var(--step-sm); }
.badge-name { display: block; line-height: 1.15; text-shadow: 0 1px 0 #fff; }
.badge .hearts { margin-top: 5px; }
.bride-badge {
  left: 4.5%; top: clamp(54px, 13%, 82px);
  top: max(clamp(54px, 13%, 82px), calc(env(safe-area-inset-top, 0px) + 52px));
}
.groom-badge { right: 4.5%; bottom: 6%; }
.battle[data-phase='start'] :is(.badge, .bride-sprite, .groom-sprite) { visibility: hidden; }
.battle.entrance .bride-sprite { animation: entrance .56s cubic-bezier(.14,.82,.25,1) both; }
.battle.entrance .bride-badge { animation: entrance .48s .10s cubic-bezier(.14,.82,.25,1) both; }
.battle.fight-flash .groom-sprite { animation: fight-flash .54s steps(1, end); }
@keyframes entrance { from { transform: translateX(68%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fight-flash { 0%, 45%, 90% { opacity: .3; filter: brightness(1.5); } 22%, 67%, 100% { opacity: 1; } }

.start {
  position: absolute; z-index: 6; inset: 0; width: 100%; border: 0; padding: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 10px;
  background: linear-gradient(transparent 28%, #8f56863d 58%, #5a2d5ce0 100%);
  color: #fff8ee; padding-bottom: max(34px, calc(env(safe-area-inset-bottom) + 20px));
}
.start-mark {
  color: #ffe39e; font-size: 30px; line-height: 1;
  text-shadow: 0 2px 0 #5a2f4e, 2px 0 0 #5a2f4e, -2px 0 0 #5a2f4e, 0 -2px 0 #5a2f4e;
}
.start-title {
  font: 900 clamp(24px, 7.6vw, 35px)/1.14 ui-monospace, monospace; letter-spacing: .05em;
  color: #fff7eb;
  text-shadow: 2px 2px 0 #5a2f4e, -2px 2px 0 #5a2f4e, 2px -2px 0 #5a2f4e, -2px -2px 0 #5a2f4e, 0 4px 0 #c9689a;
}
.start-hint {
  display: block; color: var(--ink); margin-top: 8px; padding: 13px 25px;
  font-size: 14px; font-weight: 900; letter-spacing: .02em;
  filter: drop-shadow(0 3px 0 #4d244588);
}
.start-hint::before, .start-hint::after { clip-path: var(--step-sm); }
.start:focus-visible { outline-offset: -8px; }

.command {
  position: absolute; z-index: 6; inset: auto 8px var(--command-bottom);
  min-height: 98px; display: grid;
  filter: drop-shadow(0 3px 0 #4d28446e);
}
.advance {
  width: 100%; min-height: 98px; padding: 12px 30px 12px 17px; text-align: left;
  display: flex; align-items: center;
  border: 0; background: transparent; white-space: pre-line;
  font-size: clamp(13.5px, 3.85vw, 17px); font-weight: 850; line-height: 1.45; word-break: keep-all;
  color: var(--ink);
}
.advance:focus-visible { outline-offset: -6px; }
.caret {
  position: absolute; bottom: 11px; right: 14px; color: #5a2f4e; font-size: 11px;
  text-shadow: 0 1px 0 #ffd2e4;
}
.battle-menu {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(144px, 57%); gap: 6px;
  align-items: center; padding: 11px 12px 11px 16px;
}
.battle-menu p {
  font-weight: 850; white-space: pre-line; overflow-wrap: anywhere;
  font-size: clamp(13.5px, 3.85vw, 17px); line-height: 1.45;
  color: var(--ink);
}
.choices {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 1fr;
  border: 2px solid #6e3a5f; background: #fffbf2;
  box-shadow: inset 0 0 0 1px #f6d5e3, 2px 2px 0 #d9a7c077;
}
.choices button {
  position: relative; min-height: 37px; padding: 4px 4px 4px 16px; text-align: left;
  border: 0; background: #fffbf2; white-space: normal; word-break: keep-all; overflow-wrap: anywhere;
  font-weight: 850; font-size: clamp(12.5px, 3.6vw, 16px); color: var(--ink);
}
.choices button + button { border-left: 2px solid #ddb0c6; }
.choices button[data-action='escape'] { border-left: 0; border-top: 2px solid #ddb0c6; }
.choices::after {
  content: ''; border-left: 2px solid #ddb0c6; border-top: 2px solid #ddb0c6;
  background: #fff6ec;
}
.choices button.selected, .choices button:hover { background: #fdd5e5; }
.choices button.selected::before {
  content: '▶'; position: absolute; left: 5px; top: 50%; transform: translateY(-50%);
  font-size: 9px; color: #5a2f4e;
}
.choices button.spent { color: #675e69; background: #e6e0e6; }
.choices button.spent.selected, .choices button.spent:hover { background: #dad2db; }

.bag {
  /* Keep the panel above the groom badge without resizing the arena. */
  position: absolute; z-index: 6; right: 4.5%; bottom: calc(6% + 73px); width: 60%; max-width: 250px;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px 4px;
  padding: 9px 9px 8px;
}
.bag::before, .bag::after { clip-path: var(--step-sm); }
.battle .bag > .ribbon { top: -9px; width: 28px; height: 15px; }
.bag h2 {
  grid-column: 1 / -1; padding-bottom: 3px; text-align: center;
  font-size: 13px; font-weight: 900; letter-spacing: .18em; color: var(--berry);
  border-bottom: 1px dashed #dfa9c2;
}
.bag button {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  min-width: 0; min-height: 44px; padding: 2px 3px 2px 14px;
  border: 1px solid #ebc5d7; background: #fff7f3; text-align: center; word-break: keep-all; overflow-wrap: anywhere;
  font-size: clamp(10px, 2.85vw, 12px); font-weight: 850; line-height: 1.15; color: var(--ink);
}
.bag button:hover, .bag button:focus-visible { background: #fdd5e5; }
.bag button:focus-visible { outline-offset: -3px; }
.bag button:not([data-item='close']):is(:hover, :focus-visible)::before {
  content: '▶'; position: absolute; left: 3px; top: 50%; transform: translateY(-50%);
  font-size: 9px; color: #5a2f4e;
}
.bag button img { width: 21px; height: 21px; flex-shrink: 0; }
.bag button span:first-child:not(:only-child) { width: 24px; text-align: center; color: var(--berry); flex-shrink: 0; }
.ring-icon { position: relative; height: 24px; }
.ring-icon::before, .ring-icon::after { content: ''; position: absolute; left: 50%; transform: translateX(-50%); }
.ring-icon::before {
  bottom: 2px; width: 15px; height: 14px; border: 3px solid #e7ad52; border-radius: 50%;
  box-shadow: 0 0 0 1px #5a2f4e, inset 0 0 0 1px #94583e;
}
.ring-icon::after {
  top: 2px; width: 12px; height: 10px;
  background: linear-gradient(135deg, #fff 24%, #d7eaff 24% 48%, #a7c0eb 48% 71%, #745980 71%);
  clip-path: polygon(25% 0, 75% 0, 100% 40%, 50% 100%, 0 40%);
}
.bag button[data-item='close'] {
  justify-content: center; padding-inline: 5px; color: var(--berry);
}
.sparkles { position: absolute; z-index: 6; left: 68%; top: 67%; width: 1px; height: 1px; pointer-events: none; }
.sparkles i {
  position: absolute; display: block; width: 15px; height: 15px; background: #fff099;
  filter: drop-shadow(1px 0 0 #5a2f4e) drop-shadow(-1px 0 0 #5a2f4e) drop-shadow(0 1px 0 #5a2f4e) drop-shadow(0 -1px 0 #5a2f4e);
  clip-path: polygon(43% 0, 57% 0, 57% 28%, 72% 28%, 72% 43%, 100% 43%, 100% 57%, 72% 57%,
    72% 72%, 57% 72%, 57% 100%, 43% 100%, 43% 72%, 28% 72%, 28% 57%, 0 57%, 0 43%, 28% 43%, 28% 28%, 43% 28%);
  animation: sparkle .7s ease-out both;
}
.sparkles i:nth-child(1) { --x: -44px; --y: -23px; }
.sparkles i:nth-child(2) { --x: 27px; --y: -40px; animation-delay: .08s; }
.sparkles i:nth-child(3) { --x: 40px; --y: 11px; animation-delay: .06s; }
.sparkles i:nth-child(4) { --x: -18px; --y: -52px; animation-delay: .12s; }
.sparkles i:nth-child(5) { --x: -32px; --y: 16px; animation-delay: .16s; }
@keyframes sparkle {
  from { transform: translate(-50%, -50%) scale(.2); opacity: 0; }
  23% { opacity: 1; }
  to { transform: translate(var(--x), var(--y)) scale(.85); opacity: 0; }
}

.reveal {
  min-height: 100vh; min-height: 100svh;
  padding: max(24px, env(safe-area-inset-top)) 19px max(28px, env(safe-area-inset-bottom));
  text-align: center;
  border: 4px solid #5a2f4e;
  background:
    radial-gradient(#ffffff99 1.5px, transparent 1.5px) 0 0 / 16px 16px,
    linear-gradient(180deg, #dec7ef 0%, #f5d8e8 42%, #fbeaf0 100%);
  box-shadow: inset 0 0 0 2px #f8c6db, inset 0 0 0 5px #fce3bc88;
}
.reveal.is-skipped { display: grid; align-content: center; }
.temp-note { margin: 0 0 12px; font-size: 11px; font-weight: 600; }
.reveal .temp-note { color: var(--berry); }
.dex { max-width: 365px; margin-inline: auto; padding: 20px 18px 24px; }
.dex-title {
  position: relative;
  isolation: isolate;
  width: min(77%, 232px);
  margin: 0 auto 15px;
  padding: 9px 16px;
  border: 3px solid #5a2f4e;
  background: #ffecdf;
  box-shadow: inset 0 0 0 3px #eb9ebd, 0 3px #5a2f4e30;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: .09em;
}
.dex-title::before, .dex-title::after {
  content: '';
  position: absolute;
  top: 5px;
  width: 25px;
  height: 32px;
  border: 2px solid #5a2f4e;
  background: #f8b1ce;
  z-index: -1;
}
.dex-title::before { left: -26px; transform: skewY(13deg); }
.dex-title::after { right: -26px; transform: skewY(-13deg); }
.dex-body { display: flex; justify-content: center; align-items: center; gap: 12px; margin-bottom: 15px; }
.portrait {
  width: 78px;
  height: 78px;
  flex: none;
  overflow: hidden;
  border: 2px solid #8d527a;
  background:
    radial-gradient(#fff9ee 1px, transparent 1.5px) 0 0 / 12px 12px,
    linear-gradient(#d7beee, #f3dbea);
  box-shadow: inset 0 0 0 2px #f4ca7c, inset 0 0 0 4px #fff2de;
}
.portrait img {
  display: block;
  margin: 5px auto 0;
  width: 95%;
  height: auto;
  filter: drop-shadow(0 3px 0 #6b3d6640);
}
.dex-identity { min-width: 0; text-align: left; }
.dex-identity h3 { margin-bottom: 4px; font-size: 16px; overflow-wrap: anywhere; }
.dex-identity .hearts { padding: 6px; border: 2px solid #8d527a; background: #fff9f0; }
.reveal .corner-rose { left: -3px; bottom: -3px; width: 34px; height: 28px; }
.reveal .dex > .ribbon { top: auto; bottom: -11px; }

.open-card {
  display: grid;
  justify-items: center;
  gap: 13px;
  margin-inline: auto;
  width: 100%;
  max-width: 316px;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
}
.card-slot {
  display: block;
  width: 100%;
  padding: 3px;
  border: 2px solid #8d527a;
  background: #fabbd5;
  box-shadow: 0 3px #5a2f4e25;
}
.cover-photo {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 320 / 387;
  object-fit: contain;
  background: #f5ede1;
}
.card-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 6px 14px;
  border: 2px solid #5a2f4e;
  background: #ffc5db;
  box-shadow: inset 0 0 0 3px #ffe8ec, 0 3px #5a2f4e45;
  font-size: 15px;
  font-weight: 900;
}
.open-card:hover .card-cta { background: #ffd7e6; }
.open-card:focus-visible { outline: none; }
.open-card:focus-visible .card-cta { outline: 3px dashed #863964; outline-offset: 3px; }
.card-envelope {
  width: 23px;
  height: 16px;
  border: 2px solid #783c65;
  background: var(--px-heart) center / 11px 10px no-repeat, #fff5eb;
  image-rendering: pixelated;
}

html.invitation-transition { overflow: hidden; }
.invitation-transition #invitation { pointer-events: none; }
.reveal.is-dissolving, .pixel-scatter { position: fixed; pointer-events: none; }
.reveal.is-dissolving { z-index: 10; }
.pixel-scatter { z-index: 11; }
.is-dissolving .card-slot { visibility: hidden; }
.scatter-pixel {
  position: absolute;
  width: var(--size);
  height: var(--size);
  background: var(--color);
  animation: scatter-pixel 280ms var(--delay) ease-out both;
}
@keyframes scatter-pixel {
  0% { opacity: 0; }
  12% { opacity: .9; }
  100% { transform: translate(var(--dx), var(--dy)); opacity: 0; }
}

body.is-invitation { background: #f1eae2; }
.invitation, .lightbox, .manual-copy {
  --paper-bg: #fffaf5;
  --paper-text: #413936;
  --paper-accent: #995855;
  --paper-line: #e5d6ce;
  --paper-tint: #fbf1ec;
  --paper-serif: 'Noto Serif KR', 'Nanum Myeongjo', Batang, 'Times New Roman', serif;
  background: var(--paper-bg);
  color: var(--paper-text);
  font-family: system-ui, 'Malgun Gothic', sans-serif;
}
.invitation {
  min-height: 100vh; min-height: 100svh;
  padding: max(22px, env(safe-area-inset-top)) clamp(22px, 7vw, 35px) max(25px, env(safe-area-inset-bottom));
  text-align: center;
}
.invitation h1, .invitation h2 { font-family: var(--paper-serif); }
.invite-hero { max-width: 355px; margin-inline: auto; padding-bottom: 27px; }
.invite-hero .temp-note { margin-bottom: 0; color: var(--paper-accent); }
.invite-hero h1 {
  max-width: 270px;
  margin: 18px auto 0;
  color: var(--paper-accent);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(33px, 10vw, 47px);
  font-style: italic;
  font-weight: 400;
  line-height: 1.02;
  text-wrap: balance;
}
.invite-hero h1:focus { outline: none; }
.invite-couple {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  margin: 14px 0 23px;
  font-family: var(--paper-serif);
  font-size: 17px;
}
.invite-couple::before, .invite-couple::after { content: ''; width: 32px; height: 1px; background: var(--paper-line); }
.hero-photo { display: block; width: min(100%, 320px); height: auto; margin-inline: auto; }
.hero-ceremony { padding-top: 15px; margin-top: 22px; border-top: 1px solid var(--paper-line); font-size: 14px; line-height: 1.85; }
.hero-ceremony time { font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.hero-ceremony p { font-weight: 650; }
.detail-panel, .invite-footer { padding: 31px 0; border-top: 1px solid var(--paper-line); overflow-wrap: anywhere; }
.detail-panel h2, .invite-footer h2 { margin-bottom: 13px; color: var(--paper-accent); font-size: 23px; font-weight: 500; }
.detail-panel p { font-size: 14px; line-height: 1.8; }
.detail-panel .greeting { white-space: pre-line; word-break: keep-all; }
.families { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0 0; }
.families dt { font-size: 13px; color: var(--paper-accent); font-weight: 650; }
.families dd { margin: 6px 0 0; font-size: 13px; }
.detail-panel .dday { margin-top: 10px; color: var(--paper-accent); font-size: 13px; font-weight: 650; }
.calendar { width: 100%; max-width: 303px; border-collapse: collapse; margin: 14px auto 0; table-layout: fixed; font-size: 13px; }
.calendar caption { padding: 0 0 11px; font-weight: 650; }
.calendar th { padding-bottom: 7px; border-bottom: 1px solid var(--paper-line); color: var(--paper-accent); }
.calendar td { height: 35px; }
.calendar .marked span {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--paper-accent);
  color: white;
  font-weight: 650;
}
.calendar .marked span::after { content: '♥'; position: absolute; top: -6px; right: -3px; color: var(--paper-accent); font-size: 10px; }
.gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.gallery button { display: block; border: 0; background: var(--paper-tint); width: 100%; aspect-ratio: 4 / 3; padding: 0; overflow: hidden; }
.gallery img { width: 100%; height: 100%; display: block; object-fit: cover; }
.venue-address { text-align: left; padding: 12px 15px; background: var(--paper-tint); }
.venue { font-weight: 650; }
.travel-notes { margin: 17px 0 0; text-align: left; font-size: 13px; line-height: 1.65; }
.travel-notes dt { color: var(--paper-accent); font-weight: 650; }
.travel-notes dd { margin: 3px 0 10px; white-space: pre-line; }
.contact-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 10px; border-bottom: 1px solid var(--paper-line); font-size: 14px; }
.contact-actions { display: flex; gap: 7px; }
.button-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.button-row:not(:empty) { margin-top: 12px; }
.small-button {
  display: inline-grid;
  place-items: center;
  min-height: 44px;
  padding: 5px 13px;
  border: 1px solid var(--paper-line);
  border-radius: 4px;
  background: var(--paper-bg);
  color: var(--paper-accent);
  text-decoration: none;
  font-size: 13px;
  font-weight: 650;
}
.small-button:hover, .accounts summary:hover { background: var(--paper-tint); }
.accounts details { text-align: left; border-bottom: 1px solid var(--paper-line); }
.accounts details:first-child { border-top: 1px solid var(--paper-line); }
.accounts summary { cursor: pointer; padding: 13px 10px; color: var(--paper-accent); font-size: 14px; font-weight: 650; }
.account { padding: 8px 10px; border-top: 1px solid var(--paper-line); display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; justify-content: space-between; }
.account p { font-size: 13px; }
.invite-footer { padding-bottom: 8px; }
.replay-link { min-height: 44px; margin-top: 18px; border: 0; background: none; color: var(--paper-accent); font-size: 13px; text-decoration: underline; text-underline-offset: 4px; }

.lightbox, .manual-copy { position: fixed; border: 1px solid var(--paper-line); border-radius: 5px; padding: 14px; width: min(91vw, 406px); text-align: center; }
dialog::backdrop { background: #302323cc; }
.dialog-backdrop { position: fixed; inset: 0; z-index: 12; background: #302323cc; touch-action: none; }
dialog.is-fallback[open] {
  --dialog-edge: max(14px, env(safe-area-inset-top, 0px), env(safe-area-inset-bottom, 0px));
  z-index: 13; inset: 50% auto auto 50%; margin: 0; transform: translate(-50%, -50%);
  max-height: calc(100vh - var(--dialog-edge) - var(--dialog-edge));
  max-height: calc(100svh - var(--dialog-edge) - var(--dialog-edge));
  overflow: auto; overscroll-behavior: contain;
}
.lightbox-close { text-align: right; margin-bottom: 9px; }
.lightbox img { display: block; width: 100%; max-height: 62vh; max-height: 62svh; object-fit: contain; touch-action: pan-y; touch-action: pan-y pinch-zoom; background: var(--paper-tint); }
.photo-controls { display: flex; align-items: center; justify-content: center; gap: 13px; margin-top: 10px; }
.photo-controls output { min-width: 46px; font: 650 13px ui-monospace, monospace; }
.manual-copy p { font-size: 14px; }
.manual-copy input { width: 100%; margin: 10px 0; padding: 8px; border: 1px solid var(--paper-line); background: var(--paper-bg); font-size: 16px; }
.toast:not(:empty) {
  position: fixed; z-index: 9; left: 50%; bottom: max(14px, env(safe-area-inset-bottom));
  transform: translateX(-50%); width: max-content; max-width: 90vw; padding: 9px 13px;
  border: 1px solid #ddcbc2; border-radius: 4px; background: #fffaf5; color: #413936;
  text-align: center; font-size: 13px; font-weight: 650; pointer-events: none;
}

@media (min-width: 461px) {
  .app { padding-block: 12px; }
  .battle { height: clamp(510px, calc(100vh - 24px), 820px); height: clamp(510px, calc(100svh - 24px), 820px); }
  .reveal { min-height: calc(100vh - 24px); min-height: calc(100svh - 24px); }
}
@media (max-width: 340px) {
  .badge { padding-inline: 10px; }
  .badge .heart { width: 14px; height: 13px; }
}
@media (max-height: 650px) {
  .reveal { padding-block: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-bottom)); }
  .dex { padding-block: 14px 18px; }
  .dex-title { margin-bottom: 10px; padding-block: 5px; font-size: 22px; }
  .dex-body { margin-bottom: 10px; }
  .portrait { width: 58px; height: 58px; }
  .open-card { max-width: min(100%, 43vh); max-width: min(100%, 43svh); gap: 9px; }
}

/* 세로 고정: 휴대폰을 가로로 돌리면 안내 화면으로 덮는다 */
.card-cta { white-space: nowrap; }
.rotate-notice { display: none; }
@media (orientation: landscape) and (max-height: 500px) and (hover: none) {
  .rotate-notice {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
    padding: 24px; text-align: center;
    background: radial-gradient(#d4a7c023 1px, transparent 1px) 0 0 / 12px 12px, #f9edf4;
    color: #5a2f4e; font-weight: 800; font-size: 16px; line-height: 1.5;
  }
  .rotate-notice .rotate-phone {
    width: 34px; height: 56px; border: 4px solid #5a2f4e; border-radius: 7px; background: #fffaf0;
    animation: rotate-hint 1.8s ease-in-out infinite;
  }
  html, body { overflow: hidden; }
}
@keyframes rotate-hint { 0%, 30% { transform: rotate(-90deg); } 60%, 100% { transform: rotate(0deg); } }
