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

body {
    font-family: 'Courier New', monospace;
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    color: #eee;
    overflow: hidden;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

#game-container {
    max-width: 420px;
    margin: 0 auto;
    padding: 10px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

#status-bar {
    display: flex;
    justify-content: space-around;
    padding: 10px 5px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    margin-bottom: 10px;
}

.stat {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 1rem;
    font-weight: bold;
}

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

.stat .max-value {
    color: #888;
    font-size: 0.85rem;
}

.stat.at-capacity {
    color: #ff9800;
}

.stat.full {
    color: #ff6b6b;
}

.injured-count {
    color: #ff6b6b;
    font-size: 0.85rem;
}

.injured-count:empty {
    display: none;
}

#day-counter {
    text-align: center;
    font-size: 1.3rem;
    font-weight: bold;
    color: #f0c040;
    margin-bottom: 8px;
    text-shadow: 0 0 10px rgba(240, 192, 64, 0.5);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.consumption-info {
    font-size: 0.8rem;
    color: #aaa;
    font-weight: normal;
}

#board-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    margin: 0 auto;
    max-width: 400px;
}

#game-board, #line-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 8px;
}

#game-board {
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid #333;
}

#line-canvas {
    pointer-events: none;
}

/* Ability Bar */
#ability-bar {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 8px;
    margin-top: 8px;
}

.ability-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: linear-gradient(180deg, #37474f 0%, #263238 100%);
    border: 2px solid #455a64;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    padding: 4px;
}

.ability-btn:hover:not(:disabled) {
    background: linear-gradient(180deg, #455a64 0%, #37474f 100%);
    border-color: #607d8b;
}

.ability-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.ability-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ability-btn.selected {
    border-color: #ffd54f;
    box-shadow: 0 0 10px rgba(255, 213, 79, 0.5);
    background: linear-gradient(180deg, #455a64 0%, #37474f 100%);
}

.ability-btn.active-buff {
    border-color: #4caf50;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

.ability-emoji {
    font-size: 1.5rem;
    line-height: 1;
}

.ability-cost {
    font-size: 0.7rem;
    color: #ffd54f;
    margin-top: 2px;
}

#message-area {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    padding: 10px;
    margin: 10px 0;
    min-height: 50px;
}

#game-message {
    font-size: 0.9rem;
    line-height: 1.4;
    color: #ccc;
    text-align: center;
}

#game-message.warning {
    color: #ff9800;
}

#turn-info {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 10px;
    flex-wrap: wrap;
}

#upgrade-btn {
    padding: 12px 20px;
    font-size: 1rem;
    font-family: inherit;
    font-weight: bold;
    background: linear-gradient(180deg, #5c6bc0 0%, #3949ab 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

#upgrade-btn:hover {
    background: linear-gradient(180deg, #7986cb 0%, #5c6bc0 100%);
}

#upgrade-btn:active {
    transform: scale(0.95);
}

#end-turn-btn {
    padding: 12px 30px;
    font-size: 1.1rem;
    font-family: inherit;
    font-weight: bold;
    background: linear-gradient(180deg, #4a7c4e 0%, #2d5a30 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

#end-turn-btn:hover {
    background: linear-gradient(180deg, #5a9c5e 0%, #3d7a40 100%);
}

#end-turn-btn:active {
    transform: scale(0.95);
}

#threats-warning {
    color: #ff6b6b;
    font-weight: bold;
    font-size: 0.85rem;
    width: 100%;
    text-align: center;
}

/* Upgrade Panel */
#upgrade-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
}

#upgrade-panel.hidden {
    display: none;
}

.upgrade-panel-content {
    background: #1a1a2e;
    border: 2px solid #444;
    border-radius: 12px;
    padding: 20px;
    max-width: 380px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.upgrade-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #333;
}

.upgrade-header h3 {
    color: #f0c040;
    font-size: 1.3rem;
}

