/* ==================== ROOT & VARIABLES ==================== */
:root {
    /* Light Theme Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --text-primary: #333333;
    --text-secondary: #666666;
    --border-color: #ddd;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.15);

    /* Brand Colors */
    --primary-color: #4CAF50;
    --primary-hover: #45a049;
    --danger-color: #f44336;
    --danger-hover: #da190b;
    --secondary-color: #2196F3;
    --secondary-hover: #0b7dda;

    /* Wheel Colors Palette */
    --wheel-color-1: #FF6B6B;
    --wheel-color-2: #4ECDC4;
    --wheel-color-3: #FFE66D;
    --wheel-color-4: #95E1D3;
    --wheel-color-5: #C7CEEA;
    --wheel-color-6: #FF8C42;
    --wheel-color-7: #FB5607;
    --wheel-color-8: #06D6A0;
    --wheel-color-9: #EF476F;
    --wheel-color-10: #FFD166;
    --wheel-color-11: #06FFA5;
    --wheel-color-12: #FF006E;

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Transitions */
    --transition-fast: 150ms ease-in-out;
    --transition-normal: 300ms ease-in-out;
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-primary: #1e1e1e;
    --bg-secondary: #2d2d2d;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --border-color: #444;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* ==================== GLOBAL STYLES ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color var(--transition-normal), color var(--transition-normal);
    line-height: 1.5;
}

/* ==================== LAYOUT ==================== */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.navbar {
    background-color: var(--bg-secondary);
    border-bottom: 2px solid var(--border-color);
    padding: var(--spacing-md) var(--spacing-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
}

.nav-brand {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
    cursor: text;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
    transition: background-color var(--transition-fast);
    outline: none;
}

.nav-brand:hover {
    background-color: rgba(76, 175, 80, 0.1);
}

.nav-brand:focus {
    background-color: rgba(76, 175, 80, 0.15);
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.3);
}

.nav-tabs {
    display: flex;
    gap: var(--spacing-md);
}

.nav-tab {
    background: none;
    border: none;
    padding: var(--spacing-sm) var(--spacing-md);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    transition: all var(--transition-fast);
    position: relative;
}

.nav-tab:hover {
    color: var(--text-primary);
}

.nav-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.main-content {
    flex: 1;
    padding: var(--spacing-sm);
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

@media (min-width: 768px) {
    .main-content {
        padding: var(--spacing-md);
    }
}

.view {
    display: none;
}

.view.active {
    display: block;
    animation: fadeIn var(--transition-normal);
}

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

/* ==================== BUTTONS ==================== */
.btn {
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: var(--secondary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: var(--danger-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* ==================== FORMS ==================== */
.form-group {
    margin-bottom: var(--spacing-lg);
}

label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-weight: 600;
    color: var(--text-primary);
}

input[type="text"],
input[type="color"],
select {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color var(--transition-fast);
}

input[type="text"]:focus,
input[type="color"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 5px;
    background: linear-gradient(to right, var(--primary-color) 0%, var(--primary-color) 100%);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: all var(--transition-fast);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: var(--shadow-lg);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
}

input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: var(--shadow-lg);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: var(--spacing-xs);
}

input[type="checkbox"] {
    margin-right: var(--spacing-sm);
    cursor: pointer;
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
}

.error-message {
    color: var(--danger-color);
    font-size: 12px;
    margin-top: var(--spacing-xs);
    min-height: 18px;
}

/* ==================== RACE VIEW ==================== */
.race-commentary {
    margin: var(--spacing-md) auto;
    padding: var(--spacing-md) var(--spacing-lg);
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.15), rgba(33, 150, 243, 0.15));
    border-left: 4px solid var(--primary-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    max-width: 1200px;
    text-align: center;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: slideDown var(--transition-normal);
}

[data-theme="dark"] .race-commentary {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.2), rgba(33, 150, 243, 0.2));
}

.commentary-text {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.4;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    opacity: 1;
    transition: opacity 0.4s ease-in-out;
}

