/* ── Design tokens ───────────────────────────────────────────── */
:root {
  --c-bg:          #1a2332;
  --c-surface:     rgba(20, 30, 48, 0.82);
  --c-surface-alt: rgba(30, 44, 66, 0.90);
  --c-border:      rgba(100, 160, 220, 0.22);
  --c-border-hi:   rgba(140, 200, 255, 0.55);
  --c-back:        rgba(140, 200, 255, 0.22);
  --c-text:        #dce8f5;
  --c-text-info:   #C0CAC6;
  --c-text-dim:    rgba(180, 210, 240, 0.60);
  --c-accent:      #4a9edd;
  --c-accent-hi:   #74bfff;
  --c-danger:      #e05555;
  --c-success:     #4bcc7a;
  --c-warn:        #f0b84a;
  --radius-sm:     6px;
  --radius-md:     10px;
  --radius-lg:     16px;
  --shadow-panel:  0 8px 32px rgba(0,0,0,0.55), 0 2px 8px rgba(0,0,0,0.35);
  --shadow-hub:    0 4px 16px rgba(0,0,0,0.55), 0 1px 4px rgba(0,0,0,0.35);
  --shadow-btn:    0 2px 6px rgba(0,0,0,0.4);
  --blur:          blur(12px);
  --transition:    150ms ease;
  --font-ui:       'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ── Reset ───────────────────────────────────────────────────── */
* { padding:0; margin:0;
    -webkit-user-select:none; -moz-user-select:none; user-select:none;
    box-sizing: border-box; }

html { width:100%; height:100%; }
body { background: var(--c-bg); font: 12px/1.4 var(--font-ui); width:100%; height:100%; color: var(--c-text); overflow:hidden; }

/* ── Containers ──────────────────────────────────────────────── */
#container { min-width:465px; min-height:465px; width:100%; height:100%; overflow:hidden; text-align:center; }
#container canvas { position:absolute; top:0; left:0; width:100%; height:100%; }
#hub { position:absolute; top:0; left:0; height:100%; width:100%; pointer-events:none; display:block; text-align:center; }

/* ── Hub panels / windows ────────────────────────────────────── */
.hub-panel {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-panel);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  color: var(--c-text);
}

/* ── Buttons ─────────────────────────────────────────────────── */

.hub-btn {
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--c-surface-alt);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  color: var(--c-text);
  font: 600 12px/1 var(--font-ui);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  pointer-events: auto;
  transition: background var(--transition), border-color var(--transition),
              color var(--transition), transform var(--transition);
  box-shadow: var(--shadow-btn);
}
.hub-btn-select {
  display: inline-block;
  background: var(--c-accent);
  border: 1px solid var(--c-accent-hi);
  border-radius: var(--radius-sm);
  color: #fff;
  font: 600 12px/1 var(--font-ui);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  pointer-events: auto;
  transition: background var(--transition), border-color var(--transition),
              color var(--transition), transform var(--transition);
  box-shadow: var(--shadow-btn);
}
.hub-btn:hover {
  background: var(--c-accent);
  border-color: var(--c-accent-hi);
  color: #fff;
  //transform: translateY(-1px);
}
.selector-title {
  color: var(--c-text-dim);
  font-size:12px; 
  margin-top:4px;
  font-weight:600; 
  letter-spacing:0.06em;
}
.hub-btn:active { transform: translateY(0); }

/* ── Top menu strip ──────────────────────────────────────────── */
.hub-topmenu {
  position: absolute;
  top: 0px; left: 0; right: 0;
  width: calc(100% - 214px);
  //height: 36px;
  //background: var(--c-surface);
  //border-bottom: 1px solid var(--c-border);
  //-webkit-backdrop-filter: var(--blur);
  //backdrop-filter: var(--blur);
  display: flex;
  padding: 4px 8px;
  gap: 6px 6px;
  pointer-events: none;
  flex-wrap:wrap;
}
.hub-topmenu .hub-btn {
  height: 26px;
  padding: 0 14px;
  font-size: 11px;
  border-radius: 4px;
}

