/* ---------------------------------------------------------------
   SkyTycoon — Operations Console
   Design concept: a real flight-ops tool, not a mobile game menu.
   Reference points: FlightRadar24/FlightAware's dark map-first
   layouts, airline OCC (operations control center) dashboards with
   data panels docked around a live map, and Duolingo-style XP bars
   for legible at-a-glance progress. The map is the home view; the
   sidebar/topbar are the instrument panel around it.
   ---------------------------------------------------------------- */
:root {
  --bg: #0b1220;
  --bg-raised: #101a2c;
  --panel: #131f34;
  --panel-line: rgba(148, 172, 209, 0.14);

  --cyan: #22d3ee;
  --cyan-dim: #0e7490;
  --amber: #f5b942;
  --amber-dim: #8a611f;
  --grass: #34d399;
  --grass-dim: #0f766e;
  --sunset: #f2685c;

  --ink: #eaf1fb;
  --ink-soft: #9fb0cc;
  --ink-faint: #5c6d8c;

  --font-display: 'Fredoka', sans-serif;
  --font-body: 'Nunito', -apple-system, sans-serif;

  --radius: 14px;
  --radius-sm: 10px;
  --sidebar-w: 220px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-body);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
}

body {
  background-image: radial-gradient(circle at 90% -10%, rgba(34, 211, 238, 0.08), transparent 45%);
}

/* ---------------- App shell ---------------- */

.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-raised);
  border-right: 1px solid var(--panel-line);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  gap: 22px;
}

.sidebar__brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  color: var(--cyan);
  padding: 4px 10px;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.navitem {
  appearance: none;
  background: none;
  border: none;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}

.navitem:hover { background: rgba(255, 255, 255, 0.04); color: var(--ink); }

.navitem.is-active {
  background: rgba(34, 211, 238, 0.12);
  color: var(--cyan);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

/* ---------------- Topbar ---------------- */

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--panel-line);
  background: var(--bg-raised);
}

.topbar__player {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 220px;
}

.topbar__name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  white-space: nowrap;
}

.xp-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.xp-bar__level {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  color: #1a1305;
  background: var(--amber);
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.xp-bar__track {
  width: 110px;
  height: 7px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.xp-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan-dim), var(--cyan));
  border-radius: 999px;
  transition: width 0.4s ease;
}

.topbar__readouts {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
}

.readout {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.readout__label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.readout__value {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  font-size: 19px;
  font-weight: 600;
  color: var(--amber);
}

.readout--dim .readout__value { font-size: 15px; color: var(--ink); }

.board__account {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-soft);
}

.board__account a { color: var(--cyan); text-decoration: none; }

/* ---------------- Event banner ---------------- */

.event-banner {
  background: rgba(245, 185, 66, 0.12);
  border-bottom: 1px solid rgba(245, 185, 66, 0.35);
  padding: 8px 22px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--amber);
}

/* ---------------- Content / panels ---------------- */

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 22px;
}

.panel--map {
  padding: 0;
  overflow: hidden;
}

#world-map {
  width: 100%;
  height: 100%;
  background: var(--panel);
}

.panel__block { margin-bottom: 30px; }

.panel__title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 14px;
}

.map-hint {
  position: absolute;
  z-index: 500;
  margin: 14px;
  background: rgba(11, 18, 32, 0.85);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  max-width: 320px;
}

/* ---------------- Cards ---------------- */

.cardgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.empty-note { color: var(--ink-faint); font-size: 13.5px; font-weight: 600; grid-column: 1 / -1; }

.card {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card--owned { border-color: rgba(52, 211, 153, 0.4); }

.card__head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card__name { font-family: var(--font-display); font-size: 15px; font-weight: 600; color: var(--ink); }

.card__tag {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--bg);
  background: var(--cyan);
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.card--owned .card__tag { background: var(--grass); }

.card__stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 600;
}
.card__stats span b { color: var(--ink); font-weight: 800; }

