:root {
    --primary: #ff6b35;
    --primary-glow: #ff8c5a;
    --primary-dark: #e55a2b;
    --secondary: #00d4aa;
    --secondary-glow: #00f5c4;
    --accent: #a855f7;
    --accent-glow: #c084fc;
    --bg-dark: #050508;
    --bg-card: #0c0c12;
    --text-white: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.5);
    --glass-bg: rgba(255, 255, 255, 0.025);
    --glass-border: rgba(255, 255, 255, 0.06);
    --glass-highlight: rgba(255, 255, 255, 0.08);
    --shadow-dark: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 80px rgba(255, 107, 53, 0.25);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text-white);
    min-height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.bg-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.4;
    pointer-events: none;
    animation: orbFloat 20s ease-in-out infinite;
}

.orb-1 {
    width: 400px;
    height: 400px;
    background: var(--primary);
    top: -100px;
    left: -100px;
    animation-delay: 0s;
}

.orb-2 {
    width: 300px;
    height: 300px;
    background: var(--accent);
    bottom: -50px;
    right: -50px;
    animation-delay: -7s;
}

.orb-3 {
    width: 200px;
    height: 200px;
    background: var(--secondary);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -14s;
    opacity: 0.2;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -30px) scale(1.1); }
    50% { transform: translate(-20px, 20px) scale(0.9); }
    75% { transform: translate(20px, 10px) scale(1.05); }
}

.bg-grid {
    position: fixed;
    inset: 0;
    background-image: 
        linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
    background-size: 50px 50px;
    mask-image: radial-gradient(ellipse at center, black 20%, transparent 70%);
    pointer-events: none;
}

.particles {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.particle {
    position: absolute;
    border-radius: 50%;
    opacity: 0;
    animation: particleFloat linear infinite;
}

@keyframes particleFloat {
    0% {
        transform: translateY(100vh) rotate(0deg) scale(0);
        opacity: 0;
    }
    5% {
        opacity: 0.8;
    }
    95% {
        opacity: 0.3;
    }
    100% {
        transform: translateY(-100vh) rotate(720deg) scale(1);
        opacity: 0;
    }
}

#app {
    width: 100%;
    max-width: 480px;
    padding: 0.75rem;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

main {
    width: 100%;
    position: relative;
}

.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
    padding: 2.5rem 2rem;
    background: linear-gradient(180deg, rgba(12, 12, 18, 0.95) 0%, rgba(5, 5, 8, 0.98) 100%);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-radius: 36px;
    border: 1px solid var(--glass-border);
    box-shadow: 
        var(--shadow-dark),
        inset 0 1px 0 rgba(255, 255, 255, 0.03);
    min-height: 620px;
    position: relative;
    overflow: hidden;
}

.screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
}

.screen::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: linear-gradient(to top, rgba(5, 5, 8, 0.5), transparent);
    pointer-events: none;
}

.screen.active {
    display: flex;
    animation: screenEnter 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes screenEnter {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
        filter: blur(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

.screen.exit {
    animation: screenExit 0.35s cubic-bezier(0.7, 0, 0.3, 1) forwards;
}

@keyframes screenExit {
    to {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
        filter: blur(10px);
    }
}

/* Screen 1 - Landing */
.logo-wrapper {
    position: relative;
    margin-bottom: 1.75rem;
}

.logo-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 140px;
    height: 140px;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(255, 107, 53, 0.4) 0%, transparent 70%);
    animation: glowPulse 2s ease-in-out infinite;
}

@keyframes glowPulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.6; }
    50% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
}

.logo-icon {
    width: 100px;
    height: 100px;
    background: linear-gradient(145deg, var(--primary) 0%, var(--primary-glow) 50%, var(--primary-dark) 100%);
    border-radius: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    box-shadow: 
        0 20px 40px rgba(255, 107, 53, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset;
    animation: logoFloat 4s ease-in-out infinite;
    position: relative;
    z-index: 1;
}

@keyframes logoFloat {
    0%, 100% { transform: translateY(0) rotate(-2deg); }
    50% { transform: translateY(-12px) rotate(2deg); }
}

.title {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    margin-bottom: 0.75rem;
}

.title-line {
    font-family: 'Syne', sans-serif;
    font-size: 2.8rem;
    font-weight: 800;
    color: var(--text-white);
    letter-spacing: -2px;
    line-height: 1.1;
}

.title-line.accent {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-glow) 50%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: titleShimmer 4s ease-in-out infinite;
    background-size: 200% 100%;
}

