/*
    Robot Wars - styles.css
    V1.3.1 - Miglioramenti layout e scroll
    - Body con scroll verticale
    - Robot list più alta (600px)
    - Game layout ottimizzato (2fr 1fr, 370px auto)
    - Stili per ostacoli (muri, casse, rocce)
    - Stili per power-ups (health, speed, damage, shield)
    - Triangolino fumetto spostato a sinistra
*/

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

body {
    font-family: 'Courier New', monospace;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #eee;
    padding: 0;
    min-height: 100vh;
    overflow-y: auto;
}

.container {
    max-width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

h1 {
    text-align: center;
    color: #00ff88;
    text-shadow: 0 0 10px #00ff88;
    margin: 10px 0;
    font-size: 2em;
    padding: 0 20px;
}

.version-label {
    position: fixed;
    top: 10px;
    right: 10px;
    font-size: 12px;
    color: orange;
    background: transparent;
    padding: 2px 4px;
    z-index: 9999;
    font-family: Arial, Helvetica, sans-serif;
}

.setup-section {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid #00ff88;
    border-radius: 10px;
    padding: 15px 20px;
    margin: 0 20px 10px;
/*    flex-shrink: 0;  */
}

.setup-section h2 {
    color: #00ff88;
    margin-bottom: 10px;
    font-size: 1.2em;
}

.num-robots-control {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.num-robots-control label {
    color: #aaa;
}

.num-robots-control input {
    width: 80px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #555;
    border-radius: 5px;
    color: #fff;
    font-family: inherit;
    font-size: 1em;
}

.robot-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 10px;
    max-height: 600px;
    overflow-y: auto;
}

.robot-card {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid;
    border-radius: 10px;
    padding: 10px;
}

.robot-card h3 {
    margin-bottom: 8px;
    font-size: 0.95em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.commander-preview {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid;
    object-fit: cover;
    object-position: center;
}

.config-group {
    display: flex;
    margin-bottom: 6px;
}

.config-group label {
    display: block;
    margin-bottom: 3px;
    color: #aaa;
    font-size: 0.75em;
}

.config-group input, .config-group select {
    width: 100%;
    padding: 4px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #555;
    border-radius: 5px;
    color: #fff;
    font-family: inherit;
    font-size: 0.8em;
}

.game-layout {
    display: grid;
    grid-template-columns: 2fr 450px;
    grid-template-rows: minmax(370px; 1fr) minmax(320px; 1fr);
    gap: 20px;
    min-height: 0;
    height: 85vh;
    padding: 0 20px;
    margin-bottom: 10px;
}

@media (max-width: 900px) {
  .game-layout {
    grid-template-columns: 1fr; /* Una colonna unica per schermi piccoli */
    grid-template-rows: auto;
  }
}

#arena {
    width: 100%;
    height: 100%;
    background-image: url('../images/battlefield.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border: 3px solid #ff3366;
    border-radius: 10px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(255, 51, 102, 0.5);
}

.arena-container {
    grid-row: 1 / span 2;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: stretch;
    justify-content: center;
}

.robot {
    position: absolute;
    width: 30px;
    height: 30px;
}

.robot-body {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
    font-weight: bold;
    overflow: hidden;
}

.commander-avatar {
    width: 80%;
    height: 80%;
    border-radius: 50%;
    object-fit: cover;
    object-position: center;
}

.tracks {
    position: absolute;
    width: 40px;
    height: 36px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 1;
}

.track {
    position: absolute;
    width: 100%;
    height: 6px;
    background: currentColor;
    border-radius: 3px;
    opacity: 0.6;
}

.track-left {
    top: 0;
}

.track-right {
    bottom: 0;
}

.cannon {
    position: absolute;
    width: 20px;
    height: 3px;
    background: linear-gradient(90deg, currentColor 0%, currentColor 70%, transparent 100%);
    top: 50%;
    left: 50%;
    transform-origin: left center;
    pointer-events: none;
    z-index: 3;
}

.health-bar {
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.health-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s;
}

.robot-name {
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    white-space: nowrap;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    pointer-events: none;
}

.bullet {
    position: absolute;
    width: 6px;
    height: 6px;
    background: #ffff00;
    border-radius: 50%;
    box-shadow: 0 0 8px #ffff00;
}

.obstacle {
    position: absolute;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    border: 2px solid rgba(0, 0, 0, 0.3);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3), 0 4px 10px rgba(0, 0, 0, 0.4);
    z-index: 10;
}

.explosion {
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: radial-gradient(circle, #ff6600 0%, transparent 70%);
    animation: explode 0.3s ease-out;
    pointer-events: none;
}

@keyframes explode {
    from { transform: scale(0); opacity: 1; }
    to { transform: scale(2); opacity: 0; }
}

.speech-bubble {
    position: absolute;
    background: white;
    color: #000;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: bold;
    border: 2px solid #000;
    white-space: nowrap;
    pointer-events: none;
    z-index: 100;
    animation: speechFloat 1s ease-out forwards;
}

.speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 25%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid white;
}

.speech-bubble::before {
    content: '';
    position: absolute;
    bottom: -12px;
    left: 25%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 12px solid #000;
    z-index: -1;
}

@keyframes speechFloat {
    0% {
        opacity: 0;
        transform: translateY(0) scale(0.5);
    }
    20% {
        opacity: 1;
        transform: translateY(-10px) scale(1);
    }
    80% {
        opacity: 1;
        transform: translateY(-30px) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-50px) scale(0.8);
    }
}

