/* FLX Trail — retro pixel aesthetic */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&display=swap');

:root {
    --bg: #2a1f1a;
    --bg-light: #3d2f26;
    --fg: #f0e6d0;
    --fg-dim: #c9b896;
    --accent: #e87a3c;    /* Scout orange — title, active waypoint, Scout sprite */
    --accent-2: #6fa865;  /* finger lakes green */
    --btn: #2a8a94;       /* teal — buttons only, distinct from title */
    --btn-hover: #3ba7b0;
    --border: #8b6e4e;
    --shadow: rgba(0, 0, 0, 0.45);
}

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

html, body {
    height: 100%;
    font-family: 'VT323', 'Courier New', monospace;
    background: var(--bg);
    color: var(--fg);
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
}

body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    /* No overflow:hidden on body — short viewports (mobile virtual keyboard
       on the finish form) need to be able to scroll. The game canvas has a
       fixed size and is centered; that's sufficient layout control. */
}

#app {
    width: 100%;
    max-width: 800px;
    padding: 1rem;
}

.screen {
    text-align: center;
    padding: 2rem 1rem;
    animation: fadeIn 0.4s ease;
}

.screen.hidden { display: none; }

/* Finish screen is tighter so the Save button fits above the fold on a
   13" MacBook (~700px of vertical viewport after browser chrome). */
#finish-screen { padding: 1rem 1rem 1.25rem; }
#finish-screen .title { font-size: 1.75rem; margin-bottom: 0.25rem; }
#finish-screen .blurb { font-size: 1.1rem; line-height: 1.35; margin-bottom: 0.75rem; }
#finish-screen .footnote { margin-top: 0.75rem; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.title {
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 2.25rem;
    color: var(--accent);
    letter-spacing: 2px;
    text-shadow: 3px 3px 0 var(--shadow);
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1.75rem;
    color: var(--fg-dim);
    margin-bottom: 2rem;
    letter-spacing: 1px;
}

.blurb {
    font-size: 1.375rem;
    line-height: 1.5;
    margin-bottom: 2rem;
    color: var(--fg-dim);
}

.pixel-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.875rem;
    padding: 0.9rem 1.5rem;
    background: var(--btn);
    color: var(--fg);
    border: none;
    border-radius: 0;
    cursor: pointer;
    letter-spacing: 1px;
    box-shadow: 4px 4px 0 var(--shadow);
    transition: transform 80ms, box-shadow 80ms, background 120ms;
}

.pixel-btn:hover {
    background: var(--btn-hover);
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 var(--shadow);
}

.pixel-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 0 0 0 var(--shadow);
}

.footnote {
    font-size: 1rem;
    color: var(--border);
    margin-top: 3rem;
    letter-spacing: 1px;
}

/* Game canvas */
#game-container:not(.hidden) {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#game {
    border: 3px solid var(--border);
    box-shadow: 6px 6px 0 var(--shadow);
    max-width: 100%;
    image-rendering: pixelated;
}

#hud {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.75rem;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.75rem;
    color: var(--fg-dim);
}

.hud-item { letter-spacing: 1px; }

/* Dialogue overlay */
#dialogue-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 1rem;
    z-index: 10;
}

#dialogue-overlay.hidden { display: none; }

.dialogue-box {
    width: 100%;
    max-width: 640px;
    background: var(--bg-light);
    border: 3px solid var(--border);
    box-shadow: 6px 6px 0 var(--shadow);
    padding: 1.5rem;
    font-size: 1.375rem;
    line-height: 1.5;
}

#dialogue-text {
    margin-bottom: 1rem;
    min-height: 3rem;
    white-space: pre-line;  /* preserve the \n\n between event text and clue */
}

#dialogue-choices {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.choice-btn {
    font-family: 'VT323', monospace;
    font-size: 1.25rem;
    padding: 0.5rem 0.75rem;
    background: transparent;
    color: var(--fg);
    border: 2px solid var(--border);
    cursor: pointer;
    text-align: left;
    transition: background 120ms, color 120ms;
}

.choice-btn:hover:not(:disabled) {
    background: var(--accent);
    color: var(--bg);
}

.choice-btn:disabled,
.choice-btn-wrong {
    opacity: 0.35;
    cursor: not-allowed;
    text-decoration: line-through;
}

/* Finish screen */
.final-score {
    font-family: 'Press Start 2P', monospace;
    font-size: 1.1rem;
    color: var(--accent);
    margin-bottom: 0.35rem;
    letter-spacing: 1px;
}

.bonus-note {
    font-size: 1rem;
    color: var(--accent-2);
    margin-bottom: 0.5rem;
    font-style: italic;
}

#save-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 0.75rem;
    max-width: 520px;
    margin: 0 auto 0.5rem;
}

#save-form input {
    font-family: 'VT323', monospace;
    font-size: 1.125rem;
    padding: 0.5rem 0.65rem;
    background: var(--bg-light);
    color: var(--fg);
    border: 2px solid var(--border);
}

#save-form button {
    grid-column: 1 / -1;
    justify-self: center;
}

/* Narrow viewports (mobile) — stack inputs full-width. */
@media (max-width: 520px) {
    #save-form { grid-template-columns: 1fr; max-width: 360px; }
}

#save-form input:focus {
    outline: none;
    border-color: var(--accent);
}

.save-status {
    font-size: 1.125rem;
    color: var(--fg-dim);
    margin-top: 1rem;
}

.save-status.success { color: var(--accent-2); }
.save-status.error { color: #e25c5c; }

/* Leaderboard link — default <a> blue is illegible on the dark brown bg. */
.lb-back {
    color: var(--fg);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.lb-back:hover {
    color: var(--accent);
}
