/* Moonshot - Orbital Mechanics Game */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #0a0e27;
    color: #e0e0e0;
    font-family: 'Courier New', monospace;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

#game-canvas {
    display: block;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    cursor: default;
}

/* ── Version Label ── */
#version-label {
    position: absolute;
    top: 8px;
    right: 12px;
    font-family: 'Courier New', monospace;
    font-size: 10px;
    color: rgba(255,255,255,0.2);
    z-index: 60;
    pointer-events: none;
    letter-spacing: 1px;
}

/* ── HUD ── */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    pointer-events: none;
    z-index: 10;
}

#hud > * {
    pointer-events: auto;
}

#mission-label {
    position: absolute;
    top: 12px;
    left: 16px;
    font-size: 15px;
    color: rgba(255,255,255,0.75);
    letter-spacing: 1px;
}

/* (stats panel moved to canvas rendering + bottom HUD) */

.unit-toggle {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    color: #aaa;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
}

.unit-toggle:hover {
    border-color: rgba(255,255,255,0.3);
    color: #ccc;
}

.unit-toggle.active {
    border-color: #00ff88;
    color: #00ff88;
}

/* ── Bottom Controls (playback + day + abort) ── */
#bottom-controls {
    position: absolute;
    bottom: 12px;
    right: 12px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    z-index: 10;
}

#day-display {
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

#day-display .label {
    color: #aaa;
}

#day-display .value {
    color: #00ff88;
}

#time-controls {
    display: flex;
    gap: 4px;
    align-items: center;
}

.time-btn {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.2);
    color: #ddd;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 36px;
    text-align: center;
}

.time-btn:hover {
    background: rgba(255,255,255,0.15);
}

.time-btn.active {
    background: rgba(0,255,136,0.15);
    border-color: rgba(0,255,136,0.4);
    color: #00ff88;
}

.time-btn.inactive {
    background: rgba(255,60,60,0.12);
    border-color: rgba(255,60,60,0.35);
    color: #ff6666;
}

/* ── View Controls (top right) ── */
#view-controls {
    position: absolute;
    top: 36px;
    right: 16px;
    display: flex;
    gap: 6px;
}

.view-icon {
    align-self: center;
    margin-right: 2px;
}

.view-btn {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.2);
    color: #ddd;
    width: 36px;
    height: 36px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.view-btn:hover {
    background: rgba(255,255,255,0.15);
}

.view-btn.active {
    background: rgba(0,255,136,0.15);
    border-color: rgba(0,255,136,0.4);
    color: #00ff88;
}

.view-btn.inactive {
    background: rgba(255,60,60,0.12);
    border-color: rgba(255,60,60,0.35);
    color: #ff6666;
}

.time-btn.flash-green, .view-btn.flash-green {
    animation: flashGreen 0.4s ease 3;
}

@keyframes jitter {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-3px, 1px); }
    20% { transform: translate(2px, -2px); }
    30% { transform: translate(-1px, 3px); }
    40% { transform: translate(3px, -1px); }
    50% { transform: translate(-2px, -2px); }
    60% { transform: translate(1px, 3px); }
    70% { transform: translate(-3px, -1px); }
    80% { transform: translate(2px, 2px); }
    90% { transform: translate(-1px, -3px); }
}

.jitter {
    animation: jitter 0.3s ease;
}

@keyframes flashGreen {
    0%, 100% { background: rgba(0,255,136,0.15); border-color: rgba(0,255,136,0.4); color: #00ff88; }
    50% { background: rgba(0,255,136,0.45); border-color: rgba(0,255,136,0.8); color: #fff; }
}

.time-btn.pause-btn.paused {
    background: rgba(255,165,0,0.2);
    border-color: rgba(255,165,0,0.5);
    color: #ffa500;
}

/* ── Burn Panel ── */
#burn-panel {
    display: none;
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(15, 19, 32, 0.95);
    border: 1px solid rgba(255,165,0,0.3);
    border-radius: 8px;
    padding: 20px;
    width: 260px;
    z-index: 20;
}

#burn-panel.visible {
    display: block;
}

