:root {
  --pink: #FFD1DC;
  --lavender: #E6E6FA;
  --white: #FFFFFF;
  --blush: #FFF0F5;
  --mauve: #8B5A7C;
  --plum: #6D4C68;
  --bubblegum: #FF99B8;
  --cyan: #B2EBF2;
  --cream: #FFF9C4;
  --strawberry: #FF6B8B;
  --pixel: "Press Start 2P", monospace;
  --vt: "VT323", monospace;
  --silk: "Silkscreen", monospace;

  --r-common: #b9c0d0;
  --r-rare: #b48ae0;
  --r-secret: #f0a838;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--vt);
  color: var(--plum);
  overflow-x: hidden;
}
.hidden { display: none !important; }

/* ---------- background ---------- */
.bg {
  position: fixed; inset: 0; z-index: -2;
  background: linear-gradient(160deg, #FFD1DC 0%, #F6C6E4 38%, #E6E6FA 100%);
}
.bokeh { position: fixed; border-radius: 50%; filter: blur(70px); opacity: 0.55; z-index: -1; pointer-events: none; }
.sparkle {
  position: fixed; z-index: -1; color: #fff; pointer-events: none;
  text-shadow: 0 0 6px rgba(255,255,255,0.9);
  animation: twinkle 3s ease-in-out infinite;
}
@keyframes twinkle { 0%,100% { opacity: 0.3; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1.2); } }

/* ---------- desktop grid ---------- */
.desktop {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  grid-template-areas:
    "title title"
    "box box"
    "collection collection"
    "history leaderboard";
  gap: 14px;
  max-width: 900px;
  margin: 0 auto;
  padding: 22px;
}
#win-title      { grid-area: title; }
#win-box        { grid-area: box; }
#win-collection { grid-area: collection; }
#win-history    { grid-area: history; }
#win-leaderboard { grid-area: leaderboard; }

