/* ========== SpriteLab Showdown - funky arcade theme ========== */
:root {
    --bg1: #1b1145;
    --bg2: #2c1a6b;
    --ink: #fff8f0;
    --muted: #c9bff5;
    --card: rgba(255, 255, 255, .08);
    --card-border: rgba(255, 255, 255, .18);
    --pink: #ff4d6d;
    --yellow: #ffd23f;
    --mint: #3bceac;
    --purple: #7b5cff;
    --blue: #00b4ff;
    --orange: #ff8c42;
    --radius: 22px;
    --pixel: 'Press Start 2P', monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    font-family: 'Fredoka', 'Segoe UI', system-ui, sans-serif;
    color: var(--ink);
    background: radial-gradient(1200px 600px at 10% -10%, #5b2bd1 0%, transparent 60%),
                radial-gradient(900px 500px at 110% 10%, #c81d77 0%, transparent 55%),
                linear-gradient(160deg, var(--bg1), var(--bg2));
    background-attachment: fixed;
    overflow-x: hidden;
}

a { color: var(--yellow); }
a:hover { color: #fff; }
h1, h2, h3 { line-height: 1.15; margin: .3em 0; }
h1:focus { outline: none; }

.bg-grid {
    position: fixed; inset: 0; z-index: -1; pointer-events: none;
    background-image: linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
    background-size: 40px 40px;
    animation: grid-move 6s linear infinite;
    mask-image: linear-gradient(to bottom, transparent, #000 30%, #000 70%, transparent);
}
@keyframes grid-move { to { background-position: 40px 40px; } }

/* ---------- Top bar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem;
    padding: .7rem 1.5rem;
    background: rgba(20, 10, 55, .75);
    backdrop-filter: blur(10px);
    border-bottom: 3px solid transparent;
    border-image: linear-gradient(90deg, var(--pink), var(--yellow), var(--mint), var(--blue), var(--purple)) 1;
}
.logo { display: flex; align-items: center; gap: .5rem; text-decoration: none; color: var(--ink); }
.logo-icon { font-size: 2rem; display: inline-block; animation: wobble 2.5s ease-in-out infinite; }
.logo-text { font-family: var(--pixel); font-size: .85rem; letter-spacing: 1px; }
.nav { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.nav-link {
    color: var(--ink); text-decoration: none; font-weight: 600;
    padding: .45rem .9rem; border-radius: 999px;
    transition: transform .15s, background .2s;
}
.nav-link:hover { background: rgba(255,255,255,.12); color: #fff; transform: translateY(-2px); }
.nav-link.active { background: var(--yellow); color: #2a1660; box-shadow: 0 4px 0 #c79a00; }
.as-button { background: none; border: 0; font: inherit; cursor: pointer; }
.logout-form { display: flex; align-items: center; gap: .3rem; margin: 0; }
.player-chip { background: rgba(255,255,255,.12); padding: .35rem .8rem; border-radius: 999px; font-size: .9rem; }
.login-link { border: 2px solid var(--mint); }

.content { max-width: 1150px; margin: 0 auto; padding: 1.5rem 1.2rem 3rem; }
.footer { text-align: center; color: var(--muted); padding: 1.5rem; font-size: .9rem; }

/* ---------- Generic bits ---------- */
.card {
    background: var(--card); border: 2px solid var(--card-border); border-radius: var(--radius);
    padding: 1.5rem; margin-bottom: 1.5rem; backdrop-filter: blur(6px);
    box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.big-emoji { font-size: 4rem; display: inline-block; }
.page-title { font-family: var(--pixel); font-size: clamp(1.1rem, 3.5vw, 2rem); text-align: center; margin: .5rem 0 1.5rem; text-shadow: 4px 4px 0 var(--pink); }
.section-title { text-align: center; font-size: clamp(1.6rem, 4vw, 2.4rem); margin: 2.5rem 0 1rem; }

.rainbow-text {
    background: linear-gradient(90deg, var(--pink), var(--yellow), var(--mint), var(--blue), var(--purple), var(--pink));
    background-size: 300% 100%;
    -webkit-background-clip: text; background-clip: text; color: transparent;
    animation: rainbow 4s linear infinite;
}
@keyframes rainbow { to { background-position: 300% 0; } }

.btn {
    display: inline-flex; align-items: center; gap: .4rem; justify-content: center;
    font: inherit; font-weight: 700; font-size: 1.05rem; text-decoration: none; cursor: pointer;
    padding: .75rem 1.4rem; border-radius: 16px; border: 0; color: #2a1660;
    transition: transform .12s, box-shadow .12s, filter .2s;
}
.btn:hover { transform: translateY(-3px); filter: brightness(1.08); color: #2a1660; }
.btn:active { transform: translateY(3px); box-shadow: none !important; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-primary { background: var(--yellow); box-shadow: 0 6px 0 #c79a00; }
.btn-ghost { background: rgba(255,255,255,.12); color: var(--ink); border: 2px solid rgba(255,255,255,.35); }
.btn-ghost:hover { color: #fff; }
.btn-play { background: var(--mint); box-shadow: 0 6px 0 #1f8c73; width: 100%; }
.btn-danger { background: var(--pink); color: #fff; box-shadow: 0 4px 0 #a3123a; }
.btn-small { padding: .35rem .7rem; font-size: .85rem; border-radius: 10px; }

label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; margin-bottom: .8rem; }
input, select {
    font: inherit; font-weight: 400; padding: .65rem .85rem; border-radius: 12px;
    border: 2px solid rgba(255,255,255,.25); background: rgba(10, 5, 35, .55); color: var(--ink);
    transition: border-color .2s, box-shadow .2s;
}
input:focus, select:focus { outline: none; border-color: var(--yellow); box-shadow: 0 0 0 4px rgba(255,210,63,.25); }
select option { background: var(--bg2); }
.validation-message, .error { color: #ff8fa3; font-weight: 600; }
.invalid { border-color: var(--pink) !important; }
.success { color: var(--mint); font-weight: 700; }
.notice { background: rgba(0,180,255,.15); border: 2px dashed var(--blue); padding: .8rem 1rem; border-radius: 14px; }

/* ---------- Motion helpers ---------- */
.pop-in { animation: pop-in .6s cubic-bezier(.2, 1.6, .4, 1) backwards; animation-delay: var(--delay, 0s); }
@keyframes pop-in { from { opacity: 0; transform: scale(.6) translateY(30px); } to { opacity: 1; transform: none; } }
.bounce { animation: bounce 1.6s ease-in-out infinite; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }
@keyframes wobble { 0%, 100% { transform: rotate(-10deg); } 50% { transform: rotate(10deg); } }
.wiggle-hover:hover { animation: wobble .4s ease-in-out 2; }
.shake { animation: shake .45s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.pulse { animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 6px 0 #c79a00, 0 0 0 0 rgba(255,210,63,.6); } 50% { box-shadow: 0 6px 0 #c79a00, 0 0 0 16px rgba(255,210,63,0); } }
.spin-slow { display: inline-block; animation: wobble 2s ease-in-out infinite; }
.dots::after { content: ''; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* ---------- Front page hero ---------- */
.hero {
    position: relative; overflow: hidden; text-align: center;
    padding: 4rem 1rem 6rem; border-radius: 32px;
    background: linear-gradient(135deg, rgba(123,92,255,.35), rgba(255,77,109,.25));
    border: 2px solid var(--card-border);
}
.hero-inner { position: relative; z-index: 1; }
.kicker { font-family: var(--pixel); font-size: .7rem; color: var(--yellow); letter-spacing: 1px; }
.title { font-family: var(--pixel); font-size: clamp(2rem, 8vw, 4.6rem); margin: .6rem 0 1rem; text-shadow: 5px 5px 0 #2a1660; }
.wave-letter { display: inline-block; animation: wave 1.8s ease-in-out infinite; animation-delay: calc(var(--i) * .1s); }
.wave-letter:nth-child(3n) { color: var(--yellow); }
.wave-letter:nth-child(3n+1) { color: var(--mint); }
.wave-letter:nth-child(3n+2) { color: #ff9fb2; }
@keyframes wave { 0%, 60%, 100% { transform: translateY(0) rotate(0); } 30% { transform: translateY(-18px) rotate(-6deg); } }
.title-sub { display: inline-block; font-size: .7em; margin-top: .4rem; text-shadow: none; filter: drop-shadow(4px 4px 0 #2a1660); animation: rainbow 4s linear infinite, zoom 2.4s ease-in-out infinite; }
@keyframes zoom { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.lead { font-size: clamp(1.05rem, 2.2vw, 1.35rem); max-width: 700px; margin: 0 auto 1.8rem; }
.cta-row { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: center; }

.floaters { position: absolute; inset: 0; pointer-events: none; }
.floater {
    position: absolute; left: var(--x); bottom: -3rem; font-size: var(--s);
    animation: float-up var(--d) linear infinite; animation-delay: calc(var(--i) * -.9s);
    opacity: .85; filter: drop-shadow(0 4px 6px rgba(0,0,0,.3));
}
@keyframes float-up {
    0% { transform: translateY(0) rotate(0); opacity: 0; }
    10% { opacity: .85; }
    50% { transform: translateY(-260px) translateX(30px) rotate(180deg); }
    90% { opacity: .85; }
    100% { transform: translateY(-560px) translateX(-20px) rotate(360deg); opacity: 0; }
}

.runner {
    position: absolute; bottom: 12px; left: 0; width: 100%; height: 40px; font-size: 2rem;
    border-top: 4px dashed rgba(255,255,255,.25);
}
.runner > span:first-child { position: absolute; bottom: 0; animation: run 7s linear infinite; transform: scaleX(-1); }
.coin { position: absolute; bottom: 4px; font-size: 1.4rem; animation: coin-spin 1s linear infinite; }
.coin:nth-child(2) { left: 30%; }
.coin:nth-child(3) { left: 55%; }
.coin:nth-child(4) { left: 80%; }
@keyframes run {
    0% { left: -5%; } 100% { left: 102%; }
}
@keyframes coin-spin { 0%, 100% { transform: scaleX(1); } 50% { transform: scaleX(.15); } }

/* ---------- Rules ---------- */
.rule-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.3rem; }
.rule-card {
    position: relative; padding: 1.6rem 1.4rem 1.3rem; border-radius: var(--radius);
    background: var(--card); border: 2px solid var(--card-border);
    rotate: var(--tilt); transition: transform .25s, rotate .25s, box-shadow .25s;
}
.rule-card:hover { rotate: 0deg; transform: translateY(-8px) scale(1.03); box-shadow: 0 16px 30px rgba(0,0,0,.35); }
.rule-card:nth-child(6n+1) { border-color: var(--pink); }
.rule-card:nth-child(6n+2) { border-color: var(--yellow); }
.rule-card:nth-child(6n+3) { border-color: var(--mint); }
.rule-card:nth-child(6n+4) { border-color: var(--blue); }
.rule-card:nth-child(6n+5) { border-color: var(--orange); }
.rule-card:nth-child(6n+6) { border-color: var(--purple); }
.rule-num {
    position: absolute; top: -16px; left: -10px; width: 42px; height: 42px; border-radius: 50%;
    display: grid; place-items: center; font-family: var(--pixel); font-size: .9rem;
    background: var(--yellow); color: #2a1660; box-shadow: 0 4px 0 #c79a00;
}
.rule-icon { font-size: 2.6rem; display: inline-block; transition: transform .3s; }
.rule-card:hover .rule-icon { transform: scale(1.3) rotate(-12deg); }
.rule-card p { color: var(--muted); margin: 0; }
.rule-text { white-space: pre-line; }
.rule-card:first-child { grid-column: span 2; display: flex; flex-direction: column; justify-content: center; }
.rule-card:first-child .rule-icon { font-size: 3.6rem; }
.rule-card:first-child h3 { font-size: 1.8rem; }
.rule-card:first-child p { font-size: 1.2rem; }
/* Big first card takes 2 cells, so the last card also takes 2 to keep the rows even. */
.rule-card:last-child { grid-column: span 2; }
@media (max-width: 1000px) { .rule-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) {
    .rule-grid { grid-template-columns: 1fr; }
    .rule-card:first-child, .rule-card:last-child { grid-column: auto; }
}

.point-row { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: center; margin: 1.5rem 0; }
.point-chip {
    width: 170px; text-align: center; padding: 1.1rem; border-radius: var(--radius);
    background: var(--card); border: 2px solid var(--card-border); transition: transform .2s;
}
.point-chip:hover { transform: translateY(-6px) rotate(2deg); }
.point-stars { color: var(--yellow); font-size: 1.4rem; letter-spacing: 2px; text-shadow: 0 0 12px rgba(255,210,63,.7); }
.point-value { font-family: var(--pixel); font-size: 2rem; margin: .4rem 0; }
.point-label { font-weight: 700; }
.trophy-box {
    display: flex; align-items: center; gap: 1.2rem; max-width: 720px; margin: 1rem auto 0; padding: 1.2rem 1.6rem;
    border-radius: var(--radius); background: linear-gradient(135deg, rgba(255,210,63,.25), rgba(255,140,66,.2));
    border: 2px solid var(--yellow); font-size: 1.15rem;
}
.trophy { font-size: 3.5rem; animation: bounce 1.4s ease-in-out infinite, glow 2s ease-in-out infinite; }
@keyframes glow { 0%, 100% { filter: drop-shadow(0 0 0 transparent); } 50% { filter: drop-shadow(0 0 18px var(--yellow)); } }

/* ---------- Winner page ---------- */
.podium {
    position: relative; overflow: hidden; text-align: center; padding: 2rem 1rem 1.5rem; margin-bottom: 1.5rem;
    border-radius: 28px; border: 3px solid var(--yellow);
    background: linear-gradient(135deg, rgba(255,210,63,.25), rgba(255,77,109,.25));
}
.crown { font-size: 3.5rem; }
.leader-name { font-family: var(--pixel); font-size: clamp(1.2rem, 4vw, 2.2rem); margin: .3rem 0; }
.leader-score { font-size: 1.3rem; margin: 0; }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i {
    position: absolute; top: -12px; left: var(--x); width: 8px; height: 14px; background: var(--c); border-radius: 2px;
    animation: confetti-fall calc(3s + var(--i) * .08s) linear infinite; animation-delay: calc(var(--i) * -.17s);
}
@keyframes confetti-fall { to { transform: translateY(260px) rotate(720deg); } }

.leaderboard h2 { margin-top: 0; }
.scores { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .5rem; }
.score-row {
    display: grid; grid-template-columns: 50px minmax(120px, 1.3fr) 2fr 80px; align-items: center; gap: .8rem;
    padding: .55rem .8rem; border-radius: 14px; background: rgba(255,255,255,.05); transition: background .3s;
}
.score-row.first { background: rgba(255,210,63,.18); }
.rank { font-size: 1.5rem; text-align: center; font-weight: 700; }
.score-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 16px; background: rgba(255,255,255,.1); border-radius: 999px; overflow: hidden; }
.fill {
    display: block; height: 100%; border-radius: 999px;
    background: linear-gradient(90deg, var(--mint), var(--blue), var(--purple), var(--pink));
    background-size: 200% 100%; animation: rainbow 3s linear infinite; transition: width .8s cubic-bezier(.2, 1.4, .4, 1);
}
.score-pts { font-family: var(--pixel); font-size: .9rem; text-align: right; }

.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1.3rem; margin-top: 1rem; }
.game-card {
    display: flex; flex-direction: column; gap: .5rem; padding: 1rem; border-radius: var(--radius);
    background: var(--card); border: 2px solid var(--card-border); transition: transform .2s, box-shadow .2s;
}
.game-card:hover { transform: translateY(-6px); box-shadow: 0 16px 30px rgba(0,0,0,.35); }
.game-card.mine { border-style: dashed; border-color: var(--mint); }
.game-thumb {
    height: 120px; border-radius: 16px; display: grid; place-items: center; overflow: hidden;
    background: linear-gradient(135deg, hsl(var(--hue) 85% 60%), hsl(calc(var(--hue) + 60) 85% 45%));
}
.game-thumb-emoji { font-size: 3.6rem; animation: bounce 2s ease-in-out infinite; }
.game-card:hover .game-thumb-emoji { animation: wobble .5s ease-in-out infinite; }
.game-title { margin: .2rem 0 0; font-size: 1.25rem; }
.game-card p { margin: 0; }
.vote-area { display: flex; flex-direction: column; align-items: center; gap: .4rem; margin-top: .4rem; min-height: 70px; justify-content: center; }
.vote-buttons { display: flex; gap: .4rem; }
.vote-btn {
    width: 50px; height: 50px; border-radius: 14px; cursor: pointer; font: inherit; font-weight: 700;
    display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1;
    background: rgba(255,255,255,.1); color: var(--ink); border: 2px solid rgba(255,255,255,.25);
    transition: transform .15s, background .2s;
}
.vote-btn .star { font-size: 1.3rem; color: rgba(255,255,255,.4); transition: color .2s, transform .3s; }
.vote-btn .num { font-size: .75rem; }
.vote-btn:hover { transform: scale(1.15) rotate(-5deg); background: rgba(255,210,63,.25); }
.vote-btn.lit .star { color: var(--yellow); text-shadow: 0 0 10px rgba(255,210,63,.8); }
.vote-btn.selected { border-color: var(--yellow); background: rgba(255,210,63,.3); }
.vote-btn.selected .star { animation: star-pop .5s cubic-bezier(.2, 1.8, .4, 1); }
@keyframes star-pop { from { transform: scale(.3) rotate(-90deg); } to { transform: scale(1) rotate(0); } }
.vote-buttons:hover .vote-btn .star { color: var(--yellow); }
.vote-buttons .vote-btn:hover ~ .vote-btn .star { color: rgba(255,255,255,.4); text-shadow: none; }
.vote-label { color: var(--muted); }

/* ---------- Login + admin ---------- */
.login-wrap { display: grid; place-items: center; min-height: 60vh; }
.login-card { width: min(440px, 100%); text-align: center; }
.login-card form { text-align: left; margin-top: 1rem; }
.login-card .btn { width: 100%; margin-top: .5rem; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 1rem; }
.span-2 { grid-column: 1 / -1; }
.my-game { max-width: 760px; margin-inline: auto; }
.my-game-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.my-game-head h2 { margin: 0; }
.my-game-head p { margin: .25rem 0 0; }
.my-game-icon { font-size: 3.5rem; animation: bounce 2.5s ease-in-out infinite; }
.my-game-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.input-with-button { display: flex; gap: .5rem; align-items: stretch; }
.input-with-button input { flex: 1; min-width: 0; }
.dice { white-space: nowrap; }
.dice:hover { animation: wobble .4s ease-in-out 2; }
.rule-editor { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; align-items: start; }
.rule-editor textarea {
    font: inherit; font-weight: 400; padding: .65rem .85rem; border-radius: 12px; resize: vertical;
    border: 2px solid rgba(255,255,255,.25); background: rgba(10, 5, 35, .55); color: var(--ink);
}
.rule-editor textarea:focus { outline: none; border-color: var(--yellow); box-shadow: 0 0 0 4px rgba(255,210,63,.25); }
.rule-card.rule-preview { rotate: -1.5deg; margin-top: 1rem; border-color: var(--pink); }
.rule-preview .rule-icon { font-size: 3.6rem; }
.rule-preview h3 { font-size: 1.8rem; }
.rule-preview p { font-size: 1.2rem; }
@media (max-width: 800px) { .rule-editor { grid-template-columns: 1fr; } }
.actions.wrap { flex-wrap: wrap; white-space: normal; gap: .5rem; }
.btn-ai {
    color: #fff; background: linear-gradient(135deg, var(--purple), var(--blue));
    box-shadow: 0 6px 0 #3d2a99;
}
.btn-ai:hover { color: #fff; }
.spin { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { padding: .6rem .5rem; text-align: left; border-bottom: 1px solid rgba(255,255,255,.12); vertical-align: middle; }
.admin-table th { color: var(--yellow); font-size: .9rem; }
.admin-table input, .admin-table select { width: 100%; min-width: 120px; padding: .4rem .6rem; }
.admin-table tbody tr { transition: background .2s; }
.admin-table tbody tr:hover { background: rgba(255,255,255,.05); }
.link-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { white-space: nowrap; display: flex; gap: .3rem; }
.role-badge { padding: .2rem .6rem; border-radius: 999px; font-size: .85rem; font-weight: 700; }
.role-badge.admin { background: rgba(255,210,63,.25); color: var(--yellow); }
.role-badge.user { background: rgba(59,206,172,.2); color: var(--mint); }
.user-icon { font-size: 1.8rem; text-align: center; }
.admin-table .icon-select { min-width: 150px; }
.score-icon { font-size: 1.3rem; }

/* ---------- Blazor framework UI ---------- */
#blazor-error-ui {
    color-scheme: light only; background: lightyellow; color: #000; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2);
    box-sizing: border-box; display: none; left: 0; padding: .6rem 1.25rem .7rem; position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; border-radius: 12px; }
.blazor-error-boundary::after { content: "An error has occurred."; }

@media (max-width: 640px) {
    .score-row { grid-template-columns: 40px 1fr 70px; }
    .score-row .bar { display: none; }
    .trophy-box { flex-direction: column; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
