:root {
  color-scheme: dark;
  --ink: #f7f2e8;
  --muted: #a3b2c9;
  --panel-bg: rgba(10, 17, 30, 0.62);
  --panel-border: rgba(255, 255, 255, 0.08);
  --glass-glow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --line: rgba(255, 255, 255, 0.12);
  --gold: #f4c76f;
  --gold-glow: rgba(244, 199, 111, 0.45);
  --cyan: #8ed8ff;
  --cyan-glow: rgba(142, 216, 255, 0.35);
  --rose: #ff9f9f;
  --green: #93e6b6;
  --font-sans: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: Georgia, "Times New Roman", serif;
}

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

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #030611;
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

input,
textarea,
select,
button {
  font-family: inherit;
  color: inherit;
}

/* App Shell Layout */
.app-shell {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Fullscreen sky canvas */
#skyCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  cursor: crosshair;
  touch-action: none;
}

/* Floating Top HUD */
.top-hud {
  position: absolute;
  top: 24px;
  left: 24px;
  right: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  pointer-events: none;
}

.hud-brand {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 400;
  letter-spacing: 0.5px;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  pointer-events: auto;
  user-select: none;
}

.hud-info {
  display: flex;
  align-items: center;
  gap: 16px;
  pointer-events: auto;
}

.hud-item {
  font-size: 13px;
  color: var(--muted);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
  background: rgba(5, 9, 19, 0.45);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(8px);
}

.hud-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--cyan);
  background: rgba(142, 216, 255, 0.12);
  border: 1px solid rgba(142, 216, 255, 0.25);
  padding: 4px 10px;
  border-radius: 12px;
  backdrop-filter: blur(8px);
}

/* Side Floating Controls */
.side-controls {
  position: absolute;
  right: 24px;
  top: 100px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  z-index: 10;
}

.circle-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--glass-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 160ms cubic-bezier(0.4, 0, 0.2, 1);
}

.circle-btn:hover {
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.08);
}

.circle-btn:active {
  transform: translateY(0);
}

.circle-btn.active {
  color: var(--gold);
  border-color: var(--gold);
  background: rgba(244, 199, 111, 0.15);
}

/* Minimap design */
.mini-map {
  width: 140px;
  height: 140px;
  border: 1px solid var(--panel-border);
  border-radius: 50%;
  background: rgba(5, 9, 16, 0.62);
  box-shadow: var(--glass-glow);
  cursor: pointer;
  pointer-events: auto;
  transition: all 200ms ease;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  opacity: 0;
  pointer-events: none;
}

.is-real-sky .mini-map {
  opacity: 1;
  pointer-events: auto;
}

.mini-map:hover {
  border-color: rgba(142, 216, 255, 0.4);
}

/* Floating Bottom Toolbar */
.bottom-toolbar {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 28px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--glass-glow);
  transition: all 250ms ease;
}

.toolbar-group {
  display: none;
  align-items: center;
  gap: 8px;
}

.toolbar-group.active {
  display: flex;
}

/* Base button styling */
button {
  border: 0;
  border-radius: 20px;
  height: 40px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 140ms ease;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

.primary {
  background: linear-gradient(135deg, var(--gold), #f08964);
  color: #0b101c;
  box-shadow: 0 4px 12px var(--gold-glow);
}

.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px var(--gold-glow);
}

.secondary,
.secondary-icon-btn,
#copyBtn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.secondary:hover,
.secondary-icon-btn:hover,
#copyBtn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.secondary-icon-btn {
  padding: 0 12px;
  border-radius: 20px;
}

.secondary-icon-btn span {
  font-size: 12px;
}

.ghost {
  background: transparent;
  border: 1px solid rgba(147, 230, 182, 0.25);
  color: var(--green);
}

.ghost:hover {
  background: rgba(147, 230, 182, 0.08);
  border-color: var(--green);
}

/* Floating Bottom Sheet */
.bottom-sheet {
  position: absolute;
  bottom: 0;
  left: 24px;
  width: 380px;
  height: calc(100% - 48px);
  max-height: 480px;
  border-radius: 24px 24px 0 0;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-bottom: 0;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 -12px 45px rgba(0, 0, 0, 0.5);
  z-index: 15;
  display: flex;
  flex-direction: column;
  transition: transform 380ms cubic-bezier(0.19, 1, 0.22, 1);
  transform: translateY(100%);
}

