* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1a1a2e;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
}

#game-canvas {
    display: block;
}

/* HUD */
#hud {
    position: absolute;
    top: 20px;
    left: 20px;
    color: #fff;
    font-size: 18px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
}

#hud > div, #hud > button {
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 16px;
    border-radius: 4px;
    border-left: 3px solid #f4a460;
}

#health-bar {
    font-size: 22px;
    font-weight: bold;
    padding: 12px 20px !important;
    border-left-color: #ff3333 !important;
}

#health-hearts {
    letter-spacing: 2px;
}

#score, #team-count, #inventory-count {
    font-size: 13px;
    padding: 5px 12px !important;
}

#save-btn {
    font-size: 13px;
    padding: 5px 12px !important;
}

.hud-btn {
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    border: 2px solid #f4a460;
    transition: all 0.2s;
    text-align: center;
}

.hud-btn:hover {
    background: rgba(244, 164, 96, 0.4) !important;
    transform: translateY(-1px);
}

/* Crosshair */
#crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 24px;
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    opacity: 0.7;
}

/* Interaction Prompt */
#interaction-prompt {
    position: absolute;
    bottom: 150px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    transition: opacity 0.3s;
}

#interaction-prompt .key {
    display: inline-block;
    background: #f4a460;
    color: #1a1a2e;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: bold;
    margin: 0 4px;
}

/* Panels */
.hidden {
    display: none !important;
}

#interaction-panel,
#type-selector,
#inventory-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, rgba(30, 30, 50, 0.95), rgba(20, 20, 35, 0.98));
    border: 2px solid #f4a460;
    border-radius: 12px;
    padding: 24px;
    color: #fff;
    min-width: 350px;
    max-width: 450px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

#interaction-panel h2,
#type-selector h2,
#inventory-panel h2 {
    text-align: center;
    margin-bottom: 16px;
    color: #f4a460;
    font-size: 22px;
}

#robot-status {
    text-align: center;
    padding: 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    margin-bottom: 16px;
}

#robot-status.beyond-repair {
    border-left: 4px solid #e74c3c;
}

#robot-status.repairable {
    border-left: 4px solid #2ecc71;
}

#parts-list {
    margin-bottom: 16px;
}

#parts-list h3 {
    font-size: 14px;
    color: #aaa;
    margin-bottom: 8px;
}

.part-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    margin-bottom: 4px;
}

.part-item.has-part {
    color: #2ecc71;
}

.part-item.needs-part {
    color: #e74c3c;
}

.part-check {
    font-size: 16px;
}

#panel-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.panel-btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.panel-btn:hover {
    transform: translateY(-2px);
}

#salvage-btn {
    background: #e74c3c;
    color: #fff;
}

#salvage-btn:hover {
    background: #c0392b;
}

#repair-btn {
    background: #2ecc71;
    color: #fff;
}

#repair-btn:hover {
    background: #27ae60;
}

#repair-btn:disabled {
    background: #555;
    cursor: not-allowed;
    transform: none;
}

#close-panel,
#close-inventory {
    background: #555;
    color: #fff;
    width: 100%;
}

#close-panel:hover,
#close-inventory:hover {
    background: #666;
}

/* Type Selector */
#type-options {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.type-btn {
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid #555;
    border-radius: 12px;
    padding: 16px;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
    width: 120px;
    text-align: center;
}

.type-btn:hover {
    border-color: #f4a460;
    transform: translateY(-4px);
    background: rgba(244, 164, 96, 0.2);
}

.type-icon {
    font-size: 36px;
    margin-bottom: 8px;
}

.type-name {
    font-weight: bold;
    margin-bottom: 4px;
}

.type-desc {
    font-size: 11px;
    color: #aaa;
}

/* Inventory Panel */
#inventory-items {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 16px;
    max-height: 300px;
    overflow-y: auto;
}

.inventory-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    border-left: 3px solid #f4a460;
}

.inventory-item .count {
    background: #f4a460;
    color: #1a1a2e;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: bold;
    font-size: 14px;
}

/* Start Screen */
#start-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #fff;
    z-index: 100;
}

