.nav-btn {
    position: absolute;
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.nav-btn:active {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(0.95);
}

.nav-btn.north {
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
}
.nav-btn.north:active { transform: translateX(-50%) scale(0.95); }

.nav-btn.south {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
}
.nav-btn.south:active { transform: translateX(-50%) scale(0.95); }

.nav-btn.west {
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
}
.nav-btn.west:active { transform: translateY(-50%) scale(0.95); }

.nav-btn.east {
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
}
.nav-btn.east:active { transform: translateY(-50%) scale(0.95); }

/* Character selection menu - Redesigned */
.char-select-screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 20px;
    padding-bottom: 20px;
    pointer-events: auto;
    background: radial-gradient(circle at center, rgba(15, 5, 25, 0.95), rgba(0,0,0,1));
    color: white;
    z-index: 10;
    overflow-y: auto;
}

.selected-char-name {
    font-size: 28px;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 3px;
    text-shadow: 0 0 15px rgba(156, 39, 176, 0.6);
    color: #e1bee7;
}

.carousel-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    width: 100%;
    justify-content: center;
    flex-shrink: 0;
}

.sprite-display-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: -20px; /* Slight overlap */
    position: relative;
}

.char-preview-sprite {
    width: 80px;
    height: 80px;
    background-repeat: no-repeat;
    transition: all 0.3s ease;
}

.char-preview-sprite.curr {
    width: 120px;
    height: 120px;
    z-index: 2;
    filter: drop-shadow(0 0 15px rgba(156, 39, 176, 0.4));
}

.char-preview-sprite.prev, .char-preview-sprite.next {
    width: 60px;
    height: 60px;
    opacity: 0.3;
    filter: grayscale(1.0);
    z-index: 1;
}

.carousel-nav-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.carousel-nav-btn:active {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0.9);
}

.char-info-panel {
    display: flex;
    width: 95%;
    max-width: 400px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 15px;
    gap: 15px;
    margin-bottom: 20px;
}

