* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* ================================================
   BETA NOTICE
   ================================================ */
#beta-notice {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(21, 101, 192, 0.92);
    color: #fff;
    padding: 10px 38px 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.4;
    max-width: 380px;
    width: calc(100% - 24px);
    z-index: 100000;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    animation: betaSlideIn 0.4s ease-out;
}

@keyframes betaSlideIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

#beta-notice strong {
    color: #ffca28;
}

#beta-close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    padding: 2px 6px;
}

#beta-close:hover {
    color: #fff;
}

#beta-version {
    display: block;
    text-align: right;
    font-size: 10px;
    color: rgba(255,255,255,0.5);
    margin-top: 4px;
}

#beta-notice.hidden {
    display: none;
}

html,
body {
    background: #1a1a2e;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    height: 100%;
    width: 100%;
    touch-action: manipulation;
    /* Safe area for notched/rounded phones */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* ================================================
   DESKTOP LAYOUT: canvas left, UI panel right
   ================================================ */
#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: row;
}

#curling-canvas {
    display: block;
    flex: 1;
    min-width: 0;
}

#ui-overlay {
    width: 300px;
    min-width: 300px;
    height: 100%;
    background: rgba(10, 10, 30, 0.95);
    display: flex;
    flex-direction: column;
    padding: 12px;
    gap: 10px;
    overflow-y: auto;
    border-left: 2px solid #333;
    z-index: 10;
}

/* ================================================
   WELCOME SCREEN
   ================================================ */
#welcome-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 25, 0.95);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: welcomeFadeIn 0.4s ease-out;
}

@keyframes welcomeFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

#welcome-content {
    text-align: center;
    max-width: 360px;
    padding: 20px;
}

#welcome-title {
    font-size: 28px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}

#welcome-subtitle {
    color: #888;
    font-size: 14px;
    margin-bottom: 24px;
}

#welcome-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#feedback-link {
    display: inline-block;
    margin-top: 18px;
    color: #aaa;
    font-size: 13px;
    text-decoration: none;
    transition: color 0.2s;
}

#feedback-link:hover,
#feedback-link:active {
    color: #fff;
}

.welcome-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: rgba(42, 74, 122, 0.25);
    border: 1px solid #3a5a8a;
    border-radius: 12px;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.welcome-btn:hover {
    background: rgba(42, 74, 122, 0.5);
    border-color: #5c9ae6;
    transform: translateY(-1px);
}

.welcome-btn:active {
    transform: translateY(0);
}

.welcome-btn-primary {
    border-color: #5c9ae6;
    background: rgba(42, 74, 122, 0.4);
}

.welcome-btn-icon {
    font-size: 28px;
    width: 40px;
    text-align: center;
    flex-shrink: 0;
}

.welcome-btn-label {
    font-size: 17px;
    font-weight: 600;
}

.welcome-btn-desc {
    font-size: 12px;
    color: #888;
    margin-left: auto;
}

/* ================================================
   SETTINGS TOGGLE & DROPDOWN
   ================================================ */
#settings-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

#settings-label {
    color: #888;
    font-size: 11px;
    user-select: none;
}

#settings-toggle {
    width: 34px;
    height: 34px;
    font-size: 18px;
    line-height: 1;
    background: #222;
    color: #999;
    border: 1px solid #444;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

#settings-toggle:hover {
    background: #333;
    color: #ddd;
}

#settings-toggle.active {
    background: #2a4a7a;
    color: #fff;
    border-color: #5c9ae6;
}

#settings-dropdown {
    display: none;
    position: absolute;
    top: 40px;
    right: 0;
    background: rgba(20, 20, 45, 0.97);
    border: 1px solid #444;
    border-radius: 8px;
    padding: 8px;
    z-index: 100;
    min-width: 200px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    animation: settingsFadeIn 0.15s ease-out;
}

#settings-dropdown.open {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

@keyframes settingsFadeIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ================================================
   MODE & DIFFICULTY SELECTORS (inside dropdown)
   ================================================ */
#mode-selector {
    display: flex;
    gap: 6px;
}

.mode-btn {
    flex: 1;
    padding: 8px 6px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid #444;
    background: #222;
    color: #aaa;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

.mode-btn:hover {
    background: #333;
    color: #ddd;
}

.mode-btn.active {
    background: #2a4a7a;
    color: #fff;
    border-color: #5c9ae6;
}

#difficulty-selector {
    display: flex;
    gap: 6px;
}

.diff-btn {
    flex: 1;
    padding: 6px 4px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid #444;
    background: #222;
    color: #aaa;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

.diff-btn:hover {
    background: #333;
    color: #ddd;
}

#diff-easy.active {
    background: #2e7d32;
    color: #fff;
    border-color: #4caf50;
}

#diff-medium.active {
    background: #e65100;
    color: #fff;
    border-color: #fb8c00;
}

#diff-hard.active {
    background: #b71c1c;
    color: #fff;
    border-color: #e53935;
}

#difficulty-selector.hidden {
    display: none;
}

#ends-selector-local {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

#ends-selector-local .ends-label {
    font-size: 12px;
    font-weight: 600;
    color: #aaa;
    margin-right: 2px;
}

.ends-local-btn {
    flex: 1;
    padding: 6px 4px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid #444;
    background: #222;
    color: #aaa;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

.ends-local-btn:hover {
    background: #333;
    color: #ddd;
}

.ends-local-btn.active {
    background: #1565c0;
    color: #fff;
    border-color: #1e88e5;
}

#ends-selector-local.hidden {
    display: none;
}

/* ================================================
   BOT THINKING INDICATOR
   ================================================ */
