* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    height: 100vh;
    font-family: "Inter", "Segoe UI", sans-serif;
    background: radial-gradient(circle at top, #063970 0%, #020617 45%, #000000 100%);
    color: #d1fae5;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.5rem;
    overflow: hidden;
}

.aurora {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at 20% 20%, rgba(34, 197, 94, 0.15), transparent 60%),
        radial-gradient(ellipse at 80% 0%, rgba(16, 185, 129, 0.15), transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(217, 70, 239, 0.1), transparent 55%);
    filter: blur(40px);
    pointer-events: none;
}

.app-shell {
    position: relative;
    width: min(1360px, 100%);
    height: calc(100vh - 1rem);
    max-height: 100%;
    padding: clamp(1rem, 2vw, 1.75rem);
    border-radius: 24px;
    background: rgba(2, 6, 23, 0.85);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.65);
    border: 1px solid rgba(16, 185, 129, 0.3);
    z-index: 1;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 0.8rem;
}

header {
    text-align: center;
    margin-bottom: 0.2rem;
}

header h1 {
    margin: 0;
    font-size: clamp(1.4rem, 2.4vw, 2.1rem);
    background: linear-gradient(120deg, #22d3ee, #34d399, #bef264);
    -webkit-background-clip: text;
    color: transparent;
}

header p {
    color: #94a3b8;
    margin-top: 0.25rem;
    font-size: 0.9rem;
}

.header-meta {
    margin-top: 0.8rem;
    display: flex;
    justify-content: center;
}

.timer {
    font-size: 1.2rem;
    font-weight: 600;
    color: #bef264;
    padding: 0.35rem 1rem;
    border-radius: 999px;
    background: rgba(101, 163, 13, 0.15);
    border: 1px solid rgba(190, 242, 100, 0.4);
}

.game-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
    gap: 1rem;
    align-items: stretch;
    min-height: 0;
}

.game-wrapper {
    position: relative;
    padding: 0.75rem;
    background: rgba(15, 23, 42, 0.8);
    border-radius: 24px;
    border: 1px solid rgba(16, 185, 129, 0.35);
    box-shadow: inset 0 0 30px rgba(15, 118, 110, 0.2);
    min-height: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

#board {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 18px;
    background: #010b13;
    border: 2px solid rgba(16, 185, 129, 0.6);
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.35);
    aspect-ratio: 3 / 2;
}

.status-chip {
    position: absolute;
    top: -2.6rem;
    left: 0;
    background: rgba(16, 185, 129, 0.2);
    padding: 0.35rem 1rem;
    border-radius: 999px;
    font-size: 0.9rem;
    color: #bbf7d0;
    border: 1px solid rgba(16, 185, 129, 0.6);
}

.hud {
    display: grid;
    grid-auto-rows: max-content;
    gap: 0.85rem;
    min-height: 0;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.hud-card {
    background: rgba(15, 23, 42, 0.9);
    border-radius: 20px;
    padding: 0.9rem;
    border: 1px solid rgba(16, 185, 129, 0.25);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
}

.hud-card h2 {
    margin: 0 0 0.8rem;
    font-size: 1.05rem;
    color: #a7f3d0;
}

#leaderboard {
    list-style: decimal-leading-zero;
    margin: 0;
    padding-left: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

#leaderboard li {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.35rem 0.2rem;
    color: #f8fafc;
}

.hud-card p {
    margin: 0.2rem 0;
    color: #cbd5f5;
    line-height: 1.4;
}

#player-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 240px;
    overflow-y: auto;
}

.player-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    padding: 0.55rem 0.75rem;
    border-radius: 12px;
    background: rgba(2, 132, 199, 0.08);
    color: #f9fafb;
}

.player-row.me {
    background: rgba(34, 197, 94, 0.2);
    border: 1px solid rgba(34, 197, 94, 0.4);
}

.player-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.color-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(15, 23, 42, 0.8);
}

.controls {
    text-align: center;
}

.control-grid {
    display: grid;
    grid-template-columns: repeat(3, 58px);
    grid-template-rows: repeat(2, 58px);
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin: 0.8rem auto;
}

.control-grid > div {
    width: 58px;
    height: 58px;
}

.control-btn {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(52, 211, 153, 0.5);
    border-radius: 16px;
    color: #ecfccb;
    font-size: 1.4rem;
    padding: 0.65rem;
    cursor: pointer;
    transition: transform 0.1s ease, background 0.2s ease;
}

.control-btn:active {
    transform: scale(0.95);
    background: rgba(34, 197, 94, 0.3);
}

.hint {
    color: #9ca3af;
    font-size: 0.8rem;
    margin: 0;
}

.respawn-btn {
    margin-top: 1rem;
    width: 100%;
    padding: 0.8rem;
    border-radius: 14px;
    border: 1px solid rgba(248, 250, 252, 0.35);
    background: linear-gradient(120deg, rgba(249, 115, 22, 0.2), rgba(236, 72, 153, 0.2));
    color: #fef9c3;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.rules-card {
    padding: 0.6rem 0.8rem 0.9rem;
}

.rules-card summary {
    cursor: pointer;
    font-weight: 600;
    color: #a7f3d0;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.rules-card summary::-webkit-details-marker {
    display: none;
}

.rules-card summary::after {
    content: "+";
    font-size: 1.1rem;
    color: #86efac;
}

.rules-card[open] summary::after {
    content: "−";
}

.rules-body {
    margin-top: 0.6rem;
}

.rules-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.45rem;
    color: #cbd5f5;
    font-size: 0.9rem;
}

.rules-list li {
    position: relative;
    padding-left: 1.1rem;
    line-height: 1.4;
}

.rules-list li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: #86efac;
}

.respawn-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

@media (max-width: 1100px) {
    .game-layout {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1fr) minmax(0, auto);
    }
    .hud {
        max-height: 40vh;
        overflow: auto;
    }
}

@media (max-height: 760px) {
    header p {
        display: none;
    }

    .header-meta {
        margin-top: 0.4rem;
    }

    .hud {
        max-height: 45vh;
    }
}

@media (max-width: 600px) {
    body {
        padding: 0.5rem;
    }

    .app-shell {
        padding: 1.1rem;
    }

    .control-grid {
        grid-template-columns: repeat(3, 54px);
        grid-template-rows: repeat(2, 54px);
    }
}
.name-overlay {
    position: fixed;
    inset: 0;
    background: rgba(1, 6, 18, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
    z-index: 3;
    transition: opacity 0.3s ease;
}

.name-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay-card {
    background: rgba(15, 23, 42, 0.95);
    padding: 2rem;
    border-radius: 24px;
    width: min(480px, 90vw);
    text-align: center;
    border: 1px solid rgba(16, 185, 129, 0.3);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.7);
}

.overlay-card h2 {
    margin-top: 0;
    color: #d1fae5;
}

#name-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

#name-input {
    padding: 0.9rem 1.1rem;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.5);
    background: rgba(2, 6, 23, 0.7);
    color: #f1f5f9;
    font-size: 1rem;
}

#name-form button {
    padding: 0.85rem;
    border-radius: 14px;
    border: none;
    background: linear-gradient(120deg, #f59e0b, #ec4899);
    color: #0f172a;
    font-weight: 600;
    cursor: pointer;
}
