/* ═══════════════════════════════════════════════════════════
   GrimDay Design System — Endzeitspiel 2.0
   Custom CSS: tokens, layout shell, components
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Share+Tech+Mono&display=swap');

/* ─── Design Tokens ────────────────────────────────────────── */
:root {
  --bg-deep:    #0a0e14;
  --bg-surface: #111820;
  --bg-card:    #161d27;
  --bg-elevated:#1c2533;
  --bg-hover:   #222d3a;

  --text-primary:   #d4dae3;
  --text-secondary: #7a8a9e;
  --text-muted:     #4a5568;
  --text-bright:    #edf0f5;

  --accent:       #e89a3e;
  --accent-bright:#f5b04a;
  --accent-dim:   #a06828;
  --accent-glow:  rgba(232,154,62,0.15);

  --health:    #3dd68c;
  --damage:    #e8553e;
  --radiation: #d4f542;
  --rad-glow:  rgba(212,245,66,0.25);
  --water:     #3ea8e8;
  --energy:    #a86ef5;
  --hunger:    #e8983e;

  --border:        #2a3545;
  --border-bright: #3a4a5e;
  --border-accent: rgba(232,154,62,0.4);

  --hazard: #e8c93e;
  --clip:   10px;
  --sidebar:  220px;
  --rightbar: 240px;
}

/* ─── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.5;
  overflow: hidden;
}

/* Scanline overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0,0,0,0.02) 3px,
    rgba(0,0,0,0.02) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* ─── SVG Icons ────────────────────────────────────────────── */
.icon    { display: inline-block; width: 16px; height: 16px; vertical-align: middle; fill: currentColor; flex-shrink: 0; }
.icon-sm { width: 12px; height: 12px; }
.icon-lg { width: 20px; height: 20px; }
.icon-xl { width: 24px; height: 24px; }

/* ─── Shell ─────────────────────────────────────────────────── */
.gd-shell {
  display: grid;
  grid-template-rows: 58px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ─── Topbar ─────────────────────────────────────────────────── */
.topbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 18px;
  height: 58px;
  gap: 14px;
  overflow: hidden;
}

.tb-logo {
  font-weight: 700;
  font-size: 17px;
  color: var(--text-bright);
  letter-spacing: 1px;
  white-space: nowrap;
  text-decoration: none;
}
.tb-logo span { color: var(--accent); }

.tb-div {
  width: 1px;
  height: 22px;
  background: var(--border);
  flex-shrink: 0;
}

.tb-res { display: flex; gap: 14px; flex-shrink: 0; }

.tb-r { display: flex; align-items: center; gap: 5px; }

.tb-r-v {
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  color: var(--accent-bright);
}

.tb-ticker {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 14px;
  background: var(--accent-glow);
  border: 1px solid var(--border-accent);
  clip-path: polygon(5px 0, calc(100% - 5px) 0, 100% 5px, 100% calc(100% - 5px), calc(100% - 5px) 100%, 5px 100%, 0 calc(100% - 5px), 0 5px);
  flex-shrink: 0;
}
.tb-ticker-t { font-weight: 600; font-size: 12px; color: var(--text-bright); }
.tb-ticker-v { font-family: 'Share Tech Mono', monospace; font-size: 13px; color: var(--accent-bright); font-weight: 500; }

.tb-player { display: flex; align-items: center; gap: 10px; flex-shrink: 0; margin-left: 8px; }
.tb-player-n { font-weight: 600; font-size: 13px; color: var(--text-bright); }
.tb-player-lv {
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 2px 8px;
  border: 1px solid var(--border-accent);
}

/* ─── Main Grid ──────────────────────────────────────────────── */
.gd-main {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr var(--rightbar);
  overflow: hidden;
  height: 100%;
}

@media (max-width: 1024px) {
  .gd-main { grid-template-columns: var(--sidebar) 1fr; }
  .gd-rightbar { display: none; }
}

@media (max-width: 768px) {
  .gd-main { grid-template-columns: 1fr; }
  .gd-sidebar { display: none; }
  .topbar { padding: 0 10px; }
  .tb-res { display: none; }
}

/* ─── Left Sidebar ───────────────────────────────────────────── */
.gd-sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sb-sec {
  padding: 14px;
  border-bottom: 1px solid var(--border);
}

.sb-label {
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--accent);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
}
.sb-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border-accent), transparent);
}