.powerup {
    position: absolute;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border: 2px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.6);
    animation: powerupPulse 1s ease-in-out infinite, powerupFloat 2s ease-in-out infinite;
    cursor: pointer;
    z-index: 50;
}

.powerup-health {
    background: linear-gradient(135deg, #ff6b9d 0%, #c06c84 100%);
}

.powerup-speed {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.powerup-damage {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

.powerup-shield {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
}

@keyframes powerupPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 15px rgba(255, 255, 255, 0.6);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 25px rgba(255, 255, 255, 0.9);
    }
}

@keyframes powerupFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.powerup-effect {
    position: absolute;
    pointer-events: none;
    font-size: 12px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.8);
    animation: effectFloat 1.5s ease-out forwards;
    z-index: 150;
}

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

.controls {
    text-align: center;
    padding: 10px 20px;
    display: flex;
    gap: 10px;
    justify-content: center;
    align-self: center;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-self: center;
    flex-wrap: wrap;
}

label {
    align-self: center;
}

button {
    padding: 10px 20px;
    font-size: 1em;
    background: linear-gradient(135deg, #00ff88 0%, #00cc66 100%);
    border: none;
    border-radius: 5px;
    color: #000;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
    text-transform: uppercase;
    box-shadow: 0 5px 15px rgba(0, 255, 136, 0.3);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 7px 20px rgba(0, 255, 136, 0.5);
}

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

.info-button {
    padding: 8px 15px;
    font-size: 0.9em;
    background: rgba(0, 255, 136, 0.2);
    border: 1px solid #00ff88;
}

.stats-panel {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid #ff3366;
    border-radius: 10px;
    padding: 15px;
}

.stats-panel h3 {
    color: #ff3366;
    margin-bottom: 10px;
    font-size: 1em;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    padding: 6px;
    margin-bottom: 4px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    border-left: 3px solid;
    font-size: 0.85em;
}

.battle-log {
    max-height: 240px;  
    overflow-y: scroll;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px;
    border-radius: 5px;
    font-size: 0.8em;
}

.battle-log div {
    margin-bottom: 5px;
}

.log-hit { 
    color: #ff3366; 
}

.log-destroyed { 
    color: #ffff00; 
    font-weight: bold; 
}

.winner-banner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    padding: 30px 60px;
    border: 3px solid #00ff88;
    border-radius: 15px;
    font-size: 2em;
    font-weight: bold;
    color: #00ff88;
    text-shadow: 0 0 20px #00ff88;
    z-index: 1000;
    text-align: center;
}

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