#bot-thinking {
    position: absolute;
    top: 50%;
    left: 0;
    right: 300px;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    pointer-events: none;
}

.thinking-text {
    background: rgba(0, 0, 0, 0.75);
    color: #fdd835;
    font-size: 20px;
    font-weight: 700;
    padding: 12px 24px;
    border-radius: 12px;
    letter-spacing: 1px;
}

.thinking-text .dots {
    animation: thinkDots 1.4s infinite;
}

@keyframes thinkDots {

    0%,
    20% {
        opacity: 0.2;
    }

    50% {
        opacity: 1;
    }

    80%,
    100% {
        opacity: 0.2;
    }
}

/* Disabled controls during bot turn */
#controls-panel.bot-disabled {
    opacity: 0.45;
    pointer-events: none;
}

#controls-panel.bot-disabled input[type="range"] {
    cursor: not-allowed;
}

/* ================================================
   SCOREBOARD
   ================================================ */
#scoreboard {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 8px 10px;
}

.team-score {
    display: flex;
    align-items: center;
    gap: 6px;
}

.team-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
}

.red-dot {
    background: #e53935;
}

.yellow-dot {
    background: #fdd835;
}

.hammer-icon {
    font-size: 18px;
    line-height: 1;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
    animation: hammerGlow 2s ease-in-out infinite;
}

@keyframes hammerGlow {

    0%,
    100% {
        filter: drop-shadow(0 0 2px rgba(255, 200, 0, 0.3));
    }

    50% {
        filter: drop-shadow(0 0 6px rgba(255, 200, 0, 0.7));
    }
}

.team-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.team-name {
    color: #ccc;
    font-size: 13px;
    font-weight: 600;
}

.player-name {
    font-size: 10px;
    color: #999;
    max-width: 95px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.score-value {
    color: #fff;
    font-size: 22px;
    font-weight: 700;
    min-width: 26px;
    text-align: center;
}

#end-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #888;
    font-size: 11px;
    line-height: 1.2;
}

#end-display #current-end {
    color: #fff;
    font-size: 20px;
    font-weight: 700;
}

/* ================================================
   SHOT INFO
   ================================================ */
#shot-info {
    text-align: center;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

#current-team-label {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: #e53935;
    margin-bottom: 1px;
    transition: color 0.3s ease, transform 0.3s ease;
}

#current-team-label.team-change-pulse {
    animation: teamPulse 0.4s ease-out;
}

@keyframes teamPulse {
    0% {
        transform: scale(1.0);
    }

    30% {
        transform: scale(1.15);
    }

    100% {
        transform: scale(1.0);
    }
}

#stones-remaining {
    display: block;
    font-size: 12px;
    color: #999;
}

/* ================================================
   CONTROLS PANEL
   ================================================ */
#controls-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
}

.control-row {
    /* single row control */
}

.control-row.two-col {
    display: flex;
    gap: 10px;
}

.control-row.two-col>div {
    flex: 1;
}

#controls-panel label {
    color: #bbb;
    font-size: 12px;
    display: block;
    margin-bottom: 3px;
}

#controls-panel label span {
    color: #fff;
    font-weight: 600;
}

/* ================================================
   SLIDERS
   ================================================ */
input[type="range"] {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: #333;
    border-radius: 4px;
    outline: none;
    margin: 2px 0;
}

#weight-slider {
    background: linear-gradient(to right, #4caf50, #8bc34a, #fdd835, #ff9800, #e53935);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    background: #5c9ae6;
    border-radius: 50%;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    background: #5c9ae6;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* ================================================
   BUTTONS
   ================================================ */
#spin-buttons,
#sweep-buttons {
    display: flex;
    gap: 6px;
}

.spin-btn,
.sweep-btn {
    flex: 1;
    padding: 8px 6px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid #444;
    background: #222;
    color: #aaa;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

.spin-btn:hover,
.sweep-btn:hover {
    background: #333;
    color: #ddd;
}

.spin-btn.active,
.sweep-btn.active {
    background: #2a4a7a;
    color: #fff;
    border-color: #5c9ae6;
}

.action-row {
    display: flex;
    gap: 8px;
}

#zoom-btn {
    padding: 14px 16px;
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, #37474f, #546e7a);
    color: white;
    border: 2px solid #546e7a;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

#zoom-btn:active {
    transform: scale(0.97);
}

#zoom-btn.zoomed {
    background: linear-gradient(135deg, #1565c0, #1e88e5);
    border-color: #42a5f5;
    box-shadow: 0 0 8px rgba(33, 150, 243, 0.4);
}

#throw-btn {
    flex: 1;
    padding: 14px;
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, #2e7d32, #43a047);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 1px;
    user-select: none;
}

#throw-btn:hover {
    background: linear-gradient(135deg, #388e3c, #4caf50);
}

#throw-btn:active {
    transform: scale(0.97);
}

#throw-btn:disabled {
    background: #444;
    cursor: not-allowed;
    transform: none;
}

#throw-btn.connecting {
    background: linear-gradient(135deg, #bf360c, #e65100);
    cursor: wait;
    animation: pulse-connect 1.5s infinite;
}

