:root {
  color-scheme: dark;
  --panel: rgba(5, 12, 18, .88);
  --cyan: #00ffff;
  --teal: #008080;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  font-family: Arial, sans-serif;
  color: white;
  text-align: center;
  background: linear-gradient(rgba(7,12,16,.48), rgba(7,12,16,.62)), url('../images/backgrounds/pack_reveal_bg.png') center/cover fixed no-repeat;
}
.snow {
  position: fixed; inset: 0;
  background: url('../images/effects/snowfall.gif') center/cover no-repeat;
  opacity: .28; pointer-events: none; z-index: 0;
}
.reveal-shell {
  position: relative; z-index: 1;
  width: min(1100px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: clamp(26px, 5vh, 56px) 18px 88px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
#reveal-title {
  margin: 0 0 12px;
  font-size: clamp(34px, 5vw, 60px);
  line-height: 1.05;
  text-shadow: 0 0 16px rgba(255,255,255,.9);
  animation: title-drop-in .85s ease-out both;
}
@keyframes title-drop-in { from { transform: translateY(-45px); opacity: 0; } to { transform: none; opacity: 1; } }
.connection-status {
  margin: 0 0 18px; padding: 7px 12px; border-radius: 999px;
  background: rgba(0,0,0,.62); border: 1px solid #777; font-weight: 700; font-size: 14px;
}
.connection-status.ok { border-color: #00d48a; color: #b8ffe6; }
.connection-status.loading { border-color: #69d6ff; color: #cdf5ff; }
.connection-status.error { border-color: #ff5d73; color: #ffd3da; }
#cardEntranceEffect {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); z-index: 10;
  animation: entrance-float 1.8s ease-in-out infinite;
}
.card-back-glow-effect { width: min(220px, 48vw); border-radius: 12px; box-shadow: 0 0 40px 12px white; }
#cardEntranceEffect.fade-out { animation: fade-out-card .65s ease forwards; }
@keyframes entrance-float { 0%,100% { transform: translate(-50%,-52%); } 50% { transform: translate(-50%,-48%); } }
@keyframes fade-out-card { to { opacity: 0; transform: translate(-50%,-50%) scale(1.25); } }
.card-container {
  width: 100%;
  display: grid; grid-template-columns: repeat(3, minmax(0, 210px)); justify-content: center;
  gap: clamp(18px, 4vw, 48px); padding: 22px 0 12px;
  opacity: 0; transition: opacity .45s ease;
}
.card-container.show { opacity: 1; }
.card-slot {
  position: relative; width: 100%; aspect-ratio: 200 / 310; perspective: 1000px;
  border-radius: 12px;
}
.card-slot.drop-in { animation: drop-in .8s ease both; }
@keyframes drop-in { from { transform: translateY(-50px); opacity: 0; } to { transform: none; opacity: 1; } }
.card-img {
  position: absolute; inset: 0 0 auto 0; width: 100%; aspect-ratio: 200 / 290; object-fit: contain;
  border-radius: 8px; backface-visibility: hidden; transition: transform .6s ease, opacity .6s ease;
  background: rgba(0,0,0,.4);
}
.card-back.flip-out { transform: rotateY(90deg); }
.card-front { transform-origin: center; }
.image-fallback { background: linear-gradient(145deg, #17242c, #070b0e); border: 1px solid #627985; }
.border-common { box-shadow: 0 0 24px 6px #32cd32; }
.border-uncommon { box-shadow: 0 0 24px 6px #1e90ff; }
.border-rare { box-shadow: 0 0 24px 6px #a020f0; }
.border-legendary { box-shadow: 0 0 34px 9px gold; border: 4px solid gold; }
.border-unique { box-shadow: 0 0 34px 9px #ff4df0; border: 4px solid #ff4df0; }
.shimmer { animation: legendary-glow 1.6s ease-in-out infinite; }
@keyframes legendary-glow { 50% { filter: brightness(1.18); box-shadow: 0 0 52px 14px orange; } }
.new-unlock {
  position: absolute; top: 10px; left: 10px; z-index: 3;
  padding: 7px 10px; border-radius: 7px; background: crimson; color: white; font-size: clamp(14px, 2vw, 20px); font-weight: 800;
}
.card-label {
  position: absolute; left: 0; right: 0; bottom: 0; min-height: 46px;
  padding: 5px 7px; display: flex; flex-direction: column; justify-content: center; gap: 2px;
  background: rgba(0,0,0,.75); border-radius: 0 0 9px 9px; font-size: 13px;
}
.card-label span { color: #d5e6ee; font-size: 11px; }
#toast {
  min-height: 0; margin-top: 10px; padding: 0 18px; border-radius: 6px; opacity: 0;
  background: #111; font-size: 18px; transition: opacity .3s ease;
}
#toast.show { opacity: 1; padding-top: 12px; padding-bottom: 12px; }
#toast.pulse { animation: toast-pulse 1.4s ease-in-out; }
@keyframes toast-pulse { 50% { box-shadow: 0 0 24px 9px rgba(255,255,255,.72); } }
#countdown { min-height: 24px; margin: 10px 0; color: #d6d6d6; font-size: 18px; }
.error-panel {
  width: min(680px, 100%); margin: 16px auto; padding: 24px;
  border: 1px solid #ff687b; border-radius: 14px; background: var(--panel); box-shadow: 0 0 28px rgba(255,50,80,.18);
}
.error-panel h2 { margin-top: 0; }
.error-panel p { line-height: 1.5; color: #f4d7dc; }
.action-row, .success-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.success-actions { margin-top: 4px; }
.action-button {
  display: inline-block; padding: 10px 18px; border: 2px solid white; border-radius: 6px;
  background: var(--teal); color: white; text-decoration: none; font: 700 15px Arial, sans-serif; cursor: pointer;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease;
}
.action-button:hover:not(:disabled) { transform: scale(1.025); box-shadow: 0 0 14px var(--cyan); background: #004d4d; }
.action-button.secondary { background: rgba(0,0,0,.68); }
.action-button:disabled { opacity: .45; cursor: not-allowed; }
#musicToggle {
  position: fixed; right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); z-index: 20;
  background: rgba(0,0,0,.68); color: var(--cyan); border: 1px solid var(--cyan); border-radius: 999px;
  padding: 8px 12px; font-size: 12px; font-weight: 700; cursor: pointer;
}
#musicToggle[data-state="playing"] { color: #00ff99; border-color: #00ff99; }

@media (max-width: 760px) {
  .reveal-shell { justify-content: flex-start; padding: 28px 10px 82px; }
  #reveal-title { font-size: clamp(30px, 10vw, 42px); }
  .card-container { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 14px 0 8px; }
  .card-slot { aspect-ratio: 2 / 3.25; }
  .new-unlock { top: 5px; left: 5px; padding: 5px 7px; }
  .card-label { min-height: 38px; font-size: 11px; padding: 3px; }
  .card-label span { font-size: 9px; }
  .action-button { flex: 1 1 140px; }
  #countdown { font-size: 15px; }
}

@media (max-width: 420px) {
  .connection-status { font-size: 12px; }
  .card-label strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