#burn-panel h3 {
    color: #ffa500;
    font-size: 14px;
    margin-bottom: 16px;
    letter-spacing: 1px;
}

.burn-field {
    margin-bottom: 16px;
}

.burn-field .field-label {
    color: #aaa;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
}

.burn-field .field-value {
    color: #00ff88;
    font-size: 18px;
}

.burn-field .field-sub {
    color: #888;
    font-size: 11px;
    margin-top: 2px;
}

#burn-angle-dial {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid #444;
    position: relative;
    background: rgba(255,255,255,0.03);
    cursor: pointer;
    margin: 8px 0;
}

#burn-angle-input, #burn-duration-input {
    background: #1a1f35;
    border: 1px solid #333;
    color: #00ff88;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    padding: 6px 10px;
    border-radius: 4px;
    width: 100%;
}

#burn-duration-slider {
    width: 100%;
    accent-color: #00ff88;
    margin: 8px 0;
}

.burn-buttons {
    display: flex;
    gap: 8px;
    margin-top: 20px;
}

.burn-btn {
    flex: 1;
    padding: 10px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    cursor: pointer;
    border: 1px solid;
    transition: all 0.2s;
}

.burn-btn.execute {
    background: rgba(0,255,136,0.15);
    border-color: #00ff88;
    color: #00ff88;
}

.burn-btn.execute:hover {
    background: rgba(0,255,136,0.3);
}

.burn-btn.cancel {
    background: rgba(255,255,255,0.05);
    border-color: #444;
    color: #888;
}

.burn-btn.cancel:hover {
    background: rgba(255,255,255,0.1);
}

/* ── Launch Setup ── */
#launch-setup {
    display: none;
    position: absolute;
    left: 32px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(15, 19, 32, 0.97);
    border: 1px solid rgba(0,255,136,0.3);
    border-radius: 12px;
    padding: 32px;
    width: 340px;
    z-index: 30;
    text-align: center;
}

#launch-setup.visible {
    display: block;
}

#launch-setup h2 {
    color: #00ff88;
    font-size: 20px;
    margin-bottom: 8px;
    letter-spacing: 2px;
}

#launch-setup .subtitle {
    color: #aaa;
    font-size: 14px;
    margin-bottom: 24px;
}

.launch-field {
    margin-bottom: 20px;
    text-align: left;
}

.launch-field label {
    display: block;
    color: #aaa;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
}

.launch-field input[type="range"] {
    width: 100%;
    accent-color: #00ff88;
}

.launch-field .range-labels {
    display: flex;
    justify-content: space-between;
    color: #888;
    font-size: 11px;
    margin-top: 4px;
}

.launch-field .current-value {
    color: #00ff88;
    font-size: 18px;
    margin-top: 4px;
}

.fine-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 4px;
}

.fine-btn {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.2);
    color: #ccc;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 48px;
}

.fine-btn:hover {
    background: rgba(0,255,136,0.15);
    border-color: rgba(0,255,136,0.4);
    color: #00ff88;
}

.fine-btn:active {
    background: rgba(0,255,136,0.25);
}

#launch-angle-canvas {
    width: 120px;
    height: 120px;
    margin: 0 auto 8px;
    display: block;
    cursor: pointer;
}

#launch-btn {
    background: rgba(0,255,136,0.2);
    border: 2px solid #00ff88;
    color: #00ff88;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    padding: 12px 40px;
    border-radius: 6px;
    cursor: pointer;
    letter-spacing: 2px;
    transition: all 0.2s;
    margin-top: 8px;
}

#launch-btn:hover {
    background: rgba(0,255,136,0.35);
    box-shadow: 0 0 20px rgba(0,255,136,0.2);
}

/* ── Title Screen ── */
#title-screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    background: radial-gradient(ellipse at center, #0f1429 0%, #0a0e27 70%);
    overflow-y: auto;
    padding: 20px;
}