@keyframes pulse-connect {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

#sweep-toggle-btn {
    flex: 1;
    padding: 14px;
    font-size: 16px;
    font-weight: 700;
    background: linear-gradient(135deg, #1565c0, #1e88e5);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    animation: pulse 1.5s infinite;
    user-select: none;
    letter-spacing: 1px;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

#sweep-toggle-btn.sweeping {
    background: linear-gradient(135deg, #e65100, #fb8c00);
    animation: none;
}

/* ================================================
   INSTRUCTIONS
   ================================================ */
#instructions {
    margin-top: auto;
    padding: 8px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    color: #666;
    font-size: 11px;
    line-height: 1.4;
}

#instructions kbd {
    background: #333;
    padding: 1px 4px;
    border-radius: 3px;
    border: 1px solid #555;
    color: #ccc;
    font-size: 10px;
}

#instructions p {
    margin-bottom: 3px;
}

/* ================================================
   GAME OVER
   ================================================ */
#game-over-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

#matchup-info {
    font-size: 14px;
    color: #aaa;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

#matchup-info .rank-badge {
    font-size: 11px;
    padding: 2px 6px;
}

#game-over-screen h1 {
    color: #fff;
    font-size: 36px;
    margin-bottom: 16px;
}

#final-scores {
    color: #ccc;
    font-size: 20px;
    margin-bottom: 24px;
    text-align: center;
    line-height: 1.5;
}

#new-game-btn {
    padding: 14px 36px;
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, #2e7d32, #43a047);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

#new-game-btn:active {
    transform: scale(0.96);
}

/* ================================================
   MOBILE LAYOUT (portrait)
   Canvas on top, controls below
   ================================================ */
@media (max-width: 768px) {
    #game-container {
        flex-direction: column;
    }

    #curling-canvas {
        flex: 1;
        width: 100%;
        min-height: 0;
    }

    #ui-overlay {
        width: 100%;
        min-width: unset;
        height: auto;
        max-height: 45vh;
        border-left: none;
        border-top: 2px solid #333;
        padding: 8px 10px;
        gap: 6px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Compact mode/difficulty selectors */
    #mode-selector {
        gap: 4px;
    }

    .mode-btn {
        padding: 6px 4px;
        font-size: 12px;
        min-height: 36px;
    }

    #difficulty-selector {
        gap: 4px;
    }

    .diff-btn {
        padding: 5px 3px;
        font-size: 11px;
        min-height: 32px;
    }

    .ends-local-btn {
        padding: 5px 3px;
        font-size: 11px;
        min-height: 32px;
    }

    #bot-thinking {
        right: 0;
        top: 30%;
    }

    .thinking-text {
        font-size: 16px;
        padding: 8px 16px;
    }

    /* Compact scoreboard */
    #scoreboard {
        padding: 6px 10px;
    }

    .team-dot {
        width: 12px;
        height: 12px;
    }

    .team-name {
        font-size: 12px;
    }

    .score-value {
        font-size: 20px;
    }

    #end-display {
        font-size: 10px;
    }

    #end-display #current-end {
        font-size: 17px;
    }

    /* Compact shot info */
    #shot-info {
        padding: 4px 8px;
    }

    #current-team-label {
        font-size: 14px;
    }

    #stones-remaining {
        font-size: 11px;
    }

    /* Compact controls */
    #controls-panel {
        gap: 6px;
        padding: 6px;
    }

    #controls-panel label {
        font-size: 11px;
        margin-bottom: 2px;
    }

    /* Larger touch targets for sliders */
    input[type="range"] {
        height: 10px;
    }

    input[type="range"]::-webkit-slider-thumb {
        width: 28px;
        height: 28px;
    }

    input[type="range"]::-moz-range-thumb {
        width: 28px;
        height: 28px;
    }

    /* Larger touch targets for buttons */
    .spin-btn,
    .sweep-btn {
        padding: 10px 6px;
        font-size: 14px;
        border-radius: 8px;
        min-height: 40px;
    }

    /* Big throw/sweep buttons */
    #throw-btn {
        padding: 16px;
        font-size: 20px;
        border-radius: 10px;
        min-height: 52px;
    }

    #sweep-toggle-btn {
        padding: 16px;
        font-size: 18px;
        border-radius: 10px;
        min-height: 52px;
    }

    /* Hide keyboard instructions on mobile */
    #instructions {
        display: none;
    }
}

/* Extra small phones */
@media (max-width: 400px) {
    #ui-overlay {
        padding: 6px 8px;
        gap: 4px;
        max-height: 50vh;
    }

    #scoreboard {
        padding: 4px 8px;
    }

    .team-name {
        font-size: 11px;
    }

    .score-value {
        font-size: 18px;
    }

    #controls-panel {
        gap: 4px;
        padding: 4px;
    }

    .control-row.two-col {
        flex-direction: column;
        gap: 4px;
    }
}

/* ================================================
   LOBBY SCREEN
   ================================================ */
#lobby-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

#lobby-content {
    text-align: center;
    max-width: 360px;
    width: 100%;
}

#lobby-logo {
    height: 110px;
    width: auto;
    display: block;
    margin: 0 auto 12px;
}

#lobby-content h2 {
    color: #fff;
    font-size: 28px;
    margin-bottom: 24px;
}

#lobby-content h3 {
    color: #5c9ae6;
    font-size: 22px;
    margin-bottom: 12px;
}

#lobby-content p {
    color: #bbb;
    font-size: 14px;
    margin-bottom: 12px;
}

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

.lobby-btn {
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 700;
    border: 1px solid #5c9ae6;
    background: #2a4a7a;
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.lobby-btn:hover {
    background: #3a5a8a;
}

.lobby-btn:active {
    transform: scale(0.97);
}

.lobby-btn.secondary {
    background: #333;
    border-color: #555;
    color: #aaa;
}

.lobby-btn.secondary:hover {
    background: #444;
    color: #ddd;
}

#room-code-display {
    font-size: 48px;
    font-weight: 700;
    font-family: 'Courier New', Courier, monospace;
    color: #5c9ae6;
    letter-spacing: 12px;
    background: rgba(42, 74, 122, 0.3);
    border: 2px solid #5c9ae6;
    border-radius: 12px;
    padding: 16px 24px;
    margin: 16px 0;
    user-select: all;
}

