/* Base CSS - Core Desktop Styles */

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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #8B4513, #A0522D);
    color: #333;
    overflow: hidden;
}

#game-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background: rgba(139, 69, 19, 0.9);
    color: white;
    padding: 10px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 2px solid #654321;
}

header h1 {
    font-size: 24px;
    margin: 0.5em 1em;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

#game-stats {
    display: flex;
    gap: 20px;
    font-weight: bold;
}

#game-stats span {
    background: rgba(0,0,0,0.3);
    padding: 5px 10px;
    border-radius: 5px;
}

.header-btn {
    background: rgba(0,0,0,0.3);
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 5px;
    color: white;
    padding: 5px 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: bold;
}

.header-btn:hover {
    background: rgba(0,0,0,0.5);
    border-color: rgba(255,255,255,0.4);
    transform: translateY(-1px);
}

#countdown {
    background: rgba(255, 215, 0, 0.8) !important;
    color: #654321 !important;
    font-weight: bold;
}

#game-area {
    flex: 1;
    display: flex;
    padding: 20px;
    justify-content: center;
}

#game-content {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

#canvas-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: fit-content;
    margin: 0 auto;
    gap: 15px;
    position: relative;
}

#game-canvas {
    width: 650px;
    height: 540px;
    border: 3px solid #654321;
    border-radius: 10px;
    background: #DEB887;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    cursor: crosshair;
    flex-shrink: 0;
}

#canvas-controls {
    display: flex;
    width: 650px;
    gap: 15px;
    justify-content: space-between;
    align-items: center;
}

.canvas-btn {
    flex: 1;
    padding: 12px 20px;
    background: #F5DEB3;
    border: 2px solid #D2B48C;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    font-weight: bold;
    font-size: 14px;
    min-height: 44px;
}

.canvas-btn:hover {
    background: #FFE4B5;
    border-color: #CD853F;
    transform: translateY(-1px);
}

.canvas-btn:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
}

#game-controls {
    width: 250px;
    background: rgba(222, 184, 135, 0.9);
    border: 2px solid #8B4513;
    border-radius: 10px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

#tower-selection h3 {
    margin-bottom: 10px;
    color: #654321;
    text-align: center;
}

.tower-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tower-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #F5DEB3;
    border: 2px solid #D2B48C;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 12px;
}

.tower-btn:hover {
    background: #FFE4B5;
    border-color: #CD853F;
    transform: translateY(-1px);
}

.tower-btn.selected {
    background: #90EE90;
    border-color: #32CD32;
}

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

.hotkey {
    background: #8B4513;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: bold;
    font-size: 10px;
}

.tower-name {
    font-weight: bold;
    flex: 1;
    text-align: center;
}

.tower-cost {
    color: #B8860B;
    font-weight: bold;
}

#tower-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#tower-actions.hidden-buttons {
    display: none;
}

#tower-actions button {
    padding: 10px;
    background: #F5DEB3;
    border: 2px solid #D2B48C;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

#tower-actions button:hover:not(:disabled) {
    background: #FFE4B5;
    transform: translateY(-1px);
}

#tower-actions button:disabled {
    opacity: 0.75;
    background: #E5E5E5;
    color: #666;
    border-color: #CCC;
    cursor: not-allowed;
}

#tower-info h4 {
    margin-bottom: 5px;
    color: #654321;
    text-align: center;
}

#selected-tower-info {
    margin-bottom: 1em;
    font-size: 12px;
    line-height: 1.4;
}

#selected-tower-info p {
    margin-top: 1em;
    font-weight: bold;
    font-size: 12px;
    line-height: 1.4;
}

/* Tower Info Panel Styling */
.upgrade-cost {
    color: #B8860B;
    font-weight: bold;
}

/* Upgrading Status Styling */
.upgrading-status {
    background: rgba(255, 140, 0, 0.1);
    border: 2px solid #FF8C00;
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
    box-shadow: 0 2px 6px rgba(255, 140, 0, 0.2);
}

.upgrading-status p {
    margin: 6px 0;
    font-size: 12px;
    line-height: 1.4;
}

.upgrading-status p:first-child {
    margin-top: 0;
}

.upgrading-status p:last-child {
    margin-bottom: 0;
}

/* Selling Status Styling */
.selling-status {
    background: rgba(255, 51, 51, 0.1);
    border: 2px solid #FF3333;
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
    box-shadow: 0 2px 6px rgba(255, 51, 51, 0.2);
}

.selling-status p {
    margin: 6px 0;
    font-size: 12px;
    line-height: 1.4;
}

.selling-status p:first-child {
    margin-top: 0;
}

.selling-status p:last-child {
    margin-bottom: 0;
}

