* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: manipulation;
}

/* ── 게임 뷰포트: 9:19.5 고정 비율, 비율 불일치 시 레터박스 ── */
#game-viewport {
  position: relative;
  /* 세로/가로 어느 쪽이 좁아도 비율에 맞게 수축 */
  width: min(100vw, calc(100dvh * 9 / 19.5));
  height: min(100dvh, calc(100vw * 19.5 / 9));
  overflow: hidden;
  background: #0a0a1a url('/assets/backgrounds/space.svg') center center / cover no-repeat;
  color: #ffffff;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: linear-gradient(180deg, rgba(10,10,26,0.85) 0%, rgba(26,10,42,0.85) 100%);
  box-shadow: 0 0 50px rgba(100, 50, 200, 0.3);
}

/* Modal/Toast 컨테이너: #app 위에 절대 오버레이, 레이아웃에 영향 없음 */
#modal-container,
#toast-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
#modal-container > * {
  pointer-events: auto;
}

/* Status Bar */
#status-bar {
  padding: 0;
  background: rgba(0, 20, 40, 0.95);
  border-bottom: 1px solid rgba(100, 200, 255, 0.2);
  backdrop-filter: blur(10px);
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.status-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.7);
}

.status-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.6;
}

.status-value {
  font-size: 14px;
  font-weight: bold;
  font-family: 'Courier New', monospace;
}

.credits-value {
  color: #ffd700;
  font-size: 16px;
}

.hp-bar-container {
  width: 60px;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.hp-bar {
  height: 100%;
  background: linear-gradient(90deg, #ff4444 0%, #ff8844 100%);
  transition: width 0.3s ease, background 0.3s ease;
}

.hp-bar.high {
  background: linear-gradient(90deg, #44ff88 0%, #88ffaa 100%);
}

.hp-bar.medium {
  background: linear-gradient(90deg, #ffaa44 0%, #ffdd44 100%);
}

.hp-bar.low {
  background: linear-gradient(90deg, #ff4444 0%, #ff8844 100%);
}

.ap-dots {
  display: flex;
  gap: 3px;
}

.ap-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(100, 200, 255, 0.2);
  border: 1px solid rgba(100, 200, 255, 0.3);
}

.ap-dot.filled {
  background: #64c8ff;
  box-shadow: 0 0 8px rgba(100, 200, 255, 0.8);
}

.reputation-badge {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: bold;
  border: 1px solid;
}

.reputation-badge.high {
  background: rgba(68, 255, 136, 0.2);
  color: #44ff88;
  border-color: #44ff88;
}

.reputation-badge.neutral {
  background: rgba(255, 221, 68, 0.2);
  color: #ffdd44;
  border-color: #ffdd44;
}

.reputation-badge.low {
  background: rgba(255, 68, 68, 0.2);
  color: #ff4444;
  border-color: #ff4444;
}

/* Main View */
#main-view {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  padding: 16px;
}

#main-view::-webkit-scrollbar {
  width: 6px;
}

#main-view::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}

#main-view::-webkit-scrollbar-thumb {
  background: rgba(100, 200, 255, 0.3);
  border-radius: 3px;
}

#main-view::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 200, 255, 0.5);
}

/* Tab Bar */
#tab-bar {
  height: 60px;
  background: rgba(0, 20, 40, 0.95);
  border-top: 1px solid rgba(100, 200, 255, 0.2);
  display: flex;
  backdrop-filter: blur(10px);
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.5);
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
  background: transparent;
  outline: none;
  position: relative;
}

.tab-btn:active {
  transform: scale(0.95);
}

.tab-btn.active {
  color: #64c8ff;
}

.tab-btn.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 2px;
  background: #64c8ff;
  box-shadow: 0 0 8px rgba(100, 200, 255, 0.8);
}

.tab-icon {
  font-size: 24px;
  margin-bottom: 2px;
}

/* Cards and Panels */
.card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(100, 200, 255, 0.15);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
  backdrop-filter: blur(5px);
}

.card-header {
  font-size: 14px;
  font-weight: bold;
  margin-bottom: 8px;
  color: #64c8ff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-body {
  font-size: 13px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.8);
}

