html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    overflow: hidden;
    width: 100%;
    height: 100%;
    background: #1a1a2e;
}

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

.loading-progress circle {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: #1b6ec2;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

/* Tower Defense Game Styles */
* {
    box-sizing: border-box;
}

.game-container {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1a1a2e;
    color: #fff;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-board-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: calc(100vh * 16 / 9);
    max-height: calc(100vw * 9 / 16);
    aspect-ratio: 16 / 9;
    overflow: hidden;
}

.game-board {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

/* Portrait mode UI adjustments */
@media (orientation: portrait) {
    .game-board-container {
        max-width: 100vw;
        max-height: 100vh;
        aspect-ratio: auto;
    }
    
    .game-board {
        width: 100%;
        height: 100%;
    }
    
    .hud-overlay {
        flex-direction: column;
        gap: 6px;
        padding: 8px 10px;
        background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.4) 70%, rgba(0, 0, 0, 0) 100%);
    }
    
    .hud-stats {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }
    
    .stat {
        font-size: 0.85rem;
    }
    
    .stat-icon {
        font-size: 1rem;
    }
    
    .hud-controls {
        justify-content: center;
    }
    
    .hud-controls .btn {
        padding: 5px 10px;
        font-size: 0.75rem;
    }
    
    .btn-buy {
        bottom: 15px;
        left: 10px;
        padding: 8px 14px;
        font-size: 0.8rem;
    }
    
    .tower-panel {
        bottom: 60px;
        left: 10px;
        right: 10px;
        max-width: none;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .tower-option {
        min-width: 70px;
        padding: 6px 8px;
    }
    
    .tower-preview {
        width: 28px;
        height: 28px;
    }
    
    .tower-name {
        font-size: 0.65rem;
    }
    
    .tower-cost, .tower-stats {
        font-size: 0.55rem;
    }
    
    .tower-info-panel {
        right: 10px;
        bottom: 60px;
        width: 160px;
        padding: 10px;
    }
    
    .tower-info-panel h3 {
        font-size: 0.85rem;
    }
    
    .tower-details {
        font-size: 0.7rem;
    }
}

/* HUD Overlay */
.hud-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0) 100%);
    z-index: 10;
    pointer-events: none;
}

.hud-overlay > * {
    pointer-events: auto;
}

.hud-stats {
    display: flex;
    gap: 20px;
}