#title-screen h1 {
    font-size: 56px;
    color: #00ff88;
    letter-spacing: 8px;
    text-shadow: 0 0 30px rgba(0,255,136,0.3);
    margin-bottom: 8px;
}

#title-screen .tagline {
    color: #ccc;
    font-size: 16px;
    letter-spacing: 3px;
    margin-bottom: 48px;
}

.mission-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 360px;
}

.mission-card {
    display: block;
    width: 100%;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 16px 20px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    font-family: 'Courier New', monospace;
    color: inherit;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
}

.mission-card:hover {
    background: rgba(0,255,136,0.08);
    border-color: rgba(0,255,136,0.3);
}

.mission-card.locked {
    opacity: 0.4;
    cursor: not-allowed;
}

.mission-card .mission-name {
    color: #00ff88;
    font-size: 16px;
    margin-bottom: 4px;
}

.mission-card .mission-desc {
    color: #ccc;
    font-size: 13px;
}

/* ── Briefing Screen ── */
#briefing-screen {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    background: rgba(10, 14, 39, 0.95);
    flex-direction: column;
    align-items: center;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    padding: 40px 16px;
}

#briefing-screen.visible {
    display: flex;
}

#briefing-screen h2 {
    color: #00ff88;
    font-size: 28px;
    letter-spacing: 4px;
    margin-bottom: 8px;
}

#briefing-screen .mission-subtitle {
    color: #ffa500;
    font-size: 15px;
    margin-bottom: 32px;
}

#briefing-text {
    color: #ddd;
    font-size: 15px;
    line-height: 1.8;
    max-width: 500px;
    text-align: left;
    margin-bottom: 32px;
}

#briefing-objectives {
    max-width: 500px;
    text-align: left;
    margin-bottom: 32px;
}

#briefing-objectives h3 {
    color: #ffa500;
    font-size: 14px;
    letter-spacing: 2px;
    margin-bottom: 12px;
}

#briefing-objectives li {
    color: #ddd;
    font-size: 14px;
    margin-bottom: 6px;
    list-style: none;
    padding-left: 16px;
    position: relative;
}

#briefing-objectives li::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: #00ff88;
}

#begin-mission-btn {
    background: rgba(0,255,136,0.15);
    border: 2px solid #00ff88;
    color: #00ff88;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    padding: 12px 36px;
    border-radius: 6px;
    cursor: pointer;
    letter-spacing: 2px;
    transition: all 0.2s;
}

#begin-mission-btn:hover {
    background: rgba(0,255,136,0.3);
}

/* ── Result Screen ── */
#result-screen {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 40;
    background: rgba(10, 14, 39, 0.45);
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 24px 32px;
}

#result-screen.visible {
    display: flex;
}

#result-screen h2 {
    font-size: 26px;
    letter-spacing: 3px;
    margin-bottom: 4px;
}

#result-screen h2.success {
    color: #00ff88;
}

#result-screen h2.failure {
    color: #ff4444;
}

#result-message {
    color: #aaa;
    font-size: 14px;
    margin-bottom: 8px;
}

#result-stats {
    margin-bottom: 8px;
    font-size: 13px;
    line-height: 1.6;
}

#result-stats .stat-label {
    color: #aaa;
}

#result-stats .stat-value {
    color: #00ff88;
}

#result-records {
    margin-top: 8px;
    margin-bottom: 12px;
}

.result-buttons {
    display: flex;
    gap: 12px;
    margin-top: auto;
    padding-bottom: 16px;
}

.result-btn {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.2);
    color: #ddd;
    font-family: 'Courier New', monospace;
    font-size: 15px;
    padding: 10px 28px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.result-btn:hover {
    background: rgba(255,255,255,0.15);
}

.result-btn.primary {
    background: rgba(0,255,136,0.15);
    border-color: #00ff88;
    color: #00ff88;
}

/* ── Mission Checklist ── */
#checklist-panel {
    position: absolute;
    top: 76px;
    right: 16px;
    text-align: right;
    font-size: 13px;
    line-height: 1.9;
}

