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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #87CEEB;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

canvas {
    display: block;
}

/* Loading screen */
#loading {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a2e;
    color: #e0e0e0;
    font-size: 1.5rem;
    z-index: 100;
}

/* Controls overlay */
#controls-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    z-index: 50;
}

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

.controls-panel {
    background: #1e1e2e;
    color: #e0e0e0;
    padding: 2rem 2.5rem;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    text-align: center;
    max-width: 400px;
}

.controls-panel h2 {
    margin-bottom: 1.2rem;
    color: #87CEEB;
    font-size: 1.6rem;
}

.controls-panel table {
    margin: 0 auto 1.5rem;
    border-collapse: collapse;
}

.controls-panel td {
    padding: 0.4rem 0.8rem;
    text-align: left;
}

.controls-panel td:first-child {
    text-align: right;
    width: 80px;
}

kbd {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    background: #2d2d44;
    border: 1px solid #4a4a6a;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: #87CEEB;
    min-width: 40px;
    text-align: center;
}

#start-btn {
    padding: 0.7rem 2rem;
    background: #4a90d9;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

#start-btn:hover {
    background: #5aa0e9;
}

/* Plane selection menu */
#plane-menu {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    z-index: 58;
}

#plane-menu.hidden {
    display: none;
}

.plane-menu-panel {
    background: #1e1e2e;
    color: #e0e0e0;
    padding: 0 0 1.25rem 0;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    text-align: center;
    max-width: 720px;
    width: calc(100% - 2rem);
    max-height: min(92vh, 900px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Horizontal category tab bar */
.plane-tabs {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    border-bottom: 1px solid #4a4a6a;
}

.plane-tab {
    background: transparent;
    border: none;
    border-right: 1px solid #4a4a6a;
    color: #8899aa;
    padding: 1rem 0.5rem;
    font-size: 1rem;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.plane-tab:last-child {
    border-right: none;
}

.plane-tab:hover {
    background: #2d2d44;
    color: #ffffff;
}

.plane-tab.active {
    background: #2d2d44;
    color: #87CEEB;
    box-shadow: inset 0 -3px 0 #87CEEB;
}

/* Toolbar: heading + landscape picker */
.plane-menu-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 1.4rem 1.4rem 1.2rem;
    flex-wrap: wrap;
}

.plane-menu-heading {
    margin: 0;
    color: #e0e0e0;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-align: left;
}

.landscape-picker {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-left: auto;
}

.landscape-label {
    color: #8899aa;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 600;
}

.landscape-buttons {
    display: flex;
    gap: 0.45rem;
}

.landscape-btn {
    position: relative;
    width: 72px;
    height: 52px;
    border-radius: 8px;
    border: 2px solid #4a4a6a;
    padding: 0;
    cursor: pointer;
    overflow: hidden;
    background: #1a1a28;
    color: #e0e0e0;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
    flex-shrink: 0;
}

.landscape-btn:hover {
    border-color: #87CEEB;
    transform: translateY(-1px);
}

.landscape-btn.selected {
    border-color: #87CEEB;
    box-shadow: 0 0 0 2px rgba(135, 206, 235, 0.35), 0 4px 14px rgba(74, 144, 217, 0.35);
}

.landscape-btn canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.landscape-btn .landscape-btn-name {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 0.18rem 0.2rem;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.78));
    color: #f2f6fa;
    text-align: center;
    pointer-events: none;
}

/* Plane cards — scroll so every plane in a category stays reachable */
.plane-cards {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 0 2rem 0.5rem;
    overflow-x: hidden;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    max-height: min(58vh, 520px);
    scrollbar-width: thin;
    scrollbar-color: #4a90d9 #2a2a40;
}

.plane-cards::-webkit-scrollbar {
    width: 8px;
}

.plane-cards::-webkit-scrollbar-thumb {
    background: #4a90d9;
    border-radius: 8px;
}

.plane-card {
    background: #2d2d44;
    border: 1px solid #4a4a6a;
    border-radius: 10px;
    padding: 1rem;
    color: #e0e0e0;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.2s, background 0.2s, transform 0.15s;
    display: flex;
    align-items: center;
    gap: 1.2rem;
}

.plane-card:hover {
    border-color: #87CEEB;
    background: #34344f;
    transform: translateY(-2px);
}

