@import url('https://fonts.googleapis.com/css2?family=Space+Mono:ital,wght@0,400;0,700;1,400;1,700&family=Syne:wght@700;800&display=swap');

/* --- Reset & Core Variables --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  cursor: none; /* Hide default cursor for customized crosshair telemetry */
}

:root {
  --bg: #000000;
  --fg: #ffffff;
  --gray-dim: #111111;
  --gray-mid: #333333;
  --gray-light: #888888;
  --border-thick: 2px solid var(--fg);
  --border-thin: 1px solid var(--gray-mid);
  --border-dashed: 1px dashed var(--fg);
  --font-mono: 'Space Mono', monospace;
  --font-sans: 'Syne', sans-serif;
  --scanline-color: rgba(255, 255, 255, 0.03);
}

body {
  background-color: var(--bg);
  color: var(--fg);
  font-family: var(--font-mono);
  overflow-x: hidden;
  position: relative;
  min-height: 100vh;
  line-height: 1.5;
  letter-spacing: 0.05em;
}

/* --- CRT Scanlines & Screen Flicker --- */
body::before {
  content: " ";
  display: block;
  position: fixed;
  top: 0; left: 0; bottom: 0; right: 0;
  background: linear-gradient(var(--scanline-color) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.02), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.02));
  z-index: 9999;
  background-size: 100% 4px, 3px 100%;
  pointer-events: none;
}

/* --- Interactive Telemetry Cursor --- */
#custom-cursor {
  position: fixed;
  top: 0;
  left: 0;
  width: 24px;
  height: 24px;
  border: 1px solid var(--fg);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 10000;
  transition: width 0.1s, height 0.1s, background-color 0.1s;
}

#custom-cursor::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 4px;
  background-color: var(--fg);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

#custom-cursor-data {
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 10000;
  font-size: 8px;
  color: var(--gray-light);
  transform: translate(18px, 12px);
  white-space: nowrap;
  line-height: 1.2;
}

/* Hover cursor adjustments */
.interactive-hover:hover ~ #custom-cursor,
a:hover ~ #custom-cursor,
button:hover ~ #custom-cursor,
input:hover ~ #custom-cursor,
#custom-cursor.cursor-hover {
  width: 32px;
  height: 32px;
  background-color: rgba(255, 255, 255, 0.1);
  border-style: dashed;
}

/* --- Background Radar & Grid System --- */
.grid-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-image: 
    linear-gradient(to right, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  background-position: center;
  z-index: -2;
  pointer-events: none;
}

.radar-sweep {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 150vmax;
  height: 150vmax;
  transform: translate(-50%, -50%);
  background: conic-gradient(from 0deg at 50% 50%, rgba(255, 255, 255, 0.08) 0deg, transparent 90deg, transparent 360deg);
  z-index: -1;
  pointer-events: none;
  animation: radar-rotate 16s linear infinite;
}

@keyframes radar-rotate {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* --- Layout Containers --- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px;
  position: relative;
  z-index: 10;
}

/* --- Typography Utilities --- */
.stencil-text {
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 800;
  -webkit-text-stroke: 1px var(--fg);
  -webkit-text-fill-color: transparent;
}

h1, h2, h3, h4 {
  font-family: var(--font-sans);
  text-transform: uppercase;
  font-weight: 800;
}

.title-main {
  font-size: clamp(3rem, 10vw, 7rem);
  line-height: 0.85;
  margin-bottom: 10px;
  text-align: left;
  word-break: break-all;
}

.title-sub {
  font-size: 14px;
  text-align: left;
  color: var(--gray-light);
  letter-spacing: 0.3em;
  margin-bottom: 20px;
}

/* --- Hero --- */
.hero-deck {
  margin-bottom: 48px;
}

/* --- Header & Warning Deck --- */
header {
  border-bottom: var(--border-thin);
  padding: 20px 0;
  margin-bottom: 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.top-bar-notice {
  font-size: 10px;
  border: 1px solid var(--fg);
  padding: 4px 10px;
  display: inline-block;
  font-weight: bold;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
}

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

.timezone-label {
  font-size: 8px;
  color: var(--gray-light);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.timezone-select {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--gray-mid);
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 6px 10px;
  min-width: 200px;
  max-width: 280px;
  text-transform: uppercase;
}

.timezone-select:focus {
  outline: none;
  border-color: var(--fg);
}

/* --- VRChat Badge Styling (Custom Stencil) --- */
.vrchat-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border: var(--border-thick);
  background-color: var(--fg);
  color: var(--bg);
  text-decoration: none;
  font-weight: bold;
  font-size: 11px;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.vrchat-badge svg {
  fill: var(--bg);
  transition: fill 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.vrchat-badge:hover {
  background-color: var(--bg);
  color: var(--fg);
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.4);
}

.vrchat-badge:hover svg {
  fill: var(--fg);
}

/* --- Structural Panels --- */
.panel {
  background-color: rgba(10, 10, 10, 0.85);
  border: var(--border-thick);
  padding: 30px;
  margin-bottom: 40px;
  position: relative;
  backdrop-filter: blur(10px);
}

/* Stencil corner marks */
.panel::before, .panel::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  border: 1px solid var(--fg);
  pointer-events: none;
}

