*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --green:      #00ff41;
    --green-mid:  #00882b;
    --green-dark: #003300;
    --green-dim:  #004d00;
    --bg:         #0a0a0a;
    --bg2:        #0d0d0d;
    --white:      #e0e0e0;
    --yellow:     #f0e050;
    --cyan:       #00e5ff;
    --red:        #ff4444;
}

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--green);
    font-family: 'Courier New', Courier, monospace;
    font-size: 15px;
}

body { display: flex; flex-direction: column; }

/* ── Terminal ─────────────────────────────────────────── */

#terminal {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 20px 24px 8px;
    cursor: text;
}

#output {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 8px;
}

#output::-webkit-scrollbar { width: 4px; }
#output::-webkit-scrollbar-track { background: transparent; }
#output::-webkit-scrollbar-thumb { background: var(--green-dark); }

/* ── Lines ────────────────────────────────────────────── */

.line {
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.line.ascii { color: var(--green); }
.line.dim   { color: var(--green-dim); }
.line.hint  { color: var(--green-mid); }

/* Inline colour spans used inside HTML content */
.h { color: var(--yellow); }
.g { color: var(--green); }
.c { color: var(--cyan); }
.d { color: var(--green-dim); }
.w { color: var(--white); }
.r { color: var(--red); }

/* ── Input line ───────────────────────────────────────── */

#input-line {
    display: flex;
    align-items: center;
    padding-top: 6px;
    flex-shrink: 0;
}

.prompt {
    color: var(--green);
    font-weight: bold;
    user-select: none;
    white-space: nowrap;
}

#cmd-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--white);
    font-family: inherit;
    font-size: inherit;
    caret-color: var(--green);
    min-width: 0;
}

/* ── Quick bar ────────────────────────────────────────── */

#quick-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    padding: 8px 24px 14px;
    border-top: 1px solid #001a00;
    background: var(--bg2);
    flex-shrink: 0;
}

.qb-label {
    color: var(--green-dim);
    font-size: 0.82em;
    user-select: none;
    white-space: nowrap;
}

#quick-bar button {
    background: transparent;
    color: var(--green-mid);
    border: 1px solid var(--green-dark);
    font-family: inherit;
    font-size: 0.82em;
    padding: 3px 11px;
    cursor: pointer;
    border-radius: 2px;
    transition: color 0.12s, background 0.12s, border-color 0.12s;
}

#quick-bar button:hover,
#quick-bar button:focus {
    color: var(--bg);
    background: var(--green);
    border-color: var(--green);
    outline: none;
}

/* ── Play button accent ───────────────────────────────── */

#btn-play {
    color: var(--yellow) !important;
    border-color: var(--yellow) !important;
    margin-left: 6px;
}
#btn-play:hover, #btn-play:focus {
    background: var(--yellow) !important;
    color: var(--bg) !important;
}

/* ── Game overlay ─────────────────────────────────────── */

#game-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.88);
    align-items: center;
    justify-content: center;
}

#game-window {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--green);
    background: var(--bg);
}

#game-titlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    border-bottom: 1px solid var(--green-dark);
    background: #0d1a0d;
    font-size: 0.82em;
    color: var(--green-mid);
    user-select: none;
}

#game-score {
    color: var(--yellow);
    min-width: 80px;
    text-align: center;
}

#game-close {
    background: transparent;
    border: 1px solid var(--green-dark);
    color: var(--green-dim);
    font-family: inherit;
    font-size: inherit;
    padding: 1px 8px;
    cursor: pointer;
    border-radius: 2px;
    transition: color 0.1s, background 0.1s;
}
#game-close:hover {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
}

#snake-canvas {
    display: block;
    /* width/height set dynamically in game.js */
}

/* ── D-pad (touch controls) ───────────────────────── */

#game-dpad {
    display: none; /* shown only on touch devices */
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 0 12px;
    background: var(--bg2);
    border-top: 1px solid var(--green-dark);
}

.dpad-mid {
    display: flex;
    gap: 40px;
}

.dpad-btn {
    width: 52px;
    height: 52px;
    background: #0d1a0d;
    color: var(--green);
    border: 1px solid var(--green-dark);
    font-family: inherit;
    font-size: 20px;
    cursor: pointer;
    border-radius: 4px;
    touch-action: manipulation;
    user-select: none;
    transition: background 0.1s;
}

.dpad-btn:active {
    background: var(--green-dark);
}

@media (hover: none) and (pointer: coarse) {
    #game-dpad { display: flex; }
}

/* ── Mobile ───────────────────────────────────────────── */

@media (max-width: 600px) {
    html, body { font-size: 12px; }
    #terminal  { padding: 12px 12px 6px; }
    #quick-bar { padding: 6px 12px 10px; gap: 4px; }
}