.card__foot { display: flex; justify-content: space-between; align-items: center; margin-top: 2px; }
.card__price { font-family: var(--font-display); font-size: 15px; font-weight: 600; color: var(--amber); }
.card__status { font-size: 11.5px; font-weight: 700; color: var(--grass); }

.buy-btn {
  appearance: none;
  cursor: pointer;
  background: var(--cyan);
  border: none;
  color: #052730;
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  transition: transform 0.1s ease, background 0.15s ease;
}
.buy-btn:hover:not(:disabled) { transform: translateY(-1px); background: #52e2fb; }
.buy-btn:disabled { background: #263349; color: var(--ink-faint); cursor: not-allowed; }

.repair-btn {
  appearance: none;
  cursor: pointer;
  background: none;
  border: 1px solid var(--sunset);
  color: var(--sunset);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
}
.repair-btn:hover { background: var(--sunset); color: #fff; }

/* ---------------- Ticker ---------------- */

.ticker {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-raised);
  border-top: 1px solid var(--panel-line);
  padding: 9px 22px;
}
.ticker__label {
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--bg);
  background: var(--cyan);
  padding: 2px 9px;
  border-radius: 999px;
  flex-shrink: 0;
}
.ticker__tape {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------------- Toast ---------------- */

.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  background: var(--panel);
  border: 1px solid var(--grass);
  color: var(--ink);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  max-width: 280px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4);
}
.toast--error { border-color: var(--sunset); }

/* ---------------- Map markers / popup ---------------- */