@media (max-width: 768px) {
    .race-commentary {
        padding: var(--spacing-sm) var(--spacing-md);
        min-height: 50px;
    }

    .commentary-text {
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .race-commentary {
        padding: var(--spacing-xs) var(--spacing-sm);
        min-height: 45px;
    }

    .commentary-text {
        font-size: 16px;
    }
}

.race-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto var(--spacing-sm);
    padding: var(--spacing-md);
}

#race-track {
    width: 100%;
    height: auto;
    min-height: 450px;
    max-height: 70vh;
    border: 3px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    background: linear-gradient(to bottom,
        rgba(135, 206, 250, 0.3) 0%,
        rgba(144, 238, 144, 0.2) 50%,
        rgba(34, 139, 34, 0.2) 100%);
}

[data-theme="dark"] #race-track {
    background: linear-gradient(to bottom,
        rgba(25, 25, 112, 0.3) 0%,
        rgba(0, 100, 0, 0.2) 50%,
        rgba(0, 50, 0, 0.2) 100%);
}

.race-lane {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 1.5;
    stroke-dasharray: 15, 10;
    opacity: 0.5;
}

.race-horse-container {
    transition: none;
    /* Hint to browser for hardware acceleration during racing */
    will-change: transform;
}

.race-horse {
    transition: none;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.3));
    /* Hint to browser for hardware acceleration */
    will-change: transform, filter;
}

.race-horse text {
    user-select: none;
    pointer-events: none;
}

/* Galloping animation during race - body bounces and leans like a full gallop */
.race-horse.racing {
    animation: gallop 0.22s ease-in-out infinite;
    transform-origin: center center;
    transform-box: fill-box;
}

@keyframes gallop {
    0%   { transform: translateY(0px)  rotate(0deg); }
    25%  { transform: translateY(-7px) rotate(-4deg); }
    55%  { transform: translateY(-5px) rotate(2deg); }
    100% { transform: translateY(0px)  rotate(0deg); }
}

/* Leg pivot: rotate around the top-center of each leg group's bounding box */
.horse-front-leg-a,
.horse-front-leg-b,
.horse-back-leg-a,
.horse-back-leg-b {
    transform-box: fill-box;
    transform-origin: 50% 0%;
}

/* Head and tail transform anchors */
.horse-head-group {
    transform-box: fill-box;
    transform-origin: 0% 50%;
}
.horse-tail-group {
    transform-box: fill-box;
    transform-origin: 50% 0%;
}

/* Gallop keyframes — asymmetric: quick power stroke back, slower reach forward.
   Front A / back B lead; front B / back A trail by half a cycle. */
@keyframes gallopFrontA {
    0%   { transform: rotate(-42deg); }
    35%  { transform: rotate(38deg); }
    100% { transform: rotate(-42deg); }
}
@keyframes gallopFrontB {
    0%   { transform: rotate(38deg); }
    35%  { transform: rotate(-42deg); }
    100% { transform: rotate(38deg); }
}
@keyframes gallopBackA {
    0%   { transform: rotate(-38deg); }
    35%  { transform: rotate(42deg); }
    100% { transform: rotate(-38deg); }
}
@keyframes gallopBackB {
    0%   { transform: rotate(42deg); }
    35%  { transform: rotate(-38deg); }
    100% { transform: rotate(42deg); }
}
@keyframes headBob {
    0%   { transform: translate(0px,  0px); }
    30%  { transform: translate(2px, -4px); }
    65%  { transform: translate(-1px,  2px); }
    100% { transform: translate(0px,  0px); }
}
@keyframes tailSway {
    0%   { transform: translate(0px, 0px); }
    40%  { transform: translate(-4px, 5px); }
    100% { transform: translate(0px, 0px); }
}

