/* Game styles */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

body {
    margin: 0;
    overflow: hidden; /* Prevent page scrolling */
    user-select: none;
    touch-action: auto;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    /* Disable force touch/3D touch on iOS */
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-force-touch: none;
    -webkit-touch-force: none;
    /* Disable pull-to-refresh on Android */
    overscroll-behavior: none;
    -webkit-overflow-scrolling: auto;
    height: 100vh; /* Full viewport height */
}

body.in-game {
    overflow: hidden;
    touch-action: none;
    /* Additional force touch prevention during gameplay */
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    /* Disable pull-to-refresh on Android during game */
    overscroll-behavior: none;
    -webkit-overflow-scrolling: auto;
}

canvas {
    display: block;
    /* Disable force touch on canvas */
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-force-touch: none;
    -webkit-touch-force: none;
    touch-action: none;
}


#lobby {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #f8f8f8;
    font-family: 'Press Start 2P', monospace;
    overflow: hidden;
}

/* Lobby title - centered on full page */
#lobby > h2 {
    text-align: center;
    margin: 0;
    padding: 15px 0;
}

/* Two-column grid layout */
.lobby-grid {
    display: grid;
    grid-template-columns: 25% 1fr;
    height: calc(100vh - 50px);
    margin-right: 20px;
    position: relative;
}

/* Chamfer border for lobby-content top right corner - placed on lobby-grid which doesn't scroll with the content, corner cut via clip-path by .lobby-content */
.lobby-grid::after {
    content: '';
    position: absolute;
    top: 30px;
    right: 0px;
    width: 42.42px;
    height: 4px;
    background: #9b9b9b;
    transform: rotate(45deg);
    transform-origin: top right;
    pointer-events: none;
    z-index: 10;
}

/* Left Column: Navigation */
.lobby-nav {
    background: transparent;
    padding: 20px;
    padding-right: 0;
    padding-top: 0;
    display: flex;
    flex-direction: column;
    overflow: visible;
    z-index: 2;
}

.player-name-display {
    font-size: clamp(8px, 1.5vw, 12px);
    font-weight: bold;
    color: #444;
    margin-bottom: 15px;
    margin-right: 15px;
    margin-top: -25px;
    padding: 10px;
    text-align: left;
    min-height: 48px;
    cursor: pointer;
    border: 4px solid #9b9b9b;
    border-bottom: 7px solid #9b9b9b;
    transition: all 0.2s ease;
    background: rgba(235, 235, 235, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    position: relative;
    clip-path: polygon(0 0, calc(100% - 15px) 0, 100% 15px, 100% 100%, 0 100%); /* Chamfer top right corner */
}

/* Chamfer top right corner */
.player-name-display::after {
    content: '';
    position: absolute;
    top: 11px;
    right: -4px;
    width: 21.21px;
    height: 4px;
    background: #9b9b9b;
    transform: rotate(45deg);
    transform-origin: top right;
    pointer-events: none;
    z-index: 1;
}

.player-name-display .tank-design-preview {
    width: 56px;
    height: 56px;
    margin-right: -5px;
    margin-left: -10px;
    flex-shrink: 0;
    display: block;
}

.player-name-display .player-name-text {
    flex: 1;
    text-align: left;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    white-space: normal;
}

.player-name-display:hover {
    /* background: #f0f0f0; */
    /* font-size: clamp(9px, 1.7vw, 13px); */
    scale: 1.03;
    transition: all 0.2s ease;
}

/* Nav Buttons */
.nav-buttons {
    display: flex;
    flex-direction: column;
}

.nav-button {
    font-family: 'Press Start 2P', monospace;
    padding: 16px 16px 16px 24px;
    cursor: pointer;
    text-align: left;
    font-size: clamp(8px, 1.7vw, 12px);
    width: 100%;
    border: none;
    background: transparent;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    white-space: normal;
    word-wrap: break-word;
    white-space: normal;
}

.nav-button:hover {
    scale: 1.03;
    transition: scale 0.2s ease-in-out;
}

.nav-button.active {
    background: rgba(235, 235, 235, 1);
    border: 4px solid #9b9b9b;
    border-right: none;
    border-bottom: 7px solid #9b9b9b;
}

.nav-button.active::before {
    content: "";
    position: absolute;
    background: rgba(235, 235, 235, 1);
    top: 0px;
    bottom: 0px;
    right: -4px;
    width: 10px;
}

/* Text colors for nav buttons */
.nav-button[data-target="teamSelectionContainer"] { color: red; }
.nav-button[data-target="loadoutContainer"] { color: green; }
.nav-button[data-target="settingsContainer"] { color: blue; }
.nav-button[data-target="controlSettings"] { color: purple; }
.nav-button[data-target="leaderboardContainer"] { color: orange; }

/* Center Column: Content */
.lobby-content {
    background: rgba(235, 235, 235, 1);
    padding: 20px;
    padding-right: 30px;
    overflow-y: auto;
    position: relative;
    text-align: center;
    display: flex;
    flex-direction: column;
    border: 4px solid #9b9b9b;
    border-bottom: none;
    overflow-x: hidden;
    clip-path: polygon(0 0, calc(100% - 30px) 0, 100% 30px, 100% 100%, 0 100%); /* Chamfer top right corner of content - border created by lobby-grid::after */
}

/* Global scrollbar styling */
* {
    scrollbar-width: thin;
    scrollbar-color: #9b9b9b transparent;
}

.content-section {
    display: none;
    background: transparent;
    border: none;
    padding: 0;
    margin-bottom: 20px;
    overflow: visible;
}

.content-section.active {
    display: block;
}

.content-section h3 {
    margin-top: 30px;
    margin-bottom: 20px;
    text-align: left;
}

.content-section h3:first-of-type {
    margin-top: 0;
}

/* Separator line between h3 sections */
.content-section h3:not(:first-of-type) {
    border-top: 2px solid #ddd;
    padding-top: 20px;
}

body.dark-mode .content-section h3:not(:first-of-type) {
    border-top: 2px solid #444;
}

/* Name input styling for center column */
#nameInput {
    text-align: center;
    margin-bottom: 20px;
}

