:root {
  --wine: #7b2038;
  --wine-deep: #501326;
  --gold: #bd8b41;
  --gold-light: #e5c98e;
  --ink: #3b2528;
  --muted: #80696b;
  --shadow: 0 22px 60px rgba(67, 19, 32, 0.16);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

html, body { width: 100%; height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
  background:
    radial-gradient(circle at 50% -10%, rgba(255,255,255,.92), transparent 36%),
    linear-gradient(145deg, #f7eee5 0%, #fffaf1 48%, #f2e1dc 100%);
}

button { font: inherit; }
button:focus-visible { outline: 3px solid rgba(189,139,65,.42); outline-offset: 3px; }

.paper-texture {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .18;
  z-index: -2;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='.7' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.17'/%3E%3C/svg%3E");
}

.peony {
  position: fixed;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  z-index: -1;
  opacity: .16;
  filter: blur(1px);
  background: repeating-radial-gradient(ellipse at 48% 50%, transparent 0 22px, #a9445d 24px 34px, transparent 36px 51px);
}
.peony::before, .peony::after {
  content: "";
  position: absolute;
  inset: 15%;
  border: 2px solid #a9445d;
  border-radius: 45% 55% 50% 50%;
  transform: rotate(35deg);
}
.peony::after { inset: 24%; transform: rotate(-25deg); }
.peony-left { left: -230px; top: 18%; }
.peony-right { right: -235px; bottom: -100px; transform: rotate(130deg); }

.app-shell {
  width: 100%;
  height: 100%;
  padding: clamp(10px, 1.5vw, 24px);
}

.access-gate {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 22px;
  background: radial-gradient(circle at 50% 12%, rgba(255,255,255,.85), transparent 35%), linear-gradient(145deg, rgba(247,238,229,.96), rgba(255,250,241,.97) 48%, rgba(242,225,220,.97));
}
.access-card {
  position: relative;
  width: min(510px, 100%);
  padding: 56px 58px 39px;
  overflow: hidden;
  border: 1px solid rgba(189,139,65,.55);
  border-radius: 28px;
  background: rgba(255,252,245,.86);
  box-shadow: 0 28px 75px rgba(67,19,32,.18), inset 0 0 0 8px rgba(255,255,255,.5), inset 0 0 0 9px rgba(189,139,65,.17);
  text-align: center;
  animation: modal-in .5s both cubic-bezier(.18,.9,.24,1.1);
}
.access-card::before, .access-card::after { content: "❀"; position: absolute; color: rgba(123,32,56,.07); font-size: 125px; pointer-events: none; }
.access-card::before { left: -40px; top: -44px; }
.access-card::after { right: -40px; bottom: -51px; transform: rotate(45deg); }
.access-seal { position: relative; z-index: 1; width: 88px; height: 88px; display: grid; place-items: center; margin: 0 auto 25px; border-radius: 50%; color: #f5d9a2; background: var(--wine); box-shadow: 0 9px 25px rgba(92,21,42,.24), 0 0 0 6px #f8eddb, 0 0 0 7px #c79b54; font: 54px "STKaiti", serif; }
.access-kicker { position: relative; z-index: 1; margin: 0 0 9px; color: var(--gold); font: 700 11px Georgia, serif; letter-spacing: .22em; }
.access-card h1 { position: relative; z-index: 1; margin: 0; color: var(--wine-deep); font: 700 39px "STKaiti", "KaiTi", serif; letter-spacing: .15em; }
.access-copy { position: relative; z-index: 1; margin: 9px 0 24px; color: var(--muted); font: 16px "STKaiti", "KaiTi", serif; letter-spacing: .1em; }
.password-field { position: relative; z-index: 1; display: block; }
.password-field input { width: 100%; height: 64px; padding: 7px 20px 12px; border: 1px solid #dcc5ba; border-radius: 14px; outline: 0; color: var(--wine-deep); background: rgba(255,255,255,.76); box-shadow: inset 0 2px 6px rgba(83,47,42,.05); font: 700 31px Georgia, serif; letter-spacing: .55em; text-align: center; transition: border-color .2s, box-shadow .2s, transform .2s; }
.password-field input::placeholder { color: #c6aaa5; opacity: .75; }
.password-field input:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(189,139,65,.13), inset 0 2px 6px rgba(83,47,42,.04); }
.password-field input.invalid { border-color: #b84b58; box-shadow: 0 0 0 4px rgba(184,75,88,.1); animation: shake .34s ease; }
.access-error { position: relative; z-index: 1; min-height: 20px; margin: 7px 0 4px; color: #a43449; font-size: 12px; }
.access-button { position: relative; z-index: 1; width: 100%; padding: 15px 24px; border: 0; border-radius: 100px; color: #fff8eb; background: linear-gradient(135deg, #8f2943, #65172d); box-shadow: 0 9px 23px rgba(100,23,45,.22); cursor: pointer; font-size: 16px; letter-spacing: .16em; transition: transform .2s, box-shadow .2s; }
.access-button:hover { transform: translateY(-2px); box-shadow: 0 13px 27px rgba(100,23,45,.28); }
.access-ornament { position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 23px; color: var(--gold); }
.access-ornament span { width: 48px; height: 1px; background: linear-gradient(90deg, transparent, var(--gold-light)); }
.access-ornament span:last-child { transform: rotate(180deg); }
.access-ornament b { font: 12px "STKaiti", serif; letter-spacing: .2em; }

.section-kicker {
  margin: 0 0 7px;
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 11px;
  letter-spacing: .28em;
  font-weight: 700;
}

.stage {
  position: relative;
  width: 100%;
  height: 100%;
  padding: clamp(12px, 1.35vw, 22px);
  border: 1px solid rgba(142,80,75,.17);
  border-radius: 26px;
  background: rgba(255,252,245,.72);
  box-shadow: var(--shadow), inset 0 1px rgba(255,255,255,.9);
  backdrop-filter: blur(14px);
}
.stage::before, .stage::after {
  content: "";
  position: absolute;
  width: 55px; height: 55px;
  pointer-events: none;
  border-color: var(--gold-light);
  opacity: .68;
}
.stage::before { left: 12px; top: 12px; border-left: 1px solid; border-top: 1px solid; border-radius: 14px 0 0; }
.stage::after { right: 12px; bottom: 12px; border-right: 1px solid; border-bottom: 1px solid; border-radius: 0 0 14px; }

.panel-header h2 { margin: 0; color: var(--wine-deep); font-family: "STKaiti", "KaiTi", serif; font-size: 23px; letter-spacing: .08em; }
kbd { min-width: 25px; padding: 4px 7px; border: 1px solid #d6c2ba; border-bottom-width: 2px; border-radius: 6px; background: #fffaf3; color: var(--wine); font: 700 11px Georgia, serif; text-align: center; box-shadow: 0 2px 3px rgba(83,47,42,.08); }

.gift-grid {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: clamp(8px, 1vw, 15px);
  perspective: 1200px;
}

.gift-tile {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  container-type: inline-size;
  padding: 16px 14px;
  overflow: hidden;
  border: 1px solid rgba(152,91,78,.2);
  border-radius: 15px;
  color: var(--wine-deep);
  background:
    linear-gradient(130deg, rgba(255,255,255,.75), rgba(248,232,219,.64)),
    #f9eee4;
  box-shadow: 0 7px 18px rgba(89,36,46,.07), inset 0 0 0 1px rgba(255,255,255,.55);
  cursor: pointer;
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease, opacity .25s ease;
  animation: tile-arrive .48s both cubic-bezier(.2,.8,.2,1);
  animation-delay: calc(var(--index) * 24ms);
}
.gift-tile::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(187,139,66,.17);
  border-radius: 10px;
  pointer-events: none;
}
.gift-tile::after {
  content: "囍";
  position: absolute;
  right: -10px;
  bottom: -23px;
  color: rgba(132,47,62,.055);
  font-family: "STKaiti", serif;
  font-size: 79px;
  transform: rotate(-7deg);
}
.gift-tile:hover:not(.picked) { transform: translateY(-5px) rotateX(2deg); border-color: rgba(151,76,67,.43); box-shadow: 0 15px 29px rgba(89,36,46,.14), inset 0 0 0 1px rgba(255,255,255,.65); }
.gift-tile:active:not(.picked) { transform: translateY(-1px) scale(.985); }
.gift-tile-number { position: absolute; left: 15px; top: 12px; color: rgba(126,83,80,.46); font: italic 14px Georgia, serif; }
.gift-tile-keyword { position: relative; z-index: 1; display: block; max-width: 100%; font-family: "STKaiti", "KaiTi", serif; font-size: clamp(14px, min(16cqw, 7vh), 68px); font-weight: 700; letter-spacing: .06em; line-height: 1.1; white-space: nowrap; }
.gift-tile-english { position: relative; z-index: 1; display: block; margin-top: clamp(5px, 1.2vh, 13px); color: var(--gold); font: 700 clamp(8px, min(4.8cqw, 2.2vh), 20px) Georgia, serif; letter-spacing: .14em; white-space: nowrap; opacity: .92; }

.gift-tile.picked {
  color: #f7e2b6;
  border-color: #d0aa64;
  background:
    radial-gradient(circle at 50% 45%, rgba(180,75,94,.55), transparent 48%),
    linear-gradient(145deg, #8e2d47, #5c152b);
  box-shadow: inset 0 0 0 1px rgba(255,238,197,.22), inset 0 0 42px rgba(60,8,25,.2), 0 8px 19px rgba(89,36,46,.15);
  cursor: default;
  opacity: 1;
}
.gift-tile.picked::before { border-color: rgba(234,202,136,.68); }
.gift-tile.picked::after {
  content: "囍";
  left: 50%;
  right: auto;
  bottom: 50%;
  padding: 0;
  border: 0;
  color: rgba(244,212,147,.1);
  background: transparent;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: clamp(88px, 10vw, 170px);
  line-height: 1;
  white-space: nowrap;
  transform: translate(-50%, 50%) rotate(-5deg);
}
.gift-tile.picked .gift-tile-number { color: rgba(247,226,182,.65); }
.gift-tile.picked .gift-tile-keyword { color: #ffedc6; text-shadow: 0 2px 9px rgba(35,4,14,.28); }
.gift-tile.picked .gift-tile-english { color: #e5c27d; opacity: .94; }

.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 22px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(54,17,28,.58); backdrop-filter: blur(8px); animation: fade-in .2s both; }
.reveal-card, .panel-card, .confirm-card { position: relative; z-index: 1; animation: modal-in .42s both cubic-bezier(.18,.9,.24,1.1); }
.reveal-card {
  width: min(660px, 100%);
  overflow: hidden;
  padding: 68px 72px 58px;
  border: 1px solid #e4c37f;
  border-radius: 26px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 0, rgba(231,199,133,.22), transparent 42%),
    linear-gradient(145deg, #fffdf7, #f8eadc);
  box-shadow: 0 35px 90px rgba(40,8,20,.35), inset 0 0 0 8px #fffaf0, inset 0 0 0 9px rgba(190,139,62,.32);
}
.reveal-card::before, .reveal-card::after { content: "❀"; position: absolute; color: rgba(129,29,52,.12); font-size: 120px; }
.reveal-card::before { left: -37px; top: -44px; }
.reveal-card::after { right: -36px; bottom: -51px; transform: rotate(45deg); }
.reveal-ribbon { position: relative; z-index: 1; width: 96px; height: 96px; display: grid; place-items: center; margin: 0 auto 29px; border-radius: 50%; color: #f5d9a2; background: var(--wine); box-shadow: 0 10px 27px rgba(92,21,42,.25), 0 0 0 7px #f8eddb, 0 0 0 8px #c79b54; font: 59px "STKaiti", serif; }
.reveal-kicker { position: relative; z-index: 1; margin: 0 0 15px; color: var(--gold); font: 12px Georgia, serif; letter-spacing: .22em; }
.reveal-card h2 { position: relative; z-index: 1; margin: 0; color: var(--wine); font: 700 clamp(48px, 4.4vw, 68px) "STKaiti", "KaiTi", serif; letter-spacing: .18em; line-height: 1.15; }
.ornament { display: flex; align-items: center; justify-content: center; gap: 11px; margin: 22px 0; color: var(--gold); }
.ornament span { width: 60px; height: 1px; background: linear-gradient(90deg, transparent, var(--gold-light)); }
.ornament span:last-child { transform: rotate(180deg); }
.ornament b { font-size: 10px; }
.reveal-label { margin: 0 0 9px; color: var(--muted); font-size: 15px; letter-spacing: .22em; }
.reveal-card h3 { position: relative; z-index: 1; min-height: 43px; margin: 0; color: var(--ink); font-size: clamp(29px, 2.5vw, 38px); font-weight: 600; letter-spacing: .06em; }
.reveal-number { margin: 14px 0 31px; color: #a68d8c; font: italic 13px Georgia, serif; letter-spacing: .12em; }
.primary-button { position: relative; z-index: 1; min-width: 225px; padding: 16px 34px; border: 0; border-radius: 100px; color: #fff8eb; background: linear-gradient(135deg, #8f2943, #65172d); box-shadow: 0 9px 23px rgba(100,23,45,.25); cursor: pointer; font-size: 16px; letter-spacing: .12em; transition: transform .2s, box-shadow .2s; }
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 13px 26px rgba(100,23,45,.31); }

.close-button { position: absolute; z-index: 3; right: 18px; top: 15px; width: 34px; height: 34px; border: 0; border-radius: 50%; color: #917a79; background: rgba(255,255,255,.48); font-size: 25px; line-height: 1; cursor: pointer; }
.close-button:hover { color: var(--wine); background: rgba(135,46,64,.08); }
.panel-card { width: min(680px, 100%); max-height: min(720px, 88vh); overflow: auto; padding: 30px; border: 1px solid rgba(218,181,112,.7); border-radius: 22px; background: #fdf8ef; box-shadow: 0 30px 80px rgba(40,8,20,.3); }
.panel-header { position: relative; display: flex; align-items: flex-start; justify-content: space-between; padding-bottom: 18px; border-bottom: 1px solid #eadbd2; }
.panel-header .close-button { position: static; }
.history-list { display: grid; gap: 9px; padding-top: 18px; }
.history-item { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 13px; padding: 13px 15px; border-radius: 12px; background: #f6eae1; }
.history-index { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: #f8e8cb; background: var(--wine); font: 13px Georgia, serif; }
.history-item strong { display: block; color: var(--wine-deep); font-family: "STKaiti", serif; font-size: 18px; }
.history-item small { color: var(--muted); }
.history-time { color: #aa9592; font: 10px Georgia, serif; }
.empty-state { padding: 48px 20px; color: var(--muted); text-align: center; }
.empty-state span { display: block; margin-bottom: 8px; color: var(--gold); font: 37px "STKaiti", serif; }

.settings-note { margin: 18px 0; padding: 11px 14px; border-radius: 9px; color: #816d6b; background: #f5e9df; font-size: 12px; }
.admin-shortcuts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-bottom: 18px; }
.admin-shortcuts > div { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 11px; border: 1px solid #eadbd2; border-radius: 11px; background: rgba(255,255,255,.58); }
.admin-shortcuts kbd { flex: 0 0 auto; }
.admin-shortcuts span { min-width: 0; }
.admin-shortcuts b, .admin-shortcuts small { display: block; }
.admin-shortcuts b { color: var(--ink); font-size: 11px; }
.admin-shortcuts small { margin-top: 3px; color: #9a8582; font-size: 9px; line-height: 1.35; }
.setting-actions { display: grid; gap: 10px; }
.secondary-button { display: grid; grid-template-columns: 37px 1fr; gap: 1px 10px; align-items: center; padding: 14px 16px; border: 1px solid #e2d1c8; border-radius: 12px; color: var(--ink); background: #fffaf3; text-align: left; cursor: pointer; transition: border .2s, transform .2s; }
.secondary-button:hover { transform: translateX(3px); border-color: #c59a75; }
.secondary-button > span { grid-row: 1 / 3; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: var(--wine); background: #f3e3db; font-size: 18px; }
.secondary-button b { font-size: 14px; }
.secondary-button small { color: #96817e; font-size: 11px; }
.secondary-button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.secondary-button.danger { color: #85263a; }

.confirm-card { width: min(410px, 100%); padding: 34px; border-radius: 20px; background: #fffaf3; box-shadow: 0 30px 80px rgba(40,8,20,.33); text-align: center; }
.confirm-icon { width: 45px; height: 45px; display: grid; place-items: center; margin: 0 auto 16px; border-radius: 50%; color: #8b2940; background: #f4dfdd; font: bold 22px Georgia, serif; }
.confirm-card h2 { margin: 0 0 9px; color: var(--wine-deep); font: 24px "STKaiti", serif; }
.confirm-card p { margin: 0 0 24px; color: var(--muted); font-size: 13px; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ghost-button, .danger-button { padding: 11px; border-radius: 9px; cursor: pointer; }
.ghost-button { border: 1px solid #dfcdc5; color: var(--ink); background: #fff; }
.danger-button { border: 1px solid #7f233b; color: #fff; background: var(--wine); }

.toast { position: fixed; z-index: 80; left: 50%; bottom: 28px; padding: 11px 21px; border-radius: 100px; color: #fff8ef; background: rgba(71,24,35,.92); box-shadow: 0 12px 30px rgba(40,8,20,.25); font-size: 12px; letter-spacing: .06em; opacity: 0; transform: translate(-50%, 20px); pointer-events: none; transition: .25s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

#confetti { position: fixed; inset: 0; z-index: 70; width: 100%; height: 100%; pointer-events: none; }

@keyframes tile-arrive { from { opacity: 0; transform: translateY(15px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(28px) scale(.94); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-7px); } 75% { transform: translateX(7px); } }

@media (max-width: 800px) {
  .app-shell { padding: 7px; }
  .stage { padding: 7px; border-radius: 15px; }
  .gift-grid { gap: 6px; }
  .gift-tile { padding: 8px 5px; border-radius: 10px; }
  .gift-tile::before { inset: 4px; border-radius: 7px; }
  .gift-tile-number { left: 8px; top: 6px; font-size: 9px; }
  .gift-tile.picked::after { font-size: clamp(54px, 18vw, 90px); }
  .reveal-card { padding: 47px 27px 38px; }
  .reveal-ribbon { width: 78px; height: 78px; margin-bottom: 23px; font-size: 48px; }
  .reveal-card h2 { font-size: 42px; }
  .reveal-card h3 { font-size: 25px; }
  .admin-shortcuts { grid-template-columns: 1fr; }
  .access-card { padding: 45px 25px 31px; border-radius: 22px; }
  .access-card h1 { font-size: 32px; }
  .access-copy { font-size: 14px; }
}

@media (max-height: 760px) and (min-width: 801px) {
  .app-shell { padding: 9px; }
  .stage { padding: 9px; }
  .gift-grid { gap: 8px; }
  .gift-tile { padding-top: 9px; padding-bottom: 9px; }
}

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