/* ── Status bar ──────────────────────────────────────────────── */
.hub-statusbar {
  background: var(--c-back);
  border: 2px solid var(--c-border-hi);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0px 0px;
  gap: 0;
  border-radius: 12px;
  pointer-events: none;
}
.hub-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 170px;
  border-right: 1px solid var(--c-border);
}
.hub-stat:last-child { border-right: none; }
.hub-stat-label {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-text-dim);
  width: 150px;
  line-height: 1;
  margin-bottom: 2px;
}
.hub-stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--c-text);
  line-height: 1.4;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

.hub-stat-message {
  font-size: 22px;
  font-weight: 700;
  color: var(--c-text);
  line-height: 1.4;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

/* ── Speed selector ──────────────────────────────────────────── */
.hub-speed {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 10px;
  border-right: 1px solid var(--c-border);
}
.hub-speed-btn {
  width: 28px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-surface-alt);
  border: 1px solid var(--c-border);
  border-radius: 4px;
  color: var(--c-text-dim);
  font-size: 11px;
  cursor: pointer;
  pointer-events: auto;
  transition: background var(--transition), color var(--transition);
}
.hub-speed-btn:hover, .hub-speed-btn.select {
  background: var(--c-accent);
  border-color: var(--c-accent-hi);
  color: #fff;
}

/* ── Tool info strip ──────────────────────────────────────────── */
.hub-toolinfo {
  position: absolute;
  display: flex;
  justify-content: center;
  align-items: center;
  top: 0px; 
  right: 8px;
  width: 198px;
  height: 38px;
  font-size: 16px;
  font-weight: 800;
  color: var(--c-text);
  letter-spacing: 0.03em;
  pointer-events: none;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

/* ── RCI indicator ───────────────────────────────────────────── */
#RCI {
  position: absolute;
  bottom: 54px; right: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.rci-bars {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 32px;
}
.rci-bar {
  width: 10px;
  border-radius: 2px 2px 0 0;
  min-height: 2px;
}
.rci-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--c-text-dim);
  margin-top: 3px;
}

/* ── Slider ──────────────────────────────────────────────────── */
.hub-slider-track {
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--c-border);
  cursor: w-resize;
  pointer-events: auto;
}
.hub-slider-track:hover { border-color: var(--c-border-hi); }
.hub-slider-fill { border-radius: var(--radius-sm); }

/* ── Notification message ────────────────────────────────────── */
.hub-msg {
  position: absolute;
  bottom: 54px; left: 12px;
  width: 420px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--c-warn);
  pointer-events: none;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

.hub-bottombar{
  position:absolute;
  right:10px; 
  bottom:10px;
  display: flex;
}

.hub-version {
  text-align:right;
  font-size: 13px;
  font-weight: 600;
  //letter-spacing: 0.15em;
  color: var(--c-text-info);
  flex-shrink: 0;
}

.hub-fps {
  text-align:right;
  font-size: 13px;
  font-weight: 600;
  //letter-spacing: 0.15em;
  color: var(--c-text-info);
  flex-shrink: 0;
}