#nameInput h2 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #333;
}

/* Play tab header with inline buttons for start and become host on top of play tab title */
.play-tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.play-tab-header h3 {
    margin: 0;
}

.action-buttons-inline {
    display: flex;
    gap: 10px;
}

/* Retro button style (like example image) */
.retro-button {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    padding: 10px 16px;
    cursor: pointer;
    color: white;
    background: #666;
    border: 3px solid #9b9b9b;
    border-bottom: 6px solid #9b9b9b;
    box-shadow: inset 0 0 0 2px white;
    transition: all 0.1s ease;
    user-select: none;
    -webkit-user-select: none;
    margin: 0;
    display: block;
}

.retro-button:hover {
    scale: 1.03;
    transition: all 0.2s ease;
}

.retro-button:active {
    transform: translateY(2px);
    border-bottom-width: 3px;
}

.retro-button.small {
    font-size: 9px;
    padding: 6px 12px;
    border-width: 2px;
    border-bottom-width: 4px;
    box-shadow: inset 0 0 0 1px white;
}

#startButton.retro-button {
    background: red;
}

#becomeHostButton.retro-button {
    background: purple;
}

/* Bot control buttons */
.bot-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 12px;
}

.bot-controls-label {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    color: #666;
}

#playerList {
    margin: 20px 0;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

#playerList:empty {
    display: none;
}

#playerName {
    font-family: 'Press Start 2P', monospace;
    padding: 10px;
    margin: 10px 0;
    width: calc(100% - 24px); /* Account for padding and border */
    max-width: 300px;
    font-weight: bold;
    border: 4px solid black;
    background: white;
    box-sizing: border-box;
}

#playerName:focus {
    outline: none;
    background: #f0f0f0;
}

#joinButton {
    background: blue;
}

.player-item {
    margin: 10px 0;
    display: flex;
    align-items: center;
    padding: 5px;
    font-size: 12px;
}

.player-color {
    display: block; /* re-enabled player color box */
    display: none;  /* disabled player color box */
    width: 20px;
    height: 20px;
    margin-right: 10px;
    border: 2px solid black;
}

.winner-announcement {
    padding: 10px 20px;
    text-align: center;
    margin: 10px auto;
    animation: pulse 2s infinite;
    /* border: 4px solid black; */
    /* background: white; */
    display: inline-block;
    box-sizing: border-box;
    max-width: 320px;
    word-wrap: break-word;
}

