:root {
  --bg:          #0a0a0f;
  --bg-card:     #111118;
  --bg-card-2:   #16161f;
  --border:      #252535;
  --accent:      #c9972a;
  --accent-dim:  #7a5a12;
  --text:        #dcdce8;
  --text-dim:    #707088;
  --text-muted:  #555568;

  --success:     #27ae60;
  --success-bg:  #071a0f;
  --success-brd: #0d4020;

  --warning:     #f0a500;
  --warning-bg:  #1a1200;
  --warning-brd: #3d2d00;

  --error:       #e74c3c;
  --error-bg:    #1a0505;
  --error-brd:   #4a1010;

  --info:        #4a9eda;
  --info-bg:     #050f1a;
  --info-brd:    #0d2a45;

  --radius:      8px;
  --radius-lg:   12px;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
.header {
  background: linear-gradient(180deg, #0d0d16 0%, #0a0a0f 100%);
  border-bottom: 1px solid var(--border);
  padding: 20px 16px;
}
.header-inner {
  max-width: 760px;
  margin: 0 auto;
}
.logo {
  display: flex;
  align-items: center;
  gap: 14px;
}
.logo-sword {
  font-size: 2.4rem;
  line-height: 1;
  filter: drop-shadow(0 0 8px rgba(201,151,42,0.5));
}
.logo-text h1 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 3px;
  color: var(--accent);
  text-shadow: 0 0 20px rgba(201,151,42,0.3);
}
.logo-text p {
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
}
.beta-badge {
  font-size: 0.5rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--bg);
  background: var(--accent);
  border-radius: 3px;
  padding: 2px 6px;
  vertical-align: middle;
  position: relative;
  top: -4px;
}

/* ── Main ── */
.main {
  flex: 1;
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
  padding: 32px 16px 48px;
}

/* ── Search ── */
.search-section {
  margin-bottom: 32px;
}
.search-box {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s;
}
.search-box:focus-within {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(201,151,42,0.1);
}
.search-box input {
  flex: 1;
  background: var(--bg-card);
  border: none;
  color: var(--text);
  font-size: 1rem;
  padding: 14px 18px;
  outline: none;
}
.search-box input::placeholder {
  color: var(--text-muted);
}
.search-box button {
  background: var(--accent);
  border: none;
  color: #0a0a0f;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  padding: 14px 24px;
  transition: background 0.2s;
  white-space: nowrap;
}
.search-box button:hover { background: #dba830; }
.search-box button:active { background: #b8861e; }
.search-box button:disabled {
  background: var(--accent-dim);
  cursor: not-allowed;
}
.search-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 8px;
  padding-left: 2px;
}
.spinner {
  display: inline-block;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error ── */
.error-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--error-bg);
  border: 1px solid var(--error-brd);
  border-radius: var(--radius);
  padding: 16px 20px;
  color: #f08080;
}
.error-icon { font-size: 1.3rem; flex-shrink: 0; }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}

/* ── Profile card ── */
.profile-card {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
.avatar {
  width: 80px;
  height: 80px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-card-2);
}
.profile-info { flex: 1; min-width: 0; }
.profile-username {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-top: 10px;
}
.stat-item {
  display: flex;
  flex-direction: column;
}
.stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}
.stat-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.stat-value.accent { color: var(--accent); }

/* XP bar */
.xp-bar-wrap {
  margin-top: 14px;
}
.xp-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.xp-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.xp-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.6s ease;
}

/* ── Allocation card ── */
.alloc-card { margin-bottom: 12px; }
.alloc-card-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.alloc-row { margin-bottom: 14px; }
.alloc-row:last-child { margin-bottom: 0; }
.alloc-row-hd {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 7px;
  flex-wrap: wrap;
}
.alloc-icon { font-size: 0.95rem; width: 18px; text-align: center; flex-shrink: 0; }
.alloc-name { font-size: 0.85rem; font-weight: 700; color: var(--text); flex: 1; min-width: 0; }
.alloc-val  { font-size: 0.95rem; font-weight: 700; color: var(--text); }
.alloc-st-ok   { font-size: 0.72rem; color: var(--success); white-space: nowrap; }
.alloc-st-gap  { font-size: 0.72rem; color: var(--accent);  white-space: nowrap; font-weight: 600; }
.alloc-st-over { font-size: 0.72rem; color: var(--warning); white-space: nowrap; font-weight: 700; }

.alloc-tiles { display: flex; flex-wrap: wrap; gap: 4px; }
.alloc-tile {
  width: 28px;
  height: 28px;
  border-radius: 5px;
  border: 1px solid transparent;
  transition: opacity 0.2s;
}

