/* Reset a základní styly */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-image: url('/static/images/pozadi.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    height: 100vh;
    padding: 20px;
    color: #333;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 10px;
    flex-shrink: 0;
}

header h1 {
    color: #2c3e50;
    font-size: 3.125em;
    text-shadow: 2px 2px 4px rgba(255,255,255,0.8), 0 0 10px rgba(255,255,255,0.5);
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2.25em;
        margin-bottom: 15px;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.875em;
        margin-bottom: 10px;
    }
}

/* Screen management */
.screen {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    overflow: hidden;
    padding: 20px;
}

.screen.hidden {
    display: none;
}

/* Box style (boxy komponenty) */
.box {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    border: 3px solid #ddd;
}

/* Login box */
.login-box {
    min-width: 400px;
    text-align: center;
}

.login-box h2 {
    margin-bottom: 20px;
    color: #667eea;
    font-size: 1.875em;
}

.login-box input {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 8px;
    margin-bottom: 15px;
    outline: none;
    transition: border-color 0.3s;
}

.login-box input:focus {
    border-color: #667eea;
}

.error-message {
    color: #dc3545;
    margin-top: 10px;
    padding: 10px;
    background: #f8d7da;
    border-radius: 6px;
    display: none;
}

.error-message.show {
    display: block;
}

.version-info {
    margin-top: 15px;
    font-size: 0.85em;
    color: #666;
    text-align: center;
}

/* Buttons */
.btn-primary {
    padding: 12px 24px;
    font-size: 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
    width: 100%;
    margin-top: 10px;
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    padding: 12px 24px;
    font-size: 16px;
    border: 2px solid #dc3545;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
    width: 100%;
    margin-top: 10px;
    background: white;
    color: #dc3545;
}

.btn-secondary:hover {
    background: #dc3545;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
}

.lobby-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Lobby box */
.lobby-box {
    min-width: 500px;
}

.lobby-box h2 {
    margin-bottom: 20px;
    color: #667eea;
    text-align: center;
    font-size: 1.875em;
}

.status-message {
    margin-bottom: 20px;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    font-weight: bold;
    font-size: 0.95em;
}

.status-message.waiting {
    color: #667eea;
    background: #e7f0ff;
}

.status-message.ready {
    color: #28a745;
    background: #d4edda;
}

.players-list {
    margin-bottom: 20px;
}

.player-item {
    padding: 12px;
    margin: 8px 0;
    background: #f5f5f5;
    border-radius: 8px;
    border: 2px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.player-item.ready {
    background: #d4edda;
    border-color: #28a745;
}

.player-item .player-name {
    font-weight: bold;
}

.player-item .ready-status {
    color: #28a745;
    font-weight: bold;
}

/* Loadout selection */
.loadout-selection {
    margin-bottom: 20px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 8px;
    text-align: center;
}

.loadout-selection h3 {
    margin-bottom: 15px;
    color: #667eea;
    font-size: 1.375em;
    text-align: center;
}

.loadout-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.loadout-item {
    flex: 1;
    min-width: 200px;
    max-width: 300px;
}

.loadout-item:last-child {
    min-width: 450px;
    flex: 0 0 auto;
}

.loadout-item label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #333;
    text-align: center;
}

.select-box {
    width: 100%;
    padding: 12px 24px;
    font-size: 18px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    height: 48px;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#robot-select {
    text-align: left;
    direction: ltr;
}

#weapon-select {
    text-align: right;
    direction: ltr;
    min-width: 450px;
    width: auto;
}

.select-box option {
    direction: ltr;
    white-space: nowrap !important;
}

.select-box:focus {
    outline: none;
    border-color: #667eea;
}

/* Robot icon in select box */
.select-with-icon {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
}

.robot-icon-container {
    position: relative;
}

.robot-icon {
    width: 48px;
    height: 48px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 4px;
    background: #f5f5f5;
    border: 2px solid #ddd;
    padding: 2px;
    cursor: help;
}

/* Tooltip */
.tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 10px;
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    border-radius: 8px;
    font-size: 14px;
    white-space: pre-line;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    min-width: 200px;
    text-align: left;
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
}

.robot-icon-container:hover .tooltip,
.robot-icon:hover + .tooltip {
    opacity: 1;
}

.robot-icon-container:hover .tooltip {
    opacity: 1;
}

.select-with-icon .select-box {
    flex: 1;
}

/* Game screen */
#game-screen {
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    height: 100%;
    overflow: hidden;
}

.players-info-row {
    display: flex;
    gap: 20px;
    margin-bottom: 10px;
    padding: 0 20px;
    flex-shrink: 0;
}