/* ---------- windows ---------- */
.window {
  background: var(--white);
  border: 2px solid var(--plum);
  box-shadow: 4px 4px 0 rgba(109,76,104,0.35);
  display: flex; flex-direction: column;
}
.titlebar {
  display: flex; align-items: center; gap: 8px;
  background: linear-gradient(180deg, var(--bubblegum), var(--pink));
  border-bottom: 2px solid var(--plum);
  padding: 5px 8px;
  font-family: var(--silk); font-size: 11px; color: #5a3a4a;
  user-select: none;
}
.traffic { display: flex; gap: 4px; }
.traffic i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; border: 1px solid rgba(109,76,104,0.6); }
.traffic i:nth-child(1) { background: #ff8a8a; }
.traffic i:nth-child(2) { background: var(--cream); }
.traffic i:nth-child(3) { background: #9ce6a8; }
.title-text { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.win-btns { font-family: var(--pixel); font-size: 8px; color: #5a3a4a; letter-spacing: 1px; }
.win-body { padding: 14px; background: var(--blush); flex: 1; }

/* ---------- title ---------- */
.title-body { text-align: center; padding: 22px 14px; }
.title-body h1 {
  font-family: var(--pixel); font-size: clamp(1rem, 4vw, 1.4rem);
  color: #d6336c; text-shadow: 2px 2px 0 #fff; line-height: 1.7;
}
.title-body .tagline { margin-top: 10px; font-size: 18px; color: #9a7a90; }
.back-links {
  display: inline-block;
  font-family: var(--silk); font-size: 11px; color: var(--plum);
  background: #fff; border: 2px solid var(--plum); padding: 5px 12px;
  text-decoration: none; box-shadow: 2px 2px 0 rgba(109,76,104,0.35);
}
.back-links:active { box-shadow: 1px 1px 0 rgba(109,76,104,0.35); transform: translate(1px,1px); }
.back-links-row { max-width: 900px; margin: 0 auto; padding: 12px 22px; text-align: center; }
.back-top { text-align: left; }

/* ---------- blind box ---------- */
.box-body { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; min-height: 240px; }
.box-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  width: 100%;
}
.box-col {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  min-width: 0;
}
.box-col-left { border-right: 2px dashed rgba(109,76,104,0.35); padding-right: 8px; }
.box-col-right { padding-left: 8px; }
.box-wrap { position: relative; }
.giftbox {
  position: relative;
  width: 96px; height: 88px;
  filter: drop-shadow(4px 6px 0 rgba(109,76,104,0.35));
  animation: bob 3s ease-in-out infinite;
}
.giftbox-lid {
  position: absolute; top: 7px; left: 0; right: 0; height: 23px;
  background: linear-gradient(180deg, #ffb3cc, #ff99b8);
  border: 3px solid var(--plum);
  border-radius: 8px;
  z-index: 2;
}
.giftbox-body {
  position: absolute; top: 23px; left: 7px; right: 7px; bottom: 0;
  background: linear-gradient(180deg, #ffc2d6, #ff8fb3);
  border: 3px solid var(--plum);
  border-radius: 8px;
}
.giftbox-body::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%;
  transform: translateX(-50%); width: 19px;
  background: var(--lavender);
  border-left: 2px solid var(--plum); border-right: 2px solid var(--plum);
}
.giftbox-bow {
  position: absolute; top: -3px; left: 50%; transform: translateX(-50%);
  width: 12px; height: 12px; background: var(--strawberry);
  border: 2px solid var(--plum); border-radius: 50%; z-index: 3;
}
.giftbox-bow::before, .giftbox-bow::after {
  content: ""; position: absolute; top: 0;
  width: 21px; height: 16px;
  background: linear-gradient(180deg, var(--pink), var(--bubblegum));
  border: 2px solid var(--plum); border-radius: 50%;
}
.giftbox-bow::before { right: 6px; transform: rotate(26deg); }
.giftbox-bow::after { left: 6px; transform: rotate(-26deg); }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.box-wrap.shaking .giftbox { animation: shake 0.5s linear infinite; }
@keyframes shake {
  0%,100% { transform: translate(0,0) rotate(0); }
  25% { transform: translate(-6px,2px) rotate(-6deg); }
  50% { transform: translate(6px,-2px) rotate(6deg); }
  75% { transform: translate(-4px,-1px) rotate(-4deg); }
}
.bevel-btn.open-btn {
  max-width: 240px; margin-top: 0;
  background: linear-gradient(180deg, var(--bubblegum), var(--strawberry));
  border: 2px solid var(--plum);
  color: #fff;
  font-size: 13px;
  text-shadow: 1px 1px 0 var(--plum);
}
.bevel-btn.open-btn:active {
  background: linear-gradient(180deg, var(--strawberry), #e0557a);
  border-color: var(--plum);
}
.bevel-btn.how-btn {
  max-width: 240px; margin-top: 0;
  background: #fff;
  border: 2px dashed var(--mauve);
  color: var(--plum);
  font-size: 11px;
}
.bevel-btn.how-btn:active {
  background: var(--blush);
  border-color: var(--plum);
}
.warn {
  margin-top: 10px; padding: 8px 12px;
  font-family: var(--vt); font-size: 15px; color: #fff; text-align: center;
  background: var(--strawberry); border: 2px solid var(--plum);
  box-shadow: 2px 2px 0 rgba(109,76,104,0.35);
}

/* ---------- box controls ---------- */
.user-line { font-family: var(--silk); font-size: 11px; color: #9a7a90; text-align: center; }
.user-line #user-name { color: var(--plum); }
.switch-btn {
  display: block; margin: 3px auto 0; font-family: var(--silk); font-size: 10px;
  background: none; border: none; color: var(--strawberry); cursor: pointer;
  text-decoration: underline; padding: 0;
}
.keys-line { font-family: var(--pixel); font-size: 15px; text-align: center; color: var(--plum); }
.balance-line { font-family: var(--vt); font-size: 22px; color: var(--plum); text-align: center; }
.max-keys-line { font-family: var(--silk); font-size: 10px; color: #9a7a90; text-align: center; }
.bevel-btn.exchange-btn {
  max-width: 240px; margin-top: 0;
  background: var(--cream);
  border: 2px solid var(--plum);
  color: var(--plum);
}
.bevel-btn.exchange-btn:disabled {
  background: var(--blush); color: #c3aebd; border-color: #d8c6d3; cursor: not-allowed;
}
.exchange-row {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--silk); font-size: 11px; color: var(--plum);
}
.exchange-input {
  width: 56px; padding: 5px 6px;
  font-family: var(--vt); font-size: 18px; color: var(--plum);
  border: 2px solid var(--plum); background: #fff; text-align: center;
  -moz-appearance: textfield;
}
.exchange-input::-webkit-outer-spin-button,
.exchange-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.exchange-unit { color: #9a7a90; }
.exchange-equals { color: var(--plum); }
#exchange-amount.over { color: var(--strawberry); }
.dev-btns { display: flex; gap: 8px; }
.dev-btns .bevel-btn { margin-top: 0; }
.dev-note { font-family: var(--silk); font-size: 10px; color: #9a7a90; text-align: center; }

/* ---------- collection (bigger) ---------- */
.coll-count { font-family: var(--silk); font-size: 16px; color: #9a7a90; margin-bottom: 10px; }
.coll-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.slot {
  border: 2px solid var(--plum); background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  text-align: center; padding: 16px 10px;
  box-shadow: 2px 2px 0 rgba(109,76,104,0.3);
}
.slot .s-emoji { font-size: 44px; line-height: 1; }
.slot .s-name { font-family: var(--silk); font-size: 16px; line-height: 1.1; }
.slot .s-rarity { font-family: var(--pixel); font-size: 10px; letter-spacing: 0; }
.slot.locked { background: var(--blush); }
.slot.locked .s-emoji { filter: grayscale(1); opacity: 0.4; }
.slot.common  { border-color: var(--r-common); }
.slot.rare    { border-color: var(--r-rare); }
.slot.secret  { border-color: var(--r-secret); box-shadow: 0 0 12px rgba(240,168,56,0.6); }
.slot .s-rarity.common  { color: var(--r-common); }
.slot .s-rarity.rare    { color: var(--r-rare); }
.slot .s-rarity.secret  { color: var(--r-secret); }
.slot .s-chance { font-family: var(--silk); font-size: 14px; color: #9a7a90; }
.s-img {
  width: 100%; max-width: 160px; aspect-ratio: 1 / 1;
  object-fit: cover; object-position: center;
  border: 2px solid var(--plum); cursor: zoom-in;
  background: var(--blush);
}

/* ---------- reveal modal ---------- */
.reveal {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(109,76,104,0.55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.reveal-box {
  width: 100%; max-width: 320px; text-align: center;
  background: var(--white); border: 3px solid var(--plum);
  box-shadow: 5px 5px 0 rgba(109,76,104,0.5); padding: 22px;
}
.reveal-rarity { font-family: var(--pixel); font-size: 11px; letter-spacing: 2px; }
.reveal-emoji { font-size: 72px; line-height: 1; margin-top: 10px; display: block; }
.reveal-name { font-family: var(--pixel); font-size: 13px; color: var(--plum); margin-top: 10px; }
.reveal-note { font-family: var(--vt); font-size: 18px; color: #9a7a90; margin-top: 8px; }
.reveal-close { margin-top: 16px; }
.reveal-badge {
  display: inline-block; margin: 10px auto 0;
  padding: 4px 14px;
  font-family: var(--pixel); font-size: 11px; letter-spacing: 2px;
  border: 2px solid var(--plum);
}
.reveal-badge.new {
  color: #fff; background: linear-gradient(180deg, #ffd166, #f0a838);
  animation: newPulse 1s ease-in-out infinite;
}
.reveal-badge.dupe {
  color: #9a7a90; background: var(--blush);
  border-color: #b9c0d0; transform: rotate(-6deg); opacity: 0.9;
}
@keyframes newPulse {
  0%,100% { box-shadow: 0 0 8px rgba(240,168,56,0.7); transform: scale(1) rotate(-2deg); }
  50% { box-shadow: 0 0 22px rgba(240,168,56,1); transform: scale(1.1) rotate(2deg); }
}
.reveal-box.new { animation: revealPop 0.45s cubic-bezier(.2,1.4,.4,1); }
@keyframes revealPop { 0% { transform: scale(0.7); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.reveal-box.dupe .reveal-emoji { filter: grayscale(1); opacity: 0.5; }
.confetti {
  position: absolute; top: -20px;
  border-radius: 2px; pointer-events: none; z-index: 201;
  animation-name: confettiFall; animation-timing-function: ease-in;
  animation-fill-mode: forwards; opacity: 0;
}
@keyframes confettiFall {
  0% { opacity: 1; transform: translateY(0) rotate(0deg); }
  100% { opacity: 0; transform: translateY(72vh) rotate(720deg); }
}
.reveal-box.common  { border-color: var(--r-common); }
.reveal-box.rare    { border-color: var(--r-rare); }
.reveal-box.secret  { border-color: var(--r-secret); box-shadow: 0 0 22px rgba(240,168,56,0.7); }
.reveal-box .reveal-rarity.common  { color: var(--r-common); }
.reveal-box .reveal-rarity.rare    { color: var(--r-rare); }
.reveal-box .reveal-rarity.secret  { color: var(--r-secret); }

/* gate */
.gate-text { font-family: var(--vt); font-size: 18px; color: #9a7a90; margin-top: 12px; }
.gate-input {
  width: 100%; margin-top: 14px; padding: 8px 10px;
  font-family: var(--vt); font-size: 20px; color: var(--plum);
  border: 2px solid var(--plum); background: #fff; text-align: center;
}
.gate-note { font-family: var(--silk); font-size: 10px; color: #9a7a90; margin-top: 12px; }

/* account */
.account-box { position: relative; }
.acct-close {
  position: absolute; top: 6px; right: 8px;
  width: 22px; height: 22px;
  font-family: var(--silk); font-size: 14px; line-height: 1;
  background: #fff; border: 2px solid var(--plum);
  color: var(--plum); cursor: pointer; padding: 0;
}
.acct-close:hover { background: var(--strawberry); color: #fff; }
.notice-box { position: relative; }
.notice-emoji { font-size: 48px; line-height: 1; margin-top: 6px; display: block; }
.notice-title { font-family: var(--pixel); font-size: 12px; color: var(--plum); margin-top: 10px; }
.notice-body { font-family: var(--vt); font-size: 18px; color: #9a7a90; margin-top: 8px; line-height: 1.4; }
.notice-btn { max-width: 200px; margin-left: auto; margin-right: auto; }
.lightbox-box {
  max-width: 480px; text-align: center; position: relative;
  background: var(--white); border: 3px solid var(--plum);
  box-shadow: 5px 5px 0 rgba(109,76,104,0.5); padding: 12px;
}
.lightbox-box img {
  max-width: 100%; max-height: 70vh; display: block; margin: 0 auto;
  border: 2px solid var(--plum);
}
.lightbox-name { font-family: var(--pixel); font-size: 11px; color: var(--plum); margin-top: 10px; }
.acct-screen { text-align: center; }
.acct-screen .gate-input + .gate-input { margin-top: 8px; }
.acct-screen .bevel-btn { margin-top: 14px; }
.back-btn {
  display: block; margin: 10px auto 0; font-family: var(--silk); font-size: 10px;
  background: none; border: none; color: #9a7a90; cursor: pointer;
  text-decoration: underline; padding: 0;
}
.code-box {
  margin: 14px auto 0; padding: 10px; max-width: 220px;
  font-family: var(--pixel); font-size: 14px; color: var(--plum);
  background: var(--blush); border: 2px dashed var(--plum); letter-spacing: 2px;
}
.how-box {
  margin: 14px auto 0; padding: 10px 14px;
  border: 2px dashed var(--plum); background: #fff;
  text-align: left; max-width: 240px;
}
.how-title { font-family: var(--silk); font-size: 10px; color: var(--strawberry); margin-bottom: 6px; text-align: center; }
.how-step { font-family: var(--vt); font-size: 15px; color: var(--plum); line-height: 1.5; }

/* history */
.history-summary {
  display: flex; gap: 14px; justify-content: center;
  padding: 6px 8px; margin-bottom: 8px;
  border: 2px solid var(--plum); background: #fff;
  font-family: var(--silk); font-size: 12px; color: var(--plum);
}
.history-summary .hs-item { white-space: nowrap; }
.history-list { max-height: 220px; overflow-y: auto; }
.h-entry {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; margin-bottom: 6px;
  border: 2px solid var(--plum); background: #fff; font-family: var(--vt); font-size: 16px;
}
.h-entry:last-child { margin-bottom: 0; }
.h-entry .h-emoji { font-size: 20px; }
.h-entry .h-name { flex: 1; }
.h-entry .h-rarity { font-family: var(--pixel); font-size: 8px; }
.h-entry .h-rarity.common { color: var(--r-common); }
.h-entry .h-rarity.rare { color: var(--r-rare); }
.h-entry .h-rarity.secret { color: var(--r-secret); }
.h-entry .h-ts { font-family: var(--silk); font-size: 9px; color: #9a7a90; }
.h-empty { font-family: var(--vt); font-size: 16px; color: #9a7a90; text-align: center; padding: 16px 0; }

/* leaderboard */
.lb-list { list-style: none; max-height: 320px; overflow-y: auto; }
.lb-row {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; margin-bottom: 6px;
  border: 2px solid var(--plum); background: #fff; font-family: var(--vt); font-size: 17px;
}
.lb-row:last-child { margin-bottom: 0; }
.lb-row .rank { font-family: var(--pixel); font-size: 10px; color: var(--strawberry); width: 22px; flex-shrink: 0; }
.lb-row .lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row .lb-pulls { font-family: var(--silk); font-size: 10px; color: var(--strawberry); flex-shrink: 0; }
.lb-row .lb-cards { font-family: var(--silk); font-size: 10px; color: #9a7a90; flex-shrink: 0; }
.lb-row .lb-spend { font-family: var(--pixel); font-size: 9px; color: var(--plum); flex-shrink: 0; }
.lb-row.me { border-color: var(--strawberry); }
.hide-toggle { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-family: var(--silk); font-size: 10px; color: #9a7a90; }
.hide-toggle input { accent-color: var(--strawberry); }

/* ---------- bevel button ---------- */
.bevel-btn {
  display: block; width: 100%; margin-top: 10px;
  padding: 8px; font-family: var(--silk); font-size: 12px;
  background: #fff; border: 2px solid; border-color: #fff var(--plum) var(--plum) #fff;
  color: var(--plum); cursor: pointer; text-align: center;
}
.bevel-btn:active { border-color: var(--plum) #fff #fff var(--plum); }

.disclaimer {
  max-width: 900px; margin: 0 auto; padding: 0 22px 24px;
  font-family: var(--silk); font-size: 10px; color: #9a7a90; text-align: center; line-height: 1.7;
}

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .desktop {
    grid-template-columns: 1fr;
    grid-template-areas:
      "title"
      "box"
      "collection"
      "history"
      "leaderboard";
    padding: 12px;
  }
  .coll-grid { grid-template-columns: repeat(2, 1fr); }
  .box-columns { grid-template-columns: 1fr; gap: 14px; }
  .box-col-left { border-right: none; border-bottom: 2px dashed rgba(109,76,104,0.35); padding-right: 0; padding-bottom: 14px; }
  .box-col-right { padding-left: 0; }
  .sparkle { display: none; }
}
