/* Game: Mystery Gift Box */
.arcade-giftbox .gb-title { margin: 0; color: var(--a-fg); font-size: clamp(1.6rem, 4vw, 2.3rem); text-align: center; }
.arcade-giftbox .gb-opens { display: flex; justify-content: center; gap: 8px; margin-top: 10px; }
.arcade-giftbox .gb-opens[hidden] { display: none; }
.arcade-giftbox .gb-dot { position: relative; width: 20px; height: 18px; border: 2px solid #1C1433; border-radius: 5px; background: var(--a-accent); box-shadow: 0 2px 0 #1C1433; transition: opacity .3s, transform .3s, background .3s; }
.arcade-giftbox .gb-dot::before { content: ""; position: absolute; top: -2px; bottom: -2px; left: 50%; width: 4px; margin-left: -2px; background: var(--a-c1); }
.arcade-giftbox .gb-dot.is-used { opacity: .35; transform: scale(.85); box-shadow: none; }
.arcade-giftbox .gb-status { min-height: 1.65em; margin: 8px 0 6px; color: var(--a-fg); font-weight: 600; text-align: center; opacity: .92; text-wrap: balance; }

/* Box grid */
.arcade-giftbox .gb-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(4px, 1.6vw, 18px) clamp(10px, 3.4vw, 36px); width: min(100%, 590px); margin-top: 6px; }
.arcade-giftbox .gb-grid[data-n="3"] { width: min(100%, 610px); }
.arcade-giftbox .gb-grid[data-n="9"] { width: min(100%, 450px); gap: 2px clamp(10px, 3vw, 28px); }

.arcade-giftbox .gb-box { position: relative; display: block; width: 100%; aspect-ratio: 106 / 122; padding: 0; border: 0; border-radius: 18px; background: none; color: inherit; font: inherit; cursor: pointer; container-type: inline-size; -webkit-tap-highlight-color: transparent; }
.arcade-giftbox .gb-box:disabled { cursor: default; }
.arcade-giftbox .gb-box:focus-visible { outline: 3px solid var(--a-accent); outline-offset: 2px; }
.arcade-giftbox .gb-lift, .arcade-giftbox .gb-float, .arcade-giftbox .gb-shake { display: block; width: 100%; height: 100%; }
.arcade-giftbox .gb-lift { position: relative; z-index: 1; transition: transform .22s cubic-bezier(.3, 1.6, .5, 1), opacity .4s, filter .4s; }
.arcade-giftbox .gb-svg { display: block; width: 100%; height: 100%; overflow: visible; }
.arcade-giftbox.is-dark .gb-box::before { content: ""; position: absolute; left: 50%; top: 58%; z-index: 0; width: 125%; aspect-ratio: 1.15; transform: translate(-50%, -50%); border-radius: 50%; background: radial-gradient(closest-side, color-mix(in srgb, var(--a-accent) 26%, transparent), transparent); pointer-events: none; }
.arcade-giftbox.is-dark .gb-box.is-peek::before { opacity: .4; }