/* Buttons */
.btn {
  background: linear-gradient(135deg, #1a3a6a 0%, #0a2040 100%);
  border: 1px solid #64c8ff;
  color: white;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
  text-align: center;
  display: inline-block;
  min-width: 80px;
}

.btn:hover {
  background: linear-gradient(135deg, #2a4a7a 0%, #1a3050 100%);
  box-shadow: 0 0 15px rgba(100, 200, 255, 0.4);
  transform: translateY(-1px);
}

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

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: linear-gradient(135deg, #1a6a4a 0%, #0a4030 100%);
  border-color: #44ff88;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #2a7a5a 0%, #1a5040 100%);
  box-shadow: 0 0 15px rgba(68, 255, 136, 0.4);
}

.btn-danger {
  background: linear-gradient(135deg, #6a1a1a 0%, #401010 100%);
  border-color: #ff4444;
}

.btn-danger:hover {
  background: linear-gradient(135deg, #7a2a2a 0%, #501818 100%);
  box-shadow: 0 0 15px rgba(255, 68, 68, 0.4);
}

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
  min-width: 60px;
}

.btn-block {
  width: 100%;
  display: block;
}

/* Modal */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: 20px;
  backdrop-filter: blur(5px);
}

.modal {
  background: linear-gradient(180deg, #1a1a3a 0%, #0a0a2a 100%);
  border: 2px solid rgba(100, 200, 255, 0.3);
  border-radius: 16px;
  padding: 20px;
  max-width: 400px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}

.modal-header {
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 16px;
  color: #64c8ff;
  text-align: center;
}

.modal-body {
  margin-bottom: 16px;
}

.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* Toast Notifications */
#toast-container {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 90%;
}

.toast {
  background: rgba(0, 20, 40, 0.95);
  border: 1px solid rgba(100, 200, 255, 0.3);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 14px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  pointer-events: auto;
  max-width: 300px;
}

.toast.success {
  border-color: #44ff88;
  background: rgba(20, 40, 30, 0.95);
}

.toast.error {
  border-color: #ff4444;
  background: rgba(40, 20, 20, 0.95);
}

.toast.warning {
  border-color: #ffaa44;
  background: rgba(40, 30, 20, 0.95);
}

/* Lists */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(100, 200, 255, 0.1);
  border-radius: 8px;
  margin-bottom: 8px;
  transition: all 0.2s ease;
}

.list-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(100, 200, 255, 0.2);
}

.list-item-icon {
  font-size: 32px;
  flex-shrink: 0;
}

.list-item-content {
  flex: 1;
  min-width: 0;
}

.list-item-title {
  font-size: 14px;
  font-weight: bold;
  margin-bottom: 2px;
}

.list-item-subtitle {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}

.list-item-action {
  flex-shrink: 0;
}

/* Price displays */
.price {
  font-family: 'Courier New', monospace;
  font-weight: bold;
}

.price.up {
  color: #44ff88;
}

.price.down {
  color: #ff4444;
}

.price-trend {
  font-size: 12px;
  margin-left: 4px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: rgba(255, 255, 255, 0.4);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.3;
}

.empty-state-text {
  font-size: 14px;
}

/* Loading state */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(100, 200, 255, 0.2);
  border-top-color: #64c8ff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Utility classes */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.mt-1 {
  margin-top: 8px;
}

.mt-2 {
  margin-top: 16px;
}

.mb-1 {
  margin-bottom: 8px;
}

.mb-2 {
  margin-bottom: 16px;
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-1 {
  gap: 8px;
}

.gap-2 {
  gap: 16px;
}

.hidden {
  display: none !important;
}

/* Planet Orb */
.planet-orb {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  box-shadow: 
    inset -10px -10px 40px rgba(0,0,0,0.5),
    0 0 30px rgba(100,200,255,0.3);
  position: relative;
  overflow: hidden;
}

.planet-orb::before {
  content: '';
  position: absolute;
  top: 10%;
  left: 20%;
  width: 40%;
  height: 40%;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.4), transparent);
  border-radius: 50%;
}

.planet-orb.federation {
  background: linear-gradient(135deg, #2a5a8a 0%, #4a8aba 50%, #2a5a8a 100%);
}

.planet-orb.frontier {
  background: linear-gradient(135deg, #8a5a2a 0%, #ba8a4a 50%, #8a5a2a 100%);
}

.planet-orb.outlaw {
  background: linear-gradient(135deg, #5a2a8a 0%, #8a4aba 50%, #5a2a8a 100%);
}

.btn-small {
  font-size: 12px;
  padding: 6px 12px;
}

/* Title Screen */
.title-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #0a0a1a 0%, #1a0a2a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  overflow: hidden;
}

.title-stars {
  position: absolute;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(2px 2px at 20% 30%, white, transparent),
    radial-gradient(2px 2px at 60% 70%, white, transparent),
    radial-gradient(1px 1px at 50% 50%, white, transparent),
    radial-gradient(1px 1px at 80% 10%, white, transparent),
    radial-gradient(2px 2px at 90% 60%, white, transparent);
  background-size: 200px 200px, 300px 300px, 150px 150px, 250px 250px, 180px 180px;
  animation: twinkle 15s ease-in-out infinite;
  opacity: 0.6;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 0.8; }
}

.title-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 20px;
  animation: fadeIn 1.5s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.title-logo {
  margin-bottom: 40px;
}

.title-icon {
  font-size: 80px;
  margin-bottom: 20px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
}

.title-main {
  font-size: 48px;
  font-weight: 700;
  line-height: 1.1;
  background: linear-gradient(135deg, #64c8ff 0%, #aa66ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 10px;
  letter-spacing: 2px;
}

.title-subtitle {
  font-size: 20px;
  color: rgba(255, 255, 255, 0.7);
  margin: 0;
  letter-spacing: 4px;
}

.title-description {
  font-size: 14px;
  line-height: 1.8;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 50px;
}

.title-buttons {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 300px;
  margin: 0 auto;
}

.btn-large {
  padding: 16px 32px;
  font-size: 16px;
  font-weight: 600;
}

.title-version {
  margin-top: 30px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.3);
  text-align: center;
}
