* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1a1a2e;
    color: #eee;
    margin: 0;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#container {
    text-align: center;
    max-width: 1000px;
    width: 100%;
}

h1 {
    color: #f39c12;
    margin: 0;
    font-size: 2.5em;
}

.panel {
    background: #16213e;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.hidden {
    display: none !important;
}

/* Entry Screen Styles */
.logo-section {
    margin-bottom: 25px;
}

.logo-section.game-header {
    margin-bottom: 10px;
}

.logo-section.game-header h1 {
    font-size: 1.5em;
    margin: 0;
}

.tagline {
    color: #aaa;
    margin: 5px 0 0 0;
    font-size: 1.1em;
}

.setup-options {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-bottom: 30px;
}

.setup-options .form-group {
    flex: 1;
    max-width: 250px;
}

.game-modes {
    display: grid;
    grid-template-columns: 1fr 1.5fr 1fr;
    gap: 20px;
    justify-content: center;
    margin-bottom: 15px;
}

/* Responsive: stack on smaller screens */
@media (max-width: 900px) {
    .game-modes {
        grid-template-columns: 1fr;
    }
}

/* Per-match Observe button in competition table */
.btn-observe-match {
    background: #3498db;
    color: white;
    border: none;
    padding: 3px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
}

.btn-observe-match:hover {
    background: #2980b9;
}

.mode-card {
    background: #0f0f23;
    border: 2px solid #333;
    border-radius: 10px;
    padding: 20px;
    transition: border-color 0.2s, transform 0.2s;
}

.mode-card.competition-status-card {
    /* No specific width override - uses grid sizing */
}

.mode-card:hover {
    border-color: #f39c12;
    transform: translateY(-2px);
}

.mode-card h3 {
    margin: 0 0 10px 0;
    color: #f39c12;
}

.mode-card p {
    color: #aaa;
    font-size: 0.9em;
    margin: 0 0 15px 0;
}

.mode-card .form-group {
    margin-bottom: 15px;
    text-align: left;
}

.mode-card button {
    width: 100%;
}

#competition-round-info {
    color: #f39c12;
    font-weight: bold;
    margin-bottom: 10px;
}

#competition-matches {
    margin-bottom: 15px;
    max-height: 150px;
    overflow-y: auto;
}

#competition-matches .matches-table {
    font-size: 0.85em;
}

#addAiBtn {
    background: #9b59b6;
    margin-top: 10px;
}

#addAiBtn:hover:not(:disabled) {
    background: #7d3c98;
}

.ai-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    margin-top: 10px;
}

.ai-controls button {
    margin-top: 0;
}

#aiDifficultySelect {
    padding: 8px 12px;
    border-radius: 5px;
    background: #2a2a4a;
    color: #eee;
    border: 1px solid #444;
    cursor: pointer;
}

#aiDifficultySelect:focus {
    outline: none;
    border-color: #9b59b6;
}


.form-group {
    margin-bottom: 15px;
    text-align: left;
}

label {
    display: block;
    margin-bottom: 5px;
    color: #aaa;
    font-size: 0.9em;
}

input, select {
    width: 100%;
    padding: 10px;
    border: 1px solid #333;
    border-radius: 5px;
    background: #0f0f23;
    color: #eee;
    font-size: 14px;
}

button {
    background: #f39c12;
    color: #1a1a2e;
    border: none;
    padding: 12px 30px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.2s;
}

button:hover {
    background: #e67e22;
}

button:disabled {
    background: #555;
    cursor: not-allowed;
    opacity: 0.5;
}

#joinLobbyBtn {
    background: #27ae60;
}

#joinLobbyBtn:hover {
    background: #219a52;
}

#status {
    font-size: 18px;
    margin-bottom: 15px;
    padding: 10px;
    border-radius: 5px;
    background: #0f0f23;
}

/* Status message colors based on game state */
#status.waiting {
    color: #3498db;  /* Calm blue - anticipation */
}

#status.playing {
    color: #f39c12;  /* Orange - action/energy */
}

#status.victory {
    color: #f1c40f;  /* Gold - celebration */
    font-weight: bold;
}

#status.error {
    color: #e74c3c;  /* Red - problems */
}

