:root {
    --bg: #0f0f14;
    --bg-card: #1a1a24;
    --bg-elevated: #242433;
    --text: #f0f0f8;
    --text-muted: #9898b0;
    --accent: #7c5cff;
    --accent-hover: #9b82ff;
    --gold: #f0c040;
    --silver: #b8c0d0;
    --ssr-start: #ff6b9d;
    --ssr-mid: #c44dff;
    --ssr-end: #4dc4ff;
    --success: #4ade80;
    --warn: #fbbf24;
    --danger: #f87171;
    --radius: 12px;
    --font: "Segoe UI", system-ui, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

.hidden {
    display: none !important;
}

a {
    color: var(--accent-hover);
}

/* Nav */
.nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    background: var(--bg-card);
    border-bottom: 1px solid #2a2a3a;
    flex-wrap: wrap;
}

.brand {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text);
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 0.25rem;
    flex: 1;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    font-size: 0.9rem;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--text);
    background: var(--bg-elevated);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-pill {
    font-size: 0.85rem;
    color: var(--gold);
}

/* Layout */
main {
    max-width: 960px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 3rem;
}

h1 {
    font-size: 1.75rem;
    margin: 0 0 0.5rem;
}

.subtitle {
    color: var(--text-muted);
    margin: 0 0 1.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.55rem 1.1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.15s;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #5a3fd4);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--accent-hover), #6b52e8);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid #3a3a4a;
}

.btn-ghost:hover {
    color: var(--text);
    border-color: #5a5a6a;
}

.btn-sm {
    padding: 0.35rem 0.7rem;
    font-size: 0.85rem;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.25rem;
}

.btn-danger {
    background: var(--danger);
    color: #1a1a1a;
}

.btn-gacha {
    font-size: 1.15rem;
    padding: 0.85rem 2rem;
    background: linear-gradient(135deg, #f0c040, #e09020);
    color: #1a1000;
    box-shadow: 0 4px 24px rgba(240, 192, 64, 0.35);
}

.btn-gacha:hover:not(:disabled) {
    box-shadow: 0 6px 32px rgba(240, 192, 64, 0.5);
}

/* Cards & stats */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1rem 1.15rem;
    border: 1px solid #2a2a3a;
}

.stat-card .label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-card .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gold);
}

.panel {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid #2a2a3a;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.panel h2 {
    margin: 0 0 1rem;
    font-size: 1.1rem;
}

/* Banner */
.banner {
    padding: 0.85rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    font-size: 0.92rem;
}

.banner-warn {
    background: rgba(251, 191, 36, 0.12);
    border: 1px solid rgba(251, 191, 36, 0.35);
    color: #fde68a;
}

.banner-ok {
    background: rgba(74, 222, 128, 0.1);
    border: 1px solid rgba(74, 222, 128, 0.3);
    color: #86efac;
}

.banner a {
    margin-left: 0.5rem;
}

/* Pool checklist */
.pool-pips {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin: 0.75rem 0;
}

.pool-pip {
    padding: 0.3rem 0.65rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}

.pool-pip.ok {
    background: rgba(74, 222, 128, 0.15);
    color: var(--success);
}

.pool-pip.missing {
    background: rgba(248, 113, 113, 0.15);
    color: var(--danger);
}

/* Lists */
.item-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.item-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid #2a2a3a;
}

.item-row:last-child {
    border-bottom: none;
}

.item-row .title {
    flex: 1;
    font-weight: 500;
}

.item-row .meta {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
}

.tier-r .badge,
.badge.tier-r {
    background: #3a3a48;
    color: var(--silver);
}

.tier-sr .badge,
.badge.tier-sr {
    background: rgba(240, 192, 64, 0.2);
    color: var(--gold);
}

.tier-ssr .badge,
.badge.tier-ssr {
    background: linear-gradient(90deg, var(--ssr-start), var(--ssr-mid));
    color: white;
}

/* Forms */
.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

input,
select {
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border: 1px solid #3a3a4a;
    background: var(--bg);
    color: var(--text);
    font-size: 0.95rem;
}

input:focus,
select:focus {
    outline: 2px solid var(--accent);
    border-color: transparent;
}

label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.checkbox-label {
    flex-direction: row;
    align-items: center;
    color: var(--text);
}

/* Auth */
.auth-screen {
    max-width: 400px;
    margin: 4rem auto;
    padding: 2rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid #2a2a3a;
}

.auth-screen h1 {
    text-align: center;
}

.auth-screen form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-screen input {
    width: 100%;
}

.auth-error {
    color: var(--danger);
    font-size: 0.9rem;
}

.auth-switch {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
}

.tab {
    padding: 0.45rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 8px;
    font-weight: 600;
}

.tab.active {
    background: var(--bg-elevated);
    color: var(--text);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    background: var(--bg-elevated);
    color: var(--text);
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    border: 1px solid #3a3a4a;
    z-index: 9000;
    transition: transform 0.3s;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast-success {
    border-color: var(--success);
}

.toast-error {
    border-color: var(--danger);
}

/* Gacha page */
.gacha-center {
    text-align: center;
    padding: 2rem 0;
}

.gacha-orb {
    width: 120px;
    height: 120px;
    margin: 0 auto 1.5rem;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #fff8e0, var(--gold) 40%, #a06010);
    box-shadow: 0 0 60px rgba(240, 192, 64, 0.4);
    animation: orb-pulse 2s ease-in-out infinite;
}

@keyframes orb-pulse {
    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 0 60px rgba(240, 192, 64, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 80px rgba(240, 192, 64, 0.6);
    }
}

.inline-warn {
    color: var(--warn);
    font-size: 0.85rem;
    margin-top: 0.35rem;
}

/* Pull ceremony */
.ceremony-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
}