/* Character mini */
.sb-char { display: flex; align-items: center; gap: 10px; padding: 2px 0; }
.sb-avatar {
  width: 38px;
  height: 38px;
  position: relative;
  flex-shrink: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 6px 100%, 0 calc(100% - 6px));
}
.sb-cname { font-weight: 600; font-size: 13px; color: var(--text-bright); }
.sb-cdet { font-family: 'Share Tech Mono', monospace; font-size: 9px; color: var(--text-muted); }

/* Vital bars */
.vital { margin-bottom: 12px; }
.vital:last-child { margin-bottom: 0; }
.vital-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 5px; }
.vital-name { font-weight: 600; font-size: 11px; display: flex; align-items: center; gap: 5px; }
.vital-val { font-family: 'Share Tech Mono', monospace; font-size: 11px; }

.vital.hp .vital-name, .vital.hp .vital-val { color: var(--health); }
.vital.hu .vital-name, .vital.hu .vital-val { color: var(--hunger); }
.vital.wa .vital-name, .vital.wa .vital-val { color: var(--water); }
.vital.en .vital-name, .vital.en .vital-val { color: var(--energy); }
.vital.ra .vital-name, .vital.ra .vital-val { color: var(--radiation); }

.vbar { display: flex; gap: 2px; height: 12px; }
.vbar .s {
  flex: 1;
  background: var(--bg-deep);
  border: 1px solid rgba(42,53,69,0.5);
  transition: all 0.4s;
}
.vbar .s:first-child { clip-path: polygon(0 0, 100% 0, 100% 100%, 3px 100%, 0 calc(100% - 3px)); }
.vbar .s:last-child  { clip-path: polygon(0 0, calc(100% - 3px) 0, 100% 3px, 100% 100%, 0 100%); }
.vbar .s.on { border-color: transparent; }

.vital.hp .vbar .s.on { background: var(--health);    box-shadow: 0 0 4px rgba(61,214,140,0.2); }
.vital.hu .vbar .s.on { background: var(--hunger); }
.vital.wa .vbar .s.on { background: var(--water);     box-shadow: 0 0 3px rgba(62,168,232,0.15); }
.vital.en .vbar .s.on { background: var(--energy); }
.vital.ra .vbar .s.on { background: var(--radiation); box-shadow: 0 0 5px var(--rad-glow); }

.sb-radwarn {
  background: rgba(212,245,66,0.04);
  border: 1px solid rgba(212,245,66,0.15);
  padding: 7px 10px;
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 7px;
  animation: rp 3s ease-in-out infinite;
}
@keyframes rp {
  0%, 100% { border-color: rgba(212,245,66,0.18); }
  50%       { border-color: rgba(212,245,66,0.06); }
}
.sb-radwarn-t {
  font-family: 'Share Tech Mono', monospace;
  font-size: 9px;
  color: var(--radiation);
  letter-spacing: 0.5px;
}

.sb-hazard {
  height: 3px;
  background: repeating-linear-gradient(-45deg, var(--hazard), var(--hazard) 6px, var(--bg-deep) 6px, var(--bg-deep) 12px);
  opacity: 0.35;
}

/* Nav items */
.sb-nav {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  cursor: pointer;
  transition: all 0.12s;
  border-left: 3px solid transparent;
  font-weight: 500;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
}
.sb-nav:hover { background: var(--bg-hover); color: var(--text-primary); }
.sb-nav.active { color: var(--accent-bright); border-left-color: var(--accent); background: var(--accent-glow); }
.sb-nav-ico { width: 18px; text-align: center; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.sb-nav-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--damage); margin-left: auto; }

/* ─── Center ─────────────────────────────────────────────────── */
.gd-center {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* Page enter animation */
@keyframes fu { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }
.gd-screen { padding: 24px 28px; animation: fu 0.2s ease-out; }

/* Page header */
.pg-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 22px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.pg-title { font-weight: 700; font-size: 22px; color: var(--text-bright); letter-spacing: 0.5px; }
.pg-sub { font-family: 'Share Tech Mono', monospace; font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ─── Panel ──────────────────────────────────────────────────── */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  clip-path: polygon(0 0, calc(100% - var(--clip)) 0, 100% var(--clip), 100% 100%, var(--clip) 100%, 0 calc(100% - var(--clip)));
  position: relative;
  margin-bottom: 16px;
}
.panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  z-index: 1;
}
.panel.p-hp::before  { background: var(--health); }
.panel.p-dmg::before { background: var(--damage); }
.panel.p-wa::before  { background: var(--water); }
.panel.p-en::before  { background: var(--energy); }
.panel.p-rad::before { background: var(--radiation); }
.panel.p-hu::before  { background: var(--hunger); }