.plane-card .plane-preview {
    width: 160px;
    height: 120px;
    flex-shrink: 0;
    border-radius: 8px;
    background: linear-gradient(160deg, #20203a, #2a2a48);
    border: 1px solid #3a3a55;
    display: block;
}

.plane-card .plane-info {
    flex: 1;
    min-width: 0;
}

.plane-card .plane-title {
    font-size: 1.15rem;
    font-weight: bold;
    color: #ffffff;
}

.plane-card .plane-desc {
    font-size: 0.85rem;
    color: #8899aa;
    margin-top: 0.3rem;
}

.plane-card .plane-best {
    margin-top: 0.55rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.28rem 0.65rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    color: #c8e6ff;
    background: rgba(74, 144, 217, 0.18);
    border: 1px solid rgba(135, 206, 235, 0.35);
}

.plane-card .plane-best.empty {
    color: #7a8a9a;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.04);
    border-color: #4a4a6a;
}

.plane-card .plane-best.perfect {
    color: #052e16;
    background: linear-gradient(135deg, #4ade80, #86efac);
    border-color: #86efac;
    box-shadow: 0 0 12px rgba(74, 222, 128, 0.35);
}

.plane-card.best-perfect {
    border-color: rgba(74, 222, 128, 0.55);
}

.plane-card .plane-fly {
    margin-top: 0.7rem;
    padding: 0.45rem 1.1rem;
    background: #4a90d9;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s;
}

.plane-card .plane-fly:hover {
    background: #5aa0e9;
}

.plane-empty-note {
    color: #8899aa;
    font-size: 1rem;
    padding: 2rem;
}

/* Crash overlay */
#crash-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    z-index: 60;
}

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

.crash-panel {
    background: #2a1a1a;
    color: #ffcccc;
    padding: 2rem 2.5rem;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(120, 0, 0, 0.5);
    text-align: center;
    max-width: 400px;
    border: 2px solid #8b2020;
}

.crash-panel h2 {
    margin-bottom: 1rem;
    color: #ff4444;
    font-size: 1.8rem;
}

.crash-panel p {
    margin-bottom: 1.5rem;
    color: #d0a0a0;
    font-size: 1rem;
}

#restart-btn {
    padding: 0.7rem 2rem;
    background: #c0392b;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

#restart-btn:hover {
    background: #e74c3c;
}

/* Pause overlay */
#pause-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    z-index: 55;
}

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

.pause-panel {
    background: #1e1e2e;
    color: #e0e0e0;
    padding: 2rem 2.5rem;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    text-align: center;
    max-width: 400px;
}

.pause-panel h2 {
    margin-bottom: 1.2rem;
    color: #87CEEB;
    font-size: 1.6rem;
}

.pause-panel table {
    margin: 0 auto 1.5rem;
    border-collapse: collapse;
}

.pause-panel td {
    padding: 0.4rem 0.8rem;
    text-align: left;
}

.pause-panel td:first-child {
    text-align: right;
    width: 100px;
}

#unpause-btn {
    padding: 0.7rem 2rem;
    background: #4a90d9;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

#unpause-btn:hover {
    background: #5aa0e9;
}

/* HUD overlay */
#hud {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 40;
    font-family: 'Courier New', monospace;
}

#hud.hidden {
    display: none;
}

#pause-btn {
    position: absolute;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 1.5rem;
    background: rgba(0, 0, 0, 0.4);
    color: #e0e0e0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    pointer-events: auto;
    transition: background 0.2s;
    font-family: 'Courier New', monospace;
}

#pause-btn:hover {
    background: rgba(0, 0, 0, 0.6);
}