#close-upgrade-btn {
    background: none;
    border: none;
    color: #888;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px 10px;
}

#close-upgrade-btn:hover {
    color: #fff;
}

.upgrade-scrap {
    text-align: center;
    font-size: 1.1rem;
    color: #78909c;
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
}

.upgrade-scrap .icon {
    font-size: 1.3rem;
}

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

.upgrade-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #333;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.upgrade-item.maxed {
    opacity: 0.6;
    border-color: #4caf50;
}

.upgrade-info {
    flex: 1;
}

.upgrade-name {
    font-weight: bold;
    color: #fff;
    margin-bottom: 4px;
}

.upgrade-desc {
    font-size: 0.85rem;
    color: #aaa;
}

.upgrade-level {
    font-size: 0.8rem;
    color: #f0c040;
    margin-top: 4px;
}

.upgrade-buy-btn {
    padding: 8px 16px;
    font-size: 0.9rem;
    font-family: inherit;
    font-weight: bold;
    background: linear-gradient(180deg, #4a7c4e 0%, #2d5a30 100%);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
}

.upgrade-buy-btn:hover:not(:disabled) {
    background: linear-gradient(180deg, #5a9c5e 0%, #3d7a40 100%);
}

.upgrade-buy-btn:disabled {
    background: #444;
    color: #888;
    cursor: not-allowed;
}

.upgrade-buy-btn.maxed {
    background: #2d5a30;
    color: #4caf50;
}

/* Game Over Screen */
#game-over-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
    z-index: 100;
}

#game-over-screen.hidden {
    display: none;
}

#game-over-screen h2 {
    font-size: 2.5rem;
    color: #ff4444;
    text-shadow: 0 0 20px rgba(255, 68, 68, 0.7);
}

#game-over-screen p {
    font-size: 1.2rem;
    color: #ccc;
}

#restart-btn {
    padding: 15px 40px;
    font-size: 1.2rem;
    font-family: inherit;
    font-weight: bold;
    background: linear-gradient(180deg, #c04040 0%, #802020 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 20px;
}

#restart-btn:hover {
    background: linear-gradient(180deg, #d05050 0%, #903030 100%);
}

/* Tile colors for reference in JS */
.tile-rations { color: #7cb342; }
.tile-scrap { color: #78909c; }
.tile-power { color: #ffd54f; }
.tile-threat { color: #e53935; }

/* Animation classes */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.3s ease-in-out;
}

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

.pulse {
    animation: pulse 1s infinite;
}

/* Touch feedback */
@media (hover: none) {
    #end-turn-btn:active {
        background: linear-gradient(180deg, #5a9c5e 0%, #3d7a40 100%);
    }

    #upgrade-btn:active {
        background: linear-gradient(180deg, #7986cb 0%, #5c6bc0 100%);
    }
}

/* Pre-Run Screen (Prototype 4) */
#pre-run-screen {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

#pre-run-screen.hidden {
    display: none;
}

.pre-run-content {
    max-width: 400px;
    width: 100%;
    text-align: center;
}

.pre-run-content h1 {
    font-size: 2.5rem;
    color: #f0c040;
    text-shadow: 0 0 20px rgba(240, 192, 64, 0.5);
    margin-bottom: 5px;
}

.tagline {
    color: #888;
    font-size: 1rem;
    margin-bottom: 25px;
}

.meta-stats {
    display: flex;
    justify-content: space-around;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.meta-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.meta-label {
    font-size: 0.75rem;
    color: #888;
    text-transform: uppercase;
}

.meta-value {
    font-size: 1.3rem;
    font-weight: bold;
    color: #f0c040;
}

.survivor-selection {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.survivor-selection h3 {
    color: #fff;
    font-size: 1rem;
    margin-bottom: 15px;
}

#survivor-roster {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.survivor-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid #333;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.survivor-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.survivor-item.selected {
    border-color: #4caf50;
    background: rgba(76, 175, 80, 0.1);
}

.survivor-item.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.survivor-item.locked:hover {
    background: rgba(255, 255, 255, 0.05);
}

.survivor-emoji {
    font-size: 1.5rem;
    width: 40px;
    text-align: center;
}

.survivor-info {
    flex: 1;
    text-align: left;
}

.survivor-name {
    font-weight: bold;
    color: #fff;
    font-size: 0.95rem;
}

.survivor-desc {
    font-size: 0.8rem;
    color: #aaa;
}

.survivor-cost {
    font-size: 0.85rem;
    color: #f0c040;
    white-space: nowrap;
}

.survivor-cost.free {
    color: #4caf50;
}

#start-run-btn {
    width: 100%;
    padding: 15px;
    font-size: 1.3rem;
    font-family: inherit;
    font-weight: bold;
    background: linear-gradient(180deg, #4a7c4e 0%, #2d5a30 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 15px;
}

#start-run-btn:hover {
    background: linear-gradient(180deg, #5a9c5e 0%, #3d7a40 100%);
}

.menu-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}

.small-btn {
    background: none;
    border: 1px solid #555;
    color: #888;
    padding: 8px 15px;
    font-size: 0.8rem;
    font-family: inherit;
    border-radius: 6px;
    cursor: pointer;
}

.small-btn:hover {
    border-color: #888;
    color: #ccc;
}

/* Active Survivors Display */
#active-survivors {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
}

.active-survivor-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: rgba(76, 175, 80, 0.2);
    border: 1px solid #4caf50;
    border-radius: 20px;
    font-size: 0.8rem;
}