/* Apply animations to SVG horse parts when racing */
.race-horse.racing .horse-front-leg-a {
    animation: gallopFrontA 0.22s linear infinite;
}
.race-horse.racing .horse-front-leg-b {
    animation: gallopFrontB 0.22s linear infinite;
}
.race-horse.racing .horse-back-leg-a {
    animation: gallopBackA 0.22s linear infinite;
}
.race-horse.racing .horse-back-leg-b {
    animation: gallopBackB 0.22s linear infinite;
}
.race-horse.racing .horse-head-group {
    animation: headBob 0.22s ease-in-out infinite;
}
.race-horse.racing .horse-tail-group {
    animation: tailSway 0.44s ease-in-out infinite;
}

/* Horse fall animation: tips forward then crashes flat with a bounce */
.race-horse.fallen {
    animation: horseFall 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    transform-box: fill-box;
    transform-origin: 50% 80%;
}

@keyframes horseFall {
    0%   { transform: rotate(0deg)   translateY(0px); }
    40%  { transform: rotate(60deg)  translateY(4px); }
    70%  { transform: rotate(88deg)  translateY(10px); }
    85%  { transform: rotate(82deg)  translateY(8px); }  /* bounce */
    100% { transform: rotate(88deg)  translateY(10px); } /* settled on side */
}

.race-horse.winner {
    filter: drop-shadow(0 0 8px rgba(255, 215, 0, 1))
            drop-shadow(0 0 16px rgba(255, 215, 0, 0.8))
            drop-shadow(0 0 24px rgba(255, 215, 0, 0.6));
    animation: winnerGlow 1s ease-in-out infinite;
}

@keyframes winnerGlow {
    0%, 100% {
        filter: drop-shadow(0 0 8px rgba(255, 215, 0, 1))
                drop-shadow(0 0 16px rgba(255, 215, 0, 0.8))
                drop-shadow(0 0 24px rgba(255, 215, 0, 0.6));
    }
    50% {
        filter: drop-shadow(0 0 12px rgba(255, 215, 0, 1))
                drop-shadow(0 0 20px rgba(255, 215, 0, 0.9))
                drop-shadow(0 0 28px rgba(255, 215, 0, 0.7));
        transform: scale(1.1);
    }
}

.race-name-label {
    font-size: 16px;
    font-weight: 600;
    fill: var(--text-primary);
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

[data-theme="dark"] .race-name-label {
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

#finish-line {
    stroke: #FFD700;
    stroke-width: 8;
    stroke-dasharray: 20, 10;
    filter: drop-shadow(0 0 4px rgba(255, 215, 0, 0.6));
}

.race-controls {
    display: flex;
    justify-content: center;
    gap: var(--spacing-md);
    margin-top: var(--spacing-md);
}

@media (max-width: 768px) {
    #race-track {
        min-height: 350px;
        max-height: 60vh;
    }

    .race-name-label {
        font-size: 14px;
    }

    .race-container {
        padding: var(--spacing-sm);
    }
}

@media (max-width: 480px) {
    #race-track {
        min-height: 280px;
    }

    .race-name-label {
        font-size: 12px;
    }
}

.result-display {
    margin-bottom: var(--spacing-sm);
    padding: var(--spacing-xs) var(--spacing-md);
    background-color: var(--bg-secondary);
    border-radius: var(--radius-md);
    text-align: center;
    box-shadow: var(--shadow);
    animation: slideDown var(--transition-normal);
    font-size: 18px;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.result-name {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
}

.result-display .btn {
    margin: 0 var(--spacing-sm);
}

.hidden {
    display: none !important;
}

/* ==================== USERS VIEW ==================== */
.users-container {
    max-width: 600px;
    margin: 0 auto;
}

.user-form {
    background-color: var(--bg-secondary);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-lg);
    box-shadow: var(--shadow);
}

.user-form .form-group {
    margin-bottom: var(--spacing-sm);
}

.color-palette {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(40px, 1fr));
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.color-option {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: 3px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.color-option:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
}

.color-option.selected {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 2px var(--bg-primary), 0 0 0 4px var(--text-primary);
}

.color-preview {
    width: 100%;
    height: 40px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-color);
    margin-top: var(--spacing-sm);
}

.users-list {
    margin-top: var(--spacing-lg);
}

.users-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: var(--spacing-md);
    margin-top: var(--spacing-md);
}