#gameCanvas {
    border: 2px solid #f39c12;
    border-radius: 5px;
    background: #0f0f23;
    display: block;
}

#game-area {
    display: flex;
    justify-content: center;
    gap: 20px;
    align-items: flex-start;
}

#instructions {
    background: #0f0f23;
    border: 2px solid #333;
    border-radius: 5px;
    padding: 15px;
    min-width: 200px;
    max-width: 280px;
    text-align: left;
}

#instructions h3 {
    margin: 0 0 15px 0;
    color: #f39c12;
    text-align: center;
}

#instructions h4 {
    margin: 0 0 8px 0;
    color: #aaa;
    font-size: 14px;
    border-bottom: 1px solid #333;
    padding-bottom: 5px;
}

.instruction-section {
    margin-bottom: 15px;
}

.instruction-section p {
    margin: 0;
    font-size: 13px;
    color: #ccc;
    line-height: 1.4;
}

.key-row {
    font-size: 13px;
    margin-bottom: 5px;
    color: #ccc;
}

.key {
    display: inline-block;
    background: #333;
    border: 1px solid #555;
    border-radius: 4px;
    padding: 2px 6px;
    font-family: monospace;
    font-size: 12px;
    min-width: 20px;
    text-align: center;
    margin-right: 5px;
}

input[type="range"] {
    width: 100%;
}

#scores {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.scores-table {
    width: 100%;
    border-collapse: collapse;
    background: #1a1a2e;
    border-radius: 5px;
    overflow: hidden;
}

.scores-table th {
    background: #0f3460;
    padding: 8px;
    font-size: 0.9em;
}

.scores-table td {
    padding: 8px 12px;
}

.scores-table td:last-child {
    text-align: right;
    font-weight: bold;
}

.scores-table tr.player1 {
    background: #27ae60;
}

.scores-table tr.player2 {
    background: #e74c3c;
}

#left-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-width: 120px;
    align-items: stretch;
}

#readyBtn {
    width: 100%;
}

/* Server Settings section */
.server-settings {
    margin-top: 25px;
    padding: 15px;
    background: #0f0f23;
    border: 1px solid #333;
    border-radius: 8px;
    text-align: center;
}

.server-settings h4 {
    margin: 0 0 15px 0;
    color: #aaa;
    font-size: 0.95em;
}

.settings-grid-compact {
    display: grid;
    grid-template-columns: auto auto auto auto auto auto;
    gap: 8px 15px;
    font-size: 0.85em;
    justify-content: center;
}

.settings-grid-compact span:nth-child(even) {
    color: #f39c12;
    font-weight: bold;
}

.server-unavailable {
    color: #e74c3c;
    font-size: 0.9em;
    padding: 10px;
}

.server-info-links {
    margin-top: 10px;
    margin-bottom: 0;
    font-size: 0.8em;
    color: #666;
}

.server-info-links a {
    color: #888;
    text-decoration: underline;
    cursor: pointer;
}

.server-info-links a:hover {
    color: #f39c12;
}

/* Championship History section — two side-by-side panes */
.championship-history {
    margin-top: 20px;
}

.history-panels {
    display: flex;
    gap: 10px;
}

.history-panel {
    flex: 1;
    padding: 12px;
    background: #0f0f23;
    border: 1px solid #333;
    border-radius: 8px;
    text-align: center;
}

.history-panel h4 {
    margin: 0 0 8px 0;
    color: #f1c40f;
    font-size: 0.95em;
}

#recent-winners-list,
#leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-entry {
    display: flex;
    justify-content: space-between;
    padding: 4px 10px;
    background: #1a1a2e;
    border-radius: 4px;
    font-size: 0.85em;
    color: #ccc;
}

.history-entry .champion-name {
    color: #f1c40f;
    font-weight: bold;
}

.history-entry .win-count {
    color: #2ecc71;
    font-weight: bold;
}

.history-entry .history-scores {
    color: #888;
    font-size: 0.9em;
}

.btn-clear-history {
    display: block;
    margin: 10px auto 0;
    padding: 4px 20px;
    background: transparent;
    color: #888;
    border: 1px solid #444;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
    transition: color 0.2s, border-color 0.2s;
}

.btn-clear-history:hover {
    color: #e74c3c;
    border-color: #e74c3c;
}

