/* Haxball 3D - Authentic UI Stylesheet */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    user-select: none;
}

body {
    background-color: #0d1215;
    color: #ffffff;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* 3D Canvas Layer */
#canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

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

/* App View Containers */
.view-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
}

.view-layer > * {
    pointer-events: auto;
}

.hidden {
    display: none !important;
}

/* Dialog & Card Styles (Haxball Slate Design) */
.dialog-card {
    background-color: #1a2125;
    border-radius: 6px;
    padding: 16px 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
    border: 1px solid #283339;
}

.dialog-title {
    font-size: 20px;
    font-weight: 700;
    padding-bottom: 8px;
    margin-bottom: 16px;
    border-bottom: 3px solid #c13535;
    color: #ffffff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Buttons */
button {
    background-color: #244967;
    color: #ffffff;
    border: none;
    border-radius: 5px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

button:hover {
    background-color: #2f5e85;
}

button:active {
    background-color: #193449;
}

button.btn-green {
    background-color: #3a9933;
}
button.btn-green:hover {
    background-color: #46b83d;
}
button.btn-green:active {
    background-color: #2e7a29;
}

button.btn-red {
    background-color: #c13535;
}
button.btn-red:hover {
    background-color: #cf5050;
}
button.btn-red:active {
    background-color: #a12c2c;
}

button.btn-blue {
    background-color: #3b6cb7;
}
button.btn-blue:hover {
    background-color: #497ecc;
}

/* Inputs & Selects */
input[type="text"], select {
    background-color: #111619;
    color: #ffffff;
    border: 1px solid #244967;
    border-radius: 5px;
    padding: 8px 12px;
    font-size: 14px;
    outline: none;
}

input[type="text"]:focus, select:focus {
    border-color: #497ecc;
}

/* Modal Windows */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-content {
    width: 380px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.input-group label {
    font-size: 13px;
    color: #a0aec0;
    font-weight: 600;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

/* Room List View */
#roomlist-view .container {
    width: 700px;
    max-height: 85vh;
}

.header-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
}

.logo-title {
    font-size: 26px;
    font-weight: 900;
    letter-spacing: 1px;
    color: #ffffff;
}

.logo-title span {
    color: #e56e56;
}

.roomlist-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
}

.join-direct-box {
    display: flex;
    gap: 8px;
    background-color: #141a1d;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 15px;
    align-items: center;
}

.room-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.room-table th {
    text-align: left;
    padding: 8px 10px;
    color: #8899a6;
    font-size: 12px;
    border-bottom: 1px solid #283339;
}

.room-table td {
    padding: 10px;
    font-size: 13px;
    border-bottom: 1px solid #1f272c;
}

.room-row:hover {
    background-color: #222c31;
    cursor: pointer;
}

/* Room Lobby View */
#room-view .container {
    width: 860px;
    max-height: 90vh;
}

.room-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid #c13535;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.room-code-badge {
    background-color: #244967;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1px;
}

.teams-container {
    display: flex;
    gap: 12px;
    min-height: 220px;
    margin-bottom: 15px;
}

.team-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #141a1d;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #232c32;
}

.team-header {
    padding: 8px 12px;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.team-header.red {
    background-color: #90281b;
}

.team-header.blue {
    background-color: #1f4682;
}

.team-header.spec {
    background-color: #2b343a;
}

.player-list {
    flex: 1;
    padding: 8px;
    overflow-y: auto;
    max-height: 180px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.player-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #1b2328;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 13px;
}

.player-list-item.admin .p-name {
    color: #ffdb72;
    font-weight: bold;
}

.player-list-item .p-ping {
    font-size: 11px;
    color: #718096;
}

.lobby-settings-row {
    display: flex;
    gap: 16px;
    align-items: center;
    background-color: #141a1d;
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 15px;
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #cbd5e0;
}

.lobby-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tools-group {
    display: flex;
    gap: 6px;
}

/* In-Game HUD Overlay */
#game-view {
    pointer-events: none;
    z-index: 20;
}

.top-bar-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    pointer-events: none;
}

.scoreboard-bar {
    pointer-events: auto;
    background-color: #1a2125;
    display: flex;
    align-items: center;
    padding: 6px 20px;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    gap: 20px;
    border: 1px solid #283339;
    border-top: none;
}

.score-box {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 22px;
    font-weight: 900;
}

.team-badge {
    width: 24px;
    height: 24px;
    border-radius: 5px;
    display: inline-block;
}

.team-badge.red {
    background-color: #e56e56;
}

.team-badge.blue {
    background-color: #5689e5;
}

.score-num {
    min-width: 20px;
    text-align: center;
    transition: transform 0.2s ease, color 0.2s ease;
    display: inline-block;
}

