:root {
    --bg-color: #050510;
    --accent-color: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.45);
    --accent-hover: #4f46e5;
    --emerald: #10b981;
    --emerald-glow: rgba(16, 185, 129, 0.4);
    --rose: #f43f5e;
    --amber: #f59e0b;
    --glass-bg: rgba(255, 255, 255, 0.035);
    --glass-card: rgba(255, 255, 255, 0.045);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-border-focus: rgba(99, 102, 241, 0.6);
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display: 'Outfit', sans-serif;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-main);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
    position: relative;
}

/* Background Blobs */
.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    filter: blur(85px);
    pointer-events: none;
}

.blob {
    position: absolute;
    border-radius: 50%;
    opacity: 0.45;
    animation: move 20s infinite alternate ease-in-out;
}

.blob-1 {
    width: 450px;
    height: 450px;
    background: #4f46e5;
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 500px;
    height: 500px;
    background: #7c3aed;
    bottom: -150px;
    right: -120px;
    animation-delay: -5s;
}

.blob-3 {
    width: 350px;
    height: 350px;
    background: #db2777;
    top: 45%;
    left: 50%;
    animation-delay: -10s;
}

@keyframes move {
    from { transform: translate(0, 0); }
    to { transform: translate(70px, 80px); }
}

/* Confetti Canvas */
#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

/* App Layout */
.app-layout {
    max-width: 1250px;
    margin: 0 auto;
    padding: 1.5rem 2rem 3rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    min-height: 100vh;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding-bottom: 0.5rem;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.5rem 0.9rem;
    border-radius: 12px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    transition: all 0.2s ease;
}

.back-link svg {
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease;
}

.back-link:hover {
    color: var(--text-primary);
    border-color: var(--accent-color);
    background: rgba(99, 102, 241, 0.12);
}

.back-link:hover svg {
    transform: translateX(-3px);
}

.brand-title {
    text-align: center;
}

.logo {
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo span {
    color: var(--accent-color);
    text-shadow: 0 0 20px var(--accent-glow);
}

.logo-sub {
    display: block;
    font-size: 0.82rem;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    margin-top: -2px;
}

.header-spacer {
    width: 135px;
}

@media (max-width: 600px) {
    .header-spacer {
        display: none;
    }
}

/* Glass Panel */
.glass-panel {
    background: var(--glass-card);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.35);
}

/* Main Content Grid */
.main-content {
    display: grid;
    grid-template-columns: 390px 1fr;
    gap: 2rem;
    align-items: start;
}

/* Left Input Panel */
.input-panel {
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.title-with-badge {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.title-with-badge h2 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
}

.counter-badge {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--accent-color);
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
}

.quick-links {
    display: flex;
    gap: 0.35rem;
}

.text-link-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.25rem 0.55rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.text-link-btn:hover {
    color: var(--text-primary);
    border-color: var(--accent-color);
    background: rgba(99, 102, 241, 0.15);
}

.text-link-btn.danger:hover {
    color: var(--rose);
    border-color: var(--rose);
    background: rgba(244, 63, 94, 0.15);
}

.input-container textarea {
    width: 100%;
    height: 220px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1rem;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.95rem;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-container textarea:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 15px var(--accent-glow);
}

/* Settings Box */
.settings-box {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 1rem;
}

.checkbox-option {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    cursor: pointer;
    user-select: none;
}

.checkbox-option input[type="checkbox"] {
    display: none;
}

.checkbox-custom {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    border: 1.5px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.checkbox-option input[type="checkbox"]:checked + .checkbox-custom {
    background: var(--accent-color);
    border-color: var(--accent-color);
    box-shadow: 0 0 8px var(--accent-glow);
}

.checkbox-option input[type="checkbox"]:checked + .checkbox-custom::after {
    content: "✓";
    font-size: 11px;
    color: #ffffff;
    font-weight: 700;
}

.checkbox-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Primary Button */
.action-footer {
    padding-top: 0.25rem;
}

.primary-glow-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    padding: 1rem;
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: #ffffff;
    border: none;
    border-radius: 14px;
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 20px var(--accent-glow);
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.primary-glow-btn svg {
    width: 22px;
    height: 22px;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.5));
}