.error-message {
    color: red;
    margin-top: 5px;
    font-size: 14px;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.settings-container {
    display: block; /* Always show, controlled by content-section class */
    background: transparent; /* Remove background since content sections handle it */
    border: none; /* Remove border since content sections handle it */
    padding: 0; /* Remove padding since content sections handle it */
    margin: 0; /* Remove margin since content sections handle it */
    max-width: none; /* Remove max-width restriction */
}

/* Remove the old in-lobby class dependency */
.in-lobby .settings-container {
    display: block;
}

/* Add spacing between settings containers */
.settings-container + .settings-container {
    margin-top: 10px;
}

/* Only hide the container if both heading and content are empty */
.settings-container:empty {
    display: none;
}

/* Adjust player list margins inside container */
#lobbyContainer #playerList {
    margin: 0;
}

#lobbyContainer #playerList:empty::after {
    content: "Waiting for players...";
    display: block;
    color: #666;
    font-size: 14px;
    font-style: italic;
    text-align: center;
    margin-top: 10px;
}

.settings-container h3 {
    margin-top: 10px;
    margin-bottom: 20px;
    color: #333;
    font-size: 18px;
}

.setting-row {
    display: flex;
    flex-direction: column;
    margin-bottom: 15px;
}

/* When slider is disabled, reduce the spacing */
.setting-row:has(input[type="range"]:disabled) {
    margin-bottom: 8px;
}

.setting-row:has(input[type="range"]:disabled) .setting-header {
    margin-bottom: 0;
}

/* Horizontal layout for setting rows with range inputs */
.setting-row:has(input[type="range"]) {
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.setting-row:has(input[type="range"]) .setting-header {
    margin-bottom: 0;
    margin-top: 0;
    flex-shrink: 0;
    width: 180px;
    min-width: 180px;
    justify-content: flex-start;
}

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

.setting-row label {
    font-size: 14px;
    color: #444;
}

.setting-row input[type="range"] {
    width: 100%;
    height: 8px;
    background: #ddd;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
    tap-highlight-color: transparent;
}

.setting-row:has(input[type="range"]) input[type="range"] {
    flex: 1;
    width: auto;
}

.setting-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: #000000;
    cursor: pointer;
}

.setting-row input[type="range"]:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    display: none;
}

.setting-row input[type="range"]:disabled::-webkit-slider-thumb {
    background: #999;
    cursor: not-allowed;
    display: none;
}

.setting-row span {
    font-size: 14px;
    color: #666;
}

.setting-row:has(input[type="range"]) span {
    flex-shrink: 0;
    width: 50px;
    min-width: 50px;
    text-align: right;
}

/* Custom checkbox styling */
.setting-row input[type="checkbox"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid #000000;
    cursor: pointer;
    position: relative;
    margin: 0;
    padding: 0;
    border-radius: 0;
    -webkit-border-radius: 0;
    -webkit-transition: none !important;
    transition: none !important;
    animation: none !important;
    -webkit-animation: none !important;
}

.setting-row input[type="checkbox"]:checked {
    background-color: #000000;
    -webkit-transition: none !important;
    transition: none !important;
    animation: none !important;
    -webkit-animation: none !important;
}

.setting-row input[type="checkbox"]:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.setting-row input[type="checkbox"]:focus {
    outline: none;
}

/* Custom checkbox container styling */
.setting-row:has(input[type="checkbox"]) {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

.setting-row:has(input[type="checkbox"]) .setting-header {
    margin-bottom: 0;
}


.stats-tables {
    display: flex;
    flex-direction: column;
    /* gap: 20px; */
    margin-top: 0px;
    margin-bottom: 0px;
    align-items: center;
}

.game-stats, .overall-stats {
    width: 100%;
    max-width: 440px;
}

.team-stats {
    width: 100%;
    max-width: 440px;
    margin-bottom: 20px;
}

.stats-tables table {
    width: 100%;
    border-collapse: collapse;
    /* margin: 20px auto 0 auto; */
    background: rgba(155, 155, 155, 0.1);
    border-radius: 0px;
}

.stats-tables th, .stats-tables td {
    padding: 8px;
    text-align: center;
}

.stats-tables th {
    background: rgba(0, 0, 0, 0.2);
    font-size: 12px;
    font-family: 'Press Start 2P', monospace;
}

.stats-tables td {
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
}

.stats-tables th:first-child,
.stats-tables td:first-child {
    text-align: left;
}

.stats-tables th:last-child,
.stats-tables td:last-child {
    text-align: right;
}

#winnerAnnouncement {
    width: 100%;
    text-align: center;
    margin: 10px 0;
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

#winnerAnnouncement:empty {
    display: none;
}