.user-card {
    background-color: var(--bg-secondary);
    padding: var(--spacing-md);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
    animation: slideUp var(--transition-normal);
    transition: opacity var(--transition-fast);
}

.user-card.user-disabled {
    opacity: 0.5;
}

.user-color {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    min-width: 0;
}

/* Controls grouped under the user name */
.user-controls {
    display: flex;
    gap: var(--spacing-md);
    align-items: center;
    margin-top: var(--spacing-xs);
    flex-wrap: nowrap; /* keep color, checkbox and actions on one line */
}

.user-controls .user-actions {
    margin-left: 0;
}

/* Slightly smaller color swatch when inside controls row */
.user-controls .user-color {
    width: 36px;
    height: 36px;
}

@media (max-width: 480px) {
    .user-controls {
        flex-wrap: wrap; /* allow wrapping on very small screens */
        gap: var(--spacing-sm);
    }
}

.user-name {
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
    word-break: break-word;
}

.user-enabled-toggle {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
}

.user-enabled-toggle input[type="checkbox"] {
    cursor: pointer;
    width: auto;
    margin: 0;
}

.user-enabled-toggle:hover {
    color: var(--text-primary);
}

.user-actions {
    display: flex;
    gap: var(--spacing-sm);
    flex-shrink: 0;
}

.user-actions button {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 12px;
}

/* ==================== HISTORY VIEW ==================== */
.history-container {
    max-width: 800px;
    margin: 0 auto;
}

.history-tabs {
    display: flex;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    border-bottom: 2px solid var(--border-color);
}

.history-tab {
    background: none;
    border: none;
    padding: var(--spacing-md);
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 600;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition-fast);
}

.history-tab:hover {
    color: var(--text-primary);
}

.history-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.history-tab-content {
    display: none;
}

.history-tab-content.active {
    display: block;
}

.history-actions {
    display: flex;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.history-actions .btn {
    flex: 1;
}

.history-entries {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    max-height: 600px;
    overflow-y: auto;
    padding: var(--spacing-md);
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg);
}

.history-entry {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    background-color: var(--bg-primary);
    border-left: 4px solid var(--primary-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    margin-bottom: var(--spacing-sm);
}

.history-entry-number {
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 70px;
}

.history-entry-time {
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 180px;
}

.history-entry-name {
    font-weight: 600;
    font-size: 14px;
    flex: 1;
}

.statistics-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-lg);
}

.stat-card {
    background-color: var(--bg-secondary);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.stat-card-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.stat-color {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-md);
}

.stat-name {
    font-weight: 600;
    font-size: 16px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid var(--border-color);
}

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

.stat-label {
    color: var(--text-secondary);
    font-size: 14px;
}

.stat-value {
    font-weight: 600;
}

/* ==================== SETTINGS VIEW ==================== */
.settings-container {
    max-width: 600px;
    margin: 0 auto;
}

.settings-section {
    background-color: var(--bg-secondary);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.settings-section h3 {
    margin-bottom: var(--spacing-md);
    color: var(--primary-color);
}

/* Data management buttons - ensure consistent width */
.settings-section .btn {
    width: 100%;
    max-width: 300px;
}

#shared-link-display {
    display: flex;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
}

#shared-link-input {
    flex: 1;
    font-size: 12px;
}