/* Skill colors */
.tile-energy { background: #2a6dd9; }
.tile-prod   { background: #c07c10; }
.tile-entr   { background: #8b3fbd; }
.tile-comp   { background: #b06520; }

/* Tile states */
.tile-ok      { opacity: 1; }
.tile-over    { opacity: 1; outline: 2px solid var(--error); outline-offset: 1px; }
.tile-missing {
  opacity: 1;
  border: 1px solid var(--border);
  background: repeating-linear-gradient(
    45deg,
    color-mix(in srgb, var(--accent) 40%, transparent) 0px,
    color-mix(in srgb, var(--accent) 40%, transparent) 3px,
    var(--bg-card-2) 3px,
    var(--bg-card-2) 10px
  ) !important;
}
.tile-empty   { opacity: 0.1; }

.alloc-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.alloc-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
}
.leg-tile { width: 16px; height: 16px; flex-shrink: 0; }

/* ── Skills card ── */
.skills-card-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.step-progress {
  margin-bottom: 18px;
}
.step-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.step-label {
  font-size: 0.85rem;
  color: var(--text);
  font-weight: 600;
}
.step-pct {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.step-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.step-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  border-radius: 4px;
  transition: width 0.8s ease;
}
.goal-chip {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 4px;
  padding: 1px 5px;
  vertical-align: middle;
  margin-left: 6px;
  letter-spacing: 0.3px;
}

.skills-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.skill-item {
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
}
.skill-name {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.skill-level {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}
.skill-level .max  { color: var(--success); }
.skill-level .warn { color: var(--error); }
.skill-level .over { color: var(--warning); }

.skill-target {
  font-size: 0.7rem;
  margin-bottom: 3px;
}
.skill-target-needed { color: var(--accent); }
.skill-target-met    { color: var(--success); }
.skill-target-over   { color: var(--warning); font-weight: 700; }

.skill-mini-bar {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 5px;
  overflow: hidden;
}
.skill-mini-fill {
  height: 100%;
  border-radius: 2px;
}
.fill-eco   { background: var(--accent); }
.fill-mil   { background: var(--error); }
.fill-other { background: var(--info); }

.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}
.section-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* ── Tip cards ── */
.tip-card {
  border-radius: var(--radius-lg);
  border: 1px solid;
  padding: 16px 20px;
  margin-bottom: 12px;
}
.tip-card h3 {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.tip-card p {
  font-size: 0.88rem;
  line-height: 1.55;
}
.tip-card p a {
  color: inherit;
  text-decoration: underline;
  opacity: 0.85;
}
.tip-card p a:hover { opacity: 1; }

.tip-card.tip-error   { background: var(--error-bg);   border-color: var(--error-brd);   }
.tip-card.tip-error h3   { color: var(--error); }
.tip-card.tip-error p    { color: #d4a0a0; }

.tip-card.tip-warning { background: var(--warning-bg); border-color: var(--warning-brd); }
.tip-card.tip-warning h3 { color: var(--warning); }
.tip-card.tip-warning p  { color: #c8a870; }

.tip-card.tip-success { background: var(--success-bg); border-color: var(--success-brd); }
.tip-card.tip-success h3 { color: var(--success); }
.tip-card.tip-success p  { color: #80c8a0; }

.tip-card.tip-info    { background: var(--info-bg);    border-color: var(--info-brd);    }
.tip-card.tip-info h3    { color: var(--info); }
.tip-card.tip-info p     { color: #88b8d8; }

.tips-heading {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.tip-more-btn {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  background: none;
  border: 1px solid currentColor;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 0.15s;
}
.tip-more-btn:hover { opacity: 1; }
.tip-error   .tip-more-btn { color: var(--error); }
.tip-warning .tip-more-btn { color: var(--warning); }
.tip-success .tip-more-btn { color: var(--success); }
.tip-info    .tip-more-btn { color: var(--info); }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px 24px;
  max-width: 560px;
  width: 100%;
  max-height: 82vh;
  overflow-y: auto;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 16px;
  padding-right: 28px;
  line-height: 1.4;
}
.modal-body p {
  color: var(--text-dim);
  font-size: 0.88rem;
  line-height: 1.7;
  margin-bottom: 10px;
}
.modal-body p:last-child { margin-bottom: 0; }
.modal-body strong { color: var(--text); }
.modal-body ul {
  margin: 6px 0 10px 18px;
  color: var(--text-dim);
  font-size: 0.88rem;
  line-height: 1.7;
}
.modal-body ul:last-child { margin-bottom: 0; }

/* ── Footer ── */
.footer {
  text-align: center;
  padding: 20px 16px;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Utilities ── */
.hidden { display: none !important; }

/* ── Responsive ── */
@media (max-width: 520px) {
  .profile-card { flex-direction: column; }
  .avatar { width: 64px; height: 64px; }
  .logo-text h1 { font-size: 1.3rem; letter-spacing: 2px; }
  .skills-grid { grid-template-columns: 1fr; }
}