#room-code-input {
    width: 180px;
    font-size: 32px;
    font-weight: 700;
    font-family: 'Courier New', Courier, monospace;
    text-align: center;
    letter-spacing: 8px;
    text-transform: uppercase;
    color: #fff;
    background: rgba(42, 74, 122, 0.3);
    border: 2px solid #5c9ae6;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 12px 0;
    outline: none;
}

#room-code-input::placeholder {
    color: #555;
    letter-spacing: 8px;
}

#room-code-input:focus {
    border-color: #90caf9;
    box-shadow: 0 0 12px rgba(92, 154, 230, 0.3);
}

.lobby-error {
    color: #e53935;
    font-size: 13px;
}

.lobby-status {
    color: #888;
    font-size: 13px;
    font-style: italic;
}

.lobby-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #333;
    border-top-color: #5c9ae6;
    border-radius: 50%;
    margin: 16px auto;
    animation: lobbySpinAnim 0.8s linear infinite;
}

@keyframes lobbySpinAnim {
    to { transform: rotate(360deg); }
}

#team-assignment {
    font-size: 18px;
    font-weight: 600;
}

#your-team-label {
    font-weight: 700;
    font-size: 22px;
}

#lobby-ends-panel,
#lobby-create-panel,
#lobby-join-panel,
#lobby-queue-panel,
#lobby-starting-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

#opponent-info-bar {
    font-size: 16px;
    color: #ccc;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

#opponent-name-label {
    font-weight: 700;
    color: #fff;
}

/* ================================================
   FRIENDS PANEL
   ================================================ */
#lobby-friends-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-height: 65vh;
    overflow-y: auto;
}

#lobby-friends-panel h3 {
    margin: 0;
}

#lobby-friends-panel h4 {
    color: #5c9ae6;
    font-size: 13px;
    margin: 4px 0;
    width: 100%;
    text-align: left;
    border-bottom: 1px solid #333;
    padding-bottom: 4px;
}

#friend-add-section {
    width: 100%;
}

#friend-add-row {
    display: flex;
    gap: 8px;
    width: 100%;
}

#friend-username-input {
    flex: 1;
    padding: 10px 14px;
    font-size: 14px;
    background: rgba(42, 74, 122, 0.3);
    border: 1px solid #5c9ae6;
    border-radius: 6px;
    color: #fff;
    outline: none;
}

#friend-username-input:focus {
    border-color: #90caf9;
    box-shadow: 0 0 12px rgba(92, 154, 230, 0.3);
}

#friend-search-btn {
    padding: 10px 16px;
    font-size: 14px;
    white-space: nowrap;
}

#friend-search-results {
    width: 100%;
    max-height: 200px;
    overflow-y: auto;
    margin-top: 6px;
}

.friend-search-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: rgba(42, 74, 122, 0.2);
    border: 1px solid rgba(92, 154, 230, 0.15);
    border-radius: 8px;
    margin-bottom: 4px;
    box-sizing: border-box;
}

.search-result-name {
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-add-btn {
    padding: 5px 12px !important;
    font-size: 12px !important;
    min-width: auto !important;
    flex-shrink: 0;
}

.search-no-results {
    color: #888;
    font-size: 13px;
    text-align: center;
    padding: 8px;
}

#reg-name-row {
    display: flex;
    gap: 8px;
    width: 100%;
}

#reg-name-row input {
    flex: 1;
    min-width: 0;
}

.lobby-success {
    color: #66bb6a;
    font-size: 13px;
}

#friends-list-section {
    width: 100%;
}

.friend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: rgba(42, 74, 122, 0.15);
    border: 1px solid rgba(92, 154, 230, 0.15);
    border-radius: 8px;
    width: 100%;
    margin-bottom: 4px;
    box-sizing: border-box;
}

.friend-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.friend-status-dot.online {
    background: #66bb6a;
}

.friend-status-dot.in_game {
    background: #ffa726;
}

.friend-status-dot.offline {
    background: #555;
}

.friend-name {
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80px;
}

.friend-rank {
    flex-shrink: 0;
}

.friend-status-text {
    color: #888;
    font-size: 11px;
    margin-left: auto;
    white-space: nowrap;
}

.friend-invite-btn {
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    background: #2a4a7a;
    color: #fff;
    border: 1px solid #5c9ae6;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}

.friend-invite-btn:hover {
    background: #3a5a8a;
}

.friend-invite-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.friend-remove-btn {
    padding: 4px 6px;
    font-size: 11px;
    background: none;
    color: #666;
    border: 1px solid #444;
    border-radius: 4px;
    cursor: pointer;
    flex-shrink: 0;
}

.friend-remove-btn:hover {
    color: #e53935;
    border-color: #e53935;
}

.friend-request-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: rgba(92, 154, 230, 0.1);
    border: 1px solid rgba(92, 154, 230, 0.25);
    border-radius: 8px;
    width: 100%;
    margin-bottom: 4px;
    box-sizing: border-box;
}

.request-name {
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    flex: 1;
}

.request-accept-btn {
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    background: #2a4a7a;
    color: #fff;
    border: 1px solid #5c9ae6;
    border-radius: 4px;
    cursor: pointer;
}

.request-accept-btn:hover {
    background: #3a5a8a;
}

