/* Tower Defense Player Styles */

:root {
    --tower-primary: #f59e0b;
    --tower-secondary: #ef4444;
    --zone-red: #ef4444;
    --zone-blue: #3b82f6;
    --zone-green: #22c55e;
    --zone-orange: #f59e0b;
}

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

body {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    font-family: 'Segoe UI', system-ui, sans-serif;
    color: #fff;
    overflow-x: hidden;
}

.player-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.screen.hidden {
    display: none;
}

/* ==================== JOIN SCREEN ==================== */

#join-screen {
    align-items: center;
    justify-content: center;
    text-align: center;
}

.title {
    font-size: 2rem;
    background: linear-gradient(135deg, var(--tower-primary), var(--tower-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.towers-icons {
    font-size: 1.5rem;
    margin-bottom: 30px;
    letter-spacing: 5px;
}

.join-form {
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.join-form input {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 16px 20px;
    font-size: 1.2rem;
    color: #fff;
    text-align: center;
    transition: all 0.2s;
}

.join-form input:focus {
    outline: none;
    border-color: var(--tower-primary);
    background: rgba(255, 255, 255, 0.15);
}

.join-form input::placeholder {
    color: #666;
}

.avatar-section {
    margin: 10px 0;
}

.avatar-label {
    font-size: 0.9rem;
    color: #888;
    margin-bottom: 10px;
}

.avatar-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}

.avatar-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 10px;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.avatar-btn.selected {
    border-color: var(--tower-primary);
    background: rgba(245, 158, 11, 0.2);
}

.btn-primary {
    background: linear-gradient(135deg, var(--tower-primary), var(--tower-secondary));
    border: none;
    border-radius: 12px;
    padding: 18px;
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:active {
    transform: scale(0.98);
}

.error-message {
    color: #ef4444;
    font-size: 0.9rem;
    min-height: 20px;
}

/* ==================== LOBBY SCREEN ==================== */

#lobby-screen {
    align-items: center;
    padding-top: 50px;
}

.lobby-info {
    text-align: center;
    margin-bottom: 40px;
}

.my-zone {
    font-size: 1rem;
    font-weight: 600;
    padding: 8px 20px;
    border-radius: 20px;
    display: inline-block;
    margin-bottom: 15px;
}

.my-zone.zone-0 { background: var(--zone-red); }
.my-zone.zone-1 { background: var(--zone-blue); }
.my-zone.zone-2 { background: var(--zone-green); }
.my-zone.zone-3 { background: var(--zone-orange); }

.my-avatar {
    font-size: 4rem;
    margin-bottom: 10px;
}

.my-name {
    font-size: 1.5rem;
    font-weight: 600;
}

.waiting-message {
    color: #888;
    margin-bottom: 40px;
    animation: pulse 2s infinite;
}

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

.other-players {
    width: 100%;
    max-width: 300px;
}

.other-players h3 {
    font-size: 1rem;
    color: #888;
    margin-bottom: 15px;
}

#other-players-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.other-player {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.05);
    padding: 12px 16px;
    border-radius: 10px;
    border-left: 4px solid;
}

.other-player.zone-0 { border-color: var(--zone-red); }
.other-player.zone-1 { border-color: var(--zone-blue); }
.other-player.zone-2 { border-color: var(--zone-green); }
.other-player.zone-3 { border-color: var(--zone-orange); }

.other-player-avatar {
    font-size: 1.5rem;
}

.other-player-name {
    flex: 1;
}

/* ==================== GAME SCREEN ==================== */

#game-screen {
    padding: 15px;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.header-info {
    display: flex;
    gap: 15px;
    align-items: center;
}

.gold-display {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 1.3rem;
    font-weight: 700;
}

.gold-icon {
    font-size: 1.2rem;
}

.gold-amount {
    color: #fbbf24;
}

.wave-display {
    font-size: 0.9rem;
    color: #888;
}

.phase-badge {
    background: var(--tower-primary);
    padding: 6px 14px;
    border-radius: 15px;
    font-size: 0.85rem;
    font-weight: 600;
}

.phase-badge.wave {
    background: #ef4444;
}

/* Zone View */
.zone-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 15px;
    margin-bottom: 15px;
}

.zone-label {
    font-size: 0.9rem;
    color: #888;
    margin-bottom: 15px;
    text-align: center;
}

.slots-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    align-content: center;
}