.ceremony-overlay.ssr-moment {
    animation: ssr-flash 0.4s ease;
}

@keyframes ssr-flash {
    0%,
    100% {
        background: rgba(0, 0, 0, 0.92);
    }
    50% {
        background: rgba(80, 20, 120, 0.95);
    }
}

.ceremony-vignette {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 30%, rgba(0, 0, 0, 0.6) 100%);
}

.ceremony-stage {
    position: relative;
    text-align: center;
    width: 100%;
    max-width: 360px;
}

.ceremony-stage.hidden {
    display: none;
}

.ceremony-progress {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    letter-spacing: 0.1em;
}

.ceremony-card-wrap {
    perspective: 1000px;
    position: relative;
    margin: 0 auto;
}

.ceremony-card {
    width: 220px;
    height: 300px;
    margin: 0 auto;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}

.ceremony-card.flipped {
    transform: rotateY(180deg);
}

.ceremony-card.suspense {
    animation: card-pulse 0.6s ease-in-out infinite;
}

.ceremony-card.suspense-ssr {
    animation: card-pulse 0.35s ease-in-out infinite, shake 0.2s ease infinite;
}

.ceremony-card.shake {
    animation: shake 0.15s ease;
}

@keyframes card-pulse {
    0%,
    100% {
        filter: brightness(1);
    }
    50% {
        filter: brightness(1.2);
    }
}

@keyframes shake {
    0%,
    100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-4px);
    }
    75% {
        transform: translateX(4px);
    }
}

.ceremony-card.reveal-flash {
    filter: brightness(1.5);
}

.ceremony-card-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.ceremony-card-back {
    background: linear-gradient(145deg, #2a2040, #1a1030);
    border: 2px solid #5a4080;
    box-shadow: 0 8px 32px rgba(124, 92, 255, 0.3);
}

.card-logo {
    font-size: 4rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-hover), var(--gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 2s linear infinite;
}

@keyframes shimmer {
    0% {
        filter: hue-rotate(0deg);
    }
    100% {
        filter: hue-rotate(30deg);
    }
}

.ceremony-card-front {
    transform: rotateY(180deg);
    background: var(--bg-card);
    border: 3px solid var(--silver);
}

.ceremony-card-front.r {
    border-color: var(--silver);
    box-shadow: 0 0 24px rgba(184, 192, 208, 0.3);
}

.ceremony-card-front.sr {
    border-color: var(--gold);
    box-shadow: 0 0 40px rgba(240, 192, 64, 0.5);
}

.ceremony-card-front.ssr {
    border: 3px solid transparent;
    background:
        linear-gradient(var(--bg-card), var(--bg-card)) padding-box,
        linear-gradient(135deg, var(--ssr-start), var(--ssr-mid), var(--ssr-end)) border-box;
    box-shadow: 0 0 60px rgba(196, 77, 255, 0.6);
    animation: ssr-border 1.5s linear infinite;
}

@keyframes ssr-border {
    0% {
        filter: hue-rotate(0deg);
    }
    100% {
        filter: hue-rotate(360deg);
    }
}

.tier-badge {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
}

.ceremony-card-front.r .tier-badge {
    color: var(--silver);
}

.ceremony-card-front.sr .tier-badge {
    color: var(--gold);
}

.ceremony-card-front.ssr .tier-badge {
    background: linear-gradient(90deg, var(--ssr-start), var(--ssr-end));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.reward-title {
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
}

.ceremony-particles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.particle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: particle-burst 0.9s ease-out forwards;
}

.particle-r {
    background: var(--silver);
}

.particle-sr {
    background: var(--gold);
}

.particle-ssr {
    background: var(--ssr-mid);
    width: 10px;
    height: 10px;
}

@keyframes particle-burst {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--px), var(--py)) scale(0);
        opacity: 0;
    }
}

.ceremony-tap-hint {
    margin-top: 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.3s;
}

.ceremony-tap-hint.visible {
    opacity: 1;
    animation: pulse-hint 1.5s ease infinite;
}

@keyframes pulse-hint {
    0%,
    100% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
}

.ceremony-summary {
    text-align: center;
    padding: 1rem;
    max-width: 640px;
}

.ceremony-summary.hidden {
    display: none;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 0.65rem;
    margin: 1.25rem 0 1.5rem;
}

.summary-card {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 0.65rem;
    border: 2px solid #3a3a4a;
    font-size: 0.8rem;
}

.summary-card.r {
    border-color: var(--silver);
}

.summary-card.sr {
    border-color: var(--gold);
}

.summary-card.ssr {
    border-color: var(--ssr-mid);
    box-shadow: 0 0 16px rgba(196, 77, 255, 0.4);
}

.summary-card.best {
    transform: scale(1.05);
    z-index: 1;
}

.summary-card .tier-badge {
    font-size: 0.85rem;
    margin-bottom: 0.35rem;
}

.summary-card .reward-title {
    font-size: 0.75rem;
}

@media (prefers-reduced-motion: reduce) {
    .gacha-orb,
    .ceremony-card.suspense,
    .ceremony-card.suspense-ssr,
    .card-logo,
    .ceremony-card-front.ssr {
        animation: none;
    }
}
