* {
    box-sizing: border-box;
}

:root {
    color-scheme: dark;
    font-family: Inter, "Microsoft JhengHei", system-ui, sans-serif;
    background: #0d1024;
    color: #f7f8ff;
}

body {
    min-height: 100vh;
    margin: 0;
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at top right, rgba(94, 70, 201, 0.32), transparent 35%),
        linear-gradient(145deg, #090b18, #151a36);
}

.lobby {
    width: min(92vw, 540px);
}

h1 {
    margin: 0 0 20px;
    text-align: center;
    letter-spacing: 0.08em;
}

h2 {
    font-size: 1rem;
    margin: 0 0 10px;
}

.connection-card,
.lobby-card {
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    background: rgba(20, 24, 48, 0.92);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.connection-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding: 14px 18px;
}

.lobby-card {
    display: grid;
    gap: 14px;
    padding: 22px;
}

.label {
    color: #adb2cf;
    font-size: 0.86rem;
}

.status,
.error,
.room-info,
.players-section {
    margin: 0;
}

.status {
    font-weight: 700;
}

.success-status {
    color: #62dda4;
}

.error-status,
.error {
    color: #ff8383;
}

.error {
    min-height: 1.25em;
    font-size: 0.9rem;
}

label {
    font-weight: 700;
}

input,
button {
    min-height: 44px;
    border-radius: 9px;
    font: inherit;
}

input {
    width: 100%;
    border: 1px solid #3a3f63;
    background: #0e1126;
    color: #fff;
    padding: 10px 12px;
    outline: none;
}

input:focus {
    border-color: #8e7cff;
    box-shadow: 0 0 0 3px rgba(142, 124, 255, 0.15);
}

.actions {
    display: grid;
    gap: 10px;
}

.join-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
}

button {
    border: 0;
    cursor: pointer;
    padding: 10px 16px;
    background: #7765dd;
    color: #fff;
    font-weight: 800;
}

button:hover:not(:disabled) {
    background: #8d7bed;
}

button:disabled {
    cursor: wait;
    opacity: 0.55;
}

.room-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-radius: 10px;
    background: #0e1126;
}

.room-info strong {
    color: #b9afff;
    letter-spacing: 0.16em;
}

.players-section {
    border-top: 1px solid rgba(255, 255, 255, 0.09);
    padding-top: 14px;
}

#player-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
}

#player-list li {
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    padding: 10px 12px;
}

#player-list .empty {
    color: #888fac;
}

.host-controls {
    display: grid;
    gap: 8px;
}

.start-status {
    margin: 0;
    min-height: 1.25em;
    text-align: center;
    color: #adb2cf;
}

.game-screen {
    width: min(96vw, 1100px);
}

.game-header {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 12px;
}

.game-header div {
    display: grid;
    gap: 4px;
    text-align: center;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    background: rgba(20, 24, 48, 0.92);
}

.game-hud {
    position: relative;
}

#game-canvas {
    display: block;
    width: 100%;
    max-height: 70vh;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 14px;
    background: #29344f;
}

.hud-stats {
    position: absolute;
    left: 14px;
    bottom: 14px;
    display: flex;
    gap: 8px;
}

.hud-stats span {
    border-radius: 8px;
    background: rgba(9, 11, 24, 0.86);
    padding: 8px 10px;
}

#test-finish-game {
    position: absolute;
    right: 14px;
    bottom: 14px;
    background: #b34c62;
}

.result-screen {
    width: min(92vw, 540px);
}

.result-card {
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    background: rgba(20, 24, 48, 0.92);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
    padding: 28px;
}

.result-card h1 {
    margin-bottom: 12px;
}

@media (max-width: 480px) {
    .join-row,
    .game-header {
        grid-template-columns: 1fr;
    }

    .connection-card,
    .room-info {
        align-items: flex-start;
        gap: 8px;
    }

    .hud-stats {
        position: static;
        margin-top: 8px;
    }

    #test-finish-game {
        position: static;
        width: 100%;
        margin-top: 8px;
    }
}