#start-screen h1 {
    font-size: 64px;
    color: #f4a460;
    text-shadow: 0 4px 20px rgba(244, 164, 96, 0.5);
    margin-bottom: 16px;
}

#start-screen > p {
    font-size: 20px;
    color: #aaa;
    margin-bottom: 32px;
}

#start-screen .controls {
    background: rgba(0, 0, 0, 0.3);
    padding: 20px 40px;
    border-radius: 12px;
    margin-bottom: 32px;
    line-height: 1.8;
}

#start-btn {
    background: #f4a460;
    color: #1a1a2e;
    border: none;
    padding: 16px 48px;
    font-size: 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: bold;
}

#start-btn:hover {
    background: #e8985a;
    transform: scale(1.05);
}

/* Score Popups */
#score-popups {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.score-popup {
    position: absolute;
    color: #f4a460;
    font-size: 28px;
    font-weight: bold;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
    animation: scoreFloat 1.5s ease-out forwards;
}

@keyframes scoreFloat {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-80px) scale(1.2);
    }
}

/* Confetti */
.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    pointer-events: none;
}

@keyframes confettiFall {
    0% {
        opacity: 1;
        transform: translateY(0) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translateY(200px) rotate(720deg);
    }
}

/* Map Overlay */
#map-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
}

#map-container {
    background: linear-gradient(135deg, rgba(30, 30, 50, 0.98), rgba(20, 20, 35, 0.99));
    border: 2px solid #f4a460;
    border-radius: 12px;
    padding: 24px;
    color: #fff;
    max-width: 90vw;
    max-height: 90vh;
}

#map-container h2 {
    text-align: center;
    margin-bottom: 16px;
    color: #f4a460;
    font-size: 24px;
}

#map-content {
    display: flex;
    gap: 20px;
    margin-bottom: 16px;
}

#map-canvas {
    border: 2px solid #555;
    border-radius: 8px;
    background: #d2a679;
}

#marker-panel {
    width: 200px;
    display: flex;
    flex-direction: column;
}

#marker-panel h3 {
    color: #f4a460;
    margin-bottom: 12px;
    font-size: 16px;
}

#marker-list {
    flex: 1;
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 12px;
}

.marker-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    margin-bottom: 6px;
}

.marker-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex-shrink: 0;
}

.marker-info {
    flex: 1;
    min-width: 0;
}

.marker-name {
    font-weight: bold;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.marker-distance {
    font-size: 11px;
    color: #aaa;
}

.marker-delete {
    background: #e74c3c;
    border: none;
    color: #fff;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
}

.marker-delete:hover {
    background: #c0392b;
}

.no-markers {
    color: #888;
    font-size: 13px;
    text-align: center;
    padding: 20px 10px;
}

#add-marker-btn {
    background: #2ecc71;
    color: #fff;
}

#add-marker-btn:hover {
    background: #27ae60;
}

#map-legend {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-bottom: 16px;
    font-size: 14px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-player {
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 14px solid #00ff00;
}

.legend-marker {
    width: 12px;
    height: 12px;
    background: #ff6b6b;
    border-radius: 50%;
    border: 2px solid #000;
}

#close-map {
    background: #555;
    color: #fff;
    width: 100%;
}

#close-map:hover {
    background: #666;
}

/* Marker added notification */
.marker-notification {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(46, 204, 113, 0.9);
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    animation: fadeInOut 2s ease-in-out forwards;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateX(-50%) translateY(20px); }
    15% { opacity: 1; transform: translateX(-50%) translateY(0); }
    85% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

/* Team Control Panel (top right HUD) */
#team-control {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid #4ecdc4;
    border-radius: 8px;
    padding: 12px;
    color: #fff;
    min-width: 160px;
}

#team-status {
    margin-bottom: 10px;
}

.team-stat {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 14px;
}

.stat-label {
    color: #aaa;
}

#following-count {
    color: #2ecc71;
    font-weight: bold;
}

#deployed-count {
    color: #f4a460;
    font-weight: bold;
}

#team-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.team-btn {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: bold;
}