@keyframes titleShimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.tagline {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 400;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 2.5rem;
}

.tagline-dot {
    width: 4px;
    height: 4px;
    background: var(--primary);
    border-radius: 50%;
    animation: dotPulse 1.5s ease-in-out infinite;
}

@keyframes dotPulse {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.3); }
}

.version {
    position: absolute;
    bottom: 1.25rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 2px;
    opacity: 0.4;
}

/* Screen 2 - Rules */
.screen-header {
    margin-bottom: 2rem;
}

.icon-wrapper {
    position: relative;
    display: inline-block;
    margin-bottom: 1rem;
}

.screen-icon {
    font-size: 3.5rem;
    position: relative;
    z-index: 1;
    animation: iconBounce 2.5s ease-in-out infinite;
}

@keyframes iconBounce {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-8px) scale(1.08); }
}

.icon-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100px;
    height: 100px;
    transform: translate(-50%, -50%);
    border: 2px solid var(--glass-border);
    border-radius: 50%;
    animation: ringExpand 3s ease-in-out infinite;
}

@keyframes ringExpand {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.5; }
    50% { transform: translate(-50%, -50%) scale(1.3); opacity: 0; }
}

.screen h2 {
    font-family: 'Syne', sans-serif;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-white);
    letter-spacing: -0.5px;
}

.rules-container {
    width: 100%;
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.rule-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, var(--glass-bg) 0%, rgba(255, 107, 53, 0.03) 100%);
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    text-align: left;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.rule-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, var(--primary), var(--accent));
    opacity: 0;
    transition: opacity 0.3s;
}

.rule-card:hover {
    background: var(--glass-highlight);
    transform: translateX(6px);
    border-color: rgba(255, 107, 53, 0.2);
}

.rule-card:hover::before {
    opacity: 1;
}

.rule-icon {
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 107, 53, 0.1);
    border-radius: 12px;
}

.rule-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.rule-num {
    font-family: 'Syne', sans-serif;
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--primary);
    background: rgba(255, 107, 53, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
}

.rule-content p {
    font-size: 0.9rem;
    color: var(--text-white);
    font-weight: 400;
    line-height: 1.4;
}

/* Premium Buttons */
.premium-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1rem 2.5rem;
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.premium-btn.start-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-glow) 100%);
    box-shadow: 
        0 8px 30px rgba(255, 107, 53, 0.35),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset;
    padding: 1.125rem 3rem;
}

.premium-btn.start-btn:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 
        0 20px 50px rgba(255, 107, 53, 0.45),
        0 0 30px rgba(255, 107, 53, 0.3);
}

.btn-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.3s;
}

.premium-btn:hover .btn-bg {
    opacity: 1;
}

.btn-text {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    z-index: 1;
}

.btn-arrow {
    width: 20px;
    height: 20px;
    transition: transform 0.3s;
}

.premium-btn:hover .btn-arrow {
    transform: translateX(4px);
}

.btn-particles {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.premium-btn.play-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-glow) 100%);
    box-shadow: 0 8px 30px rgba(255, 107, 53, 0.35);
    padding: 1.125rem 3rem;
}

.btn-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    z-index: 1;
}

.btn-icon {
    font-size: 1.2rem;
}

.btn-glow {
    position: absolute;
    inset: -2px;
    background: linear-gradient(135deg, var(--primary-glow), var(--accent));
    filter: blur(15px);
    opacity: 0;
    transition: opacity 0.4s;
    z-index: -1;
    border-radius: 52px;
}

.premium-btn:hover .btn-glow {
    opacity: 0.5;
}