/* ==================== WELCOME VIEW ==================== */
.welcome-container {
    max-width: 500px;
    margin: 60px auto;
    text-align: center;
    padding: var(--spacing-lg);
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.welcome-container h1 {
    margin-bottom: var(--spacing-md);
    color: var(--primary-color);
}

.welcome-container p {
    margin-bottom: var(--spacing-md);
    color: var(--text-secondary);
}

.welcome-examples {
    background-color: var(--bg-primary);
    padding: var(--spacing-lg);
    border-radius: var(--radius-md);
    margin: var(--spacing-lg) 0;
    border-left: 4px solid var(--primary-color);
}

.welcome-examples h3 {
    margin-bottom: var(--spacing-md);
}

.welcome-examples ul {
    list-style: none;
    text-align: left;
    display: inline-block;
}

.welcome-examples li {
    padding: var(--spacing-sm);
    font-weight: 500;
}

.welcome-actions {
    margin-top: var(--spacing-lg);
}

.welcome-actions .btn {
    padding: var(--spacing-md) var(--spacing-xl);
    font-size: 16px;
}

/* ==================== MODALS ==================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background-color: var(--bg-primary);
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn var(--transition-normal);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: var(--spacing-lg);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
    border-top: 1px solid var(--border-color);
}

.faq-section {
    text-align: left;
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
}

.faq-section:last-child {
    border-bottom: none;
}

.faq-section h3 {
    margin-bottom: var(--spacing-md);
    color: var(--primary-color);
}

.faq-section ul {
    margin-left: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
}

.faq-section li {
    margin-bottom: var(--spacing-sm);
}

/* ==================== RESPONSIVE DESIGN ==================== */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: var(--spacing-md);
        padding: var(--spacing-md);
        position: sticky;
        top: 0;
        z-index: 1000;
    }

    .nav-tabs {
        width: 100%;
        overflow-x: auto;
        display: flex;
    }

    .nav-tab {
        font-size: 13px;
        padding: var(--spacing-sm) var(--spacing-md);
        flex: 1;
        text-align: center;
        white-space: nowrap;
    }

    .main-content {
        padding: var(--spacing-md);
    }

    .settings-section,
    .user-form,
    .users-list,
    .history-container {
        margin-left: 0;
        margin-right: 0;
    }

    .users-grid {
        grid-template-columns: 1fr;
    }

    /* Mobile layout for user cards - username on top, controls below */
    .user-card {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .user-info {
        order: -1;
        flex-basis: 100%;
        width: 100%;
        margin-bottom: var(--spacing-sm);
    }

    .user-name {
        font-size: 16px;
        margin-bottom: 0;
    }

    .user-color {
        order: 0;
        flex-shrink: 0;
        width: 25px;
        height: 25px;
    }

    .user-enabled-toggle {
        order: 1;
        flex-shrink: 0;
        margin-left: auto;
        margin-right: var(--spacing-sm);
    }

    .user-actions {
        order: 2;
        flex-shrink: 0;
    }

    .user-actions button {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: 12px;
    }

    .result-display .btn {
        display: block;
        width: 100%;
        margin: var(--spacing-sm) 0;
    }

    .history-actions {
        flex-direction: column;
    }

    /* Mobile layout for history entries - name on separate row */
    .history-entry {
        flex-wrap: wrap;
        gap: var(--spacing-xs);
    }

    .history-entry-number {
        order: 0;
        min-width: auto;
        flex: 0 0 auto;
    }

    .history-entry-time {
        order: 1;
        min-width: auto;
        flex: 1 1 auto;
    }

    .history-entry-name {
        order: 2;
        flex-basis: 100%;
        width: 100%;
        margin-top: var(--spacing-xs);
        padding-left: 0;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 14px;
    }

    .navbar {
        position: sticky;
        top: 0;
        z-index: 1000;
    }

    .nav-brand {
        font-size: 18px;
    }

    .nav-tabs {
        gap: var(--spacing-xs);
        justify-content: space-around;
    }

    .nav-tab {
        padding: var(--spacing-sm) var(--spacing-xs);
        min-width: 50px;
        font-size: 20px;
    }

    .tab-label {
        display: none;
    }

    .nav-tab::before {
        content: attr(data-icon);
        font-size: 24px;
    }

    nav[data-view="wheel"]::before { content: "⚙"; }
    nav[data-view="users"]::before { content: "👥"; }
    nav[data-view="history"]::before { content: "📊"; }
    nav[data-view="settings"]::before { content: "⚡"; }

    .wheel {
        width: 250px;
        height: 250px;
    }

    .welcome-container {
        margin: 20px auto;
    }

    .modal-content {
        width: 95%;
        max-height: 90vh;
    }
}