.bottom-sheet.collapsed {
  transform: translateY(calc(100% - 64px));
}

.bottom-sheet.hidden {
  transform: translateY(100%);
}

.bottom-sheet.expanded {
  transform: translateY(0);
}

.sheet-handle {
  width: 100%;
  height: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: grab;
  user-select: none;
}

.sheet-handle:active {
  cursor: grabbing;
}

.handle-bar {
  width: 44px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.16);
  transition: background 160ms ease;
}

.sheet-handle:hover .handle-bar {
  background: rgba(255, 255, 255, 0.35);
}

.sheet-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 24px 24px 24px;
  overflow: hidden;
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.sheet-title-text {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 400;
}

.mode-pill {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--cyan);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px 10px;
  background: rgba(142, 216, 255, 0.06);
}

.sheet-scroll-area {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-right: 4px;
}

/* Custom Scrollbar */
.sheet-scroll-area::-webkit-scrollbar,
.modal-body::-webkit-scrollbar {
  width: 4px;
}

.sheet-scroll-area::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.sheet-scroll-area::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

/* Sections & Forms */
.panel-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  outline: none;
  font-size: 13.5px;
  transition: all 160ms ease;
}

input,
select {
  height: 42px;
  padding: 0 14px;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='rgba(255,255,255,0.45)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-chevron-down'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
  padding-right: 36px;
}

textarea {
  min-height: 90px;
  resize: none;
  padding: 12px 14px;
  line-height: 1.5;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(142, 216, 255, 0.45);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(142, 216, 255, 0.08);
}

input:read-only,
textarea:read-only {
  opacity: 0.72;
  border-color: transparent;
  background: rgba(255, 255, 255, 0.02);
}

.coordinate-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sky-readout {
  font-size: 11px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  padding: 8px 12px;
  border-radius: 10px;
  text-align: center;
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stats-grid div {
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.03);
  text-align: center;
}

.stats-grid span {
  display: block;
  font-size: 18px;
  font-weight: 700;
  color: var(--gold);
}

.stats-grid small {
  display: block;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  margin-top: 2px;
}

/* Selection list chips */
.selected-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-content: flex-start;
}

.star-chip {
  padding: 5px 10px;
  border-radius: 14px;
  font-size: 11px;
  background: rgba(244, 199, 111, 0.08);
  border: 1px solid rgba(244, 199, 111, 0.22);
  color: #ffe0a3;
}

.star-chip.active {
  background: rgba(142, 216, 255, 0.14);
  border-color: rgba(142, 216, 255, 0.45);
  color: #dbeeff;
  box-shadow: 0 0 8px rgba(142, 216, 255, 0.2);
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.share-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: auto;
}

.share-actions button {
  width: 100%;
}

.share-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(142, 216, 255, 0.05);
  border: 1px solid rgba(142, 216, 255, 0.12);
  padding: 14px;
  border-radius: 16px;
  margin-top: 6px;
}

.copy-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.copy-row input {
  height: 36px;
  font-size: 11px;
}

.copy-row button {
  height: 36px;
}

.share-note {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}

/* Modal overlays (Settings & Search) */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(3, 5, 12, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 220ms ease;
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
}

.modal-content {
  width: 380px;
  max-width: 90%;
  border-radius: 24px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow: var(--glass-glow);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 220ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px 12px 24px;
}

.modal-header h3 {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 400;
}

.close-btn {
  background: transparent;
  border: 0;
  font-size: 22px;
  color: var(--muted);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  transition: all 140ms ease;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
}

.modal-body {
  padding: 12px 24px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 70vh;
  overflow-y: auto;
}

/* Search Results UI */
.search-panel {
  max-height: 480px;
}