.slot-btn {
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 3px dashed rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.slot-btn:active {
    transform: scale(0.95);
}

.slot-btn.empty {
    border-style: dashed;
}

.slot-btn.empty::after {
    content: '+';
    font-size: 2rem;
    color: rgba(255, 255, 255, 0.4);
}

.slot-btn.occupied {
    border-style: solid;
    border-color: var(--tower-primary);
    background: rgba(245, 158, 11, 0.1);
}

.slot-tower-emoji {
    font-size: 2.5rem;
}

.slot-tower-level {
    font-size: 0.8rem;
    color: #fbbf24;
    margin-top: 5px;
}

/* Tower Panel */
.tower-panel {
    background: rgba(0, 0, 0, 0.9);
    border-radius: 20px 20px 0 0;
    padding: 20px;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 70vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.tower-panel.hidden {
    display: none;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

#panel-title {
    font-size: 1.2rem;
    font-weight: 600;
}

.btn-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: #888;
    font-size: 1.2rem;
    cursor: pointer;
}

.build-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.tower-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    transition: all 0.2s;
}

.tower-btn:active {
    transform: scale(0.98);
    border-color: var(--tower-primary);
}

.tower-btn:disabled {
    opacity: 0.5;
}

.tower-btn .tower-emoji {
    font-size: 2rem;
}

.tower-btn .tower-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
}

.tower-btn .tower-cost {
    font-size: 0.85rem;
    color: #fbbf24;
}

.tower-btn .tower-desc {
    font-size: 0.75rem;
    color: #666;
}

/* Upgrade Options */
.upgrade-options {
    text-align: center;
}

.upgrade-options.hidden {
    display: none;
}

.tower-info {
    margin-bottom: 20px;
}

.tower-info .tower-emoji {
    font-size: 3rem;
    display: block;
    margin-bottom: 10px;
}

.tower-info .tower-name {
    font-size: 1.3rem;
    font-weight: 600;
}

.tower-info .tower-level {
    font-size: 1.5rem;
    color: #fbbf24;
    margin-top: 5px;
}

.upgrade-buttons {
    display: flex;
    gap: 15px;
}

.btn-upgrade, .btn-sell {
    flex: 1;
    padding: 15px;
    border-radius: 12px;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.btn-upgrade {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
}

.btn-upgrade:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-sell {
    background: rgba(239, 68, 68, 0.2);
    border: 2px solid #ef4444;
    color: #ef4444;
}

.upgrade-cost, .sell-refund {
    font-size: 0.85rem;
    font-weight: normal;
}

/* Ready Section */
.ready-section {
    text-align: center;
    padding: 15px;
}

.btn-ready {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    border: none;
    padding: 18px 50px;
    border-radius: 12px;
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-ready.ready {
    background: linear-gradient(135deg, #666, #444);
}

.btn-ready:active {
    transform: scale(0.98);
}

.ready-status {
    margin-top: 10px;
    color: #888;
    font-size: 0.9rem;
}

/* ==================== GAME OVER ==================== */

#gameover-screen {
    align-items: center;
    justify-content: center;
    text-align: center;
}

.gameover-icon {
    font-size: 5rem;
    margin-bottom: 20px;
}

.gameover-title {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.gameover-title.victory {
    background: linear-gradient(135deg, #22c55e, #fbbf24);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.gameover-title.defeat {
    color: #ef4444;
}

.gameover-message {
    color: #888;
    margin-bottom: 30px;
}

.my-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
}

.stat {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px 25px;
    border-radius: 12px;
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--tower-primary);
}
