/* Reset and Basic Setup */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Orbitron', 'Segoe UI', Tahoma, sans-serif;
    overflow: hidden;
    background-color: #0d0d1a;
    /* Deeper space background */
    color: #e0e0e0;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
}

#gameCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    /* Behind UI */
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    /* Let clicks pass through if needed, except where specified */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
}

.title {
    text-align: center;
    font-size: 2.5rem;
    color: #00ffff;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 0 10px #00ffff, 0 0 20px #0f3460;
}

#score-board {
    pointer-events: auto;
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 1.2rem;
    font-weight: bold;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    transform-origin: top right;

    background: rgba(10, 10, 25, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 10px 30px 10px 20px;
    border-radius: 8px;
    border: 1px solid rgba(0, 255, 255, 0.3);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.1);
}

#score-board.minimized {
    transform: scale(0.5);
    opacity: 0;
    pointer-events: none;
}

#currency {
    color: #ff00ff;
    text-shadow: 0 0 8px #ff00ff;
}

/* Login Screen */
#login-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at center, #1a1a3a 0%, #050510 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.login-box {
    background: rgba(15, 20, 40, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 40px;
    border-radius: 12px;
    border: 1px solid rgba(233, 69, 96, 0.5);
    text-align: center;
    box-shadow: 0 0 30px rgba(233, 69, 96, 0.2), inset 0 0 20px rgba(233, 69, 96, 0.1);
}

.login-box h1 {
    margin-bottom: 10px;
    color: #e94560;
    text-shadow: 0 0 10px #e94560;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.login-box p {
    margin-bottom: 20px;
    color: #ccc;
}

.login-box input {
    padding: 12px;
    font-size: 1.1rem;
    font-family: 'Orbitron', sans-serif;
    margin-bottom: 20px;
    width: 100%;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #444;
    color: #00ffff;
    text-align: center;
    transition: 0.3s;
}

.login-box input:focus {
    outline: none;
    border-color: #00ffff;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
}

.login-box button {
    padding: 12px 20px;
    font-size: 1.2rem;
    font-family: 'Orbitron', sans-serif;
    background: transparent;
    color: #e94560;
    border: 2px solid #e94560;
    border-radius: 6px;
    cursor: pointer;
    width: 100%;
    font-weight: bold;
    text-transform: uppercase;
    transition: all 0.3s ease;
    box-shadow: 0 0 10px rgba(233, 69, 96, 0.2);
}

.login-box button:hover {
    background: #e94560;
    color: white;
    box-shadow: 0 0 20px #e94560;
}

#login-error {
    color: #ff6b6b;
    margin-top: 10px;
    font-weight: bold;
}

/* Upgrade Shop */
#shop-container {
    pointer-events: auto;
    position: absolute;
    top: 100px;
    right: 20px;
    background: rgba(10, 15, 30, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 20px 25px 20px 20px;
    border-radius: 8px;
    border: 1px solid rgba(0, 255, 255, 0.2);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    transform-origin: top right;
}

#shop-container.minimized {
    transform: scale(0.5);
    opacity: 0;
    pointer-events: none;
}

#shop-container::-webkit-scrollbar {
    width: 6px;
}

#shop-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

#shop-container::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 255, 0.5);
    border-radius: 4px;
}

#shop-container h3 {
    color: #00ffff;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    text-align: center;
    border-bottom: 1px solid rgba(0, 255, 255, 0.3);
    padding-bottom: 5px;
    text-shadow: 0 0 5px rgba(0, 255, 255, 0.5);
}

.upgrade-btn {
    padding: 10px;
    font-family: 'Orbitron', sans-serif;
    background: rgba(0, 0, 0, 0.4);
    color: #ddd;
    border: 1px solid rgba(233, 69, 96, 0.6);
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}

.upgrade-btn:hover {
    background: rgba(233, 69, 96, 0.2);
    border-color: #e94560;
    color: white;
    box-shadow: 0 0 10px rgba(233, 69, 96, 0.4);
}

.upgrade-btn:disabled {
    background: #555;
    border-color: #333;
    color: #999;
    cursor: not-allowed;
}

#math-problem-container {
    pointer-events: auto;
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(10, 15, 30, 0.8);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    padding: 20px 40px;
    border-radius: 12px;
    border: 1px solid rgba(0, 255, 255, 0.4);
    text-align: center;
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.15), inset 0 0 20px rgba(0, 255, 255, 0.05);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, border-color 0.3s;
    transform-origin: bottom center;
}

#math-problem-container.minimized {
    transform: translateX(-50%) translateY(50px) scale(0.5);
    opacity: 0;
    pointer-events: none;
}

#calc-container.minimized {
    transform: translateX(-250px) translateY(50%);
    opacity: 0;
    pointer-events: none;
}

#math-problem-container:hover {
    border-color: #00ffff;
    box-shadow: 0 0 40px rgba(0, 255, 255, 0.3);
}

#math-question {
    font-size: 2rem;
    margin-bottom: 15px;
    font-weight: bold;
    color: white;
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

#math-answer {
    padding: 12px;
    font-size: 1.2rem;
    font-family: 'Orbitron', sans-serif;
    border-radius: 6px;
    border: 1px solid #444;
    background: rgba(0, 0, 0, 0.6);
    color: #ff00ff;
    outline: none;
    width: 200px;
    text-align: center;
    transition: 0.3s;
}

#math-answer:focus {
    border-color: #ff00ff;
    box-shadow: 0 0 15px rgba(255, 0, 255, 0.3);
}

