:root {
  --bg: #0b0b14;
  --panel: #1d2b53;
  --panel2: #14203f;
  --ink: #fff1e8;
  --dim: #8f88a8;
  --accent: #ffec27;
  --good: #00e436;
  --bad: #ff004d;
  --warn: #ffa300;
  --info: #29adff;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--ink);
  font: bold 12px/1.45 "Courier New", ui-monospace, Menlo, Consolas, monospace;
  text-transform: uppercase; letter-spacing: 0.5px;
  -webkit-font-smoothing: none; user-select: none;
}
canvas, img { image-rendering: pixelated; image-rendering: crisp-edges; }
.hidden { display: none !important; }
.dim { color: var(--dim); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }
b { color: var(--accent); }

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
#game.dragging { cursor: grabbing; }

.panel {
  background: var(--panel);
  border: 3px solid #000;
  box-shadow: inset 0 0 0 2px #29adff40, 4px 4px 0 #000;
}

/* ---- buttons ---- */
.btn {
  font: inherit; text-transform: uppercase; letter-spacing: 0.5px;
  color: #000; background: var(--accent);
  border: 2px solid #000; padding: 6px 10px; margin: 3px 0; cursor: pointer;
  box-shadow: inset -2px -3px 0 #ab5236, inset 2px 2px 0 #fff1e8;
}
.btn:hover:not(:disabled) { background: #fff58a; }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: inset 2px 2px 0 #ab5236; }
.btn:disabled { background: #5f574f; color: #c2c3c7; cursor: not-allowed; box-shadow: inset -2px -3px 0 #2a2420, inset 2px 2px 0 #83769c; }
.btn.red { background: #ff004d; color: #fff1e8; box-shadow: inset -2px -3px 0 #7e2553, inset 2px 2px 0 #ff77a8; }
.btn.red:hover:not(:disabled) { background: #ff4a7d; }
.btn.blue { background: #29adff; box-shadow: inset -2px -3px 0 #1d2b53, inset 2px 2px 0 #c7ecff; }
.btn.blue:hover:not(:disabled) { background: #6cc8ff; }
.btn.full { display: block; width: 100%; }
.btn.small { padding: 3px 6px; margin: 0; }
.btn.big { font-size: 16px; padding: 10px 18px; }

/* ---- top bar ---- */
#topbar {
  position: fixed; top: 8px; left: 8px; right: 8px; z-index: 5;
  display: flex; align-items: center; gap: 14px; padding: 5px 10px; flex-wrap: wrap;
}
#avatar { width: 40px; height: 40px; background: #14203f; border: 2px solid #000; }
.who { min-width: 110px; }
#pname { font-size: 13px; }
.stat { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.stat img { width: 16px; height: 16px; }
.stat small { margin-left: 4px; }
.spacer { flex: 1; }

/* ---- side panel ---- */
#side {
  position: fixed; right: 8px; top: 74px; width: 300px; max-height: calc(100% - 90px);
  display: flex; flex-direction: column; z-index: 4;
}
.tabs { display: flex; border-bottom: 3px solid #000; }
.tabs button {
  flex: 1; font: inherit; padding: 6px 0; cursor: pointer; border: 0; border-right: 2px solid #000;
  background: var(--panel2); color: var(--dim); text-transform: uppercase;
}
.tabs button:last-child { border-right: 0; }
.tabs button.on { background: var(--panel); color: var(--accent); }
.tab { padding: 10px 12px; overflow-y: auto; }
.tab h3 { margin: 0 0 6px; color: var(--accent); font-size: 14px; }
.tab p { margin: 6px 0; font-weight: normal; text-transform: none; letter-spacing: 0; }
.tab .row { display: flex; justify-content: space-between; gap: 8px; padding: 1px 0; }
.tab .row span:last-child { text-align: right; }
.tab hr { border: 0; border-top: 2px dashed #ffffff22; margin: 8px 0; }
.sw { display: inline-block; width: 10px; height: 10px; border: 1px solid #000; margin-right: 5px; vertical-align: -1px; }
.bar { height: 8px; background: #000; border: 1px solid #000; margin: 4px 0; }
.bar i { display: block; height: 100%; background: var(--good); width: 0; }
.tip { color: var(--dim); font-weight: normal; text-transform: none; letter-spacing: 0; margin: 4px 0; padding-left: 10px; text-indent: -10px; }
.tip::before { content: "▸ "; color: var(--accent); }

.tech { border: 2px solid #000; background: var(--panel2); padding: 6px 8px; margin-bottom: 6px; }
.tech.active { border-color: var(--good); }
.tname { display: flex; justify-content: space-between; color: var(--accent); }
.tdesc { color: var(--ink); font-weight: normal; text-transform: none; letter-spacing: 0; margin: 2px 0 4px; }
.pips { color: var(--good); letter-spacing: 1px; }

.rival { display: grid; grid-template-columns: 14px 1fr auto; gap: 2px 6px; align-items: center; padding: 5px 0; border-bottom: 2px dashed #ffffff18; cursor: pointer; }
.rival:hover { background: #ffffff10; }
.rival .sub { grid-column: 2 / 4; color: var(--dim); font-size: 11px; }
.dot { width: 8px; height: 8px; display: inline-block; margin-left: 4px; background: #5f574f; }
.dot.on { background: var(--good); }

/* ---- minimap ---- */
#minimap { position: fixed; left: 8px; bottom: 8px; width: 192px; height: 128px; z-index: 4; cursor: pointer; touch-action: none; }

/* ---- log + chat ---- */
#log { position: fixed; left: 212px; bottom: 8px; width: min(460px, calc(100% - 540px)); z-index: 4; pointer-events: none; }
#logLines div {
  background: #000000b0; padding: 2px 6px; margin-top: 2px; width: fit-content; max-width: 100%;
  font-weight: normal; text-transform: none; letter-spacing: 0; pointer-events: auto;
}
#logLines div[data-x] { cursor: pointer; }
#logLines div[data-x]:hover { background: #1d2b53; }
#logLines .good { color: var(--good); }
#logLines .bad { color: #ff6b8e; }
#logLines .err { color: var(--warn); }
#logLines .info { color: #c7ecff; }
#chatForm { margin-top: 4px; pointer-events: auto; }
#chatInput {
  width: 100%; font: inherit; text-transform: none; color: var(--ink); background: #000000c0;
  border: 2px solid #000; outline: none; padding: 4px 6px;
}
#chatInput:focus { border-color: var(--accent); }

/* ---- overlays ---- */
.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: #0b0b14a0; z-index: 10; padding: 16px; }
.card { padding: 22px 26px; max-width: 460px; width: 100%; text-align: center; max-height: 100%; overflow-y: auto; }
.card.wide { max-width: 820px; text-align: left; }
.card h2 { color: var(--accent); margin: 0 0 8px; text-align: center; }
.card h3 { color: var(--info); margin: 10px 0 4px; font-size: 13px; }
.card p { font-weight: normal; text-transform: none; letter-spacing: 0; }
.card .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.card #helpClose { display: block; margin: 12px auto 0; }
#logo { width: 400px; max-width: 100%; height: auto; }
.tag { color: var(--info) !important; margin: 4px 0 16px; }
#passForm label, #nameForm label { display: block; margin-bottom: 4px; color: var(--dim); }
#nameInput, #passInput {
  font: inherit; font-size: 16px; text-transform: uppercase; text-align: center; width: 100%;
  background: #000; color: var(--accent); border: 3px solid #000; box-shadow: inset 0 0 0 2px #29adff80;
  padding: 8px; margin-bottom: 10px; outline: none;
}
.pitch { list-style: none; padding: 0; margin: 16px 0 8px; text-align: left; }
.pitch li { display: flex; gap: 8px; align-items: center; margin: 6px 0; font-weight: normal; text-transform: none; letter-spacing: 0; }
.pitch img { width: 16px; height: 16px; flex: none; }

#toast {
  position: fixed; top: 80px; left: 50%; transform: translateX(-50%); z-index: 12;
  background: #000; color: var(--warn); border: 3px solid var(--warn); padding: 8px 14px; max-width: 90%; text-align: center;
}
#status { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 20; background: #000; color: var(--accent); padding: 12px 18px; border: 3px solid var(--accent); }

/* ---- small screens ---- */
@media (max-width: 760px) {
  #topbar { gap: 8px; font-size: 11px; padding: 4px 6px; left: 4px; right: 4px; top: 4px; }
  #avatar { width: 32px; height: 32px; }
  .who { min-width: 0; }
  #ptitle { display: none; }
  #side { top: auto; bottom: 4px; right: 4px; left: 4px; width: auto; max-height: 38%; }
  #minimap { width: 96px; height: 64px; top: 80px; bottom: auto; left: 4px; }
  #log { left: 4px; right: 4px; width: auto; bottom: calc(38% + 10px); }
  #logLines div:nth-last-child(n+4) { display: none; }
  .card .cols { grid-template-columns: 1fr; }
}
#passInput { text-transform: none; letter-spacing: 2px; }