/* Progress Bar Styling */
.progress-container {
    width: 100%;
    height: 12px;
    background: rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(255, 140, 0, 0.4);
    border-radius: 6px;
    overflow: hidden;
    margin: 8px 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #FF8C00, #FFA500);
    border-radius: 5px;
    transition: width 0.3s ease;
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

.progress-fill.sell-progress {
    background: linear-gradient(90deg, #FF3333, #FF6666);
}

.selling-status .progress-container {
    border-color: rgba(255, 51, 51, 0.4);
}

/* Tower Info Table Styling */
.tower-info-table {
    width: 100%;
    margin: 0;
    padding: 0;
}

.tower-info-table table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.tower-info-table thead {
    background: rgba(139, 69, 19, 0.8);
    color: white;
}

.tower-info-table th,
.tower-info-table td {
    padding: 6px 10px;
    border-bottom: 1px solid rgba(139, 69, 19, 0.2);
    font-size: 12px;
    line-height: 1.4;
}

.tower-info-table th {
    font-weight: bold;
    text-align: center;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tower-info-table td:first-child {
    text-align: left;
    font-weight: bold;
    color: #654321;
    background: rgba(222, 184, 135, 0.3);
}

.tower-info-table td:nth-child(2) {
    text-align: center;
    color: #333;
}

.tower-info-table td:nth-child(3) {
    text-align: center;
    color: #228B22;
    font-weight: bold;
}

.tower-info-table tbody tr:hover {
    background: rgba(139, 69, 19, 0.1);
}

.tower-info-table tbody tr:last-child td {
    border-bottom: none;
}

.hidden {
    display: none !important;
}

#game-menu, #game-over {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(222, 184, 135, 0.95);
    border: 3px solid #8B4513;
    border-radius: 15px;
    padding: 30px;
    text-align: center;
    box-shadow: 0 8px 16px rgba(0,0,0,0.5);
    z-index: 1000;
}

#game-menu h2, #game-over h2 {
    color: #654321;
    margin-bottom: 20px;
}

#game-menu button, #game-over button {
    padding: 10px 20px;
    margin: 5px;
    background: #F5DEB3;
    border: 2px solid #D2B48C;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
}

#game-menu button:hover, #game-over button:hover {
    background: #FFE4B5;
    transform: translateY(-1px);
}

#difficulty-selection {
    margin-top: 20px;
}

#difficulty-selection h3 {
    margin-bottom: 10px;
    color: #654321;
}

#difficulty-selection label {
    margin-left: 5px;
    margin-right: 15px;
    cursor: pointer;
}

.menu-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 2px solid rgba(139, 69, 19, 0.3);
}

.menu-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.menu-section h3 {
    color: #654321;
    margin-bottom: 15px;
    font-size: 18px;
    text-align: center;
}

.menu-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

.menu-buttons button {
    padding: 8px 12px;
    background: #F5DEB3;
    border: 2px solid #D2B48C;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.menu-buttons button:hover {
    background: #FFE4B5;
    transform: translateY(-1px);
}

#game-info-display {
    background: rgba(255, 255, 255, 0.2);
    padding: 15px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.6;
}

#game-info-display p {
    margin: 5px 0;
    display: flex;
    justify-content: space-between;
}

#game-info-display span {
    font-weight: bold;
    color: #8B4513;
}

.placeholder-text {
    text-align: center;
    font-style: italic;
    color: #A0522D;
    margin: 10px 0;
}

/* Information Overlay Styles */
#info-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(222, 184, 135, 0.95);
    border: 3px solid #8B4513;
    border-radius: 15px;
    padding: 30px;
    text-align: left;
    box-shadow: 0 8px 16px rgba(0,0,0,0.5);
    z-index: 1000;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
}

.back-button {
    position: absolute;
    top: 15px;
    left: 20px;
    padding: 8px 15px;
    background: #F5DEB3;
    border: 2px solid #D2B48C;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    color: #654321;
}

.back-button:hover {
    background: #FFE4B5;
    transform: translateY(-1px);
}

#info-overlay h2 {
    color: #654321;
    margin-bottom: 20px;
    text-align: center;
    margin-top: 10px;
}

.info-section {
    animation: fadeIn 0.3s ease-in;
}

.info-section h3 {
    color: #654321;
    border-bottom: 2px solid #8B4513;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.info-text {
    line-height: 1.6;
    color: #333;
}

.info-text h4 {
    color: #8B4513;
    margin: 15px 0 8px 0;
}

.info-text p {
    margin: 8px 0;
}

.info-text ul {
    margin: 10px 0 10px 20px;
}

.info-text li {
    margin: 5px 0;
}

/* Keyboard Shortcuts Styling */
.shortcuts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 15px;
}

.shortcut-category h4 {
    color: #654321;
    margin-bottom: 15px;
    border-bottom: 1px solid #D2B48C;
    padding-bottom: 5px;
}

.shortcut-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 8px 0;
    padding: 5px 0;
}

.shortcut-item kbd {
    background: #8B4513;
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 12px;
    min-width: 40px;
    text-align: center;
}

/* Tower Guide Styling */
.tower-item {
    background: rgba(255, 255, 255, 0.2);
    padding: 15px;
    margin: 15px 0;
    border-radius: 8px;
    border-left: 4px solid #8B4513;
}

.tower-item h4 {
    color: #654321;
    margin-bottom: 8px;
}

.tower-item p {
    margin: 5px 0;
    font-size: 14px;
}

/* Enemy Guide Styling */
.enemy-item {
    background: rgba(255, 255, 255, 0.2);
    padding: 12px;
    margin: 10px 0;
    border-radius: 8px;
    border-left: 4px solid #A0522D;
}

.enemy-item h4 {
    color: #654321;
    margin-bottom: 5px;
}

.enemy-item p {
    margin: 0;
    font-size: 14px;
}

/* Dynamic CSS Variables - Updated via JavaScript based on grid size */
:root {
    --projectile-size: 4px;
    --explosion-size: 20px;
    --explosion-scale: 3;
}

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