* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body {
    background: #f0f0f0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: hidden;
    font-family: 'Courier New', monospace;
    background: linear-gradient(135deg, #cecece 0%, #e6e6e6 100%);
}

.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s;
}

.loading-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
    max-width: 600px;
    width: 90%;
}

.loading-logo {
    max-width: 100%;
    height: auto;
    margin-bottom: 50px;
}

.loading-bar-container {
    width: 100%;
    height: 30px;
    background: #333;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 20px;
    border: 3px solid #555;
}

.loading-bar {
    width: 0%;
    height: 100%;
    background: repeating-linear-gradient(
        -45deg,
        #666 0px,
        #666 15px,
        #444 15px,
        #444 30px
    );
    transition: width 0.3s ease;
}

.loading-text {
    color: #fff;
    font-size: 24px;
    font-weight: bold;
}

.screen {
    display: none;
}

.screen.active {
    display: block;
}

.container {
    background: #fff;
    padding: 60px 40px;
    max-width: 900px;
    width: 100%;
    text-align: center;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.logo-container {
    text-align: center;
    margin-bottom: 50px;
}
.logo-image {
    max-width: 400px;
    width: 100%;
    height: auto;
}

.player-options, .difficulty-options {
    display: flex;
    justify-content: center;
    gap: 40px;
    flex-wrap: wrap;
}

.player-option, .difficulty-option {
    font-size: 32px;
    color: #333;
    cursor: pointer;
    padding: 15px 35px;
    transition: all 0.3s;
    border: 3px solid transparent;
    border-radius: 6px;
    background: rgba(255,255,255,0.5);
    font-weight: bold;
}

.player-option:hover, .difficulty-option:hover {
    color: #000;
    background: rgba(255,255,255,0.8);
    border-color: #666;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.player-option.selected, .difficulty-option.selected {
    color: #fff;
    background: #333;
    border-color: #222222;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.start-button {
    margin-top: 60px;
    padding: 18px 60px;
    font-size: 24px;
    font-weight: bold;
    background: linear-gradient(135deg, #333 0%, #1a1a1a 100%);
    color: white;
    border: 3px solid #222222;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.start-button:hover {
    background: linear-gradient(135deg, #222222 0%, #222222 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

#gameCanvas {
    display: block;
    background: #e0e0e0;
    margin: 0 auto;
    border: 2px solid #000;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.scoreboard {
    display: flex;
    justify-content: center;
    gap: 40px;
    padding-bottom: 10px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.player-score {
    text-align: center;
}

.tank-icon {
    width: 160px;
    height: 110px;
    margin-bottom: 5px;
}

.score-number {
    font-size: 36px;
    font-weight: bold;
    color: #333;
}

.victory-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.victory-modal.show {
    display: flex;
}

.victory-content {
    background: white;
    padding: 60px 80px;
    text-align: center;
    border-radius: 10px;
}

.victory-text {
    font-size: 72px;
    font-weight: bold;
    margin-bottom: 30px;
}

.victory-text.green { color: #00ff00; }
.victory-text.blue { color: #0080ff; }
.victory-text.red { color: #ff0000; }

.play-again-btn {
    margin-top: 20px;
    padding: 18px 60px;
    font-size: 24px;
    font-weight: bold;
    background: linear-gradient(135deg, #333 0%, #1a1a1a 100%);
    color: white;
    border: 3px solid #222222;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.play-again-btn:hover {
    background: linear-gradient(135deg, #222222 0%, #222222 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

.ready-title {
    font-size: 32px;
    color: #333;
    margin-bottom: 60px;
    font-weight: bold;
}

.ready-buttons {
    display: flex;
    justify-content: center;
    gap: 60px;
    flex-wrap: wrap;
}

.player-ready-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.controls-display {
    display: grid;
    grid-template-columns: repeat(3, 40px);
    grid-template-rows: repeat(3, 40px);
    gap: 5px;
    margin-top: 10px;
}

.control-key {
    width: 40px;
    height: 40px;
    border: 2px solid #999;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    background: white;
    color: #333;
}

.control-key.shoot-key {
    background: #cfcfcf;
    border-color: #b8b8b8;
}

.control-key.shoot-key.ready {
    background: #00ff00;
    border-color: #00cc00;
}

.control-up { grid-column: 2; grid-row: 1; }
.control-left { grid-column: 1; grid-row: 2; }
.control-down { grid-column: 2; grid-row: 2; }
.control-right { grid-column: 3; grid-row: 2; }
.control-shoot { grid-column: 2; grid-row: 3; }

.player-ready-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.player-label {
    font-size: 20px;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.back-btn-global {
    position: fixed;
    top: 30px;
    left: 30px;
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.9);
    border: 3px solid #333;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 1000;
    display: none;
    padding: 0;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.back-btn-global:hover {
    background: white;
    transform: scale(1.1);
    box-shadow: 0 6px 12px rgba(0,0,0,0.3);
}

.back-btn-global img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 10px;
}

.back-btn-global.show {
    display: block;
}

.confirm-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.confirm-modal.show {
    display: flex;
}

.confirm-content {
    background: white;
    padding: 60px 80px;
    text-align: center;
    border-radius: 10px;
}

.confirm-text {
    font-size: 32px;
    color: #333;
    margin-bottom: 30px;
    font-weight: bold;
}

.confirm-btn, .cancel-btn {
    margin: 10px;
    padding: 18px 60px;
    font-size: 24px;
    font-weight: bold;
    background: linear-gradient(135deg, #333 0%, #1a1a1a 100%);
    color: white;
    border: 3px solid #222222;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.confirm-btn:hover, .cancel-btn:hover {
    background: linear-gradient(135deg, #222222 0%, #222222 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

.powerup-toggle {
    margin: 30px 0;
    font-size: 20px;
}

.powerup-toggle label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
}

.powerup-toggle input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.powerup-toggle, .selfdestruct-toggle {
    display: inline-block;
    margin: 30px 20px;
    font-size: 20px;
}

.powerup-toggle label, .selfdestruct-toggle label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
}

.powerup-toggle input[type="checkbox"], .selfdestruct-toggle input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.keyboard-btn {
    margin-top: 15px;
    padding: 8px 15px;
    font-size: 16px;
    background: #666;
    color: white;
    border: none;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.keyboard-btn img {
    width: 35px;
    height: 35px;
    filter: invert(1);
    object-fit: contain;
}

.keyboard-btn:hover {
    background: #444;
    transform: scale(1.05);
}

.keyboard-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.keyboard-modal.show {
    display: flex;
}

.keyboard-content {
    background: white;
    padding: 30px;
    border-radius: 10px;
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.keyboard-title {
    font-size: 20px;
    font-weight: bold;
    color: #333;
    margin-bottom: 20px;
    text-align: center;
}

.keyboard-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    background: #f5f5f5;
    border-radius: 5px;
}

.control-label {
    font-size: 18px;
    font-weight: bold;
    color: #333;
    min-width: 100px;
}

.control-button {
    padding: 12px 30px;
    font-size: 16px;
    font-weight: bold;
    background: #666;
    color: white;
    border: 2px solid #444;
    border-radius: 5px;
    cursor: pointer;
    min-width: 80px;
    transition: all 0.3s;
}

.control-button:hover {
    background: #555;
}

.control-button.selecting {
    background: #00ff00;
    color: #000;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.virtual-keyboard {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 15px auto;
    width: 100%;
    max-width: 650px;
}

.keyboard-row {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.virtual-key {
    padding: 8px 6px;
    font-size: 11px;
    font-weight: bold;
    background: #e0e0e0;
    border: 2px solid #999;
    border-radius: 3px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    min-height: 38px;
    min-width: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.virtual-key:hover:not(.occupied) {
    background: #d0d0d0;
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.virtual-key.occupied {
    background: #333;
    color: #666;
    cursor: not-allowed;
    border-color: #555;
}

.virtual-key[data-key="backspace"] { min-width: 60px; }
.virtual-key[data-key="tab"] { min-width: 55px; }
.virtual-key[data-key="capslock"] { min-width: 65px; }
.virtual-key[data-key="enter"] { min-width: 70px; }
.virtual-key[data-key="shift"] { min-width: 80px; }
.virtual-key[data-key="ctrl"] { min-width: 50px; }
.virtual-key[data-key="alt"] { min-width: 45px; }
.virtual-key[data-key="space"] { min-width: 240px; }

.arrow-row {
    display: flex;
    gap: 4px;
    justify-content: center;
    margin-top: 6px;
}

.arrow-group {
    display: grid;
    grid-template-columns: repeat(3, 38px);
    grid-template-rows: repeat(2, 38px);
    gap: 4px;
    grid-template-areas:
        ". up ."
        "left down right";
}

.virtual-key[data-key="arrowup"] {
    grid-area: up;
}

.virtual-key[data-key="arrowleft"] {
    grid-area: left;
}

.virtual-key[data-key="arrowdown"] {
    grid-area: down;
}

.virtual-key[data-key="arrowright"] {
    grid-area: right;
}

.keyboard-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
}

.keyboard-action-btn {
    padding: 12px 35px;
    font-size: 16px;
    font-weight: bold;
    background: #333;
    color: white;
    border: none;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.3s;
}

.keyboard-action-btn:hover {
    background: #000;
}

.keyboard-action-btn.cancel {
    background: #999;
}

.keyboard-action-btn.cancel:hover {
    background: #777;
}

.settings-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: white;
    border: none;
    border-radius: 8px;
    width: 60px;
    height: 60px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.settings-icon {
    font-size: 26px;
    transition: transform 0.3s ease;
}

.settings-btn img {
    width: 40px;
    height: 40px;
    filter: brightness(0.9);
    transition: transform 1s ease;
}

.settings-btn img:hover {
    transform: rotate(360deg);
}

.settings-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.settings-modal.show {
    display: flex;
}

.settings-content {
    background: #2a2a2a;
    border: 4px solid #444;
    border-radius: 12px;
    padding: 40px;
    min-width: 500px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.settings-title {
    font-size: 32px;
    font-weight: bold;
    color: #fff;
    text-align: center;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 25px;
    gap: 20px;
}

.setting-row label {
    font-size: 18px;
    color: #fff;
    min-width: 150px;
}

.setting-row input[type="range"] {
    flex: 1;
    height: 8px;
    background: #444;
    border-radius: 5px;
    outline: none;
}

.setting-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: #4CAF50;
    cursor: pointer;
    border-radius: 50%;
}

.setting-row span {
    font-size: 18px;
    color: #4CAF50;
    min-width: 60px;
    text-align: right;
    font-weight: bold;
}

.settings-actions {
    display: flex;
    gap: 15px;
    margin-top: 40px;
    justify-content: center;
}

.settings-action-btn {
    padding: 12px 30px;
    font-size: 18px;
    font-weight: bold;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.settings-action-btn:hover {
    background: #45a049;
    transform: translateY(-2px);
}

.settings-action-btn.cancel {
    background: #f44336;
}

.settings-action-btn.cancel:hover {
    background: #da190b;
}

.settings-action-btn.reset {
    background: #9e9e9e;
}

.settings-action-btn.reset:hover {
    background: #818181;
}