.player-info-box {
    flex: 1;
    min-width: 0;
    padding: 10px 15px;
    min-height: auto;
    display: flex;
    gap: 2px;
    align-items: stretch;
    border-width: 2px;
    transition: border-width 0.3s ease, background-color 0.3s ease;
}

.player-robot-icon {
    width: 48px;
    height: auto;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 4px;
    background: #f5f5f5;
    border: 2px solid #ddd;
    padding: 2px;
    align-self: stretch;
}

.player-info-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
}

.player-info-box #player-a-name,
.player-info-box #player-b-name {
    font-size: 1em;
    font-weight: bold;
    color: #333;
    line-height: 1.2;
    text-align: center;
}

.player-info-box.my-player #player-a-name,
.player-info-box.my-player #player-b-name {
    font-size: 1.3em;
    font-weight: bold;
}

.player-info-box.current-turn {
    border-width: 4px;
    border-color: #ffffff;
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.5);
}

.player-info-box.my-player {
    background: rgba(102, 126, 234, 0.1);
}

.player-info-box.my-player.current-turn {
    background: rgba(102, 126, 234, 0.15);
}

.player-info-box.winner {
    border-width: 4px;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
}

.player-info-box #player-a-name.winner-blink,
.player-info-box #player-b-name.winner-blink {
    animation: winnerBlink 1s ease-in-out infinite;
}

@keyframes winnerBlink {
    0%, 100% {
        color: #333;
        text-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
    }
    50% {
        color: #ffd700;
        text-shadow: 0 0 15px rgba(255, 215, 0, 1), 0 0 25px rgba(255, 215, 0, 0.8);
        transform: scale(1.05);
    }
}

/* Hit effect */
.player-info-box.hit-effect {
    animation: hitFlash 0.5s ease-out;
}

.player-robot-icon.hit-flash {
    animation: iconFlash 0.5s ease-out;
    filter: brightness(1.5);
}

@keyframes hitFlash {
    0% {
        background-color: rgba(255, 0, 0, 0.8);
        box-shadow: 0 0 20px rgba(255, 0, 0, 0.8);
    }
    100% {
        background-color: transparent;
        box-shadow: none;
    }
}

@keyframes iconFlash {
    0% {
        filter: brightness(2) saturate(2) hue-rotate(0deg);
        box-shadow: 0 0 15px rgba(255, 0, 0, 1);
    }
    100% {
        filter: brightness(1) saturate(1);
        box-shadow: none;
    }
}

/* Health bar */
.health-bar {
    width: 100%;
    height: 20px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid #ccc;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.health-text {
    position: absolute;
    font-size: 0.75em;
    font-weight: bold;
    color: #333;
    z-index: 1;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
    pointer-events: none;
}

.health-fill {
    height: 100%;
    background: linear-gradient(90deg, #4caf50 0%, #8bc34a 100%);
    transition: width 0.3s ease;
    border-radius: 8px;
}

.health-fill.low {
    background: linear-gradient(90deg, #f44336 0%, #ff9800 100%);
}

.health-fill.medium {
    background: linear-gradient(90deg, #ff9800 0%, #ffc107 100%);
}

.game-container {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 20px;
    margin-bottom: 10px;
    gap: 10px;
    min-height: 0;
    overflow: hidden;
}

/* Arena box */
.arena-box {
    padding: 2px;
    overflow: hidden;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: linear-gradient(180deg, #0b1220 0%, #050814 100%);
    justify-content: center;
    align-items: center;
}

.arena-actions {
    padding: 10px 15px;
    text-align: center;
    flex-shrink: 0;
}

.arena-actions .btn-primary {
    width: auto;
    min-width: 150px;
}

#arena-container {
    position: relative;
    width: calc(100% - 4px);
    height: calc(100% - 4px);
    flex: 1 1 auto;
    margin: 2px;
    aspect-ratio: 1080 / 720;
    min-width: 400px;
    min-height: 267px;
}

#arena-svg {
    display: block;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

#grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    cursor: crosshair;
    z-index: 10;
}

#grid-overlay.active {
    pointer-events: all;
}

/* Responzivní design */
@media (max-width: 768px) {
    .login-box, .lobby-box {
        min-width: auto;
        width: 100%;
        max-width: 100%;
    }
    
    .loadout-row {
        flex-direction: column;
    }
    
    .loadout-item {
        min-width: auto;
    }
    
    .players-info-row {
        flex-direction: column;
    }
    
    #arena-container {
        max-width: 100%;
    }
    
    #arena-svg, #grid-overlay {
        width: 100%;
        height: auto;
    }
}

