/* Asteria Online UI polish (update 78). Loaded AFTER style.css: tokens, spacing scale, radii, shadows, focus rings, button states, scrollbars,
   tooltips, window chrome, tabs, tables, inputs and the login screen. It refines style.css, it does not replace it: layout (sizes, positions) is untouched.
   Anything new (e.g. the race creator) that is styled with the :root tokens inherits this look. */
:root {
  /* spacing scale (4px base) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  /* radii: the game is angular (chamfered clip-paths), so corners stay small */
  --r1: 2px; --r2: 3px; --r3: 5px;
  /* elevation */
  --sh1: 0 1px 2px rgba(0,0,0,.45); --sh2: 0 4px 14px rgba(0,0,0,.5); --sh3: 0 12px 40px rgba(0,0,0,.7);
  --glow-cyan: 0 0 14px rgba(79,209,255,.28); --glow-gold: 0 0 14px rgba(245,192,74,.3);
  /* extra colour tokens (new names: nothing in style.css is renamed) */
  --gold2: #ffe9a8; --cyan2: #9fe6ff; --ink: #eaf6ff; --line3: #3a6a92;
  --focus: 0 0 0 2px rgba(4,6,11,.9), 0 0 0 4px rgba(79,209,255,.85);
  --ease: cubic-bezier(.2,.7,.2,1);
}