#deploy-btn {
    background: #f4a460;
    color: #1a1a2e;
}

#deploy-btn:hover {
    background: #e8985a;
    transform: translateY(-1px);
}

#deploy-btn:disabled {
    background: #666;
    color: #999;
    cursor: not-allowed;
    transform: none;
}

#recall-btn {
    background: #4ecdc4;
    color: #1a1a2e;
}

#recall-btn:hover {
    background: #3dbdb5;
    transform: translateY(-1px);
}

#recall-btn:disabled {
    background: #666;
    color: #999;
    cursor: not-allowed;
    transform: none;
}

#team-hint {
    text-align: center;
    font-size: 11px;
    color: #888;
}

/* Team Management Panel */
#team-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, rgba(30, 30, 50, 0.98), rgba(20, 20, 35, 0.99));
    border: 2px solid #4ecdc4;
    border-radius: 12px;
    padding: 24px;
    color: #fff;
    min-width: 450px;
    max-width: 550px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 50;
}

#team-panel h2 {
    text-align: center;
    margin-bottom: 20px;
    color: #4ecdc4;
    font-size: 24px;
}

#team-overview {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
}

.overview-stat {
    text-align: center;
}

.overview-value {
    display: block;
    font-size: 32px;
    font-weight: bold;
    color: #4ecdc4;
}

.overview-label {
    font-size: 12px;
    color: #aaa;
}

#team-robot-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.robot-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    margin-bottom: 8px;
    border-left: 4px solid #555;
}

.robot-list-item.following {
    border-left-color: #2ecc71;
}

.robot-list-item.on-mission {
    border-left-color: #f4a460;
}

.robot-icon {
    font-size: 28px;
    width: 40px;
    text-align: center;
}

.robot-details {
    flex: 1;
}

.robot-type-name {
    font-weight: bold;
    font-size: 14px;
    text-transform: capitalize;
}

.robot-mission-status {
    font-size: 12px;
    color: #aaa;
}

.robot-mission-status.searching {
    color: #f4a460;
}

.robot-mission-status.working {
    color: #ffe66d;
}

.robot-mission-status.returning {
    color: #4ecdc4;
}

.robot-action-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.robot-action-btn.deploy {
    background: #f4a460;
    color: #1a1a2e;
}

.robot-action-btn.recall {
    background: #4ecdc4;
    color: #1a1a2e;
}

.robot-action-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.1);
}

#team-panel-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

#team-panel-actions .panel-btn {
    flex: 1;
}

.panel-btn.deploy {
    background: #f4a460;
    color: #1a1a2e;
}

.panel-btn.deploy:hover {
    background: #e8985a;
}

.panel-btn.recall {
    background: #4ecdc4;
    color: #1a1a2e;
}

.panel-btn.recall:hover {
    background: #3dbdb5;
}

#close-team {
    background: #555;
    color: #fff;
    width: 100%;
}

#close-team:hover {
    background: #666;
}

.no-robots-msg {
    text-align: center;
    color: #888;
    padding: 30px;
    font-size: 14px;
}

/* Game Over Screen */
#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;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

#game-over-screen h1 {
    color: #ff4444;
    font-size: 64px;
    margin-bottom: 20px;
    text-shadow: 0 0 20px rgba(255, 0, 0, 0.5);
}

#game-over-screen #final-score {
    color: #fff;
    font-size: 28px;
    margin-bottom: 40px;
}

#game-over-buttons {
    display: flex;
    gap: 24px;
}

.game-over-btn {
    padding: 16px 48px;
    font-size: 22px;
    font-weight: bold;
    border: 2px solid;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

#continue-btn {
    background: #2ecc71;
    border-color: #27ae60;
    color: #fff;
}

#continue-btn:hover {
    background: #27ae60;
    transform: translateY(-2px);
}

#quit-btn {
    background: #e74c3c;
    border-color: #c0392b;
    color: #fff;
}

#quit-btn:hover {
    background: #c0392b;
    transform: translateY(-2px);
}

/* Login Screen */
#login-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #fff;
    z-index: 150;
}