.respawn-btn {
    position: absolute;
    top: 3.8rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 1.5rem;
    background: rgba(0, 0, 0, 0.4);
    color: #e0e0e0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    pointer-events: auto;
    transition: background 0.2s;
    font-family: 'Courier New', monospace;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.respawn-btn:hover {
    background: rgba(0, 0, 0, 0.6);
}

.respawn-btn kbd {
    font-size: 0.75rem;
    padding: 0.1rem 0.4rem;
    min-width: auto;
}

.hud-top-left {
    position: absolute;
    top: 1rem;
    left: 1rem;
}

.hud-top-right {
    position: absolute;
    top: 1rem;
    right: 1rem;
    text-align: right;
}

.hud-item {
    background: rgba(0, 0, 0, 0.4);
    color: #e0e0e0;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    margin-bottom: 0.4rem;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.hud-top-right .hud-item {
    justify-content: flex-end;
}

.hud-label {
    color: #8899aa;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.hud-value {
    color: #ffffff;
    font-size: 1rem;
    font-weight: bold;
    min-width: 60px;
}

.hud-value.on {
    color: #4ade80;
}

.hud-value.active {
    color: #fbbf24;
}

/* Clock / time-of-day readout */
.hud-clock {
    flex-wrap: wrap;
    justify-content: flex-end;
}

.hud-clock .hud-value {
    min-width: auto;
}

.hud-clock .hud-value.fast {
    color: #fbbf24;
}

.hud-phase {
    color: #8899aa;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    width: 100%;
    text-align: right;
}

.hud-warning {
    color: #fbbf24;
    font-size: 1rem;
    font-weight: bold;
    animation: blink 0.5s infinite;
}

#hud-stall-warning {
    display: none;
}

#hud-stall-warning.visible {
    display: block;
}

#fuel-low-warning {
    display: none;
}

#fuel-low-warning.visible {
    display: block;
}

.fuel-bar {
    width: 90px;
    height: 12px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 3px;
    overflow: hidden;
}

.fuel-fill {
    height: 100%;
    width: 100%;
    background: #4ade80;
    transition: width 0.15s linear, background 0.3s;
}

.fuel-fill.med {
    background: #fbbf24;
}

.fuel-fill.low {
    background: #ef4444;
    animation: blink 0.5s infinite;
}

.hud-fuel .hud-value {
    min-width: 42px;
    text-align: right;
}

.thrust-bar {
    width: 90px;
    height: 12px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 3px;
    overflow: hidden;
}

.thrust-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #38bdf8, #a78bfa);
    transition: width 0.1s linear;
}

.hud-thrust .hud-value {
    min-width: 42px;
    text-align: right;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Landing score card — pops in after a safe touchdown */
.landing-score {
    position: absolute;
    left: 50%;
    bottom: 2.2rem;
    transform: translateX(-50%) translateY(0);
    min-width: 220px;
    padding: 0.85rem 1.15rem 1rem;
    background: rgba(8, 14, 24, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
    text-align: center;
    color: #e8eef6;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.45s ease, transform 0.45s ease;
}

.landing-score.hidden {
    display: none;
}

.landing-score.fade-out {
    opacity: 0;
    transform: translateX(-50%) translateY(12px);
}

.landing-score.new-best {
    border-color: rgba(74, 222, 128, 0.55);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35), 0 0 22px rgba(74, 222, 128, 0.28);
}

.landing-new-best {
    display: inline-block;
    margin-bottom: 0.4rem;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: #052e16;
    background: linear-gradient(135deg, #4ade80, #86efac);
}

.landing-score-title {
    color: #8899aa;
    font-size: 0.7rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 0.2rem;
}

.landing-score-grade {
    font-size: 1.55rem;
    font-weight: bold;
    letter-spacing: 1px;
    line-height: 1.15;
    margin-bottom: 0.15rem;
}

.landing-score-grade.grade-perfect { color: #4ade80; }
.landing-score-grade.grade-great   { color: #86efac; }
.landing-score-grade.grade-good    { color: #38bdf8; }
.landing-score-grade.grade-fair    { color: #fbbf24; }
.landing-score-grade.grade-rough   { color: #fb923c; }

.landing-score-points {
    font-size: 1.15rem;
    font-weight: bold;
    color: #ffffff;
    margin-bottom: 0.65rem;
}

.landing-score-max {
    color: #8899aa;
    font-size: 0.85rem;
    font-weight: normal;
    margin-left: 0.15rem;
}

.landing-score-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem 0.85rem;
    text-align: left;
}

.landing-stat {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.2rem 0.35rem;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 4px;
}

.landing-stat-label {
    color: #8899aa;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.landing-stat-value {
    color: #e8eef6;
    font-size: 0.82rem;
    font-weight: bold;
    font-variant-numeric: tabular-nums;
}