.search-results {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.search-results li {
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 140ms ease;
}

.search-results li:hover {
  background: rgba(142, 216, 255, 0.08);
  border-color: rgba(142, 216, 255, 0.2);
}

.search-results .star-name {
  font-size: 13.5px;
  font-weight: 600;
}

.search-results .star-meta {
  font-size: 11px;
  color: var(--muted);
}

/* Viewport adjustments */
@media (min-width: 841px) {
  /* On desktop, make bottom sheet look like a floating panel on the left */
  .bottom-sheet {
    left: 24px;
    bottom: 24px;
    height: auto;
    max-height: calc(100% - 148px);
    border-radius: 20px;
    border-bottom: 1px solid var(--panel-border);
    transform: translateX(-420px);
  }

  .bottom-sheet.collapsed {
    transform: translateX(-420px);
  }

  .bottom-sheet.expanded {
    transform: translateX(0);
  }
  
  .sheet-handle {
    display: none; /* No dragging needed on desktop */
  }
  
  .sheet-content {
    padding-top: 24px;
  }
}

@media (max-width: 840px) {
  .top-hud {
    top: 16px;
    left: 16px;
    right: 16px;
  }

  .hud-brand {
    font-size: 20px;
  }

  .hud-info {
    gap: 8px;
  }

  .hud-item {
    font-size: 11px;
    padding: 4px 8px;
  }

  .hud-badge {
    font-size: 10px;
    padding: 3px 6px;
  }

  .side-controls {
    right: 16px;
    top: 80px;
    gap: 8px;
  }

  .mini-map {
    width: 100px;
    height: 100px;
  }

  .bottom-toolbar {
    bottom: 16px;
    max-width: 90%;
  }

  .bottom-sheet {
    left: 0;
    width: 100%;
    border-radius: 20px 20px 0 0;
  }
}

/* Safe area support for iOS notches */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .bottom-sheet {
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-toolbar {
    bottom: calc(16px + env(safe-area-inset-bottom));
  }
}

/* World Map Selection Modal Styling */
.map-modal-content {
  width: min(860px, 96vw);
  max-width: 96vw;
}

.map-instructions {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
  text-align: center;
}

.map-container {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 1;
  max-height: 60vh;
  background: #040817;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  cursor: grab;
  margin-bottom: 14px;
  touch-action: none;
}

.map-container:active {
  cursor: grabbing;
}

.map-viewport {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.map-container img {
  width: 100%;
  height: 100%;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.map-zoom-controls {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 2;
}

.map-zoom-controls button {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  background: rgba(5, 9, 19, 0.7);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(8px);
}

.map-zoom-controls button:hover {
  background: rgba(142, 216, 255, 0.18);
}

.lang-btn.active {
  color: var(--gold);
  border-color: var(--gold);
  background: rgba(244, 199, 111, 0.15);
}

.hud-item-clickable {
  cursor: pointer;
  pointer-events: auto;
}

.hud-item-clickable:hover {
  border-color: rgba(142, 216, 255, 0.4);
  color: var(--ink);
}

.map-marker {
  position: absolute;
  width: 14px;
  height: 14px;
  background: var(--gold);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  display: none;
  animation: markerPulse 1.6s infinite ease-in-out;
  border: 2px solid #ffffff;
}

@keyframes markerPulse {
  0% {
    transform: translate(-50%, -50%) scale(1);
    box-shadow: 0 0 10px var(--gold), 0 0 20px var(--gold);
    opacity: 1;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.4);
    box-shadow: 0 0 20px var(--gold), 0 0 40px var(--gold);
    opacity: 0.8;
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    box-shadow: 0 0 10px var(--gold), 0 0 20px var(--gold);
    opacity: 1;
  }
}

.map-selection-readout {
  font-size: 12.5px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  padding: 12px;
  border-radius: 12px;
  text-align: center;
  margin-bottom: 16px;
  line-height: 1.4;
  font-weight: 600;
}

.map-selection-readout strong {
  color: var(--gold);
}

/* Toast Notification Styles */
.toast-container {
  position: fixed;
  top: 32px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast-pill {
  padding: 10px 20px;
  background: rgba(10, 17, 30, 0.85);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 40px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translateY(-20px) scale(0.9);
  transition: opacity 300ms ease, transform 300ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast-pill.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Error validation flash style */
.error-flash {
  animation: errorShake 0.4s ease;
  border-color: var(--rose) !important;
}

@keyframes errorShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

