/* UI Elements */

/* Top UI Bar */
#ui {
    position: fixed;
    top: 20px;
    width: 100%;
    display: flex;
    justify-content: space-around;
    color: #fff;
    font-size: 18px;
    text-shadow: 2px 2px 4px #000;
    pointer-events: none;
    z-index: 100;
}

/* Health Bar */
#hp-bar-container {
    width: 150px;
    height: 18px;
    background: #333;
    border-radius: 10px;
    border: 2px solid #fff;
    overflow: hidden;
}
#hp-bar-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(to right, #ffd700, #ff4b2b);
    transition: width 0.3s;
}
.hp-low { animation: pulse 0.5s infinite; }
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Stamina Bar */
#stamina-container {
    width: 100px;
    height: 10px;
    background: #333;
    border-radius: 5px;
    border: 1px solid #fff;
    overflow: hidden;
    margin-top: 5px;
}
#stamina-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(to right, #00bfff, #1e90ff);
    transition: width 0.1s;
}

/* Score Display */
#points {
    font-size: 12px;
    color: #ffd700;
}

/* Stats Display */
#stats-display {
    position: fixed;
    top: 20px;
    left: 20px;
    color: #ffd700;
    font-size: 11px;
    z-index: 100;
    text-shadow: 1px 1px 2px #000;
}
#combo-counter {
    color: #ff8c00;
    display: none;
}

/* Power-up Indicators */
#powerup-display {
    position: fixed;
    top: 70px;
    left: 20px;
    z-index: 100;
    display: flex;
    gap: 8px;
    flex-direction: column;
}
.powerup-indicator {
    padding: 6px 10px;
    background: rgba(0,0,0,0.7);
    border-radius: 15px;
    color: #fff;
    font-size: 11px;
    display: none;
    border: 1px solid currentColor;
}
.powerup-indicator.active {
    display: flex;
    align-items: center;
    gap: 6px;
}
#speed-indicator { color: #00bfff; }
#shield-indicator { color: #ffd700; }
#invisible-indicator { color: #9b59b6; }
#magnet-indicator { color: #e74c3c; }
#double-indicator { color: #f39c12; }

/* Minimap */
#map-ui {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 200px;
    height: 150px;
    background: #d2b48c;
    border: 5px solid #5d4037;
    z-index: 1000;
    cursor: pointer;
    overflow: hidden;
    box-shadow: 5px 5px 15px rgba(0,0,0,0.5);
}
#miniMapCanvas {
    width: 100%;
    height: 100%;
    display: block;
}
.map-locked { filter: blur(8px) grayscale(1); }
.map-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    text-align: center;
    color: #fff;
    font-weight: bold;
    text-shadow: 2px 2px 4px #000;
    pointer-events: none;
    font-size: 12px;
}

/* Buttons */
#leaderboard-btn, #help-btn {
    position: fixed;
    top: 20px;
    background: rgba(0,0,0,0.7);
    border: 2px solid #ffd700;
    color: #ffd700;
    padding: 6px 12px;
    border-radius: 5px;
    cursor: pointer;
    z-index: 100;
    font-size: 11px;
    transition: all 0.2s;
}
#leaderboard-btn { right: 240px; }
#help-btn { right: 290px; }
#leaderboard-btn:hover, #help-btn:hover {
    background: rgba(255, 215, 0, 0.2);
    transform: scale(1.1);
}

/* Music Toggle */
#music-toggle {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: rgba(0,0,0,0.7);
    border: 2px solid #666;
    color: #fff;
    padding: 6px 10px;
    border-radius: 5px;
    cursor: pointer;
    z-index: 100;
    font-size: 18px;
    transition: all 0.2s;
}
#music-toggle.playing { border-color: #ffd700; }
#music-toggle:hover { transform: scale(1.1); }

/* Achievement Popup */
#achievement-popup {
    position: fixed;
    top: 80px;
    right: 20px;
    background: linear-gradient(135deg, #2c1b0e, #5d4037);
    border: 3px solid #ffd700;
    padding: 15px 25px;
    color: #ffd700;
    z-index: 300;
    border-radius: 8px;
    transform: translateX(120%);
    transition: transform 0.5s ease;
    box-shadow: 0 0 20px rgba(255,215,0,0.3);
}
#achievement-popup.show { transform: translateX(0); }
#achievement-name {
    font-size: 14px;
    font-weight: bold;
}

/* Puzzle Overlay */
#puzzle-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 600;
}
#puzzle-box {
    background: linear-gradient(135deg, #fdf2e9, #f5e6d3);
    border: 8px solid #a04000;
    padding: 30px;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    color: #2c1b0e;
}
#puzzle-box h2 {
    color: #a04000;
    margin-top: 0;
}
.puzzle-symbols {
    font-size: 36px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    margin: 15px 0;
    letter-spacing: 10px;
}
.puzzle-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 15px 0;
}
.puzzle-btn {
    padding: 15px;
    font-size: 24px;
    background: #a04000;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}
.puzzle-btn:hover {
    background: #c05000;
    transform: scale(1.1);
}
.puzzle-slots {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 15px 0;
}
.puzzle-slot {
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.1);
    border: 2px dashed #a04000;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}
.puzzle-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 15px 0;
}
.puzzle-card {
    width: 60px;
    height: 60px;
    background: #a04000;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s;
}
.puzzle-card.revealed {
    background: #ffd700;
}
.puzzle-card.matched {
    background: #27ae60;
    cursor: default;
}
#puzzle-progress {
    font-size: 18px;
    font-weight: bold;
    color: #a04000;
    margin-top: 10px;
}