.request-deny-btn {
    padding: 4px 8px;
    font-size: 11px;
    background: none;
    color: #aaa;
    border: 1px solid #555;
    border-radius: 4px;
    cursor: pointer;
}

.request-deny-btn:hover {
    color: #e53935;
    border-color: #e53935;
}

#lobby-friends {
    position: relative;
}

.friend-notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e53935;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ================================================
   GAME INVITE OVERLAY
   ================================================ */
#game-invite-overlay {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1100;
    animation: inviteSlideIn 0.3s ease-out;
}

@keyframes inviteSlideIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.invite-content {
    background: rgba(20, 20, 45, 0.97);
    border: 2px solid #5c9ae6;
    border-radius: 12px;
    padding: 16px 24px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

#invite-from-text {
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
}

.invite-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
}

/* ================================================
   DISCONNECT OVERLAY
   ================================================ */
#disconnect-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 900;
}

.disconnect-content {
    text-align: center;
    background: rgba(20, 20, 45, 0.95);
    border: 1px solid #e53935;
    border-radius: 12px;
    padding: 28px 36px;
}

.disconnect-content p {
    color: #e53935;
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
}

.disconnect-content .disconnect-sub {
    color: #888;
    font-size: 13px;
    font-weight: 400;
    font-style: italic;
    margin-bottom: 16px;
}

/* ================================================
   WELCOME BACK OVERLAY (v101)
   ================================================ */
#welcome-back-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 950;
    cursor: pointer;
}

.welcome-back-content {
    text-align: center;
    background: rgba(20, 20, 45, 0.95);
    border: 1px solid #5c9ae6;
    border-radius: 12px;
    padding: 28px 36px;
    animation: welcomeBackPulse 2s ease-in-out infinite;
}

@keyframes welcomeBackPulse {
    0%, 100% { border-color: #5c9ae6; box-shadow: 0 0 8px rgba(92, 154, 230, 0.2); }
    50% { border-color: #90caf9; box-shadow: 0 0 16px rgba(92, 154, 230, 0.4); }
}

.welcome-back-content p {
    color: #fff;
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
}

.welcome-back-content .welcome-back-sub {
    color: #5c9ae6;
    font-size: 15px;
    font-weight: 400;
    margin-bottom: 0;
}

/* ================================================
   END SUMMARY OVERLAY (v115)
   ================================================ */
#end-summary-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.80);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 960;
}

.end-summary-content {
    text-align: center;
    background: rgba(20, 20, 45, 0.95);
    border: 2px solid #fdd835;
    border-radius: 14px;
    padding: 32px 40px;
    min-width: 260px;
    animation: endSummaryFadeIn 0.4s ease-out;
}

@keyframes endSummaryFadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.end-summary-content h2 {
    color: #fff;
    font-size: 24px;
    margin: 0 0 16px 0;
}

.end-summary-content p {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 10px 0;
}

.end-summary-content .end-summary-sub {
    color: #aaa;
    font-size: 15px;
    font-weight: 400;
    margin-bottom: 20px;
}

#end-summary-continue {
    margin-top: 8px;
    padding: 10px 32px;
    font-size: 16px;
}

/* ================================================
   QUICK GUIDE OVERLAY (v116)
   ================================================ */
#quick-guide-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 970;
}

.quick-guide-content {
    text-align: center;
    background: rgba(20, 20, 45, 0.95);
    border: 2px solid #5c9ae6;
    border-radius: 14px;
    padding: 28px 32px;
    max-width: 320px;
    width: 90%;
    animation: quickGuideFadeIn 0.4s ease-out;
}

@keyframes quickGuideFadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.quick-guide-content h2 {
    color: #fff;
    font-size: 20px;
    margin: 0 0 20px 0;
}

.guide-items {
    text-align: left;
    margin-bottom: 20px;
}

.guide-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}

.guide-item:last-child {
    margin-bottom: 0;
}

.guide-icon {
    font-size: 24px;
    flex-shrink: 0;
    width: 32px;
    text-align: center;
}

.guide-item strong {
    color: #fff;
    font-size: 15px;
    display: block;
    margin-bottom: 2px;
}

.guide-item p {
    color: #aaa;
    font-size: 12px;
    margin: 0;
    line-height: 1.4;
}

#quick-guide-dismiss {
    margin-top: 8px;
    padding: 12px 36px;
    font-size: 16px;
}

/* ================================================
   LEADERBOARD (v117)
   ================================================ */
#lobby-leaderboard-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

#lobby-leaderboard-panel h3 {
    color: #fff;
    margin: 0 0 12px 0;
    font-size: 18px;
}

#leaderboard-list {
    width: 100%;
    max-height: 55vh;
    overflow-y: auto;
    margin-bottom: 12px;
    scrollbar-width: thin;
    scrollbar-color: #5c9ae6 rgba(255,255,255,0.05);
}

.leaderboard-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 13px;
}

.leaderboard-row:nth-child(odd) {
    background: rgba(255, 255, 255, 0.04);
}

.leaderboard-row:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.leaderboard-self {
    background: rgba(92, 154, 230, 0.15) !important;
    border: 1px solid rgba(92, 154, 230, 0.4);
}

.lb-pos {
    width: 28px;
    text-align: center;
    font-weight: bold;
    color: #888;
    flex-shrink: 0;
}