select {
    padding: 4px;
    border: 2px solid black;
    border-radius: 0px;
    font-family: inherit;
    font-size: 11px;
    color: #444;
}

select:focus {
    outline: none;
}

#changeNameButton {
    background: blue;
}

/* Dark mode styles */
body.dark-mode {
    background: #2d2d2d;
}

body.dark-mode #lobby {
    background: #2d2d2d;
    color: #e0e0e0;
}

body.dark-mode #lobby h2 {
    color: #9b9b9b;
}

body.dark-mode #lobbyContainer #playerList .player-item {
    background: #2d2d2d;
}


body.dark-mode #playerName {
    background: #1a1a1a;
    border: 4px solid #666;
    color: #e0e0e0;
}

body.dark-mode #playerName:focus {
    background: #333;
}

body.dark-mode .settings-container {
    background: #2d2d2d;
    border-color: #9b9b9b;
}

body.dark-mode .settings-container h3 {
    color: #9b9b9b;
}

body.dark-mode .setting-row label {
    color: #9b9b9b;
}

body.dark-mode .setting-row input[type="range"] {
    background: #404040;
}

body.dark-mode .setting-row input[type="range"]::-webkit-slider-thumb {
    background: #9b9b9b;
}

body.dark-mode .setting-row input[type="checkbox"] {
    border-color: #9b9b9b;
}

body.dark-mode .setting-row input[type="checkbox"]:checked {
    background: #9b9b9b;
}

body.dark-mode .winner-announcement {
    /* background: #2d2d2d; */
    /* border-color: #9b9b9b; */
    color: #9b9b9b;
}

body.dark-mode select {
    border: 2px solid #9b9b9b;
    outline: none;
    background-color: #404040;
    color: #9b9b9b;
}

body.dark-mode #leaderboardContainer h3,
body.dark-mode .stats-tables h4 {
    color: #9b9b9b;
}

body.dark-mode .stats-tables th,
body.dark-mode .stats-tables td {
    color: #9b9b9b;
}

body.dark-mode .stats-tables table {
    background: rgba(155, 155, 155, 0.1);
}

body.dark-mode .stats-tables th {
    background: rgba(155, 155, 155, 0.2);
}

/* Team Selection Table */
.team-selection {
    display: flex;
    justify-content: center;
}

.team-selection table {
    width: 100%;
    max-width: 360px;
    border-collapse: collapse;
    margin: 10px auto;
    background: rgba(155, 155, 155, 0.1);
    border-radius: 0px;
}

.team-selection th, 
.team-selection td {
    padding: 8px;
    text-align: center;
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
}

.team-selection th {
    background: rgba(0, 0, 0, 0.2);
}

.team-selection td:first-child {
    text-align: left;
}

/* Team Box Styles */
.team-box {
    width: 18px;
    height: 18px;
    margin: 0 auto;
}

.red-box {
    background-color: red;
}

.blue-box {
    background-color: blue;
}

.green-box {
    background-color: green;
}

.orange-box {
    background-color: orange;
}

/* Team Selection Radio */
.team-selection input[type="radio"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background-color: rgba(0, 0, 0, 0.1);
    cursor: pointer;
    position: relative;
    margin: 0;
    padding: 0;
    border-radius: 0%;
    -webkit-border-radius: 0;
    -webkit-transition: none !important;
    transition: none !important;
    animation: none !important;
    -webkit-animation: none !important;
}

.team-selection input[type="radio"].team-red:checked {
    background-color: red;
    border-color: red;
}

.team-selection input[type="radio"].team-blue:checked {
    background-color: blue;
    border-color: blue;
}

.team-selection input[type="radio"].team-green:checked {
    background-color: green;
    border-color: green;
}

.team-selection input[type="radio"].team-orange:checked {
    background-color: orange;
    border-color: orange;
}


.dark-mode .team-selection input[type="radio"]{
    background-color: rgba(155, 155, 155, 0.2);
    /* border-color: rgba(0, 0, 0, 0.2); */
}



