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

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #f2f2f2;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

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

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Let clicks pass through to canvas */
}

#score-container {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 24px;
    font-weight: bold;
    color: #fff;
    text-shadow: 2px 2px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}

#level-container {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 400px;
    text-align: center;
}

#level-text {
    font-size: 20px;
    font-weight: bold;
    color: #fff;
    margin-bottom: 5px;
    text-shadow: 2px 2px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}

#xp-bar-container {
    width: 100%;
    height: 20px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    border: 2px solid #555;
    overflow: hidden;
}

#xp-bar {
    width: 0%;
    height: 100%;
    background-color: #ffd700;
    transition: width 0.2s ease-out;
}

#upgrades-container {
    position: absolute;
    bottom: 40px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: auto; /* Buttons need to be clickable */
    z-index: 10;
}

.upgrade-btn {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #333;
    border: 2px solid;
    border-radius: 8px;
    padding: 10px 14px;
    font-weight: bold;
    cursor: pointer;
    width: 260px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.upgrade-btn::after {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(135deg, rgba(255,255,255,0.6) 0%, rgba(255,255,255,0) 50%);
    pointer-events: none;
}

.upgrade-btn:hover {
    transform: translateX(15px) scale(1.03);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    background: rgba(255, 255, 255, 1);
}

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

.upgrade-btn .upgrade-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.upgrade-btn .upgrade-info .upgrade-key {
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 14px;
    font-weight: 900;
    margin-right: 8px;
    box-shadow: inset 0 0 4px rgba(0,0,0,0.1);
    color: #555;
}

.upgrade-btn .upgrade-info .upgrade-name {
    flex-grow: 1;
}

.upgrade-btn .upgrade-info .upgrade-level {
    font-size: 11px;
    color: #777;
}

.upgrade-btn .stat-bars {
    display: flex;
    gap: 3px;
    width: 100%;
}

.upgrade-btn .stat-bars div {
    flex: 1;
    height: 10px;
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

#evolutions-container {
    position: absolute;
    top: 100px;
    left: 20px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    pointer-events: auto;
    width: 260px;
}

.evolve-title {
    font-size: 16px;
    font-weight: 900;
    margin-bottom: 10px;
    text-transform: uppercase;
    color: #333;
    text-align: center;
}

.evolve-btn {
    background: rgba(0, 0, 0, 0.05);
    border: 2px solid #00b2e1;
    border-radius: 5px;
    padding: 10px;
    margin-bottom: 8px;
    font-weight: bold;
    cursor: pointer;
    text-align: center;
    color: #333;
    transition: all 0.2s;
}

.evolve-btn:hover {
    background: #00b2e1;
    color: white;
    transform: scale(1.02);
}

#leaderboard {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 200px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    padding: 10px;
    color: white;
    pointer-events: none;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#leaderboard h3 {
    margin-bottom: 8px;
    font-size: 16px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 4px;
}

#leaderboard-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

#leaderboard-list li {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 14px;
    font-weight: bold;
    text-shadow: 1px 1px 2px #000;
}

#start-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at 50% 50%, rgba(20,20,30,0.9) 0%, rgba(5,5,10,0.98) 100%);
    background-size: 200% 200%;
    animation: bgPulse 10s ease infinite;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