.premium-btn.secondary {
    background: var(--glass-bg);
    color: var(--text-white);
    border: 1px solid var(--glass-border);
    padding: 0.875rem 1.5rem;
}

.premium-btn.secondary:hover {
    background: var(--glass-highlight);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.premium-btn.secondary svg {
    width: 16px;
    height: 16px;
}

.premium-btn.large {
    padding: 1.125rem 3rem;
    font-size: 1.05rem;
}

.btn-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
}

.premium-btn:active {
    transform: translateY(-1px) scale(0.98);
}

/* Screen 3 - Game */
.game-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.deck-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.deck-visual {
    display: flex;
    align-items: center;
}

.deck-stack {
    position: relative;
    width: 50px;
    height: 70px;
}

.deck-card {
    position: absolute;
    width: 45px;
    height: 65px;
    background: linear-gradient(145deg, #1a1a24 0%, #0c0c12 100%);
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.deck-card:nth-child(1) { top: 0; left: 0; transform: translate(-10px, -5px); }
.deck-card:nth-child(2) { top: 2px; left: 2px; }
.deck-card:nth-child(3) { top: 4px; left: 4px; transform: translate(10px, 5px); }

.deck-info {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.deck-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.deck-count {
    font-family: 'Syne', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-white);
}

.card-counter {
    display: flex;
    align-items: baseline;
    gap: 3px;
    padding: 0.5rem 1rem;
    background: var(--glass-bg);
    border-radius: 24px;
    border: 1px solid var(--glass-border);
    position: relative;
}

.counter-ring {
    position: absolute;
    inset: -3px;
    border: 1px solid rgba(255, 107, 53, 0.2);
    border-radius: 28px;
    animation: ringPulse 2s ease-in-out infinite;
}

@keyframes ringPulse {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.02); }
}

.counter-current {
    font-family: 'Syne', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.counter-divider {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.counter-total {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Card Container */
#cardContainer {
    perspective: 1200px;
    width: 100%;
    height: 300px;
    margin-bottom: 1.25rem;
    position: relative;
}

.card-trail {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 24px;
    opacity: 0;
    transform: translate(10px, 10px) scale(0.95);
    filter: blur(8px);
    transition: all 0.3s ease;
}

.card-trail.trail-2 {
    transform: translate(5px, 5px) scale(0.97);
    filter: blur(4px);
    opacity: 0;
}

.card.flipping .card-trail {
    opacity: 0.4;
    transform: translate(8px, 8px) scale(0.96);
}

.card.flipping .trail-2 {
    opacity: 0.25;
    transform: translate(4px, 4px) scale(0.98);
}

.card.pop .card-trail,
.card.pop .trail-2 {
    opacity: 0;
    transform: translate(0, 0) scale(1);
}

.card {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.card.flipping {
    animation: cardFlip 0.5s ease-in-out;
}

@keyframes cardFlip {
    0% { transform: rotateY(0deg) scale(1); }
    50% { transform: rotateY(90deg) scale(0.95); }
    100% { transform: rotateY(0deg) scale(1); }
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
}

.card-front {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    background: linear-gradient(145deg, #fafafa 0%, #f0f0f5 100%);
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    box-shadow: 
        0 30px 60px -15px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.5) inset,
        0 -2px 10px rgba(255, 255, 255, 0.3) inset;
    overflow: hidden;
}

.card-shine {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent 30%,
        rgba(255, 255, 255, 0.4) 50%,
        transparent 70%
    );
    animation: cardShine 4s ease-in-out infinite;
}

@keyframes cardShine {
    0%, 100% { transform: translateX(-100%) rotate(45deg); }
    50% { transform: translateX(100%) rotate(45deg); }
}

.card-holo {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        rgba(255, 107, 53, 0.1) 0%,
        rgba(168, 85, 247, 0.1) 25%,
        rgba(0, 212, 170, 0.1) 50%,
        rgba(255, 107, 53, 0.1) 75%,
        rgba(168, 85, 247, 0.1) 100%
    );
    background-size: 200% 200%;
    animation: holoShift 5s ease-in-out infinite;
    pointer-events: none;
}

@keyframes holoShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.card-corner {
    position: absolute;
    font-size: 1rem;
    opacity: 0.3;
}

.card-corner.top-left { top: 12px; left: 12px; }
.card-corner.top-right { top: 12px; right: 12px; transform: rotate(90deg); }
.card-corner.bottom-left { bottom: 12px; left: 12px; transform: rotate(-90deg); }
.card-corner.bottom-right { bottom: 12px; right: 12px; transform: rotate(180deg); }

.card-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    z-index: 1;
}