.ph {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 20px;
  border-bottom: 1px solid var(--border);
}
.pt { font-weight: 700; font-size: 13px; color: var(--text-bright); letter-spacing: 0.5px; }
.pb {
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 3px 10px;
  border: 1px solid var(--border-accent);
}
.pbody { padding: 18px 20px; }

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 1px;
  border: none;
  cursor: pointer;
  padding: 9px 20px;
  transition: all 0.2s;
  clip-path: polygon(0 0, calc(100% - 7px) 0, 100% 7px, 100% 100%, 7px 100%, 0 calc(100% - 7px));
  display: inline-block;
  text-decoration: none;
  text-align: center;
}
.btn-p { background: var(--accent); color: var(--bg-deep); }
.btn-p:hover { background: var(--accent-bright); box-shadow: 0 0 16px var(--accent-glow); }
.btn-s { background: transparent; color: var(--accent); border: 1px solid var(--accent); clip-path: none; }
.btn-s:hover { background: var(--accent-glow); }
.btn-g { background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border); clip-path: none; }
.btn-g:hover { color: var(--text-primary); border-color: var(--border-bright); }

/* ─── Grids ──────────────────────────────────────────────────── */
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.g3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 768px) { .g2, .g3 { grid-template-columns: 1fr; } }

/* ─── Quick Actions ──────────────────────────────────────────── */
.qa-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.qa {
  padding: 14px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  display: block;
}
.qa:hover { border-color: var(--border-accent); background: rgba(232,154,62,0.04); }
.qa-ico { display: flex; justify-content: center; margin-bottom: 6px; color: var(--text-secondary); }
.qa-lbl { font-weight: 600; font-size: 11px; color: var(--text-secondary); letter-spacing: 0.5px; }

/* ─── Event Feed ─────────────────────────────────────────────── */
.ev { display: flex; gap: 14px; padding: 11px 20px; border-bottom: 1px solid rgba(42,53,69,0.3); font-size: 13px; }
.ev:last-child { border-bottom: none; }
.ev-t { font-family: 'Share Tech Mono', monospace; font-size: 10px; color: var(--text-muted); min-width: 44px; padding-top: 2px; flex-shrink: 0; }
.ev-msg { color: var(--text-secondary); line-height: 1.6; }
.ev-msg b { color: var(--text-primary); font-weight: 500; }
.ev-msg .g { color: var(--health); }
.ev-msg .r { color: var(--damage); }
.ev-msg .a { color: var(--accent-bright); }
.ev-msg .y { color: var(--radiation); }

/* ─── Stat Cards ─────────────────────────────────────────────── */
.stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 14px 16px;
  position: relative;
  clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 0 100%);
}
.stat::before { content: ''; position: absolute; top: 0; left: 0; width: 3px; height: 100%; }
.stat.pos::before { background: var(--health); }
.stat.neg::before { background: var(--damage); }
.stat.neu::before { background: var(--accent); }
.stat.wrn::before { background: var(--radiation); }
.stat-lbl { font-family: 'Share Tech Mono', monospace; font-size: 9px; color: var(--text-muted); letter-spacing: 1px; margin-bottom: 2px; text-transform: uppercase; }
.stat-val { font-weight: 700; font-size: 26px; line-height: 1; }
.stat.pos .stat-val { color: var(--health); }
.stat.neg .stat-val { color: var(--damage); }
.stat.neu .stat-val { color: var(--accent-bright); }
.stat.wrn .stat-val { color: var(--radiation); }
.stat-det { font-size: 11px; color: var(--text-secondary); margin-top: 3px; }

/* ─── Char stat rows ─────────────────────────────────────────── */
.cs { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid rgba(42,53,69,0.3); font-size: 13px; }
.cs:last-child { border-bottom: none; }
.cs-k { color: var(--text-secondary); }
.cs-v { font-family: 'Share Tech Mono', monospace; font-weight: 500; color: var(--text-primary); }

/* ─── Tabs ────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; margin-bottom: 16px; }
.tab {
  font-weight: 600;
  font-size: 12px;
  color: var(--text-secondary);
  padding: 9px 16px;
  background: none;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'DM Sans', sans-serif;
  text-decoration: none;
  display: inline-block;
}
.tab:hover { color: var(--text-primary); background: var(--bg-hover); }
.tab.on { color: var(--accent-bright); background: var(--bg-elevated); border-bottom: 2px solid var(--accent); }

/* ─── TL bar ──────────────────────────────────────────────────── */
.tl-bar { display: flex; gap: 3px; margin-top: 6px; }
.tl-s { width: 18px; height: 7px; background: var(--bg-deep); border: 1px solid var(--border); }
.tl-s.on { background: var(--accent); border-color: var(--accent-dim); }