.copy-btn {
    background: transparent;
    border: none;
    padding: 2px 4px;
    cursor: pointer;
    font-size: 0.75em;
    color: inherit;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.copy-btn:hover {
    opacity: 1;
}

.setting-label {
    color: #888;
    text-align: right;
}

/* Match info section */
.match-info {
    background: #0f0f23;
    border: 1px solid #333;
    border-radius: 5px;
    padding: 10px;
    text-align: center;
    font-size: 0.85em;
}

.match-info div {
    margin: 5px 0;
    color: #aaa;
}

.match-info span {
    color: #f39c12;
    font-weight: bold;
}

/* Game status indicators */
#game-status .in-progress {
    color: #f39c12;  /* Orange - playing */
}

#game-status .winner {
    color: #f1c40f;  /* Gold - victory */
}

#game-status .waiting {
    color: #3498db;  /* Blue - waiting */
}

/* Live matches table for observers */
.matches-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8em;
    margin-top: 5px;
}

.matches-table th {
    background: #1a1a2e;
    padding: 5px;
    font-size: 0.85em;
    color: #aaa;
}

.matches-table td {
    padding: 4px 6px;
    border-bottom: 1px solid #333;
}

.matches-table tr.current-match {
    background: #0f3460;
}

.matches-table .score {
    text-align: center;
    font-weight: bold;
    color: #f39c12;
}

/* Lobby panel styles */
.lobby-panel {
    min-height: 200px;
}

.lobby-player-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px;
    margin: 4px 0;
    background: #1a1a2e;
    border-radius: 4px;
    gap: 8px;
}

.lobby-player-assigned {
    color: #27ae60;
    font-weight: bold;
}

.lobby-player-waiting {
    color: #aaa;
}

.btn-kick {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 4px 8px;
    font-size: 0.8em;
    border-radius: 3px;
    cursor: pointer;
}

.btn-kick:hover {
    background: #c0392b;
}

.btn-add-to-slot {
    background: #27ae60;
    color: white;
    border: none;
    padding: 4px 8px;
    font-size: 0.8em;
    border-radius: 3px;
    cursor: pointer;
}

.btn-add-to-slot:hover:not(:disabled) {
    background: #1e8449;
}

.btn-add-to-slot:disabled {
    background: #555;
    cursor: not-allowed;
    opacity: 0.5;
}

/* Leave Lobby button inside the lobby panel */
.btn-leave-lobby-panel {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 8px;
    background: #e67e22;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.9em;
    cursor: pointer;
}

.btn-leave-lobby-panel:hover {
    background: #d35400;
}

/* Admin-only elements */
.admin-only {
    display: none; /* Initially hidden, shown by JS if admin */
}

/* Invite button styling */
.btn-invite {
    background: #e67e22;
    color: white;
    margin-top: 8px;
}

.btn-invite:hover {
    background: #d35400;
}

/* Competition controls */
.competition-controls {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.btn-start-competition {
    background: #27ae60;
    color: white;
}

.btn-start-competition:hover:not(:disabled) {
    background: #1e8449;
}

.btn-start-competition.blue {
    background: #3498db;
}

.btn-start-competition.blue:hover:not(:disabled) {
    background: #2980b9;
}

.start-comp-note {
    font-size: 0.8em;
    color: #aaa;
    margin: 4px 0 0 0;
    text-align: center;
}

.pause-controls {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.btn-resume {
    background: #27ae60;
    color: white;
}

.btn-resume:hover {
    background: #219a52;
}

.btn-cancel {
    background: #e74c3c;
    color: white;
}

.btn-cancel:hover {
    background: #c0392b;
}

.lobby-status-msg {
    font-size: 0.8em;
    color: #aaa;
    margin: 0 0 8px 0;
    text-align: center;
}

/* Copy to clipboard toast */
.copy-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #27ae60;
    color: white;
    padding: 12px 20px;
    border-radius: 5px;
    font-size: 14px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 1000;
}

.copy-toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* Note styling for bot link */
.note {
    font-size: 0.8em;
    color: #888;
    margin: 10px 0;
    padding: 8px;
    background: #1a1a2e;
    border-radius: 4px;
}

.note a {
    color: #f39c12;
    text-decoration: underline;
}

.note a:hover {
    color: #e67e22;
}