.podium-1 .lb-pos { color: #ffd54f; font-size: 15px; }
.podium-2 .lb-pos { color: #e0e0e0; font-size: 14px; }
.podium-3 .lb-pos { color: #cd7f32; font-size: 14px; }

.lb-name {
    flex: 1;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.leaderboard-row .rank-badge {
    font-size: 10px;
    padding: 2px 6px;
    flex-shrink: 0;
}

.lb-rating {
    color: #aaa;
    font-size: 11px;
    width: 36px;
    text-align: right;
    flex-shrink: 0;
}

.lb-record {
    color: #666;
    font-size: 11px;
    width: 48px;
    text-align: right;
    flex-shrink: 0;
}

.lb-action-btn {
    font-size: 11px !important;
    padding: 4px 10px !important;
    min-width: 58px;
    flex-shrink: 0;
}

.lb-you {
    color: #5c9ae6;
    font-size: 11px;
    font-weight: bold;
    min-width: 58px;
    text-align: center;
    flex-shrink: 0;
}

/* ================================================
   MATCH HISTORY (v118)
   ================================================ */
#lobby-history-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

#lobby-history-panel h3 {
    color: #fff;
    margin: 0 0 12px 0;
    font-size: 18px;
}

#history-list {
    width: 100%;
    max-height: 55vh;
    overflow-y: auto;
    margin-bottom: 12px;
    scrollbar-width: thin;
    scrollbar-color: #5c9ae6 rgba(255,255,255,0.05);
}

.history-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 13px;
    border-left: 3px solid transparent;
}

.history-row:nth-child(odd) {
    background: rgba(255, 255, 255, 0.04);
}

.history-row:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.history-win { border-left-color: #4caf50; }
.history-loss { border-left-color: #e53935; }
.history-draw { border-left-color: #888; }

.history-result {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 12px;
    flex-shrink: 0;
    color: #fff;
}

.history-result.win { background: #4caf50; }
.history-result.loss { background: #e53935; }
.history-result.draw { background: #666; }

.history-opp {
    flex: 1;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.history-opp .rank-badge {
    font-size: 9px;
    padding: 1px 5px;
    margin-left: 4px;
    vertical-align: middle;
}

.history-score {
    color: #fff;
    font-weight: bold;
    font-size: 13px;
    flex-shrink: 0;
    min-width: 36px;
    text-align: center;
}

.history-ends {
    color: #666;
    font-size: 11px;
    flex-shrink: 0;
    min-width: 42px;
    text-align: center;
}

.history-date {
    color: #666;
    font-size: 11px;
    flex-shrink: 0;
    min-width: 44px;
    text-align: right;
}

/* ================================================
   ONLINE TEAM BADGE
   ================================================ */
#online-team-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
    z-index: 50;
    pointer-events: none;
}

#online-team-badge.team-red {
    background: rgba(229, 57, 53, 0.85);
    color: #fff;
}

#online-team-badge.team-yellow {
    background: rgba(253, 216, 53, 0.85);
    color: #333;
}

/* ================================================
   REMATCH / LEAVE BUTTONS
   ================================================ */
#rematch-btn {
    padding: 14px 36px;
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, #1565c0, #1e88e5);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
}

#rematch-btn:active {
    transform: scale(0.96);
}

#leave-btn {
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    background: #333;
    color: #aaa;
    border: 1px solid #555;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 6px;
}

#leave-btn:hover {
    background: #444;
    color: #ddd;
}

/* ================================================
   AUTH PANEL
   ================================================ */
#auth-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    width: 100%;
}

#join-invite-banner {
    background: linear-gradient(135deg, #1565c0, #1e88e5);
    color: #fff;
    padding: 12px 16px;
    border-radius: 10px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.5;
    width: 100%;
    max-width: 280px;
    margin-bottom: 4px;
    box-shadow: 0 2px 8px rgba(21, 101, 192, 0.3);
}

#join-invite-banner small {
    font-weight: 400;
    font-size: 12px;
    opacity: 0.9;
}

/* Google Sign-In section */
#google-signin-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 4px;
    width: 100%;
    max-width: 280px;
}

.auth-divider {
    display: flex;
    align-items: center;
    width: 220px;
    margin: 8px 0;
    color: #888;
    font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #444;
}

.auth-divider span {
    padding: 0 10px;
}

#google-username-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 280px;
}

.google-welcome-text {
    color: #ccc;
    font-size: 14px;
    text-align: center;
    margin: 0;
}

#auth-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 4px;
}

.auth-tab {
    padding: 8px 20px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid #444;
    background: #222;
    color: #aaa;
    border-radius: 6px 6px 0 0;
    cursor: pointer;
    transition: all 0.15s;
}

.auth-tab:hover {
    background: #333;
    color: #ddd;
}

.auth-tab.active {
    background: #2a4a7a;
    color: #fff;
    border-color: #5c9ae6;
}

#auth-login-form,
#auth-register-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
}

#auth-panel input[type="text"],
#auth-panel input[type="password"] {
    width: 220px;
    padding: 10px 14px;
    font-size: 14px;
    background: rgba(42, 74, 122, 0.3);
    border: 1px solid #5c9ae6;
    border-radius: 6px;
    color: #fff;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#auth-panel input[type="text"]:focus,
#auth-panel input[type="password"]:focus {
    border-color: #90caf9;
    box-shadow: 0 0 12px rgba(92, 154, 230, 0.3);
}

#auth-panel input::placeholder {
    color: #667;
}

#auth-panel select {
    width: 220px;
    padding: 10px 14px;
    font-size: 14px;
    background: rgba(42, 74, 122, 0.3);
    border: 1px solid #5c9ae6;
    border-radius: 6px;
    color: #fff;
    outline: none;
    cursor: pointer;
}

#auth-panel select option {
    background: #1a1a2e;
    color: #fff;
}