.modal-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 3px solid #00ff88;
    border-radius: 15px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-content h2 {
    color: #00ff88;
    margin-bottom: 20px;
    text-align: center;
}

.robot-type-info {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #555;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.robot-type-info h3 {
    color: #00ff88;
    margin-bottom: 10px;
}

.robot-type-info p {
    color: #aaa;
    margin-bottom: 10px;
}

.robot-type-info .stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    color: #fff;
}

.close-modal {
    background: #ff3366;
    padding: 10px 20px;
    text-transform: none;
}

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

::-webkit-scrollbar-thumb {
    background: #00ff88;
    border-radius: 4px;
}

/* Settings Modal Styles */
.settings-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.setting-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #555;
    border-radius: 8px;
    padding: 15px;
    transition: all 0.3s;
}

.setting-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: #00ff88;
}

.setting-label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    width: 100%;
}

.setting-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    margin-top: 2px;
    flex-shrink: 0;
}

.setting-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.setting-info {
    flex: 1;
}

.setting-title {
    color: #00ff88;
    font-weight: bold;
    font-size: 1em;
    margin-bottom: 5px;
}

.setting-desc {
    color: #aaa;
    font-size: 0.85em;
    line-height: 1.4;
}

/* Volume slider */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #00ff88;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #00ff88;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
}

input[type="range"]:hover::-webkit-slider-thumb {
    background: #00cc66;
    transform: scale(1.1);
}

input[type="range"]:hover::-moz-range-thumb {
    background: #00cc66;
    transform: scale(1.1);
}


/* Mobile optimizations */
@media (max-width: 768px) {
    body {
        padding: 0;
    }
    
    h1 {
        font-size: 1.5em;
        margin: 5px 0;
        padding: 0 10px;
    }

    h2 {
        font-size: 1.2em;
        margin: 5px 0;
        padding: 0 10px;
    }
    
    .setup-section {
        min-height: 80vh;
        margin: 0 10px 10px;
        padding: 10px;
    }
    
    .robot-list {
        grid-template-columns: 1fr;
        max-height: 56vh; 
    }

    .config-group label, .config-group input, .config-group select {
        display: inline-block;
    }

    .game-layout {
        display: flex;
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        padding: 0;
        gap: 10px;
        margin-bottom: 0;
    }
    
    .arena-container {
        width: 100vw;
        height: 100vw;
        padding: 0;
        margin: 0;
    }
    
    #arena {
        width: 100%;
        height: 100%;
    }
    
    .stats-panel {
        margin: 0 10px;
        padding: 10px;
    }
    
    .stats-panel h3 {
        font-size: 0.9em;
    }
    
    .battle-log {
        max-height: 200px;
        font-size: 0.75em;
    }
    
    .leaderboard-item {
        font-size: 0.75em;
        padding: 4px;
    }
    
    .controls {
        padding: 10px;
    }
    
    button {
        padding: 8px 16px;
        font-size: 0.9em;
    }
    
    .winner-banner {
        font-size: 1.5em;
        padding: 20px 40px;
    }
    
    .robot-name {
        font-size: 8px;
    }
    
    .setting-label {
        gap: 8px;
    }
    
    .setting-icon {
        font-size: 20px;
    }
    
    .setting-title {
        font-size: 0.9em;
    }
    
    .setting-desc {
        font-size: 0.75em;
    }

}

@media (max-width: 480px) {
    h1 {
        font-size: 1.2em;
    }

    h2 {
        font-size: 1.1em;
    }
    
    .robot-list {
        max-height: 60vh;
    }
    
    button {
        padding: 6px 12px;
        font-size: 0.85em;
    }
}