.check-item {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}

.check-icon {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    display: inline-block;
    flex-shrink: 0;
}

.check-icon.pending {
    background: #ff4444;
    box-shadow: 0 0 4px rgba(255, 68, 68, 0.4);
}

.check-icon.done {
    background: #00ff88;
    box-shadow: 0 0 4px rgba(0, 255, 136, 0.4);
}

.check-label {
    color: #888;
}

.check-label.done {
    color: #00ff88;
}

/* ── Abort Button (inside bottom-controls) ── */
#btn-abort {
    background: rgba(255, 68, 68, 0.15);
    border: 1px solid rgba(255, 68, 68, 0.4);
    color: #ff4444;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 1px;
}

#btn-abort:hover {
    background: rgba(255, 68, 68, 0.3);
    border-color: rgba(255, 68, 68, 0.7);
}

/* ── Records Screen ── */
#records-screen {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 45;
    background: rgba(10, 14, 39, 0.97);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 40px;
}

#records-screen.visible {
    display: flex;
}

#records-content {
    max-width: 600px;
    width: 100%;
}

.records-category {
    margin-bottom: 24px;
}

.records-category h3 {
    color: #00ff88;
    font-size: 15px;
    letter-spacing: 2px;
    margin-bottom: 12px;
}

.record-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 14px;
}

.record-label {
    color: #aaa;
}

.record-value {
    color: #4a7a9e;
}

.record-value.has-record {
    color: #00ff88;
}

.record-star {
    color: #ffd700;
    font-size: 14px;
    margin-left: 6px;
}

.record-achievement {
    color: #ffd700;
    font-size: 10px;
    margin-left: 4px;
    letter-spacing: 1px;
}

.record-spoiler-btn {
    display: inline-block;
    font-size: 10px;
    cursor: pointer;
    margin-left: 6px;
    background: rgba(74, 122, 158, 0.15);
    border: 1px solid rgba(74, 122, 158, 0.4);
    color: #4a7a9e;
    font-family: 'Courier New', monospace;
    padding: 2px 8px;
    border-radius: 3px;
}

.record-spoiler-btn:hover {
    background: rgba(74, 122, 158, 0.25);
    color: #6a9abe;
}

.record-spoiler-value {
    display: none;
    color: #ffd700;
    font-size: 10px;
    margin-left: 6px;
    cursor: pointer;
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.3);
    padding: 2px 8px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
}

.record-spoiler-btn.revealed {
    display: none;
}

.record-spoiler-btn.revealed + .record-spoiler-value {
    display: inline;
}

/* ── Result Records ── */
#result-records {
    margin-top: 16px;
    font-size: 12px;
    line-height: 1.8;
    max-width: 400px;
}

.record-broken {
    color: #00ff88;
}

.record-achieved {
    color: #ffd700;
    font-weight: bold;
}

/* ── Mobile: title screen + overlays only ── */
@media (max-width: 768px) {
    #title-screen {
        justify-content: flex-start;
        padding: 24px 16px 20px;
    }
    #title-screen h1 { font-size: 36px; letter-spacing: 4px; margin-bottom: 4px; }
    #title-screen .tagline { font-size: 12px; letter-spacing: 2px; margin-bottom: 20px; }
    #title-screen #byline { font-size: 11px; }
    .mission-list { width: 90vw; max-width: 320px; }
    .mission-card .mission-name { font-size: 14px; }
    .mission-card .mission-desc { font-size: 11px; }

    /* Briefing — smaller text */
    #briefing-text { font-size: 13px; max-width: 90vw; padding: 0 16px; }
    #briefing-objectives { max-width: 90vw; padding: 0 16px; }

    /* Records */
    #records-screen { padding: 20px 16px; }
    .record-row { font-size: 12px; flex-wrap: wrap; gap: 4px; }
    .record-label { flex-basis: 100%; }
}

/* ── Utility ── */
.hidden {
    display: none !important;
}