body.dark-mode .player-name-display {
    color: #9b9b9b;
    border-color: #444;
    background: #383838;
}

body.dark-mode .player-name-display::after {
    background: #444;
}

body.dark-mode .lobby-content {
    border-color: #444;
    background: #383838;
}

/* Dark mode scrollbar styling */
body.dark-mode * {
    scrollbar-color: #444 transparent;
}

body.dark-mode .lobby-grid::after {
    background: #444;
}

body.dark-mode .nav-button.active {
    border-color: #444;
    background: #383838;
}

body.dark-mode .nav-button.active:before {
    background: #383838;
}

body.dark-mode .retro-button {
    border-color: #444;
    border-bottom-color: #444;
}

body.dark-mode .bot-controls-label {
    color: #888;
}

body.dark-mode .players-content h3 {
    color: #9b9b9b;
}

/* Base Card System */
.card-grid {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding-bottom: 10px;
    margin: 10px 0;
}

.card {
    --card-color: green;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    background: #ddd;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    width: 100px;
    min-width: 100px;
    min-height: 100px;
    border: 4px solid #9b9b9b;
    border-bottom-width: 7px;
    position: relative;
    clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 0 100%);
}

.card::after {
    content: '';
    position: absolute;
    top: 8px;
    right: -4px;
    width: 16.97px;
    height: 4px;
    background: #9b9b9b;
    transform: rotate(45deg);
    transform-origin: top right;
}

.card:hover { border-color: var(--card-color); }
.card:hover::after { background: var(--card-color); }
.card.selected { background: var(--card-color); border-color: var(--card-color); }
.card.selected::after { background: var(--card-color); }
.card.selected .card-label,
.card.selected .card-title,
.card.selected .card-description { color: white; }
.card.disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

body.dark-mode .card { background: #404040; border-color: #444; }
body.dark-mode .card::after { background: #444; }
body.dark-mode .card.selected { background: var(--card-color); border-color: var(--card-color); }
body.dark-mode .card.selected::after { background: var(--card-color); }

/* Card content elements */
.card-label {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    color: #333;
    text-align: center;
    line-height: 1.2;
}

.card-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    color: #333;
    text-align: center;
    line-height: 1.3;
}

.card-description {
    font-family: 'Press Start 2P', monospace;
    font-size: 7px;
    color: #666;
    text-align: center;
    line-height: 1.4;
}

.card-canvas {
    display: block;
    margin-bottom: 12px;
}

.card-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    margin-bottom: 8px;
    border: 1px solid #999;
}

.card-placeholder {
    width: 60px;
    height: 60px;
    background: #999;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    color: white;
    text-align: center;
}