#user-info-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px 14px;
    background: rgba(42, 74, 122, 0.2);
    border: 1px solid rgba(92, 154, 230, 0.3);
    border-radius: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

#logged-in-as {
    color: #5c9ae6;
    font-size: 14px;
    font-weight: 600;
}

#user-record {
    color: #888;
    font-size: 12px;
}

.auth-logout-btn {
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    background: #333;
    color: #aaa;
    border: 1px solid #555;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
}

.auth-logout-btn:hover {
    background: #444;
    color: #ddd;
}

/* Rank Badge */
.rank-badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 700;
    color: #111;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
}

.user-rating-text {
    color: #666;
    font-size: 11px;
}

#rating-update-info {
    margin: 8px 0;
    text-align: center;
    font-size: 14px;
}

#rating-update-info .rank-badge {
    font-size: 13px;
    padding: 3px 12px;
}

/* Password Recovery */
#forgot-password-link,
#recovery-back-link {
    color: #5c9ae6;
    font-size: 12px;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.15s;
}

#forgot-password-link:hover,
#recovery-back-link:hover {
    color: #90caf9;
    text-decoration: underline;
}

#auth-recovery-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
}

#recovery-step-1,
#recovery-step-2 {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.recovery-label {
    color: #aaa;
    font-size: 13px;
    margin: 0;
    text-align: center;
}

#recovery-question-text {
    color: #5c9ae6;
    font-weight: 600;
    font-size: 13px;
}

.recovery-success {
    color: #66bb6a;
    font-size: 13px;
    font-weight: 600;
    margin: 4px 0;
}

#auth-recovery-form input[type="text"],
#auth-recovery-form input[type="password"] {
    width: 220px;
    padding: 10px 14px;
    font-size: 14px;
    background: rgba(42, 74, 122, 0.3);
    border: 1px solid #5c9ae6;
    border-radius: 6px;
    color: #fff;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#auth-recovery-form input:focus {
    border-color: #90caf9;
    box-shadow: 0 0 12px rgba(92, 154, 230, 0.3);
}

#auth-recovery-form input::placeholder {
    color: #667;
}

/* Landscape mobile */
@media (max-height: 500px) and (max-width: 900px) {
    #game-container {
        flex-direction: row;
    }

    #ui-overlay {
        width: 260px;
        min-width: 260px;
        height: 100%;
        max-height: 100%;
        border-left: 2px solid #333;
        border-top: none;
        padding: 6px 8px;
        gap: 4px;
    }

    #mode-selector {
        gap: 3px;
    }

    .mode-btn {
        padding: 4px 3px;
        font-size: 11px;
        min-height: 28px;
    }

    #difficulty-selector {
        gap: 3px;
    }

    .diff-btn {
        padding: 3px 2px;
        font-size: 10px;
        min-height: 24px;
    }

    #ends-selector-local {
        gap: 3px;
    }

    .ends-local-btn {
        padding: 3px 2px;
        font-size: 10px;
        min-height: 24px;
    }

    #bot-thinking {
        right: 260px;
    }

    #scoreboard {
        padding: 4px 8px;
    }

    .score-value {
        font-size: 18px;
    }

    #shot-info {
        padding: 3px 6px;
    }

    #current-team-label {
        font-size: 13px;
    }

    #controls-panel {
        gap: 4px;
        padding: 4px;
    }

    #controls-panel label {
        font-size: 10px;
        margin-bottom: 1px;
    }

    .control-row.two-col {
        gap: 6px;
    }

    .spin-btn,
    .sweep-btn {
        padding: 6px 4px;
        font-size: 12px;
        min-height: 32px;
    }

    #throw-btn {
        padding: 10px;
        font-size: 16px;
        min-height: 40px;
    }

    #sweep-toggle-btn {
        padding: 10px;
        font-size: 14px;
        min-height: 40px;
    }

    #instructions {
        display: none;
    }
}

/* Ends Selector */
#ends-selector {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin: 12px 0;
}

.ends-btn {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    border: 2px solid #555;
    background: #1a1a2e;
    color: #ccc;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.15s ease;
}

.ends-btn.active {
    border-color: #1565c0;
    background: #1565c0;
    color: #fff;
}

/* Quick Chat */
#chat-btn {
    font-size: 18px;
    padding: 8px 12px;
    border-radius: 8px;
    border: none;
    background: #1565c0;
    color: #fff;
    cursor: pointer;
}

#replay-btn {
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 2px solid #fb8c00;
    background: transparent;
    color: #fb8c00;
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s;
}

#replay-btn:active {
    background: #fb8c00;
    color: #fff;
}

#skip-replay-btn {
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 2px solid #e53935;
    background: transparent;
    color: #e53935;
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s;
}
#skip-replay-btn:active {
    background: #e53935;
    color: #fff;
}

#submit-shot-btn {
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 2px solid #ffd54f;
    background: transparent;
    color: #ffd54f;
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s;
}
#submit-shot-btn:active {
    background: #ffd54f;
    color: #333;
}
#submit-shot-btn.submitted {
    border-color: #4caf50;
    color: #4caf50;
    pointer-events: none;
}

/* Best Shots Panel */
#lobby-best-shots-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

#best-shots-list {
    width: 100%;
    max-height: 55vh;
    overflow-y: auto;
    margin-bottom: 12px;
    scrollbar-width: thin;
    scrollbar-color: #5c9ae6 rgba(255,255,255,0.05);
}

.best-shot-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 13px;
}