/* ── Loading overlay ─────────────────────────────────────────── */
#hub-loading {
  position: absolute; inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #050604;
  pointer-events: none;
  overflow: hidden;
  color: #f7f1d3;
  isolation: isolate;
}
.loading-backdrop {
  position: absolute;
  inset: 0;
  z-index: -3;
  background:
    radial-gradient(circle at 50% 22%, rgba(240,185,11,.18), transparent 32%),
    linear-gradient(145deg, #050604 0%, #111107 48%, #020303 100%);
}
.loading-grid {
  position: absolute;
  inset: -20% -10%;
  z-index: -2;
  background-image:
    linear-gradient(rgba(240,185,11,.16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(240,185,11,.12) 1px, transparent 1px);
  background-size: 54px 54px;
  transform: perspective(520px) rotateX(62deg) translateY(20%);
  transform-origin: center bottom;
  animation: loadingGrid 2.4s linear infinite;
  opacity: .55;
}
.loading-scan {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, transparent 0%, rgba(240,185,11,.13) 48%, transparent 52%),
    repeating-linear-gradient(180deg, rgba(255,255,255,.035) 0 1px, transparent 1px 5px);
  animation: loadingScan 2.8s cubic-bezier(.2,.8,.2,1) infinite;
  mix-blend-mode: screen;
}
.loading-shell {
  display: flex;
  position: relative;
  width: min(560px, calc(100vw - 36px));
  min-height: 360px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 34px 34px 30px;
  border: 1px solid rgba(240,185,11,.32);
  border-radius: 10px;
  background: rgba(5, 6, 4, .58);
  box-shadow: 0 28px 90px rgba(0,0,0,.52), inset 0 1px 0 rgba(255,255,255,.08);
  backdrop-filter: blur(16px);
  animation: loadingShellIn 520ms cubic-bezier(.2,.8,.2,1) both;
}
.loading-shell::before,
.loading-shell::after {
  content: "";
  position: absolute;
  width: 42px;
  height: 42px;
  border-color: rgba(240,185,11,.72);
  border-style: solid;
}
.loading-shell::before {
  top: 12px;
  left: 12px;
  border-width: 2px 0 0 2px;
}
.loading-shell::after {
  right: 12px;
  bottom: 12px;
  border-width: 0 2px 2px 0;
}
.loading-mark {
  width: 72px;
  height: 72px;
  margin-bottom: 18px;
  border-radius: 16px;
  filter: drop-shadow(0 0 28px rgba(240,185,11,.42));
  animation: loadingMark 1.8s ease-in-out infinite;
}
.loading-title {
  font-size: 54px;
  font-weight: 900;
  letter-spacing: 0;
  color: #ffe16a;
  text-shadow: 0 0 32px rgba(240,185,11,0.48), 0 2px 8px rgba(0,0,0,0.9);
  margin-bottom: 10px;
}
.loading-subtitle {
  max-width: 420px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
  color: rgba(247,241,211,.76);
  margin-bottom: 22px;
  text-align: center;
}
.loading-progress {
  width: min(390px, 100%);
  height: 9px;
  overflow: hidden;
  border: 1px solid rgba(240,185,11,.26);
  border-radius: 999px;
  background: rgba(255,255,255,.07);
}
.loading-progress i {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(240,185,11,.35), #ffe16a, rgba(87,215,255,.72));
  box-shadow: 0 0 18px rgba(240,185,11,.42);
  animation: loadingProgress 1.65s cubic-bezier(.2,.8,.2,1) infinite;
}
.loading-status {
  min-height: 22px;
  font-size: 14px;
  font-weight: 800;
  color: #f7f1d3;
  margin-top: 20px;
  letter-spacing: 0;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}
.loading-spinner {
  position: absolute;
  top: 30px;
  right: 30px;
  width: 42px; height: 42px;
  border: 1px solid rgba(240,185,11,0.22);
  border-top-color: #ffe16a;
  border-right-color: rgba(87,215,255,.75);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
.loading-log {
  display: grid;
  width: min(390px, 100%);
  gap: 7px;
  margin-top: 20px;
  text-align: left;
}
.loading-log span {
  display: block;
  overflow: hidden;
  border-left: 2px solid rgba(240,185,11,.62);
  background: rgba(0,0,0,.28);
  color: rgba(96,211,148,.95);
  font: 700 11px/1.2 Consolas, "IBM Plex Mono", monospace;
  padding: 7px 9px;
  white-space: nowrap;
  animation: loadingLog 1.8s ease-in-out infinite both;
}
.loading-log span:nth-child(2) { animation-delay: 160ms; }
.loading-log span:nth-child(3) { animation-delay: 320ms; }
.loading-log span:nth-child(4) { animation-delay: 480ms; }
.loading-skyline {
  position: absolute;
  left: 50%;
  bottom: 0;
  display: flex;
  width: min(760px, 86vw);
  height: 120px;
  align-items: flex-end;
  justify-content: center;
  gap: 9px;
  transform: translateX(-50%);
  opacity: .9;
}
.loading-skyline i {
  display: block;
  width: 24px;
  height: var(--h);
  border: 1px solid rgba(240,185,11,.22);
  border-bottom: 0;
  background:
    repeating-linear-gradient(180deg, rgba(255,225,106,.22) 0 3px, transparent 3px 9px),
    linear-gradient(180deg, rgba(240,185,11,.22), rgba(0,0,0,.78));
  box-shadow: 0 0 18px rgba(240,185,11,.12);
  animation: loadingTower 1.9s ease-in-out infinite;
  animation-delay: var(--d);
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes loadingGrid {
  from { background-position: 0 0, 0 0; }
  to { background-position: 0 54px, 54px 0; }
}
@keyframes loadingScan {
  0% { transform: translateY(-70%); opacity: .35; }
  55% { opacity: .7; }
  100% { transform: translateY(70%); opacity: .25; }
}
@keyframes loadingShellIn {
  from { opacity: 0; transform: translateY(18px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes loadingMark {
  0%, 100% { transform: translateY(0); filter: drop-shadow(0 0 22px rgba(240,185,11,.32)); }
  50% { transform: translateY(-4px); filter: drop-shadow(0 0 34px rgba(240,185,11,.58)); }
}
@keyframes loadingProgress {
  0% { transform: translateX(-105%); }
  100% { transform: translateX(245%); }
}
@keyframes loadingLog {
  0%, 100% { opacity: .55; transform: translateX(0); }
  50% { opacity: 1; transform: translateX(4px); }
}
@keyframes loadingTower {
  0%, 100% { opacity: .58; transform: scaleY(.82); transform-origin: bottom; }
  50% { opacity: 1; transform: scaleY(1); transform-origin: bottom; }
}

/* ── Season / time wheel ─────────────────────────────────────── */
.hub-timewheel {
  position: absolute;
  bottom: 54px; left: 12px;
  width: 54px; height: 54px;
  border-radius: 50%;
  background: var(--c-surface-alt);
  border: 1px solid var(--c-border);
  overflow: hidden;
  transform: rotate(45deg);
  pointer-events: auto;
}
.hub-timewheel-cell {
  position: absolute;
  width: 27px; height: 27px;
  cursor: pointer;
  transition: background var(--transition);
}
.hub-timewheel-cell:hover { filter: brightness(1.35); }

/* ── Winter toggle ────────────────────────────────────────────── */
.hub-winter {
  position: absolute;
  bottom: 116px; left: 25px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid var(--c-border);
  cursor: pointer;
  pointer-events: auto;
  transition: background var(--transition), border-color var(--transition);
}
.hub-winter.on {
  background: rgba(180,220,255,0.35);
  border-color: var(--c-accent-hi);
}

/* ── Window headers ──────────────────────────────────────────── */
.hub-win-header {
  display: flex;
  align-items: center;
  padding: 4px 12px;
  border-bottom: 1px solid var(--c-border);
  //gap: 8px;
  pointer-events: none;
  flex-shrink: 0;
  width:  100%;
}
.hub-win-title {
  flex: 1;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--c-accent-hi);
}
.hub-win-close {
  width: 20px; height: 20px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--c-border);
  color: var(--c-text-dim);
  font-size: 12px; line-height: 1;
  cursor: pointer; pointer-events: auto;
  transition: background var(--transition), border-color var(--transition),
              color var(--transition);
  flex-shrink: 0;
  font-family: var(--font-ui);
}
.hub-win-close:hover {
  background: var(--c-danger);
  border-color: var(--c-danger);
  color: #fff;
}

/* ── Keyboard shortcut badge ─────────────────────────────────── */
.hub-kbd {
  display: inline-block;
  padding: 1px 5px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--c-border);
  border-radius: 3px;
  font-size: 9px;
  font-weight: 600;
  color: var(--c-text-dim);
  letter-spacing: 0.03em;
  font-family: var(--font-ui);
}

/* ── New-map modal overlay ───────────────────────────────────── */
.hub-newmap-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 14, 24, 0.72);
  z-index: 20;
  pointer-events: auto;
  animation: msgIn 0.2s ease;
}

/* ── Option-button group (Size / Terrain / Difficulty) ────────── */
.hub-option-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.hub-option-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--c-text-dim);
}
.hub-option-btns {
  display: flex;
  gap: 5px;
}
.hub-option-btn {
  flex: 1;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-surface-alt);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  color: var(--c-text-dim);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  pointer-events: auto;
  transition: background var(--transition), border-color var(--transition),
              color var(--transition);
}
.hub-option-btn:hover {
  background: rgba(74, 158, 221, 0.22);
  border-color: var(--c-border-hi);
  color: var(--c-text);
}
.hub-option-btn.selected {
  background: var(--c-accent);
  border-color: var(--c-accent-hi);
  color: #fff;
}