body.dark-mode .card-label,
body.dark-mode .card-title { color: #9b9b9b; }
body.dark-mode .card-description { color: #999; }
body.dark-mode .card-image { border-color: #666; }
body.dark-mode .card-placeholder { background: #666; }

/* Card color variants */
.card--green { --card-color: green; }
.card--blue { --card-color: blue; }
.card--purple { --card-color: purple; }
.card--orange { --card-color: orange; }

/* Toggle card variant - smaller compact cards */
.card--toggle {
    width: 70px;
    min-width: 70px;
    min-height: 50px;
    padding: 8px;
}

/* Perks Selection */
.perks-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 10px;
}

.perks-category {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.perks-category:not(:first-child) {
    border-top: 2px solid #ddd;
    padding-top: 15px;
}

body.dark-mode .perks-category:not(:first-child) {
    border-top: 2px solid #444;
}

.perks-category-label {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    color: #333;
    text-align: left;
}

body.dark-mode .perks-category-label {
    color: #9b9b9b;
}

/* Ensure proper scrolling for content sections */
.content-section {
    overflow: visible;
}

body.dark-mode #nameInput h2 {
    color: #e0e0e0;
}


body.dark-mode select {
    border: 2px solid #9b9b9b;
    outline: none;
    background-color: #404040;
    color: #9b9b9b;
}




/* Mobile landscape orientation notification */
.orientation-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #f8f8f8;
    z-index: 10001;
    font-family: 'Press Start 2P', monospace;
    text-align: center;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 30px;
}

.orientation-overlay h1 {
    font-size: 38px;
    margin-bottom: 30px;
    color: #333;
}

.orientation-overlay p {
    font-size: 12px;
    margin: 0;
    color: #666;
    line-height: 1.6;
    max-width: 280px;
    padding: 0 40px;
}

/* Dark mode for orientation overlay */
body.dark-mode .orientation-overlay {
    background: #333;
}

/* body.dark-mode .orientation-overlay h1 {
    color: #fff;
} */

body.dark-mode .orientation-overlay p {
    color: #ccc;
}

body.dark-mode .orientation-overlay .phone-vertical {
    stroke: #888;
    fill: #888;
}

body.dark-mode .orientation-overlay .phone-horizontal {
    stroke: #ccc;
    fill: #ccc;
}

body.dark-mode .orientation-overlay .arrow {
    stroke: #ccc;
    fill: none !important;
}

body.dark-mode .orientation-overlay .arrowhead {
    fill: #ccc;
    stroke: #ccc;
}

/* Add gamepad focus styling at the end of the file */

/* Gamepad Navigation Focus Styles */
.gamepad-focused {
    outline: 2px solid #444 !important;
    outline-offset: 2px !important;
    /* box-shadow: 0 0 8px rgba(68, 68, 68, 0.5) !important; */
    /* transition: all 0.2s ease !important; */
}

/* .gamepad-focused.tank-card {
    border-color: #444 !important;
}

.gamepad-focused.team-box {
    box-shadow: 0 0 0 3px #444 !important;
} */

.gamepad-focused input[type="checkbox"] {
    transform: scale(1.1) !important;
}

.gamepad-focused input[type="range"] {
    /* box-shadow: 0 0 8px rgba(68, 68, 68, 0.5) !important; */
    transform: scale(1.1) !important;
}

.gamepad-focused input[type="radio"] {
    transform: scale(1.25) !important;
    /* box-shadow: 0 0 8px rgba(68, 68, 68, 0.5) !important; */
}

.dark-mode .gamepad-focused {
    outline: 2px solid #9b9b9b !important;
}


/* Setting groups for conditional display */
.setting-group {
    margin-top: 10px;
}

/* Settings Popup Button */
.settings-popup-btn {
    position: fixed;
    top: 8px;
    right: 20px;
    z-index: 10000;
    padding: 4px 8px;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

/* Transform hamburger to X when open */
.settings-popup-btn.open .settings-popup-btn-line:nth-child(1) {
    transform: rotate(45deg) translate(3px, 3px);
}

.settings-popup-btn.open .settings-popup-btn-line:nth-child(2) {
    opacity: 0;
}

.settings-popup-btn.open .settings-popup-btn-line:nth-child(3) {
    transform: rotate(-45deg) translate(3px, -3px);
}

/* Settings Popup Overlay */
.settings-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.2);
    z-index: 1001;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    pointer-events: none;
}

.settings-popup-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: auto;
}

/* Settings Popup Panel */
.settings-popup {
    width: 25%;
    max-height: 80%;
    background: rgba(220, 220, 220, 0.9);
    padding: 15px;
    margin-right: 20px;
    font-family: 'Press Start 2P', monospace;
    overflow-y: auto;
    position: relative;
    border: 4px solid #9b9b9b;
    pointer-events: auto;
}

.settings-popup h3 {
    margin: 0 0 12px 0;
    font-size: 12px;
    color: #333;
    text-align: center;
}

.settings-popup .setting-row {
    margin-bottom: 8px;
}

.settings-popup .setting-header {
    margin-bottom: 8px;
    margin-top: 0;
}

.settings-popup .setting-row label {
    font-size: 12px;
}

.settings-popup .setting-row span {
    font-size: 12px;
}

/* Keep vertical layout (slider below) in settings popup */
.settings-popup .setting-row:has(input[type="range"]) {
    flex-direction: column;
}

.settings-popup .setting-row:has(input[type="range"]) .setting-header {
    width: 100%;
    min-width: auto;
    justify-content: space-between;
    margin-bottom: 8px;
}

.settings-popup .setting-row:has(input[type="range"]) input[type="range"] {
    width: 100%;
    flex: none;
}

.settings-popup .setting-row:has(input[type="range"]) span {
    width: auto;
    min-width: auto;
    text-align: left;
}

/* Dark mode support for popup */
body.dark-mode .settings-popup {
    background: rgba(42, 42, 42, 0.9);
    border-color: #555;
}

body.dark-mode .settings-popup h3 {
    color: #ddd;
}