/* ============================================
    PIXEL KNIGHT | Stylesheet
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #0a0a1e;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100vw;
    height: 100vh;
    font-family: 'Press Start 2P', monospace;
}

#gameCanvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    background: #0a0a1e;
}

/* --- UI Layer --- */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* --- Menu Screens --- */
.menu-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    background: rgba(5, 5, 20, 0.92);
    pointer-events: all;
    z-index: 100;
}

.menu-screen.active {
    display: flex;
}

.menu-content {
    text-align: center;
    color: #ffffff;
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px;
}

.menu-content::-webkit-scrollbar {
    width: 6px;
}
.menu-content::-webkit-scrollbar-track {
    background: #111;
}
.menu-content::-webkit-scrollbar-thumb {
    background: #e94560;
    border-radius: 3px;
}

/* --- Title --- */
.game-title {
    font-size: 64px;
    color: #e94560;
    text-shadow:
        0 0 20px #e94560,
        0 0 40px #e94560,
        0 0 80px #c81d4e;
    margin-bottom: 10px;
    letter-spacing: 12px;
    animation: titlePulse 2s ease-in-out infinite;
}

@keyframes titlePulse {
    0%, 100% { text-shadow: 0 0 20px #e94560, 0 0 40px #e94560, 0 0 80px #c81d4e; }
    50% { text-shadow: 0 0 30px #e94560, 0 0 60px #e94560, 0 0 120px #c81d4e; }
}

.game-subtitle {
    font-size: 18px;
    color: #aaa;
    margin-bottom: 50px;
    letter-spacing: 6px;
}

/* --- Buttons --- */
.menu-btn {
    display: block;
    width: 300px;
    margin: 12px auto;
    padding: 14px 24px;
    font-family: 'Press Start 2P', monospace;
    font-size: 14px;
    color: #ffffff;
    background: linear-gradient(180deg, #2a2a4e 0%, #1a1a3e 100%);
    border: 2px solid #e94560;
    cursor: pointer;
    transition: all 0.15s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.menu-btn:hover {
    background: linear-gradient(180deg, #e94560 0%, #c81d4e 100%);
    box-shadow: 0 0 20px rgba(233, 69, 96, 0.5);
    transform: scale(1.05);
}

.menu-btn:active {
    transform: scale(0.98);
}

.start-wave-btn {
    margin-top: 20px;
    border-color: #44cc44;
    font-size: 12px;
}

.start-wave-btn:hover {
    background: linear-gradient(180deg, #44cc44 0%, #228822 100%);
    box-shadow: 0 0 20px rgba(68, 204, 68, 0.5);
    border-color: #66ee66;
}

/* --- Game Over --- */
.game-over-title {
    font-size: 48px;
    color: #ff2244;
    text-shadow: 0 0 30px #ff2244;
    margin-bottom: 30px;
    animation: gameOverShake 0.5s ease-in-out;
}

@keyframes gameOverShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-10px); }
    40% { transform: translateX(10px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

.stats-display {
    text-align: left;
    margin: 20px auto;
    max-width: 350px;
    font-size: 11px;
    line-height: 2.2;
    color: #ccccdd;
}

.stats-display .stat-value {
    color: #ffdd00;
    float: right;
}

.game-over-subtitle {
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
    color: #ff8888;
    margin-bottom: 20px;
    animation: fadeInUp 0.8s ease-out both;
    animation-delay: 0.3s;
}

.game-over-stat-line {
    opacity: 0;
    animation: statReveal 0.4s ease-out forwards;
}

@keyframes statReveal {
    from { opacity: 0; transform: translateX(-20px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(15px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* --- Level Up --- */
.levelup-title {
    font-size: 36px;
    color: #cc66ff;
    text-shadow: 0 0 30px #cc66ff, 0 0 60px #aa44ff;
    margin-bottom: 25px;
    animation: levelUpGlow 1s ease-in-out infinite;
}

@keyframes levelUpGlow {
    0%, 100% { text-shadow: 0 0 30px #cc66ff, 0 0 60px #aa44ff; transform: scale(1); }
    50% { text-shadow: 0 0 50px #cc66ff, 0 0 100px #aa44ff; transform: scale(1.05); }
}

.levelup-info {
    font-size: 12px;
    line-height: 2;
    color: #ccccdd;
    margin-bottom: 20px;
}

.levelup-info .stat-up {
    color: #44ff66;
}

.attribute-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 15px 0;
}

.attr-btn {
    padding: 10px 16px;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    color: #fff;
    background: #1a1a3e;
    border: 2px solid #cc66ff;
    cursor: pointer;
    transition: all 0.15s ease;
}

.attr-btn:hover {
    background: #cc66ff;
    box-shadow: 0 0 15px rgba(204, 102, 255, 0.5);
}

/* --- Controls --- */
.controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 25px auto;
    max-width: 450px;
}

.control-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 11px;
    color: #ccccdd;
    text-align: left;
}

.key {
    display: inline-block;
    padding: 4px 10px;
    background: #2a2a4e;
    border: 1px solid #e94560;
    color: #e94560;
    font-size: 10px;
    min-width: 50px;
    text-align: center;
    font-family: 'Press Start 2P', monospace;
}

.controls-hint {
    font-size: 9px;
    color: #888;
    margin: 15px 0;
    line-height: 1.8;
}

/* --- Shop --- */
.shop-content {
    max-width: 800px;
}

.shop-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 15px 0;
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #333;
}

.gold-display {
    color: #ffdd00;
    font-size: 14px;
}

.wave-display {
    color: #aaaacc;
    font-size: 12px;
}

.shop-tabs {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin: 15px 0;
}

.shop-tab {
    padding: 8px 16px;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    color: #888;
    background: #111;
    border: 1px solid #333;
    cursor: pointer;
    transition: all 0.15s ease;
}

.shop-tab:hover {
    color: #fff;
    border-color: #e94560;
}

.shop-tab.active {
    color: #fff;
    background: #e94560;
    border-color: #e94560;
}

.shop-items-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 10px 0;
    max-height: 320px;
    overflow-y: auto;
    padding: 5px;
}

.shop-item {
    padding: 10px;
    background: rgba(20, 20, 50, 0.8);
    border: 1px solid #333;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
    position: relative;
}

.shop-item:hover {
    border-color: #e94560;
    background: rgba(40, 20, 50, 0.8);
}

.shop-item.owned {
    border-color: #44cc44;
    opacity: 0.7;
}

.shop-item.equipped {
    border-color: #ffdd00;
    box-shadow: 0 0 10px rgba(255, 221, 0, 0.3);
}

.shop-item.too-expensive {
    opacity: 0.4;
    cursor: not-allowed;
}

.shop-item-name {
    font-size: 10px;
    color: #ffffff;
    margin-bottom: 4px;
}

.shop-item-desc {
    font-size: 8px;
    color: #888;
    margin-bottom: 6px;
    line-height: 1.6;
}

.shop-item-price {
    font-size: 9px;
    color: #ffdd00;
}

/* ── Synergy Hints ── */
.synergy-badge {
    margin-top: 4px;
    padding: 3px 6px;
    background: rgba(255, 215, 0, 0.08);
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 4px;
    font-size: 8px;
    color: #ffcc44;
    line-height: 1.3;
}
.synergy-badge.synergy-active {
    background: rgba(255, 215, 0, 0.18);
    border-color: #ffd700;
    color: #ffd700;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.25);
}
.synergy-desc {
    color: #bbaa66;
    font-size: 7px;
}
.shop-item.has-synergy {
    border-color: rgba(255, 215, 0, 0.35);
}

.shop-item-owned-label {
    font-size: 8px;
    color: #44cc44;
    position: absolute;
    top: 5px;
    right: 8px;
}

/* ── Level-Up Attribute Points (in shop) ── */
.shop-freepoints {
    margin: 10px 0;
    padding: 12px 14px;
    background: linear-gradient(135deg, rgba(60,50,0,0.85), rgba(80,70,0,0.85));
    border: 2px solid #ffcc00;
    border-radius: 6px;
    box-shadow: 0 0 18px rgba(255, 200, 0, 0.4);
    animation: fpGlow 1.2s ease-in-out infinite alternate;
}

@keyframes fpGlow {
    from { box-shadow: 0 0 12px rgba(255, 200, 0, 0.35); }
    to   { box-shadow: 0 0 26px rgba(255, 200, 0, 0.7);  }
}

.freepoints-header {
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    color: #ffdd44;
    text-align: center;
    margin-bottom: 10px;
    text-shadow: 0 0 8px #ffaa00;
}

.freepoints-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.freepoint-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    padding: 7px 10px;
    background: rgba(80, 60, 0, 0.9);
    border: 1px solid #ffaa00;
    color: #ffee88;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.freepoint-btn:hover {
    background: rgba(180, 130, 0, 0.9);
    color: #ffffff;
    border-color: #ffdd00;
    box-shadow: 0 0 8px rgba(255, 200, 0, 0.5);
}

/* ── Weapon Ability Info Panel (in shop) ── */
.ability-info-panel {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.ability-info-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    padding: 5px 6px;
    background: rgba(20, 20, 40, 0.75);
    border: 1px solid #334;
    border-radius: 4px;
    font-family: 'Press Start 2P', monospace;
    font-size: 7px;
    line-height: 1.6;
}

.ability-info-row.ability-locked {
    opacity: 0.45;
    filter: saturate(0.3);
}

.ability-key {
    font-size: 9px;
    font-weight: bold;
    min-width: 14px;
    text-align: center;
    text-shadow: 0 0 6px currentColor;
}

.ability-info-name {
    color: #ddeeff;
    flex: 1;
}

.ability-info-cost {
    color: #88aacc;
    font-size: 6px;
}

.ability-lock-badge {
    color: #778899;
    font-size: 7px;
    margin-left: auto;
}

.ability-info-desc {
    width: 100%;
    color: #8899aa;
    font-size: 6px;
    border-top: 1px solid #334;
    padding-top: 3px;
    margin-top: 2px;
    line-height: 1.8;
}

.shop-stats {
    margin: 10px auto;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #333;
    font-size: 9px;
    color: #aaa;
    line-height: 2;
    text-align: left;
    max-width: 400px;
}

.shop-stats .stat-label {
    color: #888;
}

.shop-stats .stat-value {
    color: #fff;
    float: right;
}

/* --- Wave Announcement --- */
.wave-announcement {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 50;
}

.wave-announce-text {
    font-size: 36px;
    color: #ffffff;
    text-shadow: 0 0 20px #e94560, 0 0 40px #c81d4e;
    text-align: center;
    animation: waveAnnounce 2s ease-out forwards;
    white-space: nowrap;
}

.wave-announce-text.boss {
    color: #ff4400;
    text-shadow: 0 0 30px #ff4400, 0 0 60px #cc3300;
    font-size: 42px;
}

@keyframes waveAnnounce {
    0% { transform: scale(2); opacity: 0; }
    20% { transform: scale(1); opacity: 1; }
    80% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0.8); opacity: 0; }
}

/* --- Settings --- */
.settings-grid {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin: 22px 0 30px;
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
}

.setting-row {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 10px;
    color: #ccc;
}

.setting-row label {
    flex: 0 0 160px;
    text-align: right;
}

.setting-row input[type="range"] {
    flex: 1;
    accent-color: #e94560;
    height: 6px;
}

.setting-row select {
    flex: 1;
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    padding: 6px 8px;
    background: #1a1a3a;
    color: #fff;
    border: 1px solid #444;
    border-radius: 4px;
    outline: none;
}

.setting-row select:focus { border-color: #e94560; }

.setting-row span {
    flex: 0 0 44px;
    text-align: left;
    color: #ffd700;
    font-size: 9px;
}

/* --- Cosmetics --- */
.cosmetics-section {
    text-align: center;
}

.cosmetic-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    max-width: 500px;
    margin: 0 auto;
}

.cosmetic-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #1a1a3a;
    border: 2px solid #333;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    color: #ccc;
    transition: border-color 0.2s;
}

.cosmetic-option:hover { border-color: #888; }
.cosmetic-option.selected { border-color: #ffd700; color: #ffd700; }
.cosmetic-option.locked { opacity: 0.35; cursor: default; }
.cosmetic-option .swatch {
    width: 16px; height: 16px;
    border-radius: 3px;
    border: 1px solid #555;
}

/* --- Passive Selection --- */
.passive-selection-content {
    max-width: 820px;
    text-align: center;
}
.passive-selection-title {
    font-size: 22px;
    color: #ffd700;
    text-shadow: 0 0 16px #ffd70077;
    margin-bottom: 8px;
}
.passive-selection-sub {
    font-size: 10px;
    color: #aaa;
    margin-bottom: 28px;
    font-family: 'Press Start 2P', monospace;
}
.passive-cards {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}
.passive-card {
    background: linear-gradient(160deg, #1a1a2e 0%, #16213e 100%);
    border: 2px solid #444;
    border-radius: 12px;
    padding: 24px 20px;
    width: 200px;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.passive-card:hover {
    border-color: #ffd700;
    transform: translateY(-6px) scale(1.04);
    box-shadow: 0 8px 32px rgba(255,215,0,0.22);
}
.passive-card-icon {
    font-size: 40px;
    line-height: 1;
}
.passive-card-name {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    color: #f0f0f0;
    text-align: center;
}
.passive-card-category {
    font-family: 'Press Start 2P', monospace;
    font-size: 7px;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}
.passive-card-category.offensiv  { background: #6b1a1a; color: #ff8888; }
.passive-card-category.defensiv  { background: #1a3a1a; color: #88ff88; }
.passive-card-category.utility   { background: #3a3a10; color: #ffee88; }
.passive-card-category.magie     { background: #1a1a5a; color: #88aaff; }
.passive-card-desc {
    font-family: 'Press Start 2P', monospace;
    font-size: 7px;
    color: #bbb;
    text-align: center;
    line-height: 1.6;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .game-title { font-size: 36px; letter-spacing: 6px; }
    .game-subtitle { font-size: 12px; }
    .menu-btn { width: 250px; font-size: 11px; padding: 12px 16px; }
    .controls-grid { grid-template-columns: 1fr; }
    .shop-items-grid { grid-template-columns: 1fr; }
    .shop-tabs { flex-wrap: wrap; }
}

/* ─── Soul Altar (Meta-Progression) ─────────── */
.souls-display {
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
    color: #cc88ff;
    text-align: center;
    margin-bottom: 16px;
}

.altar-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 380px;
    overflow-y: auto;
    padding: 4px;
}

.altar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(30, 30, 60, 0.8);
    border: 1px solid rgba(120, 80, 180, 0.3);
    border-radius: 6px;
    padding: 10px 14px;
    cursor: default;
    transition: border-color 0.2s, background 0.2s;
}

.altar-item.affordable {
    cursor: pointer;
    border-color: rgba(200, 140, 255, 0.5);
}

.altar-item.affordable:hover {
    background: rgba(60, 30, 90, 0.7);
    border-color: #cc88ff;
}

.altar-item.maxed {
    opacity: 0.5;
}

.altar-icon {
    font-size: 22px;
    min-width: 32px;
    text-align: center;
}

.altar-info {
    flex: 1;
}

.altar-name {
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    color: #eee;
    margin-bottom: 3px;
}

.altar-level {
    color: #cc88ff;
    font-size: 8px;
}

.altar-desc {
    font-family: 'Press Start 2P', monospace;
    font-size: 7px;
    color: #999;
}

.altar-cost {
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    color: #cc88ff;
    min-width: 60px;
    text-align: right;
}

/* ─── Touch Controls ────────────────────────── */
#touch-controls {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: 1000;
    user-select: none;
    -webkit-user-select: none;
}

@media (pointer: coarse) {
    #touch-controls { display: block !important; }
}

.touch-btn {
    pointer-events: auto;
    position: absolute;
    border: 2px solid rgba(255,255,255,0.25);
    background: rgba(20, 20, 50, 0.55);
    color: rgba(255, 255, 255, 0.75);
    border-radius: 50%;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.08s, border-color 0.08s;
}

.touch-btn.active {
    background: rgba(233, 69, 96, 0.6);
    border-color: rgba(255, 255, 255, 0.6);
}

/* D-Pad (bottom-left) */
.touch-dpad { position: fixed; bottom: 20px; left: 20px; }
.touch-left  { position: absolute; bottom: 30px; left: 0; }
.touch-right { position: absolute; bottom: 30px; left: 76px; }
.touch-jump  { position: absolute; bottom: 96px; left: 38px; }

/* Action buttons (bottom-right) */
.touch-actions { position: fixed; bottom: 20px; right: 20px; }
.touch-attack { position: absolute; bottom: 30px; right: 76px; }
.touch-heavy  { position: absolute; bottom: 30px; right: 0; }
.touch-dash   { position: absolute; bottom: 96px; right: 76px; }
.touch-parry  { position: absolute; bottom: 96px; right: 0; }

/* Ability buttons (mid-right) */
.touch-abilities { position: fixed; bottom: 180px; right: 20px; }
.touch-q { position: absolute; bottom: 0; right: 0; width: 44px; height: 44px; font-size: 14px; }
.touch-e { position: absolute; bottom: 0; right: 52px; width: 44px; height: 44px; font-size: 14px; }
.touch-r { position: absolute; bottom: 0; right: 104px; width: 44px; height: 44px; font-size: 14px; }

/* Pause (top-right) */
.touch-pause {
    top: 12px; right: 12px;
    width: 40px; height: 40px;
    font-size: 16px;
    border-radius: 8px;
}