.info-label {
    font-size: 10px;
    text-transform: uppercase;
    font-weight: bold;
    color: #aaa;
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.char-stats-area {
    flex: 0 0 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.char-abilities-area {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.menu-abilities-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.menu-ability-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 8px;
    border-radius: 4px;
    border-left: 3px solid #555;
}

.menu-ability-item.physical { border-left-color: #cd5c5c; }
.menu-ability-item.elemental { border-left-color: #4682b4; }
.menu-ability-item.psychic { border-left-color: #9370db; }

.menu-ability-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}

.m-ability-name {
    font-size: 12px;
    font-weight: bold;
    color: #fff;
}

.m-ability-domain {
    font-size: 8px;
    text-transform: uppercase;
    opacity: 0.6;
}

.m-ability-desc {
    font-size: 10px;
    color: #ccc;
    line-height: 1.2;
}

.confirm-game-btn {
    padding: 12px 40px;
    font-size: 20px;
    background: #4a148c;
    border: 2px solid #7b1fa2;
    color: white;
    text-transform: uppercase;
    letter-spacing: 2px;
    cursor: pointer;
    border-radius: 6px;
    box-shadow: 0 4px 0 #310d5e;
    transition: transform 0.1s, box-shadow 0.1s;
    flex-shrink: 0;
}

.confirm-game-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #310d5e;
}

/* Battle Menu */
.battle-menu {
    position: absolute;
    bottom: 10px;
    left: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding: 0 10px;
    pointer-events: auto;
}

.ability-list {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    width: 100%;
}

.ability-detail-panel {
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid #7b1fa2;
    padding: 12px;
    margin-bottom: 12px;
    border-radius: 8px;
    width: 90%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: 0 -4px 15px rgba(0,0,0,0.5);
    animation: slideUp 0.2s ease-out;
    pointer-events: auto;
}

@keyframes slideUp {
    from { transform: translateY(10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.detail-header {
    display: flex;
    flex-direction: column;
    margin-bottom: 6px;
}

.detail-name {
    font-weight: bold;
    font-size: 18px;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.detail-domain {
    font-size: 10px;
    text-transform: uppercase;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 2px;
    align-self: center;
}

.detail-domain.physical { background: #501010; color: #ff9999; }
.detail-domain.elemental { background: #0b2e47; color: #99ccff; }
.detail-domain.psychic { background: #321857; color: #d1b3ff; }

.detail-desc {
    font-size: 13px;
    color: #eee;
    margin-bottom: 8px;
    font-style: italic;
}

.detail-stats {
    font-size: 11px;
    color: #aaa;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.detail-prediction {
    color: #ff8888;
    background: rgba(255, 0, 0, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid rgba(255, 0, 0, 0.2);
}

.detail-prediction strong {
    font-size: 14px;
    color: #fff;
}

.detail-status-effects {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
}

.status-effect-tag {
    font-size: 10px;
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    border: 1px solid currentColor;
    opacity: 0.9;
}

.ability-locked {
    font-size: 9px;
    color: #ff4444;
    font-weight: bold;
}

.confirm-ability-btn {
    background: #2e7d32;
    border: 2px solid #4caf50;
    color: white;
    padding: 8px 24px;
    font-weight: bold;
    border-radius: 4px;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: 0 3px 0 #1b5e20;
    transition: transform 0.1s, box-shadow 0.1s;
}

.confirm-ability-btn:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #1b5e20;
}

.ability-btn {
    background: #222;
    border: 2px solid #555;
    color: #fff;
    padding: 8px 12px;
    min-width: 80px;
    border-radius: 6px;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 0 #111;
    transition: transform 0.1s, box-shadow 0.1s;
}

.ability-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #111;
}

.ability-btn.physical { border-color: #cd5c5c; background: #501010; }
.ability-btn.elemental { border-color: #4682b4; background: #0b2e47; }
.ability-btn.psychic { border-color: #9370db; background: #321857; }

.ability-btn.selected {
    border-color: #fff;
    box-shadow: 0 0 10px rgba(255,255,255,0.5);
    transform: translateY(-2px);
}

.ability-name {
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 2px;
    text-transform: uppercase;
}
.ability-type {
    font-size: 10px;
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ability-cost {
    font-size: 9px;
    color: #88aaff;
    font-weight: bold;
}

.ability-cost-high {
    font-size: 9px;
    color: #ff8888;
    font-weight: bold;
}

.ability-cooldown {
    font-size: 9px;
    color: #ffaa44;
    font-weight: bold;
}

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

.ability-btn.disabled:active {
    transform: none;
    box-shadow: 0 4px 0 #111;
}

/* Resource Panel */
.resource-panel {
    display: flex;
    gap: 16px;
    margin-bottom: 8px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    width: 90%;
    max-width: 320px;
}

.resource-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.resource-label {
    font-size: 10px;
    text-transform: uppercase;
    font-weight: bold;
    color: #aaa;
    letter-spacing: 0.5px;
}

.resource-bar-container {
    position: relative;
    width: 100%;
    height: 16px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    overflow: hidden;
}

.resource-bar {
    height: 100%;
    transition: width 0.3s ease;
}

.entropy-bar {
    background: linear-gradient(90deg, #4a148c, #7b1fa2, #9c27b0);
    box-shadow: 0 0 8px rgba(156, 39, 176, 0.5);
}

.resource-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px;
    font-weight: bold;
    color: white;
    text-shadow: 0 0 3px black;
}

.momentum-grid {
    display: flex;
    gap: 8px;
    justify-content: space-around;
}

.momentum-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.momentum-stacks {
    font-size: 11px;
    font-weight: bold;
    min-width: 12px;
    text-align: center;
}

.momentum-item.physical .momentum-stacks { color: #ff9999; }
.momentum-item.elemental .momentum-stacks { color: #99ccff; }
.momentum-item.psychic .momentum-stacks { color: #d1b3ff; }

/* Basic Actions */
.basic-actions-list {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.basic-action-btn {
    background: rgba(40, 40, 60, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    cursor: pointer;
    text-transform: uppercase;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.basic-action-btn.selected {
    border-color: #fff;
    background: rgba(80, 80, 120, 1);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.4);
}

.basic-action-icon {
    font-size: 14px;
}

/* Power Domain Icons */
.icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    background-image: url('../powerdomainicons.png');
    background-size: 48px 32px; /* 3 icons @ 150px scaled to 16px each = 48px wide, 2 rows = 32px high */
    image-rendering: pixelated;
}

.icon.power { background-position: 0 0; }
.icon.finesse { background-position: -16px 0; }
.icon.resistance { background-position: -32px 0; }
.icon.physical { background-position: 0 -16px; }
.icon.elemental { background-position: -16px -16px; }
.icon.psychic { background-position: -32px -16px; }

.detail-domain {
    display: flex !important;
    align-items: center;
    gap: 6px;
}

.detail-stats {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Game Over Menu */
.game-over-menu {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    background: radial-gradient(circle at center, rgba(60, 0, 0, 0.95), rgba(0, 0, 0, 1));
    color: white;
    z-index: 30;
    padding: 20px;
    text-align: center;
}

.game-over-title {
    font-size: 42px;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 4px;
    color: #ff5252;
    text-shadow: 0 0 20px rgba(255, 82, 82, 0.6);
}

.game-over-stats {
    margin-bottom: 40px;
    font-size: 18px;
    line-height: 1.6;
    color: #ccc;
}

.game-over-stats strong {
    color: #fff;
    font-size: 24px;
}

.retry-btn {
    padding: 14px 30px;
    font-size: 18px;
    background: #333;
    border: 2px solid #555;
    color: white;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.retry-btn:active {
    transform: scale(0.95);
    background: #444;
}

/* Upgrade Menu */
.upgrade-menu {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    background: radial-gradient(circle at center, rgba(20,0,40,0.95), rgba(0,0,0,1));
    color: white;
    z-index: 20;
    padding: 20px;
}

.upgrade-title {
    font-size: 28px;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(156,39,176,0.8);
    color: #e1bee7;
}

.upgrade-subtitle {
    font-size: 14px;
    margin-bottom: 20px;
    color: #aaa;
}

.upgrades-container {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
    max-width: 100%;
}

.upgrade-card {
    background: rgba(30, 30, 50, 0.9);
    border: 3px solid #555;
    border-radius: 12px;
    padding: 20px;
    width: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

.upgrade-card:hover {
    transform: translateY(-8px) scale(1.05);
    box-shadow: 0 8px 25px rgba(0,0,0,0.8);
}

.upgrade-card.common {
    border-color: #9e9e9e;
}

.upgrade-card.uncommon {
    border-color: #4caf50;
    background: rgba(30, 50, 30, 0.9);
}

.upgrade-card.rare {
    border-color: #9c27b0;
    background: rgba(50, 30, 60, 0.9);
    box-shadow: 0 4px 15px rgba(156,39,176,0.3);
}

.upgrade-card.rare:hover {
    box-shadow: 0 8px 30px rgba(156,39,176,0.6);
}

.upgrade-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.upgrade-name {
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.upgrade-desc {
    font-size: 12px;
    text-align: center;
    color: #ccc;
    line-height: 1.4;
}