:root {
    --bg-color: #0d1117;
    --panel-bg: #161b22;
    --text-color: #c9d1d9;
    --primary: #58a6ff;
    --primary-hover: #3182ce;
    --success: #238636;
    --danger: #da3633;
    --warning: #d29922;
    --border: #30363d;
    --font-family: 'Space Mono', monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    user-select: none;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

#game-container {
    width: 100%;
    max-width: 800px;
    height: 100vh;
    max-height: 900px;
    display: flex;
    flex-direction: column;
    position: relative;
    background: var(--bg-color);
}

.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 2rem;
    position: absolute;
    top: 0; left: 0;
    background: var(--bg-color);
    z-index: 10;
}

.screen.active {
    display: flex;
}

.title {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.title .accent {
    color: var(--primary);
}

.subtitle {
    font-size: 1rem;
    color: #8b949e;
    margin-bottom: 2rem;
    text-align: center;
}

.btn {
    background: var(--panel-bg);
    border: 1px solid var(--border);
    color: var(--primary);
    padding: 0.75rem 1.5rem;
    font-size: 1.25rem;
    cursor: pointer;
    border-radius: 6px;
    margin-bottom: 1rem;
    transition: all 0.2s;
    font-weight: bold;
}

.btn:hover {
    background: var(--border);
    color: #fff;
}

#hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--panel-bg);
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.hud-stat {
    font-weight: bold;
}

#main-view {
    display: flex;
    flex-grow: 1;
    overflow: hidden;
}

#git-map {
    width: 200px;
    background: var(--panel-bg);
    border-right: 1px solid var(--border);
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.panel-title {
    font-size: 1rem;
    color: var(--primary);
    margin-bottom: 1rem;
    text-transform: uppercase;
}

#map-nodes {
    display: flex;
    flex-direction: column-reverse; /* Bottom up layout for commits */
    gap: 0.5rem;
    padding-left: 20px;
    position: relative;
}

.map-node {
    position: relative;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-color);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.map-node.active {
    border-color: var(--primary);
    background: rgba(88, 166, 255, 0.1);
}

.map-node.completed {
    border-color: var(--success);
    color: var(--success);
}

.map-node.locked {
    opacity: 0.5;
    pointer-events: none;
}

.map-node.boss {
    border-color: var(--danger);
    color: var(--danger);
    font-weight: bold;
}

/* Connecting branch lines logic done via SVG/CSS borders */

#canvas-container {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #000;
    position: relative;
}

canvas {
    image-rendering: pixelated;
    background: #111;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

#log-panel {
    height: 120px;
    background: var(--panel-bg);
    border-top: 1px solid var(--border);
    padding: 0.5rem;
    overflow-y: auto;
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
}

.log-entry { margin-bottom: 0.25rem; }
.log-entry.player { color: var(--primary); }
.log-entry.enemy { color: var(--danger); }
.log-entry.system { color: var(--success); }

/* Mobile Controls */
#mobile-controls {
    display: none;
    background: var(--panel-bg);
    padding: 1rem;
    border-top: 1px solid var(--border);
}

.dpad-row {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.dpad-btn {
    width: 60px;
    height: 60px;
    background: var(--bg-color);
    border: 1px solid var(--border);
    color: var(--primary);
    font-size: 1.5rem;
    border-radius: 8px;
}

.dpad-btn:active {
    background: var(--primary);
    color: #fff;
}

/* Modal */
.modal {
    background: rgba(13, 17, 23, 0.95);
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 20;
    padding: 2rem;
}

.modal.hidden { display: none; }

#node-select-modal h2 { margin-bottom: 1rem; color: var(--success); }
#node-select-modal p { margin-bottom: 2rem; color: #8b949e; }

#node-options {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.node-option-card {
    background: var(--panel-bg);
    border: 1px solid var(--border);
    padding: 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    min-width: 150px;
    transition: all 0.2s;
}

.node-option-card:hover {
    border-color: var(--primary);
    transform: translateY(-5px);
}

.node-option-title {
    font-weight: bold;
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.node-option-desc {
    font-size: 0.8rem;
    color: #8b949e;
}

/* Leaderboard Input */
.input-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

input[type="text"] {
    background: var(--bg-color);
    border: 1px solid var(--border);
    color: var(--text-color);
    padding: 0.5rem 1rem;
    font-family: var(--font-family);
}

/* Floating Scores & Screen Shake */
.shake {
    animation: shake 0.3s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

@media (max-width: 768px) {
    #git-map { display: none; }
    #mobile-controls { display: block; }
    .title { font-size: 1.8rem; }
}