.primary-glow-btn:hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 8px 30px var(--accent-glow);
    filter: brightness(1.1);
}

.primary-glow-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* History Box */
.history-box {
    margin-top: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 0.85rem;
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.history-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.clear-history-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
}

.clear-history-btn:hover {
    color: var(--rose);
}

.history-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.history-chip {
    font-size: 0.78rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    padding: 0.2rem 0.55rem;
    border-radius: 6px;
    color: var(--text-secondary);
}

/* Right Wheel Panel */
.wheel-panel {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 580px;
}

.wheel-stage {
    position: relative;
    width: 100%;
    max-width: 520px;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Pointer Indicator at Top (12 o'clock) */
.wheel-pointer-container {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    filter: drop-shadow(0 4px 12px rgba(239, 68, 68, 0.6));
    pointer-events: none;
    transition: transform 0.1s ease;
}

.wheel-pointer {
    width: 0;
    height: 0;
    border-left: 18px solid transparent;
    border-right: 18px solid transparent;
    border-top: 36px solid #ef4444;
}

/* Canvas Container */
.canvas-wrap {
    width: 100%;
    height: 100%;
    position: relative;
    border-radius: 50%;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.6), 0 0 20px var(--accent-glow);
    display: flex;
    align-items: center;
    justify-content: center;
}

#wheel-canvas {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: block;
}

/* Center Hub Spin Button */
.center-hub {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 82px;
    height: 82px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #6366f1, #312e81);
    border: 3px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 1px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 25px var(--accent-glow), inset 0 2px 4px rgba(255, 255, 255, 0.4);
    z-index: 10;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.center-hub:hover {
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 0 35px var(--accent-glow), inset 0 2px 4px rgba(255, 255, 255, 0.6);
    filter: brightness(1.15);
}

.center-hub:active {
    transform: translate(-50%, -50%) scale(0.95);
}

.wheel-footer-hint {
    margin-top: 1.25rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
}

.wheel-footer-hint strong {
    color: var(--accent-color);
}

/* Winner Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(5, 5, 16, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 1.5rem;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-card {
    background: rgba(15, 18, 38, 0.9);
    border: 1px solid rgba(99, 102, 241, 0.4);
    border-radius: 28px;
    padding: 2.75rem 2rem;
    max-width: 480px;
    width: 100%;
    text-align: center;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 40px var(--accent-glow);
    animation: popIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from { opacity: 0; transform: scale(0.85) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-tag {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--emerald);
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    display: inline-block;
    margin-bottom: 1.25rem;
}

.winner-name {
    font-family: var(--font-display);
    font-size: 3rem;
    font-weight: 800;
    line-height: 1.15;
    color: #ffffff;
    text-shadow: 0 0 25px var(--accent-glow);
    margin-bottom: 0.75rem;
    word-break: break-word;
}

.winner-sub {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 2rem;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.modal-btn {
    padding: 0.85rem 1.25rem;
    border-radius: 12px;
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.modal-btn.primary {
    background: var(--accent-color);
    color: #ffffff;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.modal-btn.primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.modal-btn.secondary {
    background: rgba(244, 63, 94, 0.15);
    border: 1px solid rgba(244, 63, 94, 0.3);
    color: #fda4af;
}

.modal-btn.secondary:hover {
    background: rgba(244, 63, 94, 0.25);
    border-color: var(--rose);
}

.modal-btn.ghost {
    background: transparent;
    color: var(--text-secondary);
}

.modal-btn.ghost:hover {
    color: #ffffff;
}

/* AdSense Section */
.adsense-container {
    margin-top: 1rem;
    width: 100%;
    display: flex;
    justify-content: center;
}

.ad-placeholder {
    width: 100%;
    min-height: 90px;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.ad-label {
    position: absolute;
    top: 6px;
    left: 14px;
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    opacity: 0.55;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid var(--glass-border-focus);
    color: #ffffff;
    padding: 0.75rem 1.5rem;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 10000;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    .wheel-stage {
        max-width: 420px;
    }
    .app-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}