/* ---------- base ---------- */
::selection { background: rgba(79,209,255,.35); color: #fff; }
html { scrollbar-color: #2b5273 #07101c; scrollbar-width: thin; }
* { scrollbar-color: #2b5273 #07101c; scrollbar-width: thin; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: rgba(4,8,14,.7); }
::-webkit-scrollbar-thumb { background: linear-gradient(180deg, #2f5b80, #234767); border: 2px solid rgba(4,8,14,.7); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: linear-gradient(180deg, #4fd1ff, #2a86ad); }
::-webkit-scrollbar-corner { background: transparent; }
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* keyboard focus: a clear ring, only for keyboard users */
button:focus-visible, .btn:focus-visible, .tab:focus-visible, .tbtn:focus-visible, #rail button:focus-visible, a:focus-visible, [tabindex]:focus-visible:not(#map) {
  outline: none; box-shadow: var(--focus); position: relative; z-index: 2;
}
.btn:focus-visible { clip-path: none; }
#map:focus-visible { outline: none; }

/* ---------- top bar & rail ---------- */
#topbar { box-shadow: 0 2px 16px rgba(0,0,0,.5); border-bottom-color: var(--line2); background: linear-gradient(180deg, rgba(8,14,28,.98), rgba(5,9,18,.88)); }
#topbar .logo { background: #070c14; }
#topbar .logo svg { display: none; }
#topbar .logo::before { content: ""; width: 38px; height: 38px; background: url(/img/brand/mark.svg) center/contain no-repeat; opacity: .92; }
.res { background: linear-gradient(180deg, rgba(16,30,52,.85), rgba(8,16,30,.85)); border-color: var(--line); transition: border-color .15s, background .15s; }
.res:hover { border-color: var(--line3); }
#rail { background: linear-gradient(90deg, rgba(5,9,18,.96), rgba(8,14,26,.92)); box-shadow: 2px 0 14px rgba(0,0,0,.4); }
#rail button { transition: color .12s, background .12s, border-color .12s; }
#rail button.on { background: linear-gradient(90deg, rgba(79,209,255,.2), rgba(79,209,255,.04)); box-shadow: inset 0 0 14px rgba(79,209,255,.08); }
#rail button:active { background: rgba(79,209,255,.22); }

/* ---------- panels & window chrome ---------- */
#panel { border-right-color: var(--line3); box-shadow: 10px 0 34px rgba(0,0,0,.5), inset -1px 0 0 rgba(79,209,255,.08); }
#panel header, .fwin header {
  padding: 9px 14px; border-bottom: 1px solid var(--line2); position: relative;
  background: linear-gradient(90deg, rgba(79,209,255,.17), rgba(79,209,255,.03) 70%, transparent);
}
#panel header::after, .fwin header::after { content: ""; position: absolute; left: 0; bottom: -1px; width: 64px; height: 1px; background: linear-gradient(90deg, var(--gold), transparent); }
#panel header h2, .fwin header h2 { text-shadow: 0 0 12px rgba(79,209,255,.35); }
.fwin { border-color: var(--line3); box-shadow: var(--sh3), 0 0 0 1px rgba(0,0,0,.4); }
.fwin.top { border-color: var(--cyan); box-shadow: var(--sh3), 0 0 0 1px rgba(79,209,255,.3), 0 0 26px rgba(79,209,255,.12); }
.fwin:not(.top) header { filter: saturate(.7) brightness(.92); }
#panel header .wb, .fwin header .wb, .x { border-radius: var(--r2); transition: color .12s, background .12s; }
#panel header .wb:hover, .fwin header .wb:hover { background: rgba(79,209,255,.12); }
.x:hover, .fwin header .wb.x:hover { background: rgba(255,91,107,.14); }
#panel .body, .fwin .body { scroll-padding: var(--s3); }
#panel .body > h3, .fwin .body > h3 { padding-bottom: 3px; border-bottom: 1px solid rgba(43,82,115,.55); }
.card { background: linear-gradient(180deg, rgba(18,30,52,.94), rgba(12,21,38,.94)); box-shadow: var(--sh1), inset 0 1px 0 rgba(120,190,240,.05); transition: border-color .15s; }
.card:hover { border-color: var(--line2); }
.card.hl { box-shadow: var(--sh1), inset 0 0 18px rgba(245,192,74,.07); }
.sep { background: linear-gradient(90deg, transparent, var(--line2), transparent); }
.empty { border-radius: var(--r2); background: rgba(8,16,28,.4); }

/* ---------- buttons ---------- */
.btn {
  position: relative; border-color: var(--line2); box-shadow: inset 0 1px 0 rgba(150,215,255,.12); font-weight: 600;
  transition: border-color .12s, background .12s, color .12s, filter .12s, transform .06s, box-shadow .12s;
}
.btn:hover:not(:disabled) { box-shadow: inset 0 1px 0 rgba(190,235,255,.22), 0 0 12px rgba(79,209,255,.22); }
.btn:active:not(:disabled) { transform: translateY(1px); filter: brightness(.88); box-shadow: inset 0 2px 5px rgba(0,0,0,.5); }
.btn:disabled { opacity: .42; filter: saturate(.4); cursor: not-allowed; box-shadow: none; }
.btn.primary { box-shadow: inset 0 1px 0 rgba(190,235,255,.25), 0 0 10px rgba(79,209,255,.16); }
.btn.primary:hover:not(:disabled) { background: linear-gradient(180deg, #2689b5, #165a7a); }
.btn.gold:hover:not(:disabled) { background: linear-gradient(180deg, #8a6a1a, #5d4510); color: #fff3cc; box-shadow: inset 0 1px 0 rgba(255,235,170,.3), var(--glow-gold); border-color: #ffd877; }
.btn.danger:hover:not(:disabled) { background: linear-gradient(180deg, #86283a, #561a28); color: #fff; border-color: #ff8a96; }
.btn.on { background: linear-gradient(180deg, #123a58, #0c2740); }
.tbtn { transition: border-color .12s, background .12s, color .12s; }
.tbtn:active { transform: translateY(1px); }

/* ---------- tabs ---------- */
.tabs { border-bottom-color: var(--line2); }
.tab { transition: color .12s, background .12s, border-color .12s; border-radius: var(--r2) var(--r2) 0 0; }
.tab:hover { background: rgba(79,209,255,.07); }
.tab.on { background: linear-gradient(180deg, rgba(79,209,255,.14), rgba(79,209,255,.02)); text-shadow: 0 0 10px rgba(79,209,255,.5); }
.tab:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- inputs ---------- */
input, select, textarea { background: linear-gradient(180deg, #060e1a, #081322); border-color: var(--line2); border-radius: var(--r1); box-shadow: inset 0 1px 3px rgba(0,0,0,.45); transition: border-color .12s, box-shadow .12s; }
input:hover:not(:disabled), select:hover:not(:disabled), textarea:hover:not(:disabled) { border-color: var(--line3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--cyan); box-shadow: inset 0 1px 3px rgba(0,0,0,.45), 0 0 0 2px rgba(79,209,255,.28); }
input:disabled, select:disabled, textarea:disabled { opacity: .5; cursor: not-allowed; }
input::placeholder, textarea::placeholder { color: #4f677b; }
input[type=checkbox], input[type=radio], input[type=range] { accent-color: var(--cyan); box-shadow: none; }
select { cursor: pointer; }

/* ---------- tables ---------- */
th { background: linear-gradient(180deg, #0f1c31, #0a1424); border-bottom: 1px solid var(--line2); }
tbody tr:nth-child(even) td { background: rgba(79,209,255,.025); }
td { transition: background .1s; }
tr.click:hover td { background: rgba(79,209,255,.1); }
tr.sel td { background: rgba(79,209,255,.18); box-shadow: inset 2px 0 0 var(--cyan); }
tr.sel td:not(:first-child) { box-shadow: none; }

/* ---------- bars, badges ---------- */
.bar { background: #071019; border-color: var(--line); border-radius: var(--r1); box-shadow: inset 0 1px 2px rgba(0,0,0,.6); }
.bar > i { box-shadow: 0 0 8px rgba(79,209,255,.35); transition: width .4s var(--ease); }
.bar.gold > i { box-shadow: 0 0 8px rgba(245,192,74,.3); } .bar.green > i { box-shadow: 0 0 8px rgba(91,227,160,.3); } .bar.red > i { box-shadow: 0 0 8px rgba(255,91,107,.3); }
.badge { border-radius: var(--r1); background: rgba(8,16,28,.5); }

/* ---------- tooltips, toasts, feed ---------- */
#tip { background: linear-gradient(180deg, rgba(14,26,46,.98), rgba(6,12,22,.98)); border: 1px solid var(--line3); border-top: 2px solid var(--cyan); border-radius: var(--r1); box-shadow: var(--sh2), var(--glow-cyan); padding: 7px 11px; line-height: 1.45; }
#toasts div { background: linear-gradient(180deg, #112440, #0b1a30); border-color: var(--cyan); border-radius: var(--r2); box-shadow: var(--sh2), var(--glow-cyan); }
#toasts div.bad { background: linear-gradient(180deg, #3a1520, #240d15); box-shadow: var(--sh2), 0 0 14px rgba(255,91,107,.22); }
#feed > div { border-radius: 0 var(--r2) var(--r2) 0; box-shadow: var(--sh1); }
#alerts, #quest { border-color: var(--line3); box-shadow: var(--sh2); }
#cmdbar .cb-box { box-shadow: var(--sh3), 0 0 0 1px rgba(79,209,255,.14), 0 0 40px rgba(79,209,255,.08); }

/* ---------- bottom bar ---------- */
#hud { box-shadow: 0 -6px 24px rgba(0,0,0,.45); border-top-color: var(--line3); }
.rtile { transition: border-color .12s, background .12s, box-shadow .12s; }
.rtile:hover { box-shadow: 0 0 10px rgba(79,209,255,.25); }
.fchip { border-radius: 0 var(--r2) var(--r2) 0; transition: border-color .12s, background .12s; box-shadow: var(--sh1); }
.hgrip:hover::after { box-shadow: 0 0 8px rgba(79,209,255,.6); }

/* ---------- login screen: key art, logo ---------- */
#auth.overlay {
  background:
    radial-gradient(ellipse at 50% 55%, rgba(4,3,16,.34) 0, rgba(4,3,16,.8) 62%, rgba(2,2,10,.96) 100%),
    #05070b url(/img/brand/keyart.jpg) center/cover no-repeat;
}
#auth.overlay.show { animation: authin .5s var(--ease); }
@keyframes authin { from { opacity: 0; } to { opacity: 1; } }
.authbox {
  position: relative; width: 420px; padding: 8px 30px 24px; border: 1px solid var(--line3); border-top: 1px solid #b08d57;
  background: linear-gradient(180deg, rgba(14,22,44,.9), rgba(6,10,22,.93)); backdrop-filter: blur(10px);
  box-shadow: var(--sh3), 0 0 0 1px rgba(0,0,0,.5), inset 0 1px 0 rgba(207,214,220,.05);
  clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 18px 100%, 0 calc(100% - 18px));
}
.authbox h1.brandlogo { margin: 24px 0 10px; text-shadow: none; letter-spacing: 0; line-height: 0; }
.authbox h1.brandlogo img { display: block; width: 100%; height: auto; filter: drop-shadow(0 4px 18px rgba(0,0,0,.6)); user-select: none; -webkit-user-drag: none; }
.authbox .sub { margin: 0 0 16px; color: #b08d57; letter-spacing: .28em; text-transform: uppercase; font-size: 10px; text-shadow: none; }
.authbox label { margin-top: 12px; }
.authbox input { padding: 8px 10px; font-size: 14px; }
.authbox .btn { padding: 11px; font-size: 12px; letter-spacing: .14em; margin-top: 18px; }
.authbox .tabs { justify-content: center; border-bottom-color: var(--line2); }
.authbox .tab { flex: 1; text-align: center; }
@media (max-width: 480px) { .authbox { padding: 6px 18px 20px; } .authbox h1.brandlogo { margin: 0 -6px; } }
@media (max-height: 560px) { #auth.overlay { align-items: flex-start; } .authbox { margin: 10px auto; } }

@media (prefers-reduced-motion: reduce) { #auth.overlay.show { animation: none; } .btn, .tab, input, select, .bar > i { transition: none; } }

/* update 95: your own resting orders in the order book */
tr.mine td { background: rgba(255,200,87,.14); font-weight: 600; }
tr.mine td:first-child { box-shadow: inset 3px 0 0 #ffc857; }
tr.mine:hover td { background: rgba(255,200,87,.24); }

/* ---- Federation chat window (update 114) ---- */
.fwin .body.fcbody { display: flex; flex-direction: column; gap: 6px; overflow: hidden; padding: 8px 10px 10px; }
.fctabs { display: flex; gap: 4px; flex: none; }
.fctab { flex: 1 1 0; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 6px 8px; font: inherit; font-size: 12px; letter-spacing: .02em; color: var(--muted); background: rgba(255,255,255,.03); border: 1px solid var(--line); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fctab:hover { color: var(--text); }
.fctab.on { color: var(--gold); border-bottom-color: var(--gold); background: rgba(245,192,74,.08); }
.fctab[data-ch="fed"].on { color: var(--green); border-bottom-color: var(--green); background: rgba(80,220,140,.08); }
.fcn { font-style: normal; font-size: 10px; line-height: 1; padding: 2px 5px; border-radius: 8px; background: var(--red); color: #fff; }
.fcn[hidden] { display: none; }
.fcroster { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 11px; min-height: 20px; }
.fcon { color: var(--green); margin-right: 2px; }
.fcchip { font: inherit; font-size: 11px; padding: 1px 7px; border-radius: 10px; color: var(--text); background: rgba(79,209,255,.08); border: 1px solid var(--line); cursor: pointer; }
.fcchip:hover { border-color: var(--cyan); color: var(--cyan); }
.fcbox { flex: 1 1 auto; min-height: 90px; overflow-y: auto; border: 1px solid var(--line); background: #060d17; padding: 6px 8px; font-size: 12.5px; line-height: 1.4; }
.fcm { display: flex; flex-wrap: wrap; gap: 0 6px; align-items: baseline; padding: 2px 0; word-break: break-word; }
.fcm .fct { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; min-width: 32px; }
.fcm .fcti { color: var(--muted); font-size: 10px; }
.fcm .fcw { color: var(--gold); font-weight: 600; } .fcm.conf .fcw { color: var(--green); } .fcm.mine .fcw { color: var(--cyan); }
.fcm .fcx { flex: 1 1 100%; padding-left: 38px; margin-top: -1px; }
.fcnone { padding: 14px 6px; text-align: center; }
.fcsend { flex: none; display: flex; gap: 6px; }
.fcsend input { flex: 1; min-width: 0; }
.fcempty { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; padding: 18px 8px; } .fcbig { font-size: 16px; color: var(--gold); }

/* update 116: a checkbox next to a long, wrapping label must not shrink into a dot */
input[type="checkbox"], input[type="radio"] { flex: none; min-width: 16px; min-height: 16px; }

/* update 116: the top bar on a laptop-sized window: the resource chips never clip; the build hint and the badges give way first */
#badges, #badges > *, #clock small, #clock #clk1 { white-space: nowrap; }
.res { flex: none; }
.res .v { white-space: nowrap; }
.res .d { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 128px; }
#badges { flex: 0 0 auto; }   /* the build hint (#nextup) shortens first; the badges keep their text */
#nextup { flex: 0 1 auto; min-width: 0; }
@media (max-width: 1500px) { #badges > .ident { display: none !important; } }   /* title and race: the Empire panel has them */
@media (max-width: 1320px) {
  .res { padding: 2px 9px; gap: 6px; }
  #nextup { max-width: 200px; }
}
@media (max-width: 1180px) {
  .res .d { display: none; }
  .res { height: 36px; }
  #clock small { display: none; }
  #nextup { display: none; }
  #badges > .fedtag { display: none; }
}

/* update 116: event toasts are never hidden behind the Getting-started list */
#feed { z-index: 7; }

/* update 116: a row of action buttons wraps as whole buttons instead of squeezing their labels into three lines */
.btnrow button, .btnrow label { white-space: nowrap; }

/* update 116: the Getting-started list sits above the hotbar, so a side panel that pushes the hotbar to the right never covers its last lines */
#quest { bottom: calc(var(--hud) + 78px); max-height: calc(100vh - var(--hud) - 178px); }

/* update 116: below ~1290 px the build hint would shrink to a single letter; the Planets list already shows the same job */
@media (max-width: 1290px) { #nextup { display: none; } }