/* Theme colours (JS sets --gb-body / --gb-rib / --gb-ink per box) */
.arcade-giftbox .gb-fill, .arcade-giftbox .gb-in { fill: var(--gb-body, var(--a-c1)); }
.arcade-giftbox .gb-rib { fill: var(--gb-rib, var(--a-accent)); }
.arcade-giftbox .gb-pf { fill: var(--gb-ink, #fff); }
.arcade-giftbox .gb-pat { opacity: .2; }
.arcade-giftbox .gb-shadow { fill: rgba(12, 6, 30, .3); }
.arcade-giftbox .gb-lid { transform-box: view-box; transform-origin: 60px 62px; transition: transform .5s cubic-bezier(.3, 1.5, .5, 1), opacity .3s; }

/* Gentle idle bob */
.arcade-giftbox .gb-float { animation: gb-bob 3.6s ease-in-out infinite; animation-delay: calc(var(--i, 0) * -.73s); transform-origin: 50% 92%; }
@keyframes gb-bob {
	0%, 100% { transform: translateY(0) rotate(0); }
	22% { transform: translateY(-5px) rotate(0); }
	44% { transform: translateY(0) rotate(0); }
	52% { transform: translateY(-1px) rotate(-3.5deg); }
	60% { transform: translateY(-1px) rotate(3deg); }
	68% { transform: translateY(0) rotate(-1.5deg); }
	76% { transform: translateY(0) rotate(0); }
}
.arcade-giftbox .gb-box:not(:disabled):hover .gb-lift,
.arcade-giftbox .gb-box:not(:disabled):focus-visible .gb-lift { transform: translateY(-9px) scale(1.04); }
.arcade-giftbox .gb-box:not(:disabled):active .gb-lift { transform: translateY(-2px) scale(.98); }
.arcade-giftbox.is-busy .gb-box:not(.is-picked) .gb-lift { opacity: .7; }
.arcade-giftbox.is-busy .gb-box:not(.is-picked) { cursor: progress; }

/* Shake, then open */
.arcade-giftbox .is-picked .gb-float, .arcade-giftbox .is-peek .gb-float { animation: none; }
.arcade-giftbox .is-shaking .gb-shake { animation: gb-shake .56s ease-in-out; transform-origin: 50% 92%; }
@keyframes gb-shake {
	0%, 100% { transform: none; }
	12% { transform: rotate(-8deg) scale(1.03); }
	26% { transform: rotate(7deg) scale(1.05); }
	40% { transform: rotate(-7deg) scale(1.05); }
	54% { transform: rotate(6deg) scale(1.06); }
	68% { transform: rotate(-4deg) scale(1.04, .96); }
	84% { transform: rotate(2deg) scale(1.06, .92); }
}
.arcade-giftbox .is-open .gb-lid { animation: gb-lid-fly .85s cubic-bezier(.25, .8, .35, 1) forwards; }
@keyframes gb-lid-fly {
	0% { transform: none; opacity: 1; }
	16% { transform: translateY(4px) scale(1.04, .9); opacity: 1; }
	48% { transform: translate(10px, -60px) rotate(20deg); opacity: 1; }
	100% { transform: translate(38px, -104px) rotate(68deg) scale(.9); opacity: 0; }
}

/* Glow and sparkles */
.arcade-giftbox .gb-glow { position: absolute; left: 50%; top: 35%; z-index: 0; width: 150%; aspect-ratio: 1; transform: translate(-50%, -50%) scale(.2); opacity: 0; pointer-events: none; }
.arcade-giftbox .gb-glow i { display: block; width: 100%; height: 100%; border-radius: 50%;
	background: radial-gradient(closest-side, color-mix(in srgb, var(--gb-ray, var(--a-accent)) 70%, transparent), transparent 70%), repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--gb-ray, var(--a-accent)) 60%, transparent) 0deg 9deg, transparent 9deg 30deg);
	-webkit-mask: radial-gradient(closest-side, #000 30%, transparent); mask: radial-gradient(closest-side, #000 30%, transparent); }
.arcade-giftbox .is-lose { --gb-ray: #FFFFFF; }
.arcade-giftbox .is-open .gb-glow { animation: gb-glow-in .7s .12s ease-out forwards; }
.arcade-giftbox .is-open.is-lose .gb-glow { animation-name: gb-glow-soft; }
.arcade-giftbox .is-open .gb-glow i { animation: gb-spin 16s linear infinite; }
@keyframes gb-glow-in { to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@keyframes gb-glow-soft { to { opacity: .45; transform: translate(-50%, -50%) scale(.8); } }
@keyframes gb-spin { to { transform: rotate(360deg); } }

.arcade-giftbox .gb-sparks { position: absolute; left: 50%; top: 37%; z-index: 4; width: 0; height: 0; pointer-events: none; }
.arcade-giftbox .gb-spark { position: absolute; left: -9px; top: -9px; width: 18px; height: 18px; background: var(--c, #fff); opacity: 0;
	clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
	animation: gb-spark .95s var(--d, 0ms) cubic-bezier(.2, .8, .3, 1) forwards; }
@keyframes gb-spark {
	0% { transform: translate(0, 0) scale(.2) rotate(0); opacity: 1; }
	65% { opacity: 1; }
	100% { transform: translate(var(--dx), var(--dy)) scale(var(--s, 1)) rotate(120deg); opacity: 0; }
}

/* Prize tag */
.arcade-giftbox .gb-prize { position: absolute; left: 50%; top: 25%; z-index: 3; box-sizing: border-box; width: max-content; max-width: 108%; padding: .34em .6em .26em; border: 2px solid #1C1433; border-radius: 12px; background: #fff; color: #1C1433;
	font: 800 clamp(12px, 13.5cqi, 23px)/1.06 var(--a-font-display); text-align: center; overflow-wrap: anywhere; text-wrap: balance;
	box-shadow: 0 4px 0 #1C1433; transform: translate(-50%, -50%); opacity: 0; visibility: hidden; pointer-events: none; }
.arcade-giftbox .gb-prize.is-win { background: var(--a-accent); color: var(--a-accent-ink); }
.arcade-giftbox .gb-prize.is-lose { background: #fff; color: #463D5E; }
.arcade-giftbox .gb-prize.is-win::before, .arcade-giftbox .gb-prize.is-win::after { content: ""; position: absolute; width: 12px; height: 12px; background: #fff; clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); filter: drop-shadow(0 0 1px #1C1433); animation: gb-twinkle 1.7s ease-in-out infinite; }
.arcade-giftbox .gb-prize.is-win::before { top: -9px; left: -8px; }
.arcade-giftbox .gb-prize.is-win::after { right: -7px; bottom: -8px; width: 9px; height: 9px; animation-delay: -.85s; }
@keyframes gb-twinkle { 0%, 100% { transform: scale(.4) rotate(0); opacity: .4; } 50% { transform: scale(1.1) rotate(45deg); opacity: 1; } }
.arcade-giftbox .is-open .gb-prize { visibility: visible; animation: gb-rise .75s .14s cubic-bezier(.2, 1.35, .4, 1) both; }
@keyframes gb-rise {
	0% { transform: translate(-50%, 20%) scale(.25); opacity: 0; }
	55% { transform: translate(-50%, -78%) scale(1.1); opacity: 1; }
	100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* Remaining boxes: lid ajar, faded, showing what they could have held */
.arcade-giftbox .is-peek .gb-lift { opacity: .74; filter: saturate(.55) brightness(.92); }
.arcade-giftbox .is-picked .gb-lift { transform: scale(1.06); }
.arcade-giftbox .is-peek .gb-lid { transform: translate(-3px, -16px) rotate(-11deg); }
.arcade-giftbox .is-peek .gb-prize { visibility: visible; top: 27%; background: rgba(255, 255, 255, .88); color: #463D5E; border-style: dashed; border-color: rgba(28, 20, 51, .5); box-shadow: none; font-size: clamp(11px, 11.5cqi, 19px); font-weight: 700; animation: gb-peek .45s .12s ease-out both; }
@keyframes gb-peek { from { transform: translate(-50%, -10%) scale(.7); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: .92; } }

/* Play again button */
.arcade-giftbox .gb-again { min-width: 180px; min-height: 52px; margin-top: 18px; background: var(--a-accent); color: var(--a-accent-ink); border-color: #1C1433; box-shadow: 0 5px 0 #1C1433; font-size: 1.1rem; }
.arcade-giftbox .gb-again:hover { color: var(--a-accent-ink); }
.arcade-giftbox .gb-again[hidden] { display: none; }

@media (max-width: 640px) {
	.arcade-giftbox .gb-status { font-size: .95rem; }
	.arcade-giftbox .gb-grid { column-gap: 10px; row-gap: 14px; }
	.arcade-giftbox .gb-prize { border-radius: 10px; box-shadow: 0 3px 0 #1C1433; }
}

/* Reduced motion */
.arcade-giftbox.is-reduced .gb-float, .arcade-giftbox.is-reduced .gb-glow i,
.arcade-giftbox.is-reduced .gb-prize.is-win::before, .arcade-giftbox.is-reduced .gb-prize.is-win::after { animation: none; }
.arcade-giftbox.is-reduced .gb-lift, .arcade-giftbox.is-reduced .gb-lid { transition: none; }
.arcade-giftbox.is-reduced .is-open .gb-lid { animation: none; opacity: 0; }
.arcade-giftbox.is-reduced .is-open .gb-glow { animation: none; opacity: 1; transform: translate(-50%, -50%) scale(1); }
.arcade-giftbox.is-reduced .is-open.is-lose .gb-glow { opacity: .45; }
.arcade-giftbox.is-reduced .is-open .gb-prize { animation: none; opacity: 1; }
.arcade-giftbox.is-reduced .is-peek .gb-prize { animation: none; opacity: .92; }
@media (prefers-reduced-motion: reduce) {
	.arcade-giftbox .gb-float, .arcade-giftbox .gb-glow i { animation: none; }
}