/* ─── Inventory Grid ─────────────────────────────────────────── */
.inv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); gap: 5px; }
.inv-slot {
  aspect-ratio: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all 0.12s;
  font-size: 22px;
}
.inv-slot:hover { border-color: var(--border-bright); background: var(--bg-hover); }
.inv-slot.eq   { border-color: var(--accent); background: var(--accent-glow); }
.inv-slot.empty { opacity: 0.2; cursor: default; }
.inv-slot .cnt { position: absolute; bottom: 2px; right: 4px; font-family: 'Share Tech Mono', monospace; font-size: 9px; color: var(--text-secondary); }
.inv-slot .rar { position: absolute; top: 0; left: 0; right: 0; height: 2px; }

/* ─── EP Progress bar ────────────────────────────────────────── */
.ep-bar-wrap { background: var(--bg-deep); border: 1px solid var(--border); height: 6px; position: relative; overflow: hidden; }
.ep-bar-fill { height: 100%; background: var(--accent); transition: width 0.6s ease; }

/* ─── Radiation Banner ───────────────────────────────────────── */
.rad-ban {
  background: linear-gradient(90deg, rgba(212,245,66,0.06), rgba(212,245,66,0.01));
  border: 1px solid rgba(212,245,66,0.2);
  border-left: 3px solid var(--radiation);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  animation: rp 3.5s ease-in-out infinite;
}

/* Level-up Banner */
.levelup-ban {
  background: linear-gradient(90deg, rgba(232,154,62,0.1), rgba(232,154,62,0.02));
  border: 1px solid var(--border-accent);
  border-left: 3px solid var(--accent);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  animation: lu 0.4s ease-out;
}
@keyframes lu { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; } }
.levelup-ban-t { font-weight: 700; font-size: 14px; color: var(--accent-bright); }
.levelup-ban-s { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ─── Right Sidebar ──────────────────────────────────────────── */
.gd-rightbar {
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.rb-sec { padding: 14px; border-bottom: 1px solid var(--border); }
.rb-title {
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--accent);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
}
.rb-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border-accent), transparent);
}

/* ─── Map ────────────────────────────────────────────────────── */
.map-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  position: relative;
  height: calc(100vh - 160px);
  min-height: 420px;
  overflow: hidden;
  margin-bottom: 16px;
}
.map-scroll { position: absolute; inset: 0; overflow: auto; display: flex; align-items: center; justify-content: center; }

/* ─── Form inputs ─────────────────────────────────────────────── */
.gd-input {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  width: 100%;
  transition: border-color 0.15s;
}
.gd-input:focus { border-color: var(--border-accent); }
.gd-input::placeholder { color: var(--text-muted); }

/* ─── Login/Register shell ───────────────────────────────────── */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-deep);
  padding: 24px;
  overflow-y: auto;
}
.auth-box {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  clip-path: polygon(0 0, calc(100% - var(--clip)) 0, 100% var(--clip), 100% 100%, var(--clip) 100%, 0 calc(100% - var(--clip)));
  position: relative;
}
.auth-box::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
}
.auth-header { padding: 24px 28px 0; }
.auth-body { padding: 24px 28px 28px; }

/* ─── Notification banner ────────────────────────────────────── */
.notif { padding: 10px 16px; margin-bottom: 16px; font-size: 13px; display: flex; align-items: center; gap: 10px; }
.notif-err { background: rgba(232,85,62,0.08); border: 1px solid rgba(232,85,62,0.25); border-left: 3px solid var(--damage); color: var(--damage); }
.notif-ok  { background: rgba(61,214,140,0.08); border: 1px solid rgba(61,214,140,0.25); border-left: 3px solid var(--health); color: var(--health); }

/* ─── Misc Utilities ─────────────────────────────────────────── */
.mono { font-family: 'Share Tech Mono', monospace; }
.accent { color: var(--accent-bright); }
.muted  { color: var(--text-muted); }
.dim    { color: var(--text-secondary); }
.bright { color: var(--text-bright); }
.c-health { color: var(--health); }
.c-damage { color: var(--damage); }
.c-rad    { color: var(--radiation); }
.c-water  { color: var(--water); }
.c-energy { color: var(--energy); }
.c-hunger { color: var(--hunger); }