.stat {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 1.1rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.stat-icon {
    font-size: 1.3rem;
}

.stat-value {
    font-weight: bold;
    color: #f0f0f0;
}

.hud-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.countdown {
    font-size: 0.9rem;
    font-weight: bold;
    color: #f39c12;
    padding: 6px 12px;
    background: rgba(243, 156, 18, 0.2);
    border-radius: 6px;
    border: 2px solid #f39c12;
}

/* Buttons */
.btn {
  padding: 8px 18px;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
  white-space: nowrap;
}.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

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

.btn-start, .btn-next {
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
    color: white;
}

.btn-pause {
    background: linear-gradient(135deg, #f39c12 0%, #d68910 100%);
    color: white;
}

.btn-resume {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
}

.btn-restart {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
}

.btn-upgrade {
    background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
    color: white;
    width: 100%;
    margin-bottom: 8px;
}

.btn-sell {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    width: 100%;
}

/* Buy Button */
.btn-buy {
    position: absolute;
    bottom: 20px;
    left: 20px;
    padding: 12px 24px;
    font-size: 1rem;
    background: linear-gradient(135deg, #27ae60 0%, #1e8449 100%);
    color: white;
    border: 2px solid transparent;
    z-index: 20;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.btn-buy:hover {
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
}

.btn-buy.active {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    border-color: #fff;
}

/* Foldable Tower Panel */
.tower-panel {
    position: absolute;
    bottom: 80px;
    left: 20px;
    display: flex;
    flex-direction: row;
    gap: 10px;
    background: rgba(0, 0, 0, 0.85);
    border-radius: 12px;
    padding: 12px;
    z-index: 15;
    max-width: calc(100% - 40px);
    overflow-x: auto;
    transform: translateY(calc(100% + 100px));
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    pointer-events: none;
}

.tower-panel.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.tower-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    min-width: 100px;
}

.tower-option:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-3px);
}

.tower-option.selected {
    border-color: #2ecc71;
    background: rgba(46, 204, 113, 0.2);
}

.tower-option.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.tower-option.disabled:hover {
    transform: none;
    background: rgba(255, 255, 255, 0.05);
}

.tower-preview {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.tower-info {
    text-align: center;
}

.tower-name {
    font-weight: bold;
    font-size: 0.8rem;
    margin-bottom: 2px;
    white-space: nowrap;
}

.tower-cost {
    font-size: 0.75rem;
    color: #f1c40f;
}

.tower-stats {
    font-size: 0.65rem;
    color: #bdc3c7;
    display: flex;
    gap: 6px;
    justify-content: center;
}

/* Tower Info Panel (for selected tower) */
.tower-info-panel {
    position: absolute;
    right: 20px;
    bottom: 20px;
    width: 200px;
    background: rgba(0, 0, 0, 0.85);
    border-radius: 12px;
    padding: 15px;
    z-index: 15;
}

.tower-info-panel h3 {
    margin: 0 0 12px 0;
    font-size: 1rem;
    color: #ecf0f1;
    border-bottom: 2px solid #34495e;
    padding-bottom: 8px;
    padding-right: 25px;
}

.tower-details {
    font-size: 0.85rem;
    margin-bottom: 12px;
}

.tower-details p {
    margin: 6px 0;
    color: #bdc3c7;
}

.tower-details strong {
    color: #ecf0f1;
}

.tower-actions {
    margin-top: 12px;
}

.btn-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.btn-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Game Overlay */
.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.game-over {
    text-align: center;
    padding: 40px;
    background: rgba(231, 76, 60, 0.9);
    border-radius: 15px;
}

.game-over h2 {
    font-size: 2.5rem;
    margin: 0 0 20px 0;
}

.game-over p {
    font-size: 1.2rem;
    margin: 10px 0;
}

.instructions-overlay {
    background: rgba(0, 0, 0, 0.85);
}

.instructions-popup {
    text-align: center;
    padding: 40px 50px;
    background: linear-gradient(135deg, #2c3e50 0%, #1a252f 100%);
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    max-width: 400px;
}

.instructions-popup h2 {
    font-size: 2rem;
    margin: 0 0 25px 0;
    color: #ecf0f1;
}

.instructions-popup ul {
    text-align: left;
    margin: 0 0 25px 0;
    padding-left: 25px;
    font-size: 1rem;
    line-height: 2;
    color: #bdc3c7;
}

.instructions-popup li {
    margin-bottom: 5px;
}

/* Animations */
.tower {
    cursor: pointer;
}

.tower:hover {
    filter: brightness(1.2);
}

.enemy {
    transition: none;
}

.enemy-hp-text {
    opacity: 0;
    pointer-events: none;
    text-shadow: 0 0 3px #000, 0 0 3px #000;
}

.enemy:hover .enemy-hp-text {
    opacity: 1;
}

.projectile {
    filter: drop-shadow(0 0 3px currentColor);
}

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

/* Responsive adjustments for smaller screens */
@media (max-width: 800px) {
    .hud-stats {
        gap: 10px;
    }
    
    .stat {
        font-size: 0.9rem;
        gap: 4px;
    }
    
    .stat-icon {
        font-size: 1rem;
    }
    
    .btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
    
    .btn-buy {
        padding: 10px 18px;
        font-size: 0.85rem;
    }
    
    .tower-panel {
        padding: 8px;
        gap: 8px;
    }
    
    .tower-option {
        padding: 8px 10px;
        min-width: 80px;
    }
    
    .tower-preview {
        width: 32px;
        height: 32px;
    }
    
    .tower-name {
        font-size: 0.7rem;
    }
    
    .tower-cost {
        font-size: 0.65rem;
    }
    
    .tower-stats {
        font-size: 0.55rem;
    }
    
    .tower-info-panel {
        width: 170px;
        padding: 12px;
    }
    
    .tower-info-panel h3 {
        font-size: 0.9rem;
    }
    
    .tower-details {
        font-size: 0.75rem;
    }
}

@media (max-height: 500px) {
    .hud-overlay {
        padding: 5px 15px;
    }
    
    .hud-stats {
        gap: 8px;
    }
    
    .stat {
        font-size: 0.8rem;
    }
    
    .stat-icon {
        font-size: 0.9rem;
    }
    
    .btn {
        padding: 5px 10px;
        font-size: 0.75rem;
    }
    
    .btn-buy {
        bottom: 10px;
        left: 10px;
        padding: 8px 14px;
        font-size: 0.8rem;
    }
    
    .tower-panel {
        bottom: 50px;
        left: 10px;
        padding: 6px;
        gap: 6px;
    }
    
    .tower-option {
        padding: 6px 8px;
        min-width: 70px;
    }
    
    .tower-preview {
        width: 28px;
        height: 28px;
    }
    
    .tower-name {
        font-size: 0.6rem;
    }
    
    .tower-cost, .tower-stats {
        font-size: 0.5rem;
    }
    
    .tower-info-panel {
        right: 10px;
        bottom: 10px;
        width: 150px;
        padding: 10px;
    }
    
    .tower-info-panel h3 {
        font-size: 0.8rem;
        padding-bottom: 6px;
        margin-bottom: 8px;
    }
    
    .tower-details {
        font-size: 0.7rem;
        margin-bottom: 8px;
    }
    
    .tower-details p {
        margin: 4px 0;
    }
    
    .btn-upgrade, .btn-sell {
        padding: 5px 8px;
        font-size: 0.65rem;
        margin-bottom: 5px;
    }
}

/* Touch-friendly enhancements */
@media (hover: none) and (pointer: coarse) {
    .tower-option {
        min-height: 60px;
    }
    
    .btn {
        min-height: 40px;
        min-width: 44px;
    }
    
    .btn-buy {
        min-height: 48px;
    }
    
    .tower-option:hover {
        transform: none;
    }
    
    .tower:hover {
        filter: none;
    }
    
    .tower-option:active {
        transform: scale(0.95);
        background: rgba(255, 255, 255, 0.15);
    }
    
    .btn:active {
        transform: scale(0.95);
    }
}

/* Safe area insets for notched devices */
@supports (padding: max(0px)) {
    .hud-overlay {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
        padding-top: max(10px, env(safe-area-inset-top));
    }
    
    .btn-buy {
        left: max(20px, env(safe-area-inset-left));
        bottom: max(20px, env(safe-area-inset-bottom));
    }
    
    .tower-panel {
        left: max(20px, env(safe-area-inset-left));
        bottom: max(80px, calc(60px + env(safe-area-inset-bottom)));
    }
    
    .tower-info-panel {
        right: max(20px, env(safe-area-inset-right));
        bottom: max(20px, env(safe-area-inset-bottom));
    }
}
