:root {
    --primary: #ff6b6b;
    --primary-dark: #ee5253;
    --secondary: #48dbfb;
    --bg-color: #222f3e;
    --text-light: #ffffff;
    --text-dark: #2d3436;
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
    user-select: none;
}

body {
    background-color: var(--bg-color);
    background-image: radial-gradient(circle at top right, #341f97 0%, #222f3e 100%);
    color: var(--text-light);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    background: var(--bg-color);
    overflow: hidden;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    background: rgba(34, 47, 62, 0.85);
    backdrop-filter: blur(10px);
}

.screen.active {
    opacity: 1;
    pointer-events: all;
    z-index: 10;
}

#game-screen.active {
    background: transparent;
    backdrop-filter: none;
}

.title {
    font-size: 3rem;
    font-weight: 900;
    color: var(--primary);
    text-transform: uppercase;
    text-shadow: 0 4px 15px rgba(255, 107, 107, 0.5);
    margin-bottom: 10px;
    text-align: center;
}

.subtitle {
    font-size: 1.2rem;
    color: var(--secondary);
    margin-bottom: 40px;
    text-align: center;
}

.btn {
    padding: 15px 30px;
    border-radius: 50px;
    border: none;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 10px 0;
    width: 80%;
    max-width: 300px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn.primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 5px 15px rgba(255, 107, 107, 0.4);
}

.btn.primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 107, 107, 0.6);
}

.btn.secondary {
    background: transparent;
    color: var(--secondary);
    border: 2px solid var(--secondary);
    box-shadow: 0 5px 15px rgba(72, 219, 251, 0.2);
}

.btn.secondary:hover {
    background: rgba(72, 219, 251, 0.1);
    transform: translateY(-2px);
}

#hud {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5;
    font-size: 1.4rem;
    font-weight: 700;
    pointer-events: none;
}

.score-board {
    position: absolute;
    top: 150px;
    left: 50%;
    transform: translateX(-50%);
    color: #feca57;
    background: rgba(10, 15, 25, 0.82);
    border: 2px solid rgba(254, 202, 87, 0.35);
    border-radius: 10px;
    padding: 8px 18px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5), 0 0 10px rgba(254, 202, 87, 0.1);
    backdrop-filter: blur(8px);
    text-shadow: 0 0 8px rgba(254, 202, 87, 0.5);
    letter-spacing: 1px;
    pointer-events: none;
}

.misses-board {
    position: absolute;
    top: 205px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--primary);
    background: rgba(10, 15, 25, 0.82);
    border: 2px solid rgba(255, 107, 107, 0.35);
    border-radius: 10px;
    padding: 8px 18px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5), 0 0 10px rgba(255, 107, 107, 0.1);
    backdrop-filter: blur(8px);
    text-shadow: 0 0 8px rgba(255, 107, 107, 0.5);
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: none;
    z-index: 5;
}

.timer-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 300px;
}

.timer-board {
    background: rgba(10, 15, 25, 0.9);
    border: 3.5px solid rgba(255, 159, 67, 0.55);
    border-radius: 12px;
    padding: 0;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.7), 0 0 20px rgba(255, 159, 67, 0.3), inset 0 0 14px rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    overflow: hidden;
}

#timer-canvas {
    display: block;
    width: 280px;
    height: 96px;
}

.timer-bar-bg {
    width: 90%;
    height: 8px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    margin-top: 8px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.8);
}

#timer-bar-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #ff9f43, #ff5252);
    box-shadow: 0 0 8px rgba(255, 159, 67, 0.8);
    border-radius: 4px;
    transition: width 0.05s linear;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.timer-danger {
    color: #ff4d4d !important;
    border-color: rgba(255, 77, 77, 0.85) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.65), 0 0 25px rgba(255, 77, 77, 0.5), inset 0 0 12px rgba(0, 0, 0, 0.95) !important;
    text-shadow: 0 0 15px rgba(255, 77, 77, 1) !important;
    animation: blink 0.3s infinite;
}

.timer-danger-bar {
    background: linear-gradient(90deg, #ff4d4d, #ff2a2a) !important;
    box-shadow: 0 0 12px rgba(255, 77, 77, 0.9) !important;
}

#canvas-container {
    width: 100%;
    height: 100%;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 400px;
    background: rgba(34, 47, 62, 0.95);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    backdrop-filter: blur(10px);
    z-index: 20;
}

.overlay h2 {
    color: var(--primary);
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.overlay p {
    font-size: 1.2rem;
    margin-bottom: 20px;
    color: white;
}

.overlay .highlight {
    color: var(--secondary);
    font-weight: 700;
    margin-bottom: 10px;
}

#name-input-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
}

input[type="text"] {
    width: 100%;
    padding: 12px 20px;
    border-radius: 10px;
    border: 2px solid var(--secondary);
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 1.1rem;
    font-family: 'Outfit', sans-serif;
    margin-bottom: 15px;
    outline: none;
    text-align: center;
    transition: all 0.3s;
}

input[type="text"]:focus {
    background: rgba(255,255,255,0.2);
    box-shadow: 0 0 10px rgba(72, 219, 251, 0.5);
}

.hidden {
    display: none !important;
}

.table-container {
    width: 90%;
    max-height: 60%;
    overflow-y: auto;
    margin: 20px 0;
    background: var(--glass-bg);
    border-radius: 15px;
    border: 1px solid var(--glass-border);
    padding: 10px;
}

/* Custom Scrollbar */
.table-container::-webkit-scrollbar {
    width: 8px;
}
.table-container::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
    border-radius: 10px;
}
.table-container::-webkit-scrollbar-thumb {
    background: var(--secondary);
    border-radius: 10px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 10px;
    text-align: left;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

th {
    color: var(--secondary);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.9rem;
    position: sticky;
    top: 0;
    background: rgba(34, 47, 62, 0.95);
}

td {
    font-size: 1.1rem;
}

tr:last-child td {
    border-bottom: none;
}

tr:nth-child(1) td {
    color: #feca57;
    font-weight: 900;
    font-size: 1.2rem;
}

tr:nth-child(2) td {
    color: #c8d6e5;
    font-weight: 700;
}

tr:nth-child(3) td {
    color: #cd6133;
    font-weight: 700;
}

/* Mobile Responsive Adjustments */
@media screen and (max-width: 600px) {
    #hud {
        top: 12px;
        left: 12px;
        right: 12px;
    }

    .timer-container {
        width: 180px;
    }

    .timer-board {
        border-width: 2px;
    }

    #timer-canvas {
        width: 168px;
        height: 57px;
    }

    .timer-bar-bg {
        height: 6px;
        margin-top: 4px;
    }

    .score-board {
        top: 95px;
        font-size: 1.1rem;
        padding: 6px 14px;
        transform: translateX(-50%);
    }

    .misses-board {
        top: 135px;
        font-size: 1.1rem;
        padding: 6px 14px;
        transform: translateX(-50%);
    }
}
