:root{
  --bg: #0b0c0f;
  --border: rgba(255,255,255,.10);
  --text: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.65);
  --shadow: 0 10px 30px rgba(0,0,0,.45);
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1100px 600px at 20% 0%, rgba(120,120,255,.14), transparent 60%),
              radial-gradient(900px 500px at 85% 10%, rgba(0,255,200,.10), transparent 55%),
              var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
}

.wrap {
  height: 100dvh;
  padding-top: calc(14px + env(safe-area-inset-top));
  padding-left: calc(14px + env(safe-area-inset-left));
  padding-right: calc(14px + env(safe-area-inset-right));
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  max-width: 1400px;
  margin: 0 auto;
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.05));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.brand{ display:flex; align-items:center; gap: 10px; min-width: 240px; }
.logo{
  width: 34px; height: 34px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(255,255,255,.18), rgba(255,255,255,.05));
  border: 1px solid var(--border);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.2);
  display:flex; align-items:center; justify-content:center;
  font-weight: 700;
  color: rgba(255,255,255,.85);
  user-select:none;
}
.titles{ line-height: 1.1; }
.titles .name{ font-size: 14px; font-weight: 650; letter-spacing: .2px; }
.titles .sub{ font-size: 12px; color: var(--muted); margin-top: 2px; }

.status{
  display:flex;
  align-items:center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.dot{
  width: 10px; height: 10px; border-radius: 50%;
  background: rgba(255,80,120,.95);
  box-shadow: 0 0 0 3px rgba(255,80,120,.12);
}
.dot.online{
  background: #39ff14;
  box-shadow:
    0 0 0 3px rgba(57,255,20,.18),
    0 0 14px rgba(57,255,20,.55),
    0 0 28px rgba(57,255,20,.35);
}

.actions{
  display:flex;
  align-items:center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

button, .seg {
  border: 1px solid var(--border);
  background: rgba(255,255,255,.06);
  color: var(--text);
  border-radius: 12px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 13px;
  user-select: none;
  touch-action: manipulation;
  transition: transform .05s ease, background .15s ease, border-color .15s ease;
}
button:hover { background: rgba(255,255,255,.09); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.seg { display:flex; padding: 0; overflow:hidden; }
.seg button{
  border: 0;
  border-radius: 0;
  padding: 8px 10px;
  background: transparent;
}
.seg button:hover{ background: rgba(255,255,255,.08); }

/* ===== 3-column main ===== */
.main{
  min-height: 0;
  display: grid;
  /* LEFT map etwas schmaler -> CENTER automatisch breiter */
  grid-template-columns: 300px 1fr 320px;
  gap: 12px;
  min-width: 0;
}
.main > * { min-width: 0; }

.card{
  border: 1px solid var(--border);
  background: rgba(255,255,255,.05);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display:grid;
  grid-template-rows: auto 1fr;
  backdrop-filter: blur(10px);
  min-height: 0;
  min-width: 0;
}

.cardhead{
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.card-terminal{
  grid-template-rows: auto 1fr auto;
}

#terminal { min-height: 0; height: 100%; min-width: 0; }
#mapTerm  { min-height: 0; height: 100%; min-width: 0; }

.xterm { padding-left: 2ch; padding-right: 1ch; }
#mapTerm .xterm { padding-left: 1ch; padding-right: 1ch; }

.mapCol { min-width: 0; }

.side-right{
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 12px;
  min-width: 0;
}

/* Command line */
.cmdline-wrap{
  border-top: 1px solid rgba(255,255,255,.08);
  padding: 10px 12px;
  background: rgba(0,0,0,.18);
  display: grid;
  gap: 6px;
}
.cmdline-label{
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .2px;
}
#cmdline{
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.06);
  color: var(--text);
  outline: none;
  font-size: 14px;
  min-width: 0;
}
#cmdline::placeholder{ color: rgba(255,255,255,.45); }
#cmdline:focus{
  border-color: rgba(57,255,20,.55);
  box-shadow: 0 0 0 2px rgba(57,255,20,.18);
}

.padWrap { padding: 12px; display: grid; gap: 10px; }
.padGrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.padGrid button { padding: 12px 10px; font-weight: 650; letter-spacing: .2px; }
.padHint { color: var(--muted); font-size: 12px; line-height: 1.25; }

.muted{ color: var(--muted); }

/* Status panels */
.statusBox{
  padding: 12px;
  display: grid;
  gap: 12px;
}
.statRow{
  display: grid;
  grid-template-columns: 60px 1fr 56px;
  gap: 10px;
  align-items: center;
  min-width: 0;
}
.statLabel{
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.statValue{
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: rgba(255,255,255,.85);
  white-space: nowrap;
}

.bar{
  height: 18px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.25);
  width: 100%;
  min-width: 0;
}
.fill{
  height: 100%;
  width: 0%;
  max-width: 100%;
  border-radius: 999px;
  transition: width .20s ease;
}

#hungerFill { background: rgba(255, 200, 90, .85); }
#durstFill  { background: rgba(90, 200, 255, .85); }
#lpFill     { background: rgba(80, 255, 140, .85); }
#kpFill     { background: rgba(255, 120, 120, .85); }

/* Responsive */
@media (max-width: 1100px) {
  /* auf kleineren Laptops: Map über Terminal, Panels rechts darunter */
  .main{
    grid-template-columns: 1fr;
  }
  .mapCol, .side-right, .card-terminal{
    min-height: 0;
  }
  .mapCol .card{ height: 260px; }
}