/* ── Action buttons inside new-map modal ─────────────────────── */
.hub-newmap-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.hub-newmap-actions .hub-btn {
  flex: 1;
  height: 32px;
  padding: 0 8px;
  font-size: 10px;
}
.hub-newmap-actions .hub-btn.primary {
  background: var(--c-accent);
  border-color: var(--c-accent-hi);
  color: #fff;
}
.hub-newmap-actions .hub-btn.primary:hover {
  background: var(--c-accent-hi);
}

/* ── Notification animation ──────────────────────────────────── */
@keyframes msgIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}
.hub-msg:not(:empty) { animation: msgIn 0.25s ease; }

/* ── Links ───────────────────────────────────────────────────── */
a:link, a:visited { text-decoration:none; color: var(--c-accent); }
a:hover { text-decoration:underline; color: var(--c-accent-hi); }

/* ── Responsive / mobile layout ─────────────────────────────── */
@media (max-width: 600px) {
  /* Enlarge touch targets on top menu */
  .hub-topmenu {
    position: absolute;
    display: flex; 
    justify-content: center; 
    align-items: center;`
    height: 45px;
    left: 200px;
    width:1096px;
    top: 0px;
    padding: 0 0;
  }
  
  /* Status bar: smaller, horizontally scrollable */
  .hub-statusbar {
    height: 40px;
    padding: 0 6px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .hub-statusbar::-webkit-scrollbar { display: none; }
  .hub-stat {
    padding: 0 10px;
    flex-shrink: 0;
  }
  .hub-stat-label { font-size: 8px; }
  .hub-stat-value { font-size: 11px; }
  /* Speed buttons: slightly larger for touch */
  .hub-speed-btn {
    width: 32px;
    height: 30px;
    font-size: 12px;
  }
  /* Notification message: narrower on small screens */
  .hub-msg { width: calc(100vw - 24px); }

  /* Panel windows: constrain width on small screens */
  /*.hub-panel { 
    max-width: calc(100vw - 20px); 
    position:absolute; 
    top:44px; 
    left:10px; 
    width:180px;
    pointer-events:none; 
    display:flex; 
    flex-direction:column; 
    border-radius:10px;
  }*/

  /* Loading screen title */
  .loading-shell {
    width: calc(100vw - 28px);
    min-height: 330px;
    padding: 28px 20px 24px;
  }
  .loading-mark {
    width: 58px;
    height: 58px;
    margin-bottom: 14px;
  }
  .loading-title { font-size: 38px; }
  .loading-subtitle { font-size: 12px; margin-bottom: 18px; }
  .loading-log span { font-size: 10px; }
  .loading-skyline {
    width: 96vw;
    gap: 5px;
  }
  .loading-skyline i {
    width: 16px;
  }
}

@media (max-width: 380px) {
  .hub-topmenu .hub-btn { padding: 0 6px; font-size: 9px; }
  .hub-stat { padding: 0 7px; }
}

@media (max-height: 500px) and (orientation: landscape) {
  /* Landscape phone: compact vertical spacing */
  .hub-topmenu { height: 36px; }
  .hub-statusbar { height: 34px; }
  .hub-stat-value { font-size: 11px; }
  //.hub-panel { max-height: calc(100vh - 80px); overflow-y: auto; }
}


.scroller {
  overflow-y: scroll;
  scrollbar-color: rebeccapurple green;
  scrollbar-width: thin;
}

@media (prefers-reduced-motion: reduce) {
  .loading-grid,
  .loading-scan,
  .loading-shell,
  .loading-mark,
  .loading-progress i,
  .loading-log span,
  .loading-skyline i,
  .loading-spinner {
    animation: none;
  }
}