.best-shot-row:nth-child(odd) {
    background: rgba(255, 255, 255, 0.04);
}
.best-shot-row:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.bs-rank {
    width: 24px;
    text-align: center;
    font-weight: bold;
    color: #888;
    flex-shrink: 0;
}
.bs-rank-1 { color: #ffd54f; font-size: 15px; }
.bs-rank-2 { color: #e0e0e0; font-size: 14px; }
.bs-rank-3 { color: #cd7f32; font-size: 14px; }

.bs-name {
    flex: 1;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.bs-votes {
    color: #ffd54f;
    font-weight: bold;
    font-size: 12px;
    flex-shrink: 0;
    min-width: 30px;
    text-align: center;
}

.bs-play-btn,
.bs-vote-btn {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid;
    background: transparent;
    cursor: pointer;
    font-weight: 600;
    flex-shrink: 0;
    transition: background 0.2s, color 0.2s;
}

.bs-play-btn {
    border-color: #fb8c00;
    color: #fb8c00;
}
.bs-play-btn:active {
    background: #fb8c00;
    color: #fff;
}

.bs-vote-btn {
    border-color: #4caf50;
    color: #4caf50;
}
.bs-vote-btn:active {
    background: #4caf50;
    color: #fff;
}
.bs-vote-btn.voted {
    border-color: #666;
    color: #666;
    pointer-events: none;
}

#sync-btn {
    font-size: 18px;
    padding: 6px 10px;
    border-radius: 8px;
    border: 2px solid #5c9ae6;
    background: transparent;
    color: #5c9ae6;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s, color 0.2s;
    line-height: 1;
}

#sync-btn:active {
    background: #5c9ae6;
    color: #fff;
}

#sync-btn.syncing {
    animation: syncSpin 0.8s linear;
    pointer-events: none;
}

@keyframes syncSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

#chat-popup {
    position: absolute;
    bottom: 60px;
    right: 10px;
    background: #222;
    border-radius: 10px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 200;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

.chat-preset {
    background: #1565c0;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 14px;
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
}
.chat-preset:active {
    background: #0d47a1;
}

#chat-toast-container {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    pointer-events: none;
}

.chat-toast {
    background: rgba(0,0,0,0.85);
    color: #fff;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    animation: chatToastIn 0.3s ease, chatToastOut 0.3s ease 2.7s forwards;
    pointer-events: none;
}
.chat-toast .chat-from {
    font-weight: bold;
    margin-right: 6px;
    color: #64b5f6;
}

@keyframes chatToastIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes chatToastOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Tutorial */
#tutorial-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}

#tutorial-box {
    background: #222;
    color: #fff;
    border-radius: 12px;
    padding: 20px 24px;
    max-width: 340px;
    text-align: center;
    box-shadow: 0 6px 24px rgba(0,0,0,0.6);
}

#tutorial-step-counter {
    font-size: 12px;
    color: #888;
    margin-bottom: 8px;
}

#tutorial-text {
    font-size: 16px;
    line-height: 1.4;
    margin-bottom: 16px;
}

.tutorial-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.tutorial-buttons button {
    padding: 8px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}

#tutorial-skip {
    background: #555;
    color: #ccc;
}

#tutorial-next {
    background: #1565c0;
    color: #fff;
}

.tutorial-highlight {
    outline: 3px solid #1565c0 !important;
    outline-offset: 2px;
    animation: tutorialPulse 1s ease-in-out infinite;
}

@keyframes tutorialPulse {
    0%, 100% { outline-color: #1565c0; }
    50% { outline-color: #42a5f5; }
}

/* ================================================
   DEBUG PANEL (activated by triple-tap on beta text)
   ================================================ */
#debug-toggle {
    position: fixed;
    bottom: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(30, 30, 60, 0.8);
    border: 1px solid #555;
    color: #aaa;
    font-size: 16px;
    z-index: 9999;
    cursor: pointer;
}

#debug-panel {
    position: fixed;
    bottom: 50px;
    right: 8px;
    width: min(400px, 90vw);
    max-height: 50vh;
    background: rgba(10, 10, 30, 0.95);
    border: 1px solid #444;
    border-radius: 8px;
    z-index: 9998;
    display: flex;
    flex-direction: column;
    font-family: monospace;
    font-size: 11px;
}

#debug-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
    background: rgba(40, 40, 80, 0.9);
    border-bottom: 1px solid #444;
    border-radius: 8px 8px 0 0;
    color: #ccc;
    font-size: 12px;
}

#debug-header > div {
    display: flex;
    align-items: center;
    gap: 4px;
}
#debug-header button {
    background: none;
    border: none;
    color: #aaa;
    font-size: 16px;
    cursor: pointer;
    padding: 2px 6px;
}
#debug-copy {
    font-size: 11px !important;
    padding: 2px 8px !important;
    border-radius: 3px;
    background: rgba(60, 60, 100, 0.8) !important;
    border: 1px solid #555 !important;
}
#debug-copy:active { color: #4CAF50 !important; border-color: #4CAF50 !important; }
#gameover-copy-logs {
    background: transparent;
    border: 1px solid #555;
    color: #888;
    font-size: 12px;
    padding: 6px 16px;
    border-radius: 6px;
    cursor: pointer;
    margin-top: 16px;
}
#gameover-copy-logs:active { color: #4CAF50; border-color: #4CAF50; }

#debug-log {
    overflow-y: auto;
    padding: 4px 8px;
    max-height: 45vh;
    color: #0f0;
    line-height: 1.4;
    word-break: break-all;
}

#debug-log .debug-error { color: #e53935; }
#debug-log .debug-warn { color: #ffb300; }
#debug-log .debug-info { color: #64b5f6; }