#submit-answer {
    padding: 12px 20px;
    font-size: 1.2rem;
    font-family: 'Orbitron', sans-serif;
    margin-left: 10px;
    border-radius: 6px;
    border: 2px solid #00ffff;
    background-color: transparent;
    color: #00ffff;
    cursor: pointer;
    font-weight: bold;
    text-transform: uppercase;
    transition: all 0.3s;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.2);
}

#submit-answer:hover {
    background-color: #00ffff;
    color: black;
    box-shadow: 0 0 20px #00ffff;
}

#game-over {
    pointer-events: auto;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    padding: 40px;
    border-radius: 15px;
    border: 2px solid red;
    text-align: center;
}

#game-over h2 {
    font-size: 3rem;
    color: red;
    margin-bottom: 20px;
}

#restart-btn {
    padding: 10px 25px;
    font-size: 1.5rem;
    border-radius: 8px;
    border: none;
    background: white;
    color: black;
    cursor: pointer;
    font-weight: bold;
}

.hidden {
    display: none !important;
}

#notifications {
    position: absolute;
    top: 80px;
    right: 20px;
    width: 300px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    z-index: 20;
}

.notification {
    background: rgba(233, 69, 96, 0.9);
    color: white;
    padding: 10px 15px;
    border-radius: 6px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
    font-size: 1rem;
    animation: slideIn 0.3s ease-out forwards, fadeOut 0.5s ease-in 4.5s forwards;
    opacity: 1;
}

@keyframes slideIn {
    from {
        transform: translateX(120%);
    }

    to {
        transform: translateX(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

#skill-tree-modal,
#property-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    pointer-events: auto;
}

#skill-tree-modal.hidden,
#property-modal.hidden {
    display: none !important;
}

#skill-tree-content {
    width: 700px;
    max-width: 95vw;
    padding: 30px;
    border-color: #ff00ff;
    box-shadow: 0 0 40px rgba(255, 0, 255, 0.2), inset 0 0 20px rgba(255, 0, 255, 0.05);
}

.skill-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.skill-node {
    background: rgba(20, 20, 40, 0.8);
    border: 1px solid #444;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    transition: 0.3s;
}

.skill-node:hover {
    border-color: #ff00ff;
    box-shadow: 0 0 15px rgba(255, 0, 255, 0.3);
}

.skill-node h4 {
    color: #ffb8b8;
    margin-bottom: 8px;
    font-size: 1.1rem;
}

.skill-node p {
    font-size: 0.85rem;
    color: #ccc;
    margin-bottom: 12px;
    min-height: 50px;
}

.skill-btn {
    width: 100%;
    border-color: #ff00ff;
    color: #ff00ff;
}

/* Responsive Design for iPad / Tablets */
@media (max-width: 1024px) {
    .title {
        font-size: 1.5rem;
    }

    #score-board {
        top: 10px;
        right: 10px;
        font-size: 1rem;
        padding: 8px 12px;
    }

    #shop-container {
        top: 60px;
        right: 10px;
        padding: 10px;
        max-height: 60vh;
        overflow-y: auto;
        /* Allow scrolling if it gets too tall */
        width: 220px;
    }

    #shop-container h3 {
        font-size: 1rem;
        margin-bottom: 5px;
    }

    .upgrade-btn {
        padding: 6px;
        font-size: 0.9rem;
    }

    #math-problem-container {
        bottom: 15px;
        padding: 10px 20px;
    }

    #math-question {
        font-size: 1.4rem;
        margin-bottom: 5px;
    }

    #math-answer {
        width: 140px;
        font-size: 1rem;
        padding: 6px;
    }

    #submit-answer {
        font-size: 1rem;
        padding: 6px 12px;
    }
}

/* Responsive Design for smaller phones */
@media (max-width: 768px) {
    .title {
        font-size: 1.2rem;
    }

    #score-board {
        font-size: 0.85rem;
        padding: 5px 8px;
    }

    #shop-container {
        width: 180px;
        top: 50px;
        max-height: 40vh;
        overflow-y: auto;
    }

    .upgrade-btn {
        font-size: 0.8rem;
        padding: 4px;
    }

    #math-problem-container {
        bottom: 5vh;
        padding: 8px 10px;
        width: 95vw;
        left: 50%;
        transform: translateX(-50%);
    }

    #math-question {
        font-size: 1.1rem;
        margin-bottom: 5px;
    }

    #math-answer {
        width: 120px;
        font-size: 0.9rem;
        padding: 4px;
    }

    #submit-answer {
        font-size: 0.9rem;
        padding: 4px 8px;
    }
}

/* Minimize & Dock UI Elements */
.dock-btn {
    pointer-events: auto;
    position: absolute;
    background: rgba(10, 15, 30, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 255, 255, 0.5);
    color: #00ffff;
    padding: 10px 15px;
    font-family: 'Orbitron', sans-serif;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.2);
    transition: all 0.3s;
    z-index: 1000;
}

.dock-btn:hover {
    background: rgba(0, 255, 255, 0.2);
    box-shadow: 0 0 25px rgba(0, 255, 255, 0.5);
}

#dock-scoreboard {
    top: 20px;
    left: 0;
    border-radius: 0 8px 8px 0;
    border-left: none;
}

#dock-shop {
    top: 100px;
    right: 0;
    border-radius: 8px 0 0 8px;
    border-right: none;
}

#dock-math {
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 8px 8px 0 0;
    border-bottom: none;
}

.minimize-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    line-height: 0.8;
    padding: 8px 15px;
    transition: all 0.2s;
    z-index: 20;
}

.minimize-btn:hover {
    background: rgba(0, 255, 255, 0.2);
    border-color: #00ffff;
    color: #00ffff;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
}