:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #0284c7;
  --accent-dark: #0369a1;
  --danger: #dc2626;
  --success: #059669;
}

* {
  box-sizing: border-box;
  user-select: none;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

#gameCanvas {
  display: block;
  width: 100vw;
  height: 100vh;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.hidden {
  display: none !important;
}

.overlay, .modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}

.card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
}

.entry-card {
  width: 100%;
  max-width: 560px;
}

.modal-card {
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  overflow-y: auto;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.atom-badge {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #334155;
  color: #ffffff;
  border: 2px solid #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.form-group {
  margin-bottom: 16px;
}

.form-group label, .section-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
  color: #334155;
}

input[type="text"], input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  user-select: text;
}

input:focus {
  border-color: var(--accent);
}

.atom-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.atom-option {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 8px 6px;
  text-align: center;
  cursor: pointer;
  background: #f8fafc;
  transition: border-color 0.15s, background 0.15s;
}

.atom-option.selected {
  border-color: var(--accent);
  background: #e0f2fe;
}

.atom-option .sym {
  font-size: 18px;
  font-weight: 800;
}

.atom-option .meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.btn {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: 1.5px solid transparent;
}

.btn-primary {
  flex: 1;
  background: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent-dark);
}

.btn-secondary {
  width: 100%;
  background: #0f172a;
  color: #ffffff;
}

.btn-ghost {
  background: #f1f5f9;
  border-color: var(--border);
  color: var(--text);
}

.auth-panel {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-tabs {
  display: flex;
  gap: 6px;
}

.tab-btn {
  flex: 1;
  padding: 6px;
  border: 1px solid var(--border);
  background: #f8fafc;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.tab-btn.active {
  background: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
}

.error-text {
  color: var(--danger);
  font-size: 12px;
  min-height: 16px;
}

.controls-hint {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}

/* HUD */
.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}

.hud-panel {
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.92);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
}

.hud-top-left {
  position: fixed;
  top: 14px;
  left: 14px;
  min-width: 240px;
}

.zone-title {
  font-size: 15px;
  font-weight: 800;
}

.zone-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat-bars {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
}

.bar-row > span:first-child {
  width: 50px;
}

.bar-track {
  flex: 1;
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  transition: width 0.12s;
}

.hp-fill { background: #10b981; }
.e-fill { background: #0284c7; }

.hud-top-right {
  position: fixed;
  top: 14px;
  right: 14px;
  display: flex;
  gap: 8px;
}

.hud-btn {
  border: 1px solid var(--border);
  background: #f8fafc;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.hud-btn:hover {
  background: #e2e8f0;
}

.hud-bottom-center {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.skill-slot {
  background: rgba(255, 255, 255, 0.94);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  min-width: 138px;
  text-align: center;
  cursor: pointer;
}

.skill-slot kbd {
  display: inline-block;
  padding: 2px 6px;
  background: #0f172a;
  color: #ffffff;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}

.skill-name {
  font-size: 13px;
  font-weight: 800;
  margin-top: 4px;
}

.skill-desc {
  font-size: 11px;
  color: var(--muted);
}

.toast-container {
  position: fixed;
  top: 72px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 320px;
}

.toast {
  background: #0f172a;
  color: #f8fafc;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
}

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

.modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.close-btn {
  border: none;
  background: #f1f5f9;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
}

.modal-note {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 12px;
}

.selected-orbitals, .warehouse-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.sub-chip {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
}

.sub-chip:hover {
  border-color: var(--accent);
}

.dex-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dex-item {
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
}

.dex-item.locked {
  color: #94a3b8;
  background: #f8fafc;
}