/* ==================== WINNER EFFECTS ==================== */

/* Confetti */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    top: -10px;
    pointer-events: none;
    animation: confettiFall 10s ease-in forwards;
    transform: rotate(45deg);
}

@keyframes confettiFall {
    to {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Firework Particles */
.firework-particle {
    position: fixed;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    pointer-events: none;
    box-shadow: 0 0 20px currentColor, 0 0 30px currentColor;
    z-index: 1000;
}

/* Balloons */
.balloon {
    position: fixed;
    width: 30px;
    height: 40px;
    bottom: -60px;
    border-radius: 50% 50% 45% 45%;
    pointer-events: none;
    animation: balloonRise 5s ease-in forwards;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
    opacity: 0;
    z-index: 1000;
}

.balloon::before {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: 15px;
    background: rgba(150, 150, 150, 0.6);
}

@keyframes balloonRise {
    0% {
        transform: translateY(0) translateX(0);
        opacity: 0;
    }
    5% {
        opacity: 1;
    }
    95% {
        opacity: 1;
    }
    100% {
        transform: translateY(-110vh) translateX(100px);
        opacity: 0;
    }
}

/* Sparkles */
.sparkle {
    position: fixed;
    width: 15px;
    height: 15px;
    pointer-events: none;
    animation: sparkleAnimation 10s ease-out forwards;
    font-size: 20px;
    line-height: 15px;
}

.sparkle::before {
    content: '✨';
    position: absolute;
    animation: sparkleRotate 2s ease-out forwards;
}

@keyframes sparkleAnimation {
    to {
        opacity: 0;
        transform: scale(0);
    }
}

@keyframes sparkleRotate {
    to {
        transform: rotate(360deg) scale(0);
    }
}

/* Glow Pulse */
.glow-pulse-effect {
    animation: glowPulseAnimation 10s ease-in-out;
}

@keyframes glowPulseAnimation {
    0%, 100% {
        box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
    }
    50% {
        box-shadow: 0 0 30px rgba(76, 175, 80, 1);
    }
}

/* Bounce */
.bounce-effect {
    animation: bounceEffect 10s ease-out;
}

@keyframes bounceEffect {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

/* Light Pulse */
.light-pulse {
    position: fixed;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: radial-gradient(circle, #FFD700, transparent);
    pointer-events: none;
    animation: lightPulseAnimation 10s ease-out forwards;
    box-shadow: 0 0 20px #FFD700;
}

@keyframes lightPulseAnimation {
    0% {
        opacity: 1;
        box-shadow: 0 0 20px #FFD700;
    }
    100% {
        opacity: 0;
        box-shadow: 0 0 40px #FFD700;
    }
}

/* Ticker Tape */
.ticker-tape {
    position: fixed;
    top: -40px;
    font-size: 30px;
    pointer-events: none;
    animation: tickerTapeFall 10s ease-in forwards;
    transform: rotate(15deg);
}

@keyframes tickerTapeFall {
    to {
        transform: translateY(100vh) rotate(-15deg);
        opacity: 0;
    }
}

/* Screen Flash */
.screen-flash {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    pointer-events: none;
    z-index: 1000;
    animation: screenFlashAnimation 10s ease-out;
}

@keyframes screenFlashAnimation {
    0% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

/* Winner Popup */
.winner-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 60px;
    font-weight: bold;
    color: var(--primary-color);
    pointer-events: none;
    z-index: 1001;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    animation: popupAnimation 10s ease-out forwards;
}

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

.pop-animate {
    animation: popAnimation 1s ease-out forwards;
}

@keyframes popAnimation {
    0% {
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        transform: translate(-50%, -50%) scale(1.5);
    }
}

/* ==================== UTILITY CLASSES ==================== */
.text-center {
    text-align: center;
}

.mt-md {
    margin-top: var(--spacing-md);
}

.mb-md {
    margin-bottom: var(--spacing-md);
}

.mb-lg {
    margin-bottom: var(--spacing-lg);
}

/* ==================== SCROLLBAR STYLING ==================== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}
