/* Mystery cape opening — Minecraft-style look. Static, self-contained.
   Font: Monocraft (SIL Open Font License, see assets/fonts). Textures in
   assets/tex are original pixel art made for this site, not game files. */
@font-face { font-family: "Monocraft"; src: url("assets/fonts/Monocraft.ttf") format("truetype"); font-weight: 400; font-display: block; }
@font-face { font-family: "Monocraft"; src: url("assets/fonts/Monocraft-Bold.ttf") format("truetype"); font-weight: 700; font-display: block; }

:root {
  --ink: #ffffff;
  --shadow: #3f3f3f;          /* Minecraft text shadow: same text, darker, offset down-right */
  --mut: #c6c6c6;
  --yellow: #ffff55;
  --gold: #ffaa00;
  --accent: #a64dff;          /* changed per cape by script.js */
  --px: 4px;                  /* one "pixel" of the UI */
  --tile: clamp(110px, 9.5vw, 190px);
  --font: "Monocraft", ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #14121b; color: var(--ink); font-family: var(--font); overflow: hidden; }
body { -webkit-font-smoothing: none; font-smooth: never; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
body.nocursor, body.nocursor * { cursor: none !important; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h1, .btn, .slot-name, .won-name, .won-label, .final-title, .tile span, .fslot span { text-shadow: .09em .09em 0 var(--shadow); }

/* ---------- background: tiled deepslate-style blocks, darkened like a game menu ---------- */
#bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; }
.bg-gradient {
  position: absolute; inset: -96px;
  background: url("assets/tex/bg.png") 0 0 / 96px 96px repeat;
  image-rendering: pixelated;
  animation: pan 60s linear infinite;
}
@keyframes pan { to { transform: translate3d(96px, 96px, 0); } }
.bg-stars { position: absolute; inset: 0; background: radial-gradient(120% 90% at 50% 40%, rgba(70, 30, 120, .35), rgba(8, 6, 14, .82) 75%); }
.bg-tint { position: absolute; inset: 0; background: radial-gradient(60% 60% at 50% 50%, var(--accent), transparent 70%); opacity: 0; transition: opacity 1.2s, background 1.2s; mix-blend-mode: screen; }
body.tinted .bg-tint { opacity: .16; }

#fx-back, #fx-front { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; image-rendering: pixelated; }
#fx-back { z-index: 1; }
#fx-front { z-index: 40; }
#app { position: fixed; inset: 0; z-index: 2; }
#app.shake { animation: shake var(--shake-ms, 500ms) steps(2, end); }
@keyframes shake {
  10%, 90% { transform: translate3d(-8px, 4px, 0); } 20%, 80% { transform: translate3d(8px, -4px, 0); }
  30%, 50%, 70% { transform: translate3d(-12px, 4px, 0); } 40%, 60% { transform: translate3d(12px, -8px, 0); }
}
#flash { position: fixed; inset: 0; z-index: 50; background: #fff; opacity: 0; pointer-events: none; }
#flash.on { animation: flash .7s steps(6, end); }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- screens ---------- */
.screen { position: absolute; inset: 0; opacity: 0; visibility: hidden; transition: opacity .5s ease, visibility 0s linear .5s; }
.screen.active { opacity: 1; visibility: visible; transition: opacity .5s ease; }

/* ---------- Minecraft-style buttons: stone face, black outline, bevel; white outline on hover ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; text-decoration: none;
  color: #fff; font-weight: 700; letter-spacing: .02em;
  background: url("assets/tex/stone.png") 0 0 / 48px 48px repeat; image-rendering: pixelated;
  border: var(--px) solid #000; border-radius: 0;
  box-shadow: inset var(--px) var(--px) 0 rgba(255,255,255,.42), inset calc(var(--px) * -1) calc(var(--px) * -1.5) 0 rgba(0,0,0,.42);
  padding: 14px 34px; font-size: clamp(16px, 1.45vw, 26px);
}
.btn:hover, .btn:focus-visible { background-image: url("assets/tex/stone_hover.png"); border-color: #fff; outline: none; }
.btn:active { box-shadow: inset var(--px) var(--px) 0 rgba(0,0,0,.35), inset calc(var(--px) * -1) calc(var(--px) * -1) 0 rgba(255,255,255,.2); }
.btn:disabled { cursor: default; color: #a0a0a0; background-image: url("assets/tex/stone.png"); filter: brightness(.55); border-color: #000; box-shadow: none; text-shadow: none; }
.btn-primary { padding: 16px 40px; font-size: clamp(18px, 1.6vw, 28px); }

/* tooltip-style panel (dark, purple frame) used for the badge and QR box */
.panel {
  background: rgba(16, 0, 16, .92);
  border: var(--px) solid #100010;
  box-shadow: inset 0 0 0 calc(var(--px) * .75) #2d0a6b, inset 0 0 0 calc(var(--px) * 1.5) #5000ff40;
}

/* ---------- intro ---------- */
#intro { display: grid; place-items: center; text-align: center; }
.intro-inner { padding: 24px; display: flex; flex-direction: column; align-items: center; }
.intro-collab { margin: 0 0 14px; font-size: clamp(16px, 1.8vw, 30px); color: var(--mut); text-shadow: .09em .09em 0 #2a2a2a; }
.title-wrap { position: relative; margin: 0 0 56px; }
.intro-title { margin: 0; font-size: clamp(34px, 6.4vw, 118px); font-weight: 700; line-height: 1; letter-spacing: .02em; color: #fff; text-shadow: .07em .07em 0 #3f3f3f; }
.splash {
  position: absolute; right: -3%; bottom: -62%; margin: 0; color: var(--yellow); font-weight: 700; font-size: clamp(14px, 1.7vw, 30px);
  text-shadow: .1em .1em 0 #3f3f15; transform: rotate(-16deg); white-space: nowrap;
  animation: splash .5s ease-in-out infinite alternate;
}
@keyframes splash { from { transform: rotate(-16deg) scale(1); } to { transform: rotate(-16deg) scale(1.1); } }
.loader { width: min(560px, 80vw); margin: 0 auto; }
.loader-bar { height: 18px; border: var(--px) solid #fff; background: #000; padding: 3px; }
.loader-fill { height: 100%; width: 0; background: #fff; transition: width .2s steps(4, end); }
.loader-label { color: #fff; margin: 14px 0 0; font-size: clamp(14px, 1.1vw, 18px); text-shadow: .1em .1em 0 var(--shadow); }
.btn-start { animation: appear .3s steps(3, end) both; }
@keyframes appear { from { opacity: 0; } to { opacity: 1; } }

/* ---------- main page ---------- */
#main { display: flex; align-items: center; justify-content: center; }
.main-stage { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(8px, 1.4vh, 22px); transform-origin: 50% 50%; transition: transform .9s cubic-bezier(.2,.7,.2,1); padding: 60px 24px 70px; }
.main-title { margin: 0; font-size: clamp(26px, 3.8vw, 72px); font-weight: 700; text-align: center; transition: opacity .5s; }
.hero { display: flex; justify-content: center; transition: opacity .5s; }
.model-wrap { position: relative; width: clamp(160px, 14vw, 260px); height: clamp(200px, 25vh, 330px); }
.model { position: absolute; inset: 0; }
.model canvas, .stage-slot canvas { width: 100% !important; height: 100% !important; display: block; }

.slots { display: flex; gap: clamp(18px, 4vw, 90px); justify-content: center; align-items: flex-end; }
.slot { display: flex; flex-direction: column; align-items: center; gap: 14px; transition: opacity .6s ease, filter .6s ease; --glow: 10px; }
.slot.fade { opacity: 0; filter: blur(8px); pointer-events: none; }
.cape-float { position: relative; width: clamp(96px, 9.5vw, 180px); aspect-ratio: 10 / 16; animation: float 3.2s ease-in-out infinite; }
.slot:nth-child(2) .cape-float { animation-delay: -1.1s; }
.slot:nth-child(3) .cape-float { animation-delay: -2.2s; }
@keyframes float { 50% { transform: translateY(-12px); } }
.cape-shake { width: 100%; height: 100%; transform: translate3d(var(--sx, 0), var(--sy, 0), 0) rotate(var(--sr, 0deg)); }
/* a cape: the front of the 64x32 texture with hard pixels and a black pixel outline */
.cape-face {
  width: 100%; height: 100%;
  background-repeat: no-repeat; background-size: 640% 200%; background-position: 1.852% 6.25%;
  image-rendering: pixelated; image-rendering: crisp-edges;
  filter: drop-shadow(4px 0 0 #000) drop-shadow(-4px 0 0 #000) drop-shadow(0 4px 0 #000) drop-shadow(0 -4px 0 #000) drop-shadow(0 0 var(--glow) var(--accent));
}
.slot:not(.revealed):hover { --glow: 26px; }
.slot:not(.revealed):hover .cape-shake { animation: tremble .1s steps(2, end) infinite; }
@keyframes tremble { 50% { transform: translate(2px, -2px); } }
.slot-name { min-height: 1.3em; margin: 0; font-weight: 700; font-size: clamp(14px, 1.25vw, 22px); text-align: center; }
.slot.revealed .slot-name { color: var(--yellow); text-shadow: .09em .09em 0 #3f3f15; }
.reveal-btn { min-width: clamp(140px, 11vw, 220px); }

/* ---------- spin ---------- */
#spin { overflow: hidden; background: rgba(6, 4, 12, .88); }
.spin-tint { position: absolute; inset: 0; background: radial-gradient(70% 60% at 50% 50%, var(--accent), transparent 75%); opacity: 0; }
.spin-dim { position: absolute; inset: 0; background: #000; opacity: 0; transition: opacity .8s ease; }
#spin.slowmo .spin-dim { opacity: .5; }
.reel-scene { position: absolute; inset: 0; display: grid; place-items: center; perspective: 1100px; transition: transform 1.1s cubic-bezier(.2,.7,.2,1); }
#spin.slowmo .reel-scene { transform: scale(1.32); }
#spin.enter .reel-scene { animation: reelIn .6s cubic-bezier(.2,.8,.2,1); }
@keyframes reelIn { from { transform: scale(1.5); opacity: 0; filter: brightness(3); } to { transform: none; opacity: 1; filter: none; } }
.reel-tilt { position: relative; width: 100vw; transform: rotateX(16deg); transform-style: preserve-3d; }
.reel {
  position: relative; height: calc(var(--tile) * 1.62 + 64px); overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 22%, #000 78%, transparent 100%);
          mask-image: linear-gradient(90deg, transparent 0%, #000 22%, #000 78%, transparent 100%);
  background: url("assets/tex/panel.png") 0 0 / 64px 64px repeat; image-rendering: pixelated;
  border-top: var(--px) solid #000; border-bottom: var(--px) solid #000;
}
.strip { position: absolute; left: 0; top: 30px; display: flex; will-change: transform; }
/* each reel tile is an inventory slot: grey with a dark top-left and light bottom-right edge */
.tile { flex: 0 0 var(--tile); width: var(--tile); padding: 0 calc(var(--tile) * .06); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.slotbox { background: #8b8b8b; box-shadow: inset var(--px) var(--px) 0 #373737, inset calc(var(--px) * -1) calc(var(--px) * -1) 0 #ffffff; }
.tile .slotbox { width: 100%; height: calc(var(--tile) * 1.3); padding: 10%; }
.tile .cape-face { --glow: 0px; filter: drop-shadow(3px 0 0 #000) drop-shadow(-3px 0 0 #000) drop-shadow(0 3px 0 #000) drop-shadow(0 -3px 0 #000); }
.tile span { font-weight: 700; font-size: clamp(11px, .85vw, 16px); color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.marker { position: absolute; top: -14px; bottom: -14px; left: 50%; width: 8px; transform: translateX(-50%); background: var(--yellow); border: 2px solid #000; box-shadow: 0 0 24px var(--accent); }
.marker::before, .marker::after { content: ""; position: absolute; left: 50%; transform: translateX(-50%); border: 16px solid transparent; }
.marker::before { top: -30px; border-top-color: var(--yellow); }
.marker::after { bottom: -30px; border-bottom-color: var(--yellow); }
.marker.tick { animation: tick .14s steps(2, end); }
@keyframes tick { 0% { background: #fff; box-shadow: 0 0 40px #fff; } }
.vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 45%, rgba(0,0,0,.85) 100%); }
.vignette.pulse { animation: vig .2s ease-out; }
@keyframes vig { 0% { background: radial-gradient(ellipse at center, transparent 35%, rgba(0,0,0,.95) 100%); } }

/* ---------- the big moment ---------- */
#moment { display: grid; place-items: center; overflow: hidden; }
.rays { position: absolute; left: 50%; top: 46%; width: 220vmax; height: 220vmax; transform: translate(-50%, -50%) scale(.2); opacity: 0;
  background: repeating-conic-gradient(from 0deg, var(--accent) 0deg 8deg, transparent 8deg 22.5deg);
  -webkit-mask-image: radial-gradient(closest-side, #000 0%, transparent 70%); mask-image: radial-gradient(closest-side, #000 0%, transparent 70%); }
#moment.beat1 .rays { opacity: .38; transform: translate(-50%, -50%) scale(1); transition: opacity .5s, transform .7s cubic-bezier(.2,.8,.2,1); animation: spinRays 24s linear infinite; }
@keyframes spinRays { to { rotate: 360deg; } }
#moment.beat2 .rays { opacity: .16; }
.shock { position: absolute; left: 50%; top: 46%; width: 64px; height: 64px; border: 8px solid var(--accent); transform: translate(-50%, -50%) scale(0) rotate(45deg); opacity: 0; }
.shock.go { animation: shock .8s cubic-bezier(.1,.7,.3,1); }
@keyframes shock { 0% { opacity: 1; transform: translate(-50%, -50%) scale(0) rotate(45deg); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(26) rotate(45deg); border-width: 1px; } }
.won-cape { position: absolute; left: 50%; top: 44%; width: clamp(150px, 15vw, 290px); aspect-ratio: 10 / 16; transform: translate(-50%, -50%) scale(0); opacity: 0; }
.won-cape .cape-face { --glow: 36px; }
#moment.beat1 .won-cape { animation: popIn .7s cubic-bezier(.2,1.6,.4,1) forwards; }
@keyframes popIn { 0% { transform: translate(-50%, -50%) scale(.35); opacity: 0; } 100% { transform: translate(-50%, -50%) scale(1); opacity: 1; } }
#moment.beat2 .won-cape { animation: flyAway .6s cubic-bezier(.5,0,.8,.4) forwards; }
@keyframes flyAway { 0% { transform: translate(-50%, -50%) scale(1); opacity: 1; } 100% { transform: translate(-50%, -260%) scale(.15); opacity: 0; } }
.beam { position: absolute; left: 50%; top: 0; bottom: 0; width: clamp(120px, 11vw, 220px); transform: translateX(-50%) scaleX(0); opacity: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.55) 30%, rgba(255,255,255,.85) 50%, rgba(255,255,255,.55) 70%, transparent); will-change: transform, opacity; }
.beam.go { animation: beam 1.1s cubic-bezier(.2,.7,.2,1) forwards; }
@keyframes beam { 0% { opacity: 0; transform: translateX(-50%) scaleX(.2); } 18% { opacity: 1; transform: translateX(-50%) scaleX(1); } 100% { opacity: 0; transform: translateX(-50%) scaleX(.6); } }
.stage-slot { position: absolute; left: 50%; top: 40%; width: min(50vh, 46vw); height: min(62vh, 80vw); transform: translate(-50%, -50%); }
#moment .stage-slot { opacity: 0; transform: translate(-50%, -50%) scale(.96); transition: opacity .5s ease, transform .6s cubic-bezier(.2,.8,.2,1); }
#moment.materialize .stage-slot { opacity: 1; transform: translate(-50%, -50%); }
.won-text { position: absolute; left: 0; right: 0; top: 66%; text-align: center; transition: top .9s cubic-bezier(.2,.7,.2,1); pointer-events: none; }
#moment.beat2 .won-text { top: 71%; }
.won-label { margin: 0; font-size: clamp(16px, 1.8vw, 32px); font-weight: 700; color: var(--yellow); opacity: 0; text-shadow: .1em .1em 0 #3f3f15; }
.won-name { margin: 6px 0 0; font-size: clamp(34px, 5.6vw, 104px); font-weight: 700; line-height: 1; opacity: 0; color: #fff; text-shadow: .08em .08em 0 #3f3f3f, 0 0 40px var(--accent); }
#moment.text .won-label { animation: slam .35s steps(5, end) forwards; }
#moment.text .won-name { animation: slam .4s cubic-bezier(.2,1.6,.4,1) .1s forwards; }
@keyframes slam { 0% { opacity: 0; transform: scale(2.4); } 100% { opacity: 1; transform: none; } }
.btn-back { position: absolute; bottom: clamp(34px, 4.5vh, 54px); left: 50%; transform: translateX(-50%); animation: appear .3s steps(3, end) both; }

/* advancement-style toast */
.toast { position: fixed; top: 22px; right: 22px; z-index: 55; display: flex; align-items: center; gap: 16px; padding: 14px 22px 14px 14px; min-width: 330px;
  background: #212121; border: var(--px) solid #000; box-shadow: inset 0 0 0 var(--px) #555;
  transform: translateX(130%); transition: transform .45s cubic-bezier(.2,.9,.3,1); }
.toast.on { transform: none; }
.toast-icon { width: 40px; height: 64px; flex: 0 0 auto; --glow: 0px; filter: none; }
.toast p { margin: 0; }
.toast-title { color: var(--yellow); font-weight: 700; font-size: 18px; text-shadow: .1em .1em 0 #3f3f15; }
.toast-name { color: #fff; font-size: 18px; margin-top: 6px !important; text-shadow: .1em .1em 0 var(--shadow); }
body:has(.toast.on) .hud { opacity: 0; }

/* ---------- final ---------- */
#final { display: grid; place-items: center; overflow-y: auto; }
.final-inner { width: 100%; max-width: 1500px; padding: 64px 24px 80px; display: flex; flex-direction: column; align-items: center; gap: clamp(8px, 1.6vh, 20px); }
.final-title { margin: 0; font-size: clamp(30px, 5vw, 96px); font-weight: 700; text-align: center; opacity: 0; color: var(--yellow); text-shadow: .08em .08em 0 #3f3f15, 0 0 40px var(--gold); }
#final.done .final-title { animation: slam .45s cubic-bezier(.2,1.6,.4,1) forwards; }
.final-show { display: flex; flex-direction: column; align-items: center; gap: clamp(4px, 1vh, 14px); }
.final-model { position: relative; left: auto; top: auto; transform: none; width: clamp(180px, 30vh, 340px); height: clamp(220px, 38vh, 430px); }
.final-row { display: flex; gap: clamp(14px, 3vw, 60px); justify-content: center; }
.fslot { display: flex; flex-direction: column; align-items: center; gap: 8px; cursor: pointer; background: none; border: 0; padding: 6px; opacity: 0; transform: translateY(40px) scale(.6); transition: opacity .3s steps(3, end), transform .5s cubic-bezier(.2,1.5,.4,1); }
.fslot.lit { opacity: 1; transform: none; }
.fslot .slotbox { padding: 10px; }
.fslot.wearing .slotbox { outline: var(--px) solid var(--yellow); outline-offset: 2px; }
.fslot .cape-face { width: clamp(52px, 5.2vw, 96px); height: auto; aspect-ratio: 10 / 16; --glow: 0px; }
.fslot span { font-weight: 700; font-size: clamp(12px, 1.05vw, 20px); }
.final-hint { margin: 0; color: var(--mut); font-size: clamp(13px, 1vw, 17px); text-shadow: .1em .1em 0 #2a2a2a; }
.cta { display: flex; align-items: center; gap: clamp(18px, 3vw, 48px); flex-wrap: wrap; justify-content: center; margin-top: 6px; }
.qr { display: flex; align-items: center; gap: 14px; padding: 12px 18px 12px 12px; }
.qr img { width: clamp(96px, 7.5vw, 140px); height: auto; background: #fff; padding: 6px; image-rendering: pixelated; border: var(--px) solid #000; }
.qr p { margin: 0; max-width: 230px; font-weight: 700; font-size: clamp(13px, 1.05vw, 18px); line-height: 1.35; text-shadow: .1em .1em 0 var(--shadow); }
.yt-link { color: #55ffff; font-size: clamp(13px, 1vw, 17px); text-decoration: underline; text-underline-offset: 4px; text-shadow: .1em .1em 0 #153f3f; }

/* ---------- chrome ---------- */
.hud { position: fixed; top: 18px; right: 18px; z-index: 60; display: flex; gap: 10px; }
.hud-btn { width: 50px; height: 50px; padding: 0; display: grid; place-items: center; }
.hud-btn svg { fill: #fff; filter: drop-shadow(2px 2px 0 var(--shadow)); }
.hud-btn .ico-off, body.muted .hud-btn .ico-on { display: none; }
body.muted .hud-btn .ico-off { display: inline; }
.badge { position: fixed; left: 18px; top: 18px; z-index: 60; padding: 9px 14px; color: #fff; text-decoration: none; font-size: clamp(12px, .85vw, 15px); text-shadow: .1em .1em 0 var(--shadow); }
.badge:hover { color: var(--yellow); }
.disclaimer { position: fixed; left: 0; right: 0; bottom: 10px; z-index: 60; text-align: center; color: rgba(255,255,255,.5); font-size: clamp(10px, .7vw, 13px); pointer-events: none; }

/* ---------- phones ---------- */
@media (max-width: 700px), (max-aspect-ratio: 4/5) {
  :root { --px: 3px; }
  .main-stage { padding: 72px 10px 70px; }
  .slots { gap: 10px; }
  .cape-float { width: 26vw; }
  .reveal-btn { min-width: 0; width: 28vw; padding: 10px 4px; font-size: 14px; }
  .slot-name { font-size: 12px; }
  .stage-slot { width: 70vw; height: 52vh; top: 40%; }
  #moment.beat2 .won-text { top: 72%; }
  .final-model { width: 56vw; height: 34vh; }
  .final-row { gap: 10px; }
  .badge { top: auto; bottom: 30px; left: 50%; transform: translateX(-50%); white-space: nowrap; }
  .disclaimer { bottom: 8px; padding: 0 8px; }
  .splash { right: 0; bottom: -40%; }
  .toast { left: 12px; right: 12px; min-width: 0; top: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .bg-gradient, .cape-float, .splash { animation: none; }
}
