/* The Kolorian — deep-space UI */
:root {
  --bg: #05070f;
  --bg-panel: rgba(17, 24, 43, 0.82);
  --bg-panel-solid: #111b2c;
  --bg-input: #0a1120;
  --border: #223252;
  --border-soft: #1a2740;
  --text: #cfd9ea;
  --text-dim: #7e8ca6;
  --text-bright: #eef4ff;
  --accent: #6ee7ff;
  --accent-2: #f5c76a;
  --good: #4cd17e;
  --bad: #ff7a6b;
  --ally: #58a6ff;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
html { scrollbar-color: #2b3a5c var(--bg); }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Starfield backdrop */
.stars {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(1.4px 1.4px at 12% 22%, #cfe4ff 60%, transparent),
    radial-gradient(1px 1px at 31% 71%, #ffffffcc 60%, transparent),
    radial-gradient(1.8px 1.8px at 44% 12%, #ffe9bd 60%, transparent),
    radial-gradient(1px 1px at 58% 48%, #cfe4ff99 60%, transparent),
    radial-gradient(1.3px 1.3px at 67% 83%, #ffffffb0 60%, transparent),
    radial-gradient(1px 1px at 78% 29%, #cfe4ffcc 60%, transparent),
    radial-gradient(1.7px 1.7px at 89% 61%, #ffe9bdb0 60%, transparent),
    radial-gradient(1px 1px at 5% 88%, #ffffff90 60%, transparent),
    radial-gradient(1.2px 1.2px at 24% 45%, #cfe4ffb0 60%, transparent),
    radial-gradient(1px 1px at 94% 9%, #ffffffcc 60%, transparent),
    radial-gradient(ellipse 80% 55% at 70% -10%, rgba(64, 96, 190, 0.22), transparent),
    radial-gradient(ellipse 60% 45% at 10% 110%, rgba(120, 70, 180, 0.16), transparent);
  background-repeat: repeat, repeat, repeat, repeat, repeat, repeat, repeat, repeat, repeat, repeat, no-repeat, no-repeat;
  background-size: 900px 700px, 700px 500px, 1100px 800px, 800px 600px, 950px 750px,
    650px 550px, 1200px 900px, 850px 650px, 750px 600px, 1000px 800px, 100% 100%, 100% 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.55em; letter-spacing: 0.02em; color: var(--text-bright); margin: 0.4em 0 0.6em; }
h2 { font-size: 1.12em; margin: 1.3em 0 0.5em; color: var(--text-bright); letter-spacing: 0.04em;
  text-transform: uppercase; font-size: 0.95em; }
h2::before { content: "◢ "; color: var(--accent-2); }
h3 { color: var(--text-bright); }
h1 small, h2 small, h3 small { color: var(--text-dim); font-weight: normal; font-size: 0.68em;
  text-transform: none; letter-spacing: 0; }

/* ===== Top bar ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.4em 1.2em;
  padding: 0.55em 1.2em;
  background: linear-gradient(180deg, rgba(13, 19, 36, 0.97), rgba(10, 15, 29, 0.92));
  border-bottom: 1px solid var(--border); backdrop-filter: blur(6px);
}
.logo {
  display: flex; align-items: center; gap: 0.5em;
  font-size: 1.1em; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-bright); text-decoration: none;
}
.logo:hover { text-decoration: none; }
.logo b { color: var(--accent-2); font-weight: 700; }
.logo-orb {
  width: 18px; height: 18px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #b8f1ff, var(--accent) 45%, #1d5f86 100%);
  box-shadow: 0 0 10px rgba(110, 231, 255, 0.7);
}
.topbar nav { display: flex; flex-wrap: wrap; gap: 0.15em; flex: 1; }
.topbar nav a {
  position: relative; padding: 0.3em 0.7em; border-radius: 6px; color: var(--text);
  border: 1px solid transparent; letter-spacing: 0.02em;
}
.topbar nav a:hover { background: rgba(110, 231, 255, 0.08); text-decoration: none; }
.topbar nav a.active {
  color: var(--accent); background: rgba(110, 231, 255, 0.1);
  border-color: rgba(110, 231, 255, 0.35);
}
.badge {
  display: inline-block; margin-left: 0.4em; padding: 0 0.45em; border-radius: 999px;
  background: var(--accent-2); color: #201503; font-size: 0.78em; font-weight: 700;
}
.topbar-user { color: var(--text-dim); font-size: 0.9em; white-space: nowrap; }
.topbar-user a { font-size: 1.1em; }

/* ===== Resource bar ===== */
.resourcebar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5em 1.4em;
  padding: 0.5em 1.2em;
  background: linear-gradient(180deg, rgba(9, 14, 27, 0.95), rgba(7, 11, 22, 0.9));
  border-bottom: 1px solid var(--border-soft); font-size: 0.92em;
}
.planetswitch { display: flex; flex-wrap: wrap; gap: 0.3em; }
.planetswitch a {
  padding: 0.2em 0.6em; border-radius: 6px; border: 1px solid var(--border-soft);
  color: var(--text-dim); background: rgba(17, 24, 43, 0.6);
}
.planetswitch a small { opacity: 0.75; }
.planetswitch a:hover { text-decoration: none; color: var(--text); }
.planetswitch a.active { color: var(--accent); border-color: rgba(110, 231, 255, 0.4); }
.res-group { display: flex; flex-wrap: wrap; gap: 0.4em 1.3em; margin-left: auto; }
.res { display: flex; align-items: center; gap: 0.45em; }
.res-icon {
  font-style: normal; width: 1.7em; height: 1.7em; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(110, 231, 255, 0.08); border: 1px solid var(--border-soft); font-size: 0.95em;
}
.res-metal .res-icon { color: #b7c4d8; }
.res-crystal .res-icon { color: #8fd7ff; }
.res-gas .res-icon { color: #c7a6ff; }
.res-food .res-icon { color: #a7e28b; }
.res-energy .res-icon { color: var(--accent-2); }
.res-body { display: flex; flex-direction: column; line-height: 1.15; }
.res-body small { color: var(--text-dim); font-size: 0.72em; text-transform: uppercase; letter-spacing: 0.08em; }
.res-body b { color: var(--text-bright); font-variant-numeric: tabular-nums; font-size: 0.98em; }
.res-body b em { font-style: normal; color: var(--text-dim); font-size: 0.85em; }
.meter { display: block; width: 74px; height: 3px; margin-top: 2px; border-radius: 2px; background: #1a2438; overflow: hidden; }
.meter-fill { display: block; height: 100%; border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 1s linear; }
.res.warn .res-body b, .res.warn { color: var(--bad); }
.res.warn .res-icon { border-color: rgba(255, 122, 107, 0.5); color: var(--bad); }
.immobilized { font-weight: 600; }

/* ===== Layout ===== */
.content { padding: 1.2em 1.5em 2em; max-width: 1200px; margin: 0 auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2em; align-items: start; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

.panel {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 0.9em 1.2em 1.1em; box-shadow: var(--shadow); backdrop-filter: blur(4px);
}
.panel h2:first-child, .panel h3:first-child { margin-top: 0.25em; }

.pagefoot {
  text-align: center; color: var(--text-dim); font-size: 0.82em; padding: 1.2em; letter-spacing: 0.05em;
}
.pagefoot .dim { opacity: 0.6; }

/* ===== Tables ===== */
.datatable { width: 100%; border-collapse: collapse; margin: 0.6em 0; }
.datatable th, .datatable td { text-align: left; padding: 0.5em 0.7em; border-bottom: 1px solid var(--border-soft); }
.datatable th {
  color: var(--text-dim); font-weight: 600; font-size: 0.8em;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.datatable tbody tr:hover td, .datatable tr:hover td { background: rgba(110, 231, 255, 0.04); }
.datatable tr.highlight td { background: rgba(245, 199, 106, 0.08); }
.cost { white-space: nowrap; margin-right: 0.5em; color: var(--text); }
.cost-metal { color: #b7c4d8; } .cost-crystal { color: #8fd7ff; }
.cost-gas { color: #c7a6ff; } .cost-food { color: #a7e28b; }

/* ===== Forms & buttons ===== */
button {
  background: linear-gradient(180deg, #274a7d, #1d3a66); color: #e6f0ff;
  border: 1px solid #3a6096; border-radius: 7px; padding: 0.38em 1em;
  cursor: pointer; font: inherit; letter-spacing: 0.02em;
  transition: filter 0.15s, transform 0.05s;
}
button:hover { filter: brightness(1.18); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.4; cursor: not-allowed; filter: none; }
button.danger { background: linear-gradient(180deg, #6d2836, #521e29); border-color: #8a3547; }

input, select, textarea {
  background: var(--bg-input); color: var(--text-bright); border: 1px solid var(--border);
  border-radius: 7px; padding: 0.4em 0.6em; font: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(110, 231, 255, 0.15);
}
label { display: block; margin: 0.6em 0; color: var(--text-dim); }
label input, label textarea, label select { width: 100%; max-width: 26em; display: block; margin-top: 0.2em; }
form.inline { display: inline-block; margin: 0.15em 0.3em 0.15em 0; }
form.inline input, form.inline select { width: auto; display: inline-block; }

.flash { padding: 0.55em 1em; border-radius: 8px; border: 1px solid; }
.flash.error { background: rgba(96, 28, 38, 0.5); border-color: #7c2f3f; color: #ffb9b0; }
.flash.success { background: rgba(22, 60, 35, 0.5); border-color: #2e6b41; color: #a9e8bc; }

/* ===== Auth ===== */
.authbox {
  max-width: 27em; margin: 9vh auto; background: var(--bg-panel);
  border: 1px solid var(--border); border-radius: 14px; padding: 1.8em 2.2em 1.6em;
  box-shadow: var(--shadow); backdrop-filter: blur(6px);
}
.authbox h1 { margin-top: 0; }
.auth-hero { text-align: center; margin-bottom: 1em; }
.auth-hero .logo-orb { width: 46px; height: 46px; margin: 0 auto 0.5em; display: block; }
.auth-hero .gamename {
  font-size: 1.5em; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text-bright);
}
.auth-hero .gamename b { color: var(--accent-2); }
.auth-hero .tagline { color: var(--text-dim); font-size: 0.9em; margin-top: 0.2em; }
.authbox button { width: 100%; padding: 0.6em; margin-top: 0.6em; font-size: 1.02em; }

/* ===== Messages ===== */
.message {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 10px;
  margin: 0.55em 0; padding: 0.5em 0.9em;
}
.message.unread { border-color: rgba(110, 231, 255, 0.45); box-shadow: 0 0 12px rgba(110, 231, 255, 0.08); }
.message summary { cursor: pointer; }
.message .tag {
  background: rgba(110, 231, 255, 0.1); border: 1px solid var(--border);
  border-radius: 5px; padding: 0.05em 0.55em; font-size: 0.78em; margin-right: 0.5em;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent);
}
.messagebody { white-space: pre-wrap; font-family: inherit; color: var(--text); }
.countdown { font-variant-numeric: tabular-nums; color: var(--accent-2); }

/* ===== SVG map ===== */
#map-wrap { position: relative; height: calc(100vh - 150px); min-height: 420px; }
#map {
  width: 100%; height: 100%; border: 1px solid var(--border); border-radius: 12px;
  background: radial-gradient(ellipse at 30% 20%, #0d1730 0%, #060a15 55%, #04060c 100%);
  cursor: grab; touch-action: none; box-shadow: var(--shadow);
}
#map:active { cursor: grabbing; }
#map-hud { position: absolute; top: 0.8em; left: 0.8em; display: flex; gap: 0.5em; align-items: center; }
#map-hud button { backdrop-filter: blur(4px); }
#map-status {
  color: var(--text-dim); font-size: 0.85em; background: rgba(8, 12, 22, 0.8);
  padding: 0.25em 0.7em; border-radius: 6px; border: 1px solid var(--border-soft);
  text-transform: uppercase; letter-spacing: 0.1em;
}
#planet-panel {
  position: absolute; top: 0.8em; right: 0.8em; width: 330px; max-height: 92%; overflow: auto;
  background: rgba(12, 18, 34, 0.96); border: 1px solid rgba(110, 231, 255, 0.35);
  border-radius: 12px; padding: 0.9em 1.1em; box-shadow: var(--shadow);
}
#planet-panel.hidden { display: none; }
#planet-panel h3 { margin: 0.2em 0 0.5em; }
#planet-panel .closebtn { float: right; padding: 0.1em 0.5em; }

.gal-cell { stroke: #223252; stroke-width: 4; transition: filter 0.15s; }
.gal-cell:hover { filter: brightness(1.4); }
.gal-label { fill: #8fa1bd; text-anchor: middle; pointer-events: none; letter-spacing: 0.1em; }
.sys-dot { fill: #5d7195; }
.sys-dot:hover { fill: var(--accent); }
.sys-dot.settled { fill: var(--accent-2); }
.sys-label { fill: #4a5871; text-anchor: middle; pointer-events: none; }
.star { fill: var(--accent-2); }
.orbit-ring { fill: none; stroke: #1c2942; stroke-width: 0.5; }
.planet-free { fill: #39465f; }
.planet-free:hover { fill: #55688c; }
.planet-own { fill: var(--good); }
.planet-alliance { fill: var(--ally); }
.planet-foreign { fill: var(--bad); }
.debris-mark { fill: #c8ab6d; }
.planet-name { fill: var(--text); text-anchor: middle; pointer-events: none; }
.fleet-line { stroke-dasharray: 4 4; fill: none; opacity: 0.75; }
.fleet-line.own { stroke: var(--good); }
.fleet-line.alliance { stroke: var(--ally); }
.fleet-line.hostile { stroke: var(--bad); }
.fleet-dot.own { fill: var(--good); }
.fleet-dot.alliance { fill: var(--ally); }
.fleet-dot.hostile { fill: var(--bad); }
.city-building { fill: #2c4f86; stroke: #6ea8e8; stroke-width: 0.5; }
.city-label { fill: var(--text); font-size: 9px; text-anchor: middle; }