#login-screen h1 {
    font-size: 64px;
    color: #f4a460;
    text-shadow: 0 4px 20px rgba(244, 164, 96, 0.5);
    margin-bottom: 16px;
}

#login-screen > p {
    font-size: 18px;
    color: #aaa;
    margin-bottom: 24px;
}

#login-form,
#signup-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 300px;
    align-items: center;
}

#login-form input,
#signup-form input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #555;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

#login-form input:focus,
#signup-form input:focus {
    border-color: #f4a460;
}

#login-form input::placeholder,
#signup-form input::placeholder {
    color: #888;
}

.login-action-btn {
    width: 100%;
    background: #f4a460;
    color: #1a1a2e;
    border: none;
    padding: 14px 48px;
    font-size: 18px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: bold;
}

.login-action-btn:hover {
    background: #e8985a;
    transform: scale(1.02);
}

.login-error {
    color: #e74c3c;
    font-size: 14px;
    min-height: 20px;
}

.login-toggle {
    color: #aaa;
    font-size: 14px;
}

.login-toggle a {
    color: #f4a460;
    text-decoration: none;
}

.login-toggle a:hover {
    text-decoration: underline;
}

#guest-divider {
    color: #666;
    font-size: 14px;
    margin: 16px 0 8px;
}

.login-action-btn.guest {
    background: #555;
    color: #fff;
    width: 300px;
}

.login-action-btn.guest:hover {
    background: #666;
}

#existing-accounts {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 400px;
}

.account-quick-btn {
    background: rgba(244, 164, 96, 0.15);
    border: 2px solid #555;
    border-radius: 8px;
    padding: 8px 16px;
    color: #f4a460;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.account-quick-btn:hover {
    border-color: #f4a460;
    background: rgba(244, 164, 96, 0.3);
}

/* Account Switcher Modal */
#account-switcher {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, rgba(30, 30, 50, 0.95), rgba(20, 20, 35, 0.98));
    border: 2px solid #f4a460;
    border-radius: 12px;
    padding: 24px;
    color: #fff;
    min-width: 350px;
    max-width: 450px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 200;
}

#account-switcher h2 {
    text-align: center;
    margin-bottom: 16px;
    color: #f4a460;
    font-size: 22px;
}

#switcher-account-list {
    max-height: 250px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.switcher-account-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    margin-bottom: 6px;
    border-left: 3px solid #555;
    cursor: pointer;
    transition: all 0.2s;
}

.switcher-account-item:hover {
    background: rgba(244, 164, 96, 0.15);
    border-left-color: #f4a460;
}

.switcher-account-item.current {
    border-left-color: #2ecc71;
    background: rgba(46, 204, 113, 0.1);
}

.switcher-account-name {
    font-weight: bold;
}

.switcher-current-label {
    font-size: 12px;
    color: #2ecc71;
}

#switcher-actions {
    display: flex;
    gap: 12px;
}

#logout-btn {
    background: #e74c3c;
    color: #fff;
}

#logout-btn:hover {
    background: #c0392b;
}

#switcher-cancel {
    background: #555;
    color: #fff;
}

#switcher-cancel:hover {
    background: #666;
}

/* Playing-as label on start screen */
#start-screen > #playing-as {
    color: #f4a460;
    font-size: 16px;
    margin-bottom: 8px;
}

#switch-user-btn {
    font-size: 13px;
    padding: 5px 12px !important;
}

/* Switcher password prompt */
.switcher-password-row {
    display: flex;
    gap: 8px;
    margin-top: 6px;
}

.switcher-password-row input {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #555;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    font-size: 14px;
    outline: none;
}

.switcher-password-row input:focus {
    border-color: #f4a460;
}

.switcher-password-row button {
    padding: 8px 16px;
    background: #f4a460;
    color: #1a1a2e;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
}

.switcher-password-row button:hover {
    background: #e8985a;
}

/* Game notification popup */
.notification-popup {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(78, 205, 196, 0.95);
    color: #1a1a2e;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    animation: fadeInOut 2s ease-in-out forwards;
    z-index: 100;
}