.map-marker { font-size: 22px; line-height: 1; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5)); position: relative; }
.map-marker--plane { font-size: 18px; }
.map-marker--low-fuel::after {
  content: '⛽';
  position: absolute;
  top: -6px;
  right: -8px;
  font-size: 11px;
  filter: drop-shadow(0 0 2px #000);
}

.map-popup { font-family: var(--font-body); color: #1a2333; }
.map-popup h4 { margin: 0 0 4px; font-family: var(--font-display); font-size: 14px; }
.map-popup p { margin: 0 0 6px; font-size: 12.5px; color: #445; font-weight: 600; }
.map-popup select {
  width: 100%; font-family: var(--font-body); font-size: 12.5px; font-weight: 700;
  padding: 6px 8px; border-radius: 8px; border: 1px solid #ccd6e6; margin-bottom: 6px;
}
.map-popup .buy-btn { width: 100%; text-align: center; }

.dispatch-price-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.dispatch-price-row input[type="range"] { flex: 1; }
.dispatch-price-value { font-family: var(--font-display); font-size: 12px; font-weight: 600; color: #8a611f; min-width: 46px; text-align: right; }
.dispatch-estimate { font-size: 11.5px; font-weight: 700; color: #445; margin: 0 0 8px; }

/* ---------------- Fuel market ---------------- */

.fuel-price {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 18px;
}
.fuel-price__value {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 600;
  color: var(--amber);
}
.fuel-price__unit { font-size: 12.5px; color: var(--ink-soft); font-weight: 700; }

.fuel-sparkline { width: 100%; max-width: 480px; height: 60px; display: block; margin-bottom: 22px; }

.fuel-plane-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.fuel-plane-row__name { font-family: var(--font-display); font-weight: 600; font-size: 13.5px; flex: 1; min-width: 160px; }
.fuel-gauge { width: 140px; height: 8px; background: rgba(255,255,255,0.08); border-radius: 999px; overflow: hidden; }
.fuel-gauge__fill { height: 100%; background: var(--grass); }
.fuel-gauge__fill--low { background: var(--sunset); }
.fuel-plane-row__pct { font-size: 11.5px; font-weight: 700; color: var(--ink-soft); min-width: 70px; }

/* ---------------- Leaderboard ---------------- */

.leaderboard { display: flex; flex-direction: column; gap: 8px; }
.leaderboard-row { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--panel-line); border-radius: var(--radius-sm); padding: 10px 16px; }
.leaderboard-row--you { border-color: var(--grass); }
.leaderboard-rank { font-family: var(--font-display); font-weight: 600; color: var(--ink-faint); width: 24px; }
.leaderboard-name { flex: 1; font-weight: 700; font-size: 13.5px; }
.leaderboard-tag { font-size: 10px; font-weight: 700; color: #fff; background: var(--ink-faint); padding: 2px 8px; border-radius: 999px; margin-left: 8px; }
.leaderboard-worth { font-family: var(--font-display); font-weight: 600; color: var(--amber); }

/* ---------------- Account panel ---------------- */

.account-card {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  padding: 20px 22px;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.account-card a.buy-btn, .account-card button.buy-btn { text-decoration: none; text-align: center; display: inline-block; }

/* ---------------- Auth pages ---------------- */

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--panel-line);
  padding: 28px 26px;
  text-align: center;
}
.auth-card .board__mark { justify-content: center; margin-bottom: 2px; font-family: var(--font-display); color: var(--cyan); font-size: 22px; font-weight: 600; }
.auth-card .board__sub { margin-bottom: 20px; color: var(--ink-soft); font-size: 13px; font-weight: 600; }
.auth-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.auth-form label { font-size: 12px; font-weight: 700; color: var(--ink-soft); display: flex; flex-direction: column; gap: 5px; }
.auth-form input {
  font-family: var(--font-body); font-size: 14px; font-weight: 600; color: var(--ink);
  background: var(--bg-raised); padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--panel-line);
}
.auth-form input:focus { outline: none; border-color: var(--cyan); }
.auth-submit { margin-top: 6px; width: 100%; text-align: center; padding: 11px 18px; }
.auth-error, .auth-note {
  font-size: 12.5px; font-weight: 700; padding: 8px 12px; border-radius: var(--radius-sm); margin: 0 0 16px;
}
.auth-error, .auth-note--error { background: rgba(242, 104, 92, 0.12); border: 1px solid var(--sunset); color: var(--sunset); }
.auth-note--ok { background: rgba(52, 211, 153, 0.12); border: 1px solid var(--grass); color: var(--grass); }
.auth-switch { margin: 18px 0 0; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.auth-switch a { color: var(--cyan); font-weight: 700; }

/* ---------------- Simple page header (admin.php) ---------------- */

.board {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--panel-line);
  background: var(--bg-raised);
}
.board__ident { display: flex; flex-direction: column; gap: 2px; }
.board__mark { font-family: var(--font-display); font-weight: 600; font-size: 18px; color: var(--cyan); }
.board__sub { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }

/* ---------------- Admin page ---------------- */

.admin-grid { padding: 22px; display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.admin-grid__full { grid-column: 1 / -1; }
.admin-form { display: flex; flex-direction: column; gap: 10px; background: var(--panel); border: 1px solid var(--panel-line); border-radius: var(--radius); padding: 18px; }
.admin-form label { font-size: 11.5px; font-weight: 700; color: var(--ink-soft); display: flex; flex-direction: column; gap: 4px; }
.admin-form input, .admin-form select {
  font-family: var(--font-body); font-size: 13px; font-weight: 600; color: var(--ink);
  background: var(--bg-raised); padding: 8px 10px; border-radius: 8px; border: 1px solid var(--panel-line);
}
.admin-list { max-height: 280px; overflow-y: auto; background: var(--panel); border: 1px solid var(--panel-line); border-radius: var(--radius); padding: 12px 16px; }
.admin-list__row { font-size: 12.5px; padding: 4px 0; border-bottom: 1px solid var(--panel-line); color: var(--ink-soft); }
.admin-list__row code { color: var(--cyan); }

/* ---------------- Responsive ---------------- */

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    padding: 8px 10px;
    overflow-x: auto;
    order: 2;
  }
  .sidebar__brand { display: none; }
  .sidebar__nav { flex-direction: row; }
  .navitem span { display: none; }
  .main { order: 1; min-height: calc(100vh - 56px); }
  .admin-grid { grid-template-columns: 1fr; }
  .topbar__readouts { gap: 12px; }
  .readout__value { font-size: 16px; }
}