.panel::before { top: 5px; left: 5px; border-right: none; border-bottom: none; }
.panel::after { bottom: 5px; right: 5px; border-left: none; border-top: none; }

.panel-header {
  border-bottom: var(--border-dashed);
  padding-bottom: 15px;
  margin-bottom: 25px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-title {
  font-size: 18px;
  letter-spacing: 0.15em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-title::before {
  content: '//';
  color: var(--gray-light);
}

/* --- Scheduled Flights Log (Table layout) --- */
.flight-grid {
  width: 100%;
  border-collapse: collapse;
  margin-top: 15px;
}

.flight-grid th {
  text-align: left;
  padding: 12px 10px;
  border-bottom: var(--border-thick);
  font-size: 11px;
  color: var(--gray-light);
  text-transform: uppercase;
}

.flight-grid td {
  padding: 18px 10px;
  border-bottom: var(--border-thin);
  font-size: 13px;
  vertical-align: middle;
}

.flight-row {
  transition: background-color 0.2s ease;
}

.flight-row:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.flight-row.selected-flight {
  background-color: rgba(255, 255, 255, 0.1);
  border-left: 4px solid var(--fg);
}

.schedule-wrap {
  margin-top: 15px;
}

.flight-lineup {
  color: var(--gray-light);
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: bold;
  border: 1px solid var(--fg);
  text-transform: uppercase;
}

.status-boarding {
  background-color: var(--fg);
  color: var(--bg);
  animation: blink 1.2s infinite;
}

.status-ontime {
  border-color: var(--fg);
  color: var(--fg);
}

.status-delayed {
  border-color: var(--gray-light);
  color: var(--gray-light);
}

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

.input-group {
  margin-bottom: 20px;
  position: relative;
}

.input-label {
  display: block;
  font-size: 11px;
  color: var(--gray-light);
  margin-bottom: 8px;
  text-transform: uppercase;
}

.input-field {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--gray-mid);
  color: var(--fg);
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 14px;
  transition: border-color 0.3s;
}

.input-field:focus {
  outline: none;
  border-color: var(--fg);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

.departure-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.departure-picker-sublabel {
  display: block;
  font-size: 9px;
  color: var(--gray-light);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.departure-input {
  padding: 10px 8px;
  font-size: 12px;
  color-scheme: dark;
  min-height: 42px;
}

.departure-input::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
  opacity: 0.85;
}

.departure-quick-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.departure-quick-btn {
  background: transparent;
  color: var(--gray-light);
  border: 1px solid var(--gray-mid);
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: border-color 0.2s, color 0.2s;
}

.departure-quick-btn:hover {
  border-color: var(--fg);
  color: var(--fg);
}

@media (max-width: 480px) {
  .departure-picker {
    grid-template-columns: 1fr;
  }
}

.btn-primary {
  width: 100%;
  background: var(--fg);
  color: var(--bg);
  border: var(--border-thick);
  padding: 15px;
  font-family: var(--font-sans);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 14px;
  letter-spacing: 0.1em;
  transition: all 0.2s ease;
  margin-top: 10px;
}

.btn-primary:hover {
  background: var(--bg);
  color: var(--fg);
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

.btn-secondary {
  width: 100%;
  background: transparent;
  color: var(--fg);
  border: var(--border-thin);
  padding: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  transition: all 0.2s ease;
  margin-top: 15px;
}

.btn-secondary:hover {
  border-color: var(--fg);
  background-color: rgba(255, 255, 255, 0.05);
}

/* --- Countdown Deck --- */
.countdown-section {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 120px;
  padding: 20px 0;
  flex-wrap: wrap;
}

.countdown-loading-msg {
  font-size: 11px;
  color: var(--gray-light);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin: 0;
}

.countdown-display {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 30px;
  flex-wrap: wrap;
}

.countdown-display[hidden] {
  display: none !important;
}

.countdown-loading-msg[hidden] {
  display: none !important;
}

.countdown-box {
  text-align: center;
}

.countdown-number {
  font-size: clamp(2rem, 6vw, 4.5rem);
  font-weight: 800;
  font-family: var(--font-sans);
  line-height: 1;
}

.countdown-label {
  font-size: 10px;
  color: var(--gray-light);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.countdown-colon {
  font-size: clamp(2rem, 6vw, 4.5rem);
  font-weight: 800;
  line-height: 1;
  color: var(--gray-mid);
  animation: blink 1s step-end infinite;
}

/* --- Hidden Hangar Admin Panel Overlay --- */
#admin-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.95);
  z-index: 999;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 20px;
}

#admin-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

#admin-overlay,
#admin-overlay * {
  cursor: auto !important;
}

.admin-terminal {
  width: 100%;
  max-width: 750px;
  background-color: var(--bg);
  border: var(--border-thick);
  padding: 30px;
  position: relative;
  box-shadow: 0 0 50px rgba(255, 255, 255, 0.15);
}

.admin-console-header {
  border-bottom: var(--border-dashed);
  padding-bottom: 12px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-console-title {
  font-family: var(--font-sans);
  font-weight: 800;
  letter-spacing: 0.1em;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-close-btn {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--fg);
  padding: 4px 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
}

.admin-close-btn:hover {
  background: var(--fg);
  color: var(--bg);
}

/* Authentication Interface */
#admin-auth-panel {
  text-align: center;
  padding: 40px 0;
}

/* Operational Console Grid */
#admin-console-panel {
  display: none; /* Shown after auth success */
}

.admin-panel-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 25px;
}

