:root {
    color-scheme: dark;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #0b0b0d;
    color: #e4e4e7;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: #0b0b0d;
    color: #e4e4e7;
    overscroll-behavior: none;
}

button,
input {
    font: inherit;
}

button {
    min-height: 44px;
    flex: 1;
    padding: 12px 20px;
    border: 0;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
}

button:active {
    transform: scale(0.98);
}

button:disabled {
    cursor: wait;
    opacity: 0.55;
}

button:focus-visible,
input:focus-visible,
canvas:focus-visible {
    outline: 2px solid #60a5fa;
    outline-offset: 3px;
}

.btn-primary {
    background: #2563eb;
    color: #fff;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: #18181b;
    color: #a1a1aa;
    border: 1px solid #27272a;
}

.btn-secondary:hover {
    background: #27272a;
    color: #fff;
}

#app-shell {
    display: flex;
    width: min(100%, 800px);
    justify-content: center;
    align-items: center;
}

.container,
.end-card {
    width: 100%;
    max-width: 400px;
    padding: 32px;
    border: 1px solid #202024;
    border-radius: 12px;
    background: #121215;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
    text-align: center;
}

h1,
h2 {
    margin-top: 0;
    text-transform: uppercase;
}

h2 {
    margin-bottom: 24px;
    color: #a1a1aa;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.auth-title {
    margin-bottom: 16px;
    color: #fff;
    font-size: 18px;
    letter-spacing: 1px;
}

input {
    width: 100%;
    margin: 8px 0;
    padding: 12px 16px;
    border: 1px solid #27272a;
    border-radius: 6px;
    background: #18181b;
    color: #fff;
    font-family: monospace;
    font-size: 14px;
}

input:focus {
    border-color: #3b82f6;
    outline: none;
}

.btn-group {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.btn-block {
    width: 100%;
}

.btn-narrow {
    max-width: 360px;
}

.mt-10 {
    margin-top: 10px;
}

.mt-20 {
    margin-top: 20px;
}

.profile-card {
    margin-bottom: 20px;
    padding: 16px;
    border: 1px solid #27272a;
    border-radius: 8px;
    background: #18181b;
    font-family: monospace;
    font-size: 14px;
    text-align: left;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.online-status {
    display: flex;
    align-items: center;
    margin-top: 12px;
    color: #71717a;
    font-size: 12px;
}

.leaderboard {
    margin-top: 24px;
    text-align: left;
}

.leaderboard-title {
    margin-bottom: 12px;
    color: #71717a;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #18181b;
    font-family: monospace;
    font-size: 13px;
}

.leaderboard-elo,
.text-primary {
    color: #3b82f6;
}

.text-white {
    color: #fff;
}

.empty-state {
    color: #71717a;
    font-size: 12px;
}

.spinner {
    width: 28px;
    height: 28px;
    margin: 24px auto;
    border: 2px solid #18181b;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.relative {
    position: relative;
}

#dashboard-ui,
#game-view,
#matchmaking-ui,
#practice-view,
#end-ui {
    display: none;
}

#game-view,
#practice-view {
    width: 100%;
    max-width: 800px;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

canvas {
    display: block;
    width: 100%;
    aspect-ratio: 2 / 1;
    border: 2px solid #202024;
    border-radius: 8px;
    background: #09090b;
    image-rendering: pixelated;
    touch-action: none;
}

#mobile-controls {
    display: none;
    width: 100%;
    gap: 12px;
}

.touch-btn {
    height: 60px;
    border: 1px solid #202024;
    border-radius: 8px;
    background: #121215;
    color: #fff;
    user-select: none;
    touch-action: none;
}

.touch-btn:active {
    border-color: #2563eb;
    background: #2563eb;
}

.meta,
.hint {
    font-family: monospace;
}

.meta {
    color: #71717a;
    font-size: 12px;
}

.hint {
    color: #52525b;
    font-size: 11px;
}

#queue-timer {
    font-size: 13px;
}

#connection-status {
    min-height: 16px;
}

.end-card {
    max-width: 400px;
    padding: 40px 32px;
    border-radius: 16px;
}

#end-result-title {
    margin: 0 0 12px;
    color: #fff;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.stat-badge-container {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 20px 0 28px;
}

.stat-badge {
    padding: 10px 16px;
    border: 1px solid #27272a;
    border-radius: 8px;
    background: #18181b;
    color: #e4e4e7;
    font-family: monospace;
    font-size: 13px;
}

#practice-btn,
#end-secondary-btn {
    display: none;
}

#countdown-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 2;
    display: none;
    transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.12);
    font-size: 64px;
    font-weight: 700;
    pointer-events: none;
}

#alert-box {
    min-height: 16px;
    margin-top: 20px;
    color: #3b82f6;
    font-family: monospace;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-align: center;
    text-transform: uppercase;
}

.reconnect-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(9, 9, 11, 0.94);
}

.overlay-title {
    margin-bottom: 12px;
    font-size: 18px;
    font-weight: 600;
}

.overlay-btn {
    width: auto;
    min-width: 220px;
    padding: 12px 24px;
}

.overlay-btn + .overlay-btn {
    margin-top: 10px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 768px) {
    #mobile-controls {
        display: flex;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    .container,
    .end-card {
        padding: 24px 18px;
    }

    .btn-group {
        flex-direction: column;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}