@keyframes bgPulse {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.glass-panel {
    background: linear-gradient(135deg, rgba(20, 20, 35, 0.6) 0%, rgba(10, 10, 20, 0.8) 100%);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 24px;
    padding: 40px;
    text-align: center;
    color: white;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6), inset 0 2px 20px rgba(255, 255, 255, 0.05);
    width: 480px;
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideUp {
    0% { opacity: 0; transform: translateY(30px) scale(0.95); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.glass-panel h1 {
    font-size: 38px;
    margin-bottom: 30px;
    font-weight: 900;
    letter-spacing: 2px;
    text-transform: uppercase;
    background: linear-gradient(90deg, #fff, #aaa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

.glass-panel input {
    width: 100%;
    padding: 15px;
    margin-bottom: 25px;
    border: none;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.4);
    color: white;
    font-size: 16px;
    outline: none;
    border: 2px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.5);
}

.glass-panel input:focus {
    border-color: rgba(0, 178, 225, 0.6);
    background: rgba(0, 0, 0, 0.6);
    box-shadow: 0 0 15px rgba(0, 178, 225, 0.2), inset 0 2px 5px rgba(0,0,0,0.5);
}

.team-selection h3 {
    margin-bottom: 15px;
    font-size: 18px;
}

.teams {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
}

.team-option {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 12px;
    text-transform: uppercase;
    color: #fff;
    cursor: pointer;
    border: 3px solid transparent;
    opacity: 0.5;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
    box-shadow: inset 0 0 15px rgba(0,0,0,0.5), 0 5px 15px rgba(0,0,0,0.3);
    user-select: none;
    -webkit-user-select: none;
}

.team-option:hover {
    opacity: 0.9;
    transform: translateY(-5px) scale(1.05);
    box-shadow: inset 0 0 15px rgba(0,0,0,0.2), 0 10px 20px rgba(0,0,0,0.4);
}

.team-option.selected {
    opacity: 1;
    transform: translateY(-5px) scale(1.15);
    border-color: #fff !important;
    box-shadow: 0 0 20px currentColor, inset 0 0 10px rgba(0,0,0,0.2);
}

.mode-selection {
    margin-top: 15px;
    margin-bottom: 25px;
}

.mode-selection h3 {
    margin-bottom: 10px;
    font-size: 18px;
}

.modes {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.mode-option {
    flex: 1;
    min-width: 120px;
    padding: 15px 10px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    user-select: none;
    -webkit-user-select: none;
}

.mode-title {
    font-weight: 900;
    font-size: 14px;
    text-transform: uppercase;
    color: #fff;
    letter-spacing: 0.5px;
    transition: color 0.3s ease;
}

.mode-desc {
    font-size: 10px;
    font-weight: 500;
    color: #aaaaaa;
    line-height: 1.2;
}

.mode-option:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-3px);
    box-shadow: 0 8px 15px rgba(0,0,0,0.3);
}

.mode-option.selected {
    background: linear-gradient(135deg, rgba(0, 178, 225, 0.2) 0%, rgba(0, 85, 255, 0.1) 100%);
    border-color: #00b2e1;
    box-shadow: 0 0 20px rgba(0, 178, 225, 0.4);
    transform: translateY(-3px);
}

.mode-option.selected .mode-title {
    color: #00b2e1;
    text-shadow: 0 0 8px rgba(0, 178, 225, 0.6);
}

#start-btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(270deg, #00b2e1, #0055ff, #00b2e1);
    background-size: 200% 200%;
    animation: gradientShift 3s ease infinite;
    color: white;
    font-size: 20px;
    font-weight: 900;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 8px 25px rgba(0,178,225,0.4);
    margin-top: 15px;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

#start-btn:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 12px 30px rgba(0,178,225,0.6);
}

.footer-copy {
    margin-top: 25px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 500;
    letter-spacing: 0.5px;
}

.footer-copy a {
    color: #00b2e1;
    text-decoration: none;
    font-weight: 700;
    transition: all 0.3s ease;
}

.footer-copy a:hover {
    color: #fff;
    text-shadow: 0 0 10px #00b2e1;
}

#event-log {
    position: absolute;
    bottom: 250px;
    left: 20px;
    width: 300px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    pointer-events: none;
    z-index: 5;
}

.event-log-item {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: bold;
    animation: slideIn 0.3s ease-out forwards;
    border-left: 4px solid #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    opacity: 0;
}

@keyframes slideIn {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.event-log-item.fade-out {
    animation: fadeOut 0.5s ease-out forwards;
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Sandbox UI Overhaul */
#sandbox-ui {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(0, 178, 225, 0.3);
    box-shadow: 0 10px 30px rgba(0,0,0,0.6), inset 0 0 15px rgba(0, 178, 225, 0.1);
    border-radius: 16px;
    padding: 20px;
    width: 260px;
    z-index: 100;
    color: white;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.sandbox-header {
    text-align: center;
    font-size: 16px;
    font-weight: 900;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #00b2e1;
    text-shadow: 0 0 10px rgba(0,178,225,0.5);
}

.sandbox-tools {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sandbox-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    margin: 5px 0;
}

.sandbox-btn {
    padding: 10px 15px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 12px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-transform: uppercase;
}

.sandbox-btn span {
    font-size: 16px;
    line-height: 0;
}

.sandbox-btn.primary {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.1);
}
.sandbox-btn.primary:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.sandbox-btn.draw-btn {
    background: rgba(255, 215, 0, 0.1);
    color: #ffd700;
    border-color: rgba(255, 215, 0, 0.3);
}
.sandbox-btn.draw-btn:hover {
    background: rgba(255, 215, 0, 0.2);
}

.sandbox-btn.dummy-btn {
    background: rgba(0, 178, 225, 0.1);
    color: #00b2e1;
    border-color: rgba(0, 178, 225, 0.3);
}
.sandbox-btn.dummy-btn:hover {
    background: rgba(0, 178, 225, 0.2);
}

.sandbox-btn.danger-btn {
    background: rgba(255, 68, 68, 0.1);
    color: #ff4444;
    border-color: rgba(255, 68, 68, 0.3);
}
.sandbox-btn.danger-btn:hover {
    background: rgba(255, 68, 68, 0.2);
    box-shadow: 0 0 10px rgba(255,68,68,0.3);
}