@media (max-width: 700px) {
  .admin-panel-grid {
    grid-template-columns: 1fr;
  }
}

.admin-flight-list {
  border: var(--border-thin);
  max-height: 280px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.02);
}

.admin-flight-item {
  padding: 10px 15px;
  border-bottom: 1px solid var(--gray-mid);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
}

.admin-flight-item:last-child {
  border-bottom: none;
}

.admin-item-actions {
  display: flex;
  gap: 8px;
}

.admin-small-btn {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--fg);
  padding: 2px 6px;
  font-size: 9px;
  text-transform: uppercase;
  cursor: pointer;
  pointer-events: auto;
  position: relative;
  z-index: 1;
}

.admin-small-btn:hover {
  background: var(--fg);
  color: var(--bg);
}

.admin-small-btn.btn-delete {
  border-color: #ff3333;
  color: #ff3333;
}

.admin-small-btn.btn-delete:hover {
  background: #ff3333;
  color: var(--bg);
}

.admin-form-panel {
  border: var(--border-thin);
  padding: 15px;
  background: rgba(255, 255, 255, 0.01);
}

.admin-json-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.admin-json-btn {
  width: auto;
  flex: 1;
  min-width: 120px;
  margin-top: 0;
  font-size: 10px;
  padding: 8px 10px;
}