/* NPC Overlay */
#npc-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 550;
}
#npc-box {
    background: linear-gradient(135deg, #fdf2e9, #f5e6d3);
    border: 8px solid #a04000;
    padding: 30px;
    border-radius: 8px;
    max-width: 450px;
    width: 90%;
    text-align: center;
    color: #2c1b0e;
}
#npc-box h2 {
    color: #a04000;
    margin-top: 0;
}
.npc-portrait {
    width: 80px;
    height: 80px;
    margin: 0 auto 15px;
    border-radius: 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.npc-hat {
    width: 50px;
    height: 25px;
    border-radius: 25px 25px 0 0;
    position: absolute;
    top: 5px;
}
.npc-dialog {
    font-style: italic;
    background: rgba(0, 0, 0, 0.05);
    padding: 15px;
    border-radius: 10px;
    margin: 15px 0;
    font-size: 16px;
}
.quest-info {
    background: rgba(160, 64, 0, 0.1);
    border: 2px solid #a04000;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
}
.quest-reward {
    font-size: 24px;
    color: #ffd700;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

/* Quest Indicator */
#quest-indicator {
    position: fixed;
    top: 120px;
    left: 20px;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #ffd700;
    padding: 10px 15px;
    border-radius: 8px;
    color: #fff;
    z-index: 100;
}
#quest-name {
    color: #ffd700;
    font-weight: bold;
    font-size: 12px;
    margin-bottom: 5px;
}
#quest-progress {
    font-size: 11px;
    color: #ccc;
}

/* Coin Display */
#coin-display {
    position: fixed;
    top: 50px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #ffd700;
    padding: 8px 15px;
    border-radius: 20px;
    color: #ffd700;
    font-size: 16px;
    font-weight: bold;
    z-index: 100;
    text-shadow: 1px 1px 2px #000;
}

/* Shop Button */
#shop-btn {
    position: fixed;
    top: 50px;
    right: 120px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #ffd700;
    color: #ffd700;
    padding: 6px 12px;
    border-radius: 5px;
    cursor: pointer;
    z-index: 100;
    font-size: 18px;
    transition: all 0.2s;
}
#shop-btn:hover {
    background: rgba(255, 215, 0, 0.2);
    transform: scale(1.1);
}

/* Shop Overlay */
#shop-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 700;
}
#shop-box {
    background: linear-gradient(135deg, #2c1b0e, #4a3728);
    border: 8px solid #ffd700;
    padding: 20px;
    border-radius: 15px;
    max-width: 700px;
    width: 95%;
    max-height: 85vh;
    overflow-y: auto;
    color: #fff;
}

.shop-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #ffd700;
}
.shop-header h2 {
    color: #ffd700;
    margin: 0;
    font-size: 24px;
}
.shop-coins {
    background: rgba(255, 215, 0, 0.2);
    padding: 8px 15px;
    border-radius: 20px;
    color: #ffd700;
    font-size: 18px;
    font-weight: bold;
}

.shop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.shop-item {
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid #666;
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    transition: all 0.2s;
}
.shop-item:hover {
    border-color: #888;
    transform: translateY(-2px);
}
.shop-item.affordable {
    border-color: #ffd700;
}
.shop-item.affordable:hover {
    border-color: #fff;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}
.shop-item.maxed {
    border-color: #27ae60;
    opacity: 0.8;
}

.shop-item-icon {
    font-size: 36px;
    margin-bottom: 8px;
}
.shop-item-name {
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 5px;
    color: #fff;
}
.shop-item-level {
    font-size: 11px;
    color: #aaa;
    margin-bottom: 5px;
}
.shop-item-effect {
    font-size: 12px;
    color: #7bed9f;
    margin-bottom: 10px;
}
.shop-item-maxed {
    color: #27ae60;
    font-weight: bold;
    font-size: 14px;
}

.shop-buy-btn {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    border: none;
    color: #fff;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.2s;
    width: 100%;
}
.shop-buy-btn:hover {
    background: linear-gradient(135deg, #e67e22, #d35400);
    transform: scale(1.05);
}
.shop-buy-btn.disabled {
    background: #666;
    cursor: not-allowed;
    opacity: 0.6;
}
.shop-buy-btn.disabled:hover {
    transform: none;
}

.shop-close-btn {
    display: block;
    width: 100%;
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    border: none;
    color: #fff;
    padding: 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    transition: all 0.2s;
}
.shop-close-btn:hover {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    transform: scale(1.02);
}