.active-survivor-badge .emoji {
    font-size: 1rem;
}

/* Run Rewards */
#run-reward-section {
    display: flex;
    gap: 15px;
    margin: 15px 0;
}

#run-reward-section.hidden {
    display: none;
}

.reward-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 20px;
    background: rgba(240, 192, 64, 0.1);
    border: 1px solid #f0c040;
    border-radius: 8px;
}

.reward-label {
    font-size: 0.75rem;
    color: #aaa;
    text-transform: uppercase;
}

.reward-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #f0c040;
}

.secondary-btn {
    padding: 10px 25px;
    font-size: 1rem;
    font-family: inherit;
    background: transparent;
    color: #aaa;
    border: 1px solid #555;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 10px;
}

.secondary-btn:hover {
    border-color: #888;
    color: #fff;
}

/* Help Button */
#help-btn {
    padding: 10px 14px;
    font-size: 1.1rem;
    background: linear-gradient(180deg, #5c6bc0 0%, #3949ab 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

#help-btn:hover {
    background: linear-gradient(180deg, #7986cb 0%, #5c6bc0 100%);
}

/* Help Panel */
#help-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    z-index: 200;
    overflow-y: auto;
}

#help-panel.hidden {
    display: none;
}

.help-panel-content {
    background: #1a1a2e;
    border: 2px solid #444;
    border-radius: 12px;
    max-width: 400px;
    width: 100%;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.help-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #333;
    position: sticky;
    top: 0;
    background: #1a1a2e;
}

.help-header h3 {
    color: #f0c040;
    font-size: 1.3rem;
    margin: 0;
}

#close-help-btn {
    background: none;
    border: none;
    color: #888;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px 10px;
}

#close-help-btn:hover {
    color: #fff;
}

.help-body {
    padding: 15px 20px;
}

.help-section {
    margin-bottom: 20px;
}

.help-section:last-child {
    margin-bottom: 0;
}

.help-section h4 {
    color: #fff;
    font-size: 1rem;
    margin-bottom: 8px;
    border-bottom: 1px solid #333;
    padding-bottom: 5px;
}

.help-section p {
    color: #ccc;
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0;
}

.help-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.help-section li {
    color: #ccc;
    font-size: 0.85rem;
    padding: 5px 0;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.tile-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.help-section strong {
    color: #fff;
}
