:root {
    --bg-page: #020617; /* slate-950 */
    --bg-panel: rgba(15, 23, 42, 0.4); /* slate-900/40 */
    --border-panel: #1e293b; /* slate-800 */
    --text-primary: #f1f5f9; /* slate-100 */
    --text-secondary: #94a3b8; /* slate-400 */
    --text-muted: #64748b; /* slate-500 */
    
    --color-sky-400: #38bdf8;
    --color-sky-500: #0ea5e9;
    --color-indigo-500: #6366f1;
    --color-indigo-600: #4f46e5;
    --color-indigo-900: #312e81;
    --color-red-400: #f87171;
    --color-red-500: #ef4444;

    --gradient-primary: linear-gradient(to right, var(--color-sky-400), var(--color-indigo-500));
    --gradient-btn: linear-gradient(to right, var(--color-sky-500), var(--color-indigo-600));
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-page);
    color: var(--text-primary);
    min-height: 100vh;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

@media (min-width: 768px) {
    .app-container {
        padding: 2rem;
    }
}

/* Header */
.main-header {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    gap: 1rem;
    border-bottom: 1px solid var(--border-panel);
    padding-bottom: 1.5rem;
}

@media (min-width: 768px) {
    .main-header {
        flex-direction: row;
    }
}

.header-title h1 {
    font-size: 2.25rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    line-height: 1.2;
}

.header-title p {
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.header-controls {
    display: flex;
    gap: 1rem;
    background-color: rgba(15, 23, 42, 0.5);
    padding: 0.5rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border-panel);
}

.mode-btn {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
    color: var(--text-secondary);
}

.mode-btn:hover {
    background-color: var(--border-panel);
}

.mode-btn.active {
    background-color: var(--color-sky-500);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Main Layout */
.main-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    flex-grow: 1;
}

@media (min-width: 1024px) {
    .main-grid {
        grid-template-columns: 4fr 8fr;
    }
}

.left-column, .right-column {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Panels */
.panel {
    background-color: var(--bg-panel);
    border-radius: 1.5rem;
    padding: 1.5rem;
    border: 1px solid var(--border-panel);
    backdrop-filter: blur(4px);
}

@media (min-width: 768px) {
    .panel {
        padding: 2rem;
    }
}

/* Globe Component */
.globe-panel {
    position: relative;
    overflow: hidden;
}

.globe-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 16rem;
    margin-bottom: 2rem;
}

.globe {
    width: 12rem;
    height: 12rem;
    border-radius: 50%;
    border: 4px solid var(--border-panel);
    position: relative;
    overflow: hidden;
    transition: all 0.7s;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.globe.spinning {
    border-color: var(--color-sky-400);
    animation: spin-border 2s linear infinite;
}

.globe-shine {
    position: absolute;
    top: -2.5rem;
    left: -2.5rem;
    width: 8rem;
    height: 8rem;
    background: rgba(255, 255, 255, 0.1);
    filter: blur(40px);
    border-radius: 50%;
    pointer-events: none;
}

.globe-balls {
    position: absolute;
    inset: 1rem;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    opacity: 0.6;
}

.globe-ball {
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background: linear-gradient(to top right, #7dd3fc, #6366f1);
    transition: transform 0.5s;
}

.globe.spinning .globe-ball {
    transform: scale(1.1);
}

.globe-stand-top {
    width: 8rem;
    height: 1rem;
    background-color: var(--border-panel);
    border-radius: 9999px;
    margin-top: -0.5rem;
    z-index: 10;
}

.globe-stand-bottom {
    width: 10rem;
    height: 0.5rem;
    background-color: rgba(30, 41, 59, 0.5);
    border-radius: 9999px;
    margin-top: 0.25rem;
}

.drawing-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--color-sky-400);
    font-weight: 700;
    font-size: 1.25rem;
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    text-shadow: 0 0 10px rgba(0,0,0,0.5);
}

/* Controls */
.controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.btn-primary {
    width: 100%;
    padding: 1rem 2rem;
    border-radius: 1rem;
    font-size: 1.25rem;
    font-weight: 800;
    border: none;
    cursor: pointer;
    background: var(--gradient-btn);
    color: white;
    transition: all 0.2s;
    box-shadow: 0 0 30px rgba(56, 189, 248, 0.3);
}

.btn-primary:hover {
    transform: scale(1.02);
    box-shadow: 0 0 40px rgba(56, 189, 248, 0.4);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:disabled {
    background: var(--border-panel);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.btn-secondary {
    width: 100%;
    padding: 0.75rem 2rem;
    border-radius: 1rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--border-panel);
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary.confirm-state {
    background-color: rgba(239, 68, 68, 0.2);
    color: var(--color-red-400);
    border: 1px solid rgba(239, 68, 68, 0.5);
    animation: pulse 2s infinite;
}

.reset-msg {
    text-align: center;
    font-size: 0.625rem;
    color: rgba(248, 113, 113, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    animation: fadeIn 0.3s;
}

/* Last Number Panel */
.last-number-panel {
    background: linear-gradient(to bottom right, rgba(49, 46, 129, 0.3), var(--bg-page));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    text-align: center;
}

.last-number-panel h3 {
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
}

.last-number-display {
    position: relative;
    margin-bottom: 2rem;
}

#last-number-value, #last-number-placeholder {
    font-size: 6rem;
    font-weight: 900;
    line-height: 1;
}

@media (min-width: 768px) {
    #last-number-value, #last-number-placeholder {
        font-size: 8rem;
    }
}

#last-number-value {
    color: white;
    text-shadow: 0 0 20px rgba(0,0,0,0.5);
    position: relative;
    z-index: 2;
}

#last-number-value::before {
    content: '';
    position: absolute;
    inset: -20px;
    background: rgba(14, 165, 233, 0.2);
    filter: blur(40px);
    border-radius: 50%;
    z-index: -1;
}

#last-number-placeholder {
    color: var(--border-panel);
}

#last-number-animating {
    font-size: 6rem;
    font-weight: 900;
    color: rgba(51, 65, 85, 0.3);
    animation: bounce 1s infinite;
}

.last-number-tag {
    padding: 0.25rem 1rem;
    background: rgba(14, 165, 233, 0.1);
    color: var(--color-sky-400);
    border: 1px solid rgba(14, 165, 233, 0.3);
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

/* Board and History */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.panel-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.indicator-bar {
    width: 0.5rem;
    height: 2rem;
    border-radius: 9999px;
    display: inline-block;
}

.indicator-bar.sky { background-color: var(--color-sky-500); }
.indicator-bar.indigo { background-color: var(--color-indigo-500); }

.stats {
    color: var(--text-secondary);
    font-family: monospace;
}

.number-board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
}

@media (min-width: 640px) {
    .number-board {
        grid-template-columns: repeat(10, 1fr);
    }
}

@media (min-width: 768px) {
    .number-board {
        gap: 0.75rem;
    }
}

.board-number {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    font-weight: 700;
    font-size: 0.875rem;
    transition: all 0.3s;
    background-color: rgba(30, 41, 59, 0.4);
    color: var(--text-muted);
    border: 1px solid rgba(51, 65, 85, 0.5);
}

@media (min-width: 768px) {
    .board-number {
        font-size: 1rem;
    }
}

.board-number.drawn {
    background-color: var(--border-panel);
    color: #7dd3fc;
    border-color: transparent;
}

.board-number.latest {
    background-color: var(--color-sky-500);
    color: white;
    box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.3), 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    transform: scale(1.1);
    z-index: 10;
    animation: pulse 2s infinite;
}

.draw-history {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    max-height: 15rem;
    overflow-y: auto;
    padding-right: 0.5rem;
}

/* Custom Scrollbar */
.draw-history::-webkit-scrollbar {
    width: 6px;
}
.draw-history::-webkit-scrollbar-track {
    background: transparent;
}
.draw-history::-webkit-scrollbar-thumb {
    background-color: var(--border-panel);
    border-radius: 20px;
}

.history-ball {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    background-color: var(--border-panel);
    color: #cbd5e1;
    border: 1px solid var(--border-panel);
    position: relative;
}

.history-ball.latest {
    background: linear-gradient(to top right, var(--color-sky-400), var(--color-indigo-600));
    color: white;
    transform: scale(1.1);
    box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.2);
    border: none;
}

.empty-history {
    width: 100%;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    padding: 2rem;
    border: 2px dashed var(--border-panel);
    border-radius: 1rem;
}

.main-footer {
    margin-top: 3rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-panel);
}

/* Animations */
@keyframes spin-border {
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .5; }
}

@keyframes bounce {
    0%, 100% { transform: translateY(-25%); animation-timing-function: cubic-bezier(0.8,0,1,1); }
    50% { transform: none; animation-timing-function: cubic-bezier(0,0,0.2,1); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.hidden {
    display: none !important;
}