.score-num.score-pop {
    animation: scorePopAnim 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes scorePopAnim {
    0% { transform: scale(1); color: #ffffff; }
    35% { transform: scale(1.85); color: #ffeb3b; text-shadow: 0 0 15px rgba(255, 235, 59, 0.9); }
    100% { transform: scale(1); color: #ffffff; }
}

.timer-box {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 1px;
    color: #f7fafc;
}

.overtime-indicator {
    background-color: #e53e3e;
    color: #ffffff;
    font-size: 10px;
    font-weight: 900;
    padding: 2px 6px;
    border-radius: 3px;
    letter-spacing: 1px;
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    from { opacity: 0.6; }
    to { opacity: 1; }
}

.ingame-menu-btns {
    position: absolute;
    top: 10px;
    right: 15px;
    display: flex;
    gap: 8px;
    pointer-events: auto;
}

/* Floating Draggable Chatbox */
.chatbox-wrapper {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: 680px;
    height: 150px;
    background-color: rgba(26, 33, 37, 0.88);
    backdrop-filter: blur(6px);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    z-index: 30;
    pointer-events: auto;
}

.chat-log {
    flex: 1;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.4;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 6px;
    scrollbar-width: thin;
}

.chat-msg {
    word-break: break-word;
}

.chat-input-row {
    display: flex;
    gap: 6px;
    height: 32px;
}

.chat-input-row input {
    flex: 1;
    height: 100%;
    padding: 4px 10px;
    font-size: 13px;
}

.chat-input-row button {
    padding: 4px 14px;
}

/* Goal Banner Announcement */
.goal-announcement {
    position: absolute;
    top: 35%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(17, 22, 25, 0.95);
    border: 3px solid #c13535;
    padding: 24px 50px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    animation: goalPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    z-index: 50;
}

@keyframes goalPop {
    0% { transform: translate(-50%, -50%) scale(0.6); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.goal-announcement h1 {
    font-size: 44px;
    font-weight: 900;
    letter-spacing: 2px;
    margin-bottom: 8px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}

.goal-announcement p {
    font-size: 18px;
    color: #cbd5e0;
}

/* Countdown Overlay */
.countdown-container {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 80px;
    font-weight: 900;
    color: #ffdb72;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.9);
    pointer-events: none;
    z-index: 45;
}

/* Controls Hint Box */
.controls-hint {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(26, 33, 37, 0.7);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 11px;
    color: #a0aec0;
    pointer-events: none;
    z-index: 25;
}

.controls-hint span {
    color: #ffffff;
    font-weight: bold;
}

/* Host Waiting Notice for Guest Players */
.host-waiting-notice {
    font-size: 14px;
    font-weight: 700;
    color: #ffd166;
    background: rgba(255, 209, 102, 0.12);
    border: 1px dashed #ffd166;
    padding: 8px 18px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: pulse 1.8s infinite alternate;
}

/* Kick / Remove Button in Lobby */
.btn-kick-player {
    background-color: transparent;
    border: none;
    color: #e53e3e;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
}

.btn-kick-player:hover {
    background-color: #e53e3e;
    color: #ffffff;
}

/* Disabled Setting Inputs */
select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: #121619;
    border-color: #20272b;
}

/* Room table join button */
.btn-table-join {
    background-color: #38a169;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-table-join:hover {
    background-color: #2f855a;
}

/* Replay Broadcast Overlay */
.replay-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 40;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
    padding: 24px 30px;
}

.replay-badge {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(229, 62, 62, 0.9);
    color: #ffffff;
    font-size: 16px;
    font-weight: 900;
    letter-spacing: 2px;
    padding: 6px 16px;
    border-radius: 6px;
    box-shadow: 0 4px 15px rgba(229, 62, 62, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.replay-rec-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #ffffff;
    display: inline-block;
    animation: pulse 1s infinite alternate;
}

.replay-bottom-bar {
    align-self: center;
    margin-bottom: 30px;
    pointer-events: auto;
}

.btn-skip-replay {
    background: linear-gradient(135deg, #d69e2e, #b7791f);
    color: #ffffff;
    font-size: 15px;
    font-weight: 800;
    padding: 10px 24px;
    border: 1px solid #ecc94b;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(214, 158, 46, 0.5);
    transition: transform 0.15s ease, background 0.2s ease;
}

.btn-skip-replay:hover {
    background: linear-gradient(135deg, #ecc94b, #d69e2e);
    transform: translateY(-2px);
}

.guest-replay-hint {
    background: rgba(20, 26, 29, 0.85);
    color: #ffd166;
    font-size: 13px;
    font-weight: 700;
    padding: 8px 18px;
    border-radius: 6px;
    border: 1px solid #4a5568;
}

/* Bottom Right Square Ping HUD Widget */
.ping-hud {
    position: absolute;
    bottom: 16px;
    right: 18px;
    width: 84px;
    height: 84px;
    background: rgba(18, 24, 28, 0.88);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 7px 10px;
    box-sizing: border-box;
    z-index: 50;
    user-select: none;
    pointer-events: none;
}

.ping-header {
    display: flex;
    align-items: center;
    gap: 5px;
}

.ping-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: #48bb78;
    box-shadow: 0 0 6px #48bb78;
    display: inline-block;
}

.ping-dot.ping-good { background-color: #48bb78; box-shadow: 0 0 6px #48bb78; }
.ping-dot.ping-med { background-color: #ecc94b; box-shadow: 0 0 6px #ecc94b; }
.ping-dot.ping-bad { background-color: #f56565; box-shadow: 0 0 6px #f56565; }

.ping-title {
    font-size: 10px;
    font-weight: 800;
    color: #8899a6;
    letter-spacing: 0.5px;
}

.ping-body {
    display: flex;
    align-items: baseline;
    gap: 3px;
}

.ping-value {
    font-size: 20px;
    font-weight: 900;
    color: #48bb78;
    font-family: 'Consolas', 'Courier New', monospace;
    line-height: 1;
}

.ping-unit {
    font-size: 10px;
    color: #a0aec0;
    font-weight: 700;
}

.ping-bar-track {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.ping-bar-fill {
    height: 100%;
    width: 90%;
    background: #48bb78;
    border-radius: 2px;
    transition: width 0.3s ease, background 0.3s ease;
}

.ping-good-bar { background: #48bb78; }
.ping-med-bar { background: #ecc94b; }
.ping-bad-bar { background: #f56565; }

.ping-quality-label {
    font-size: 9px;
    font-weight: 700;
    color: #8899a6;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