.card-suit {
    font-size: 2.25rem;
    animation: suitPulse 2s ease-in-out infinite;
}

@keyframes suitPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

.card-text {
    font-family: 'Outfit', sans-serif;
    font-size: 1.15rem;
    font-weight: 600;
    color: #1a1a2e;
    text-align: center;
    line-height: 1.45;
    max-width: 90%;
}

.card.special-wave {
    animation: cardWave 0.8s ease-in-out;
}

@keyframes cardWave {
    0%, 100% { transform: rotateY(180deg) rotate(0deg) translateY(0); }
    25% { transform: rotateY(180deg) rotate(-3deg) translateY(-10px); }
    75% { transform: rotateY(180deg) rotate(3deg) translateY(-10px); }
}

.card.special-glow .card-front {
    box-shadow: 
        0 30px 60px -15px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.5) inset,
        0 0 50px rgba(255, 107, 53, 0.4),
        0 -2px 10px rgba(255, 255, 255, 0.3) inset;
}

@keyframes cardGlow {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.05); }
}

.card.pop {
    animation: cardPop 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cardPop {
    0% { transform: rotateY(180deg) scale(0.85); opacity: 0; }
    60% { transform: rotateY(180deg) scale(1.03); }
    100% { transform: rotateY(180deg) scale(1); opacity: 1; }
}

/* Controls */
.controls {
    display: flex;
    gap: 0.875rem;
    width: 100%;
    justify-content: center;
    align-items: center;
}

.controls .premium-btn.secondary {
    flex-shrink: 0;
}

.controls .premium-btn.primary {
    flex: 1;
    max-width: 180px;
}

/* Game Footer */
.game-footer {
    position: absolute;
    bottom: 1.5rem;
    left: 2rem;
    right: 2rem;
}

.progress-bar {
    height: 3px;
    background: var(--glass-border);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 2px;
    width: 0%;
    transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Sound Toggle */
.sound-toggle {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    width: 40px;
    height: 40px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 100;
}

.sound-toggle:hover {
    background: var(--glass-highlight);
    border-color: rgba(255, 255, 255, 0.15);
}

.sound-toggle svg {
    width: 18px;
    height: 18px;
    stroke: var(--text-muted);
}

/* Responsive */
@media (max-width: 480px) {
    .screen {
        padding: 2rem 1.5rem;
        min-height: 100vh;
        border-radius: 0;
    }
    
    .title-line {
        font-size: 2.2rem;
    }
    
    #cardContainer {
        height: 260px;
    }
    
    .card-text {
        font-size: 1rem;
    }
    
    .card-suit {
        font-size: 1.75rem;
    }
    
    .controls {
        flex-direction: column;
    }
    
    .controls .premium-btn.primary {
        max-width: none;
        width: 100%;
    }
    
    .game-footer {
        left: 1.5rem;
        right: 1.5rem;
    }
}

/* Animation delays for rules */
@media (hover: hover) {
    .screen.active .rule-card {
        animation: ruleSlideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) backwards;
    }
    
    .rule-card:nth-child(1) { animation-delay: 0.15s; }
    .rule-card:nth-child(2) { animation-delay: 0.25s; }
    .rule-card:nth-child(3) { animation-delay: 0.35s; }
    
    @keyframes ruleSlideIn {
        from {
            opacity: 0;
            transform: translateX(-25px);
        }
        to {
            opacity: 1;
            transform: translateX(0);
        }
    }
}