.admin-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.admin-json-status {
  font-size: 10px;
  margin-top: 8px;
  min-height: 1.2em;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.admin-json-status.is-ok {
  color: #00ff88;
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 0 0 10px #00ff8866;
}

.admin-json-status.is-error {
  color: #ff6666;
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.admin-json-hint {
  font-size: 9px;
  color: var(--gray-light);
  margin-top: 6px;
  line-height: 1.4;
}

.admin-json-hint code {
  color: var(--fg);
  font-size: 9px;
}

/* --- Footer Ref telemetry --- */
footer {
  border-top: var(--border-thin);
  padding: 30px 0;
  margin-top: 80px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 9px;
  color: var(--gray-light);
  flex-wrap: wrap;
  gap: 15px;
}

.footer-screw-anchor {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid var(--gray-mid);
  position: relative;
  cursor: none;
}

.footer-screw-anchor::before {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 8px; height: 1px;
  background-color: var(--gray-mid);
  transform: translate(-50%, -50%) rotate(45deg);
}

.footer-screw-anchor:hover {
  border-color: var(--fg);
}

.footer-screw-anchor:hover::before {
  background-color: var(--fg);
}

/* --- Mobile & Touch Device Cursor Compatibility --- */
@media (hover: none) and (pointer: coarse) {
  #custom-cursor, #custom-cursor-data {
    display: none !important;
  }
  *, *::before, *::after {
    cursor: auto !important;
  }

  .flight-row {
    cursor: pointer !important;
  }
}

/* --- Mobile layout (desktop table unchanged above 768px) --- */
@media (max-width: 768px) {
  .container {
    padding: 24px 16px;
  }

  header {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    margin-bottom: 28px;
    padding: 16px 0;
  }

  .top-bar-notice {
    text-align: center;
  }

  .top-bar-right {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .timezone-select {
    min-width: 0;
    max-width: none;
    width: 100%;
  }

  .vrchat-badge {
    justify-content: center;
    width: 100%;
  }

  .hero-deck {
    margin-bottom: 32px;
  }

  .title-main {
    font-size: clamp(2.5rem, 18vw, 4rem);
    word-break: normal;
    text-align: center;
  }

  .title-sub {
    font-size: 11px;
    letter-spacing: 0.2em;
    text-align: center;
  }

  .panel {
    padding: 18px 14px;
    margin-bottom: 28px;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 18px;
    padding-bottom: 12px;
  }

  .panel-title {
    font-size: 14px;
    letter-spacing: 0.1em;
    line-height: 1.3;
  }

  .panel-header > span {
    font-size: 9px !important;
    line-height: 1.4;
    max-width: 100%;
    word-break: break-word;
  }

  .countdown-section {
    min-height: 100px;
    padding: 12px 0;
  }

  .countdown-display {
    gap: 10px 6px;
    width: 100%;
    justify-content: space-between;
  }

  .countdown-box {
    flex: 1 1 20%;
    min-width: 56px;
  }

  .countdown-number {
    font-size: clamp(1.5rem, 8vw, 2.5rem);
  }

  .countdown-colon {
    font-size: clamp(1.25rem, 6vw, 2rem);
    align-self: center;
    flex: 0 0 auto;
  }

  .countdown-label {
    font-size: 8px;
  }

  /* Schedule: card stack instead of cramped table */
  .schedule-wrap {
    overflow: visible;
  }

  .flight-grid thead {
    display: none;
  }

  .flight-grid,
  .flight-grid tbody,
  .flight-grid tr,
  .flight-grid td {
    display: block;
    width: 100%;
  }

  .flight-grid tr {
    border: var(--border-thin);
    margin-bottom: 12px;
    padding: 4px 0;
    background: rgba(255, 255, 255, 0.02);
  }

  .flight-grid tr:last-child {
    margin-bottom: 0;
  }

  .flight-grid td {
    display: grid;
    grid-template-columns: minmax(88px, 34%) 1fr;
    gap: 8px 12px;
    align-items: start;
    padding: 10px 12px;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
    font-size: 12px;
    text-align: left;
  }

  .flight-grid td:last-child {
    border-bottom: none;
  }

  .flight-grid td::before {
    content: attr(data-label);
    font-size: 9px;
    color: var(--gray-light);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: bold;
  }

  .flight-grid td[data-label="Flight"] {
    font-weight: 800;
    font-family: var(--font-sans);
    font-size: 15px;
    grid-template-columns: 1fr auto;
    border-bottom: var(--border-thin);
    padding-bottom: 12px;
    margin-bottom: 2px;
  }

  .flight-grid td[data-label="Flight"]::before {
    display: none;
  }

  .flight-grid td[data-label="Status"] {
    grid-template-columns: minmax(88px, 34%) 1fr;
  }

  .flight-row.selected-flight {
    border-left: none;
    border-top: 3px solid var(--fg);
    background-color: rgba(255, 255, 255, 0.08);
  }

  .flight-row:hover {
    background-color: rgba(255, 255, 255, 0.04);
  }

  .flight-grid tr.flight-empty-row td {
    display: block;
    text-align: center;
    grid-template-columns: 1fr;
    color: var(--gray-light);
    padding: 32px 12px;
  }

  .flight-grid tr.flight-empty-row td::before {
    display: none;
  }

  #admin-overlay {
    align-items: flex-start;
    padding: 10px;
    overflow-y: auto;
  }

  .admin-terminal {
    padding: 16px;
    margin: auto 0;
    max-height: none;
  }

  .admin-console-header {
    flex-wrap: wrap;
    gap: 10px;
  }

  .admin-flight-item {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .admin-item-actions {
    justify-content: flex-end;
  }

  .admin-json-btn {
    min-width: 0;
    flex: 1 1 calc(50% - 4px);
  }
}

@media (max-width: 400px) {
  .countdown-colon {
    margin: 0 -2px;
  }

  .departure-quick-btns {
    flex-direction: column;
  }

  .departure-quick-btn {
    width: 100%;
    text-align: center;
  }
}
