/* The Worst MMO — deliberately plain. White background, black text, Roboto. */
:root {
  --line: #000;
  --dim: #666;
  --bg: #fff;
  --accent: #000;
  --hover: #f0f0f0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: #000;
  font-family: 'Roboto', system-ui, Arial, sans-serif;
  font-size: 14px;
  overflow: hidden;
}

button {
  font-family: inherit;
  font-size: 13px;
  background: #fff;
  color: #000;
  border: 1px solid var(--line);
  padding: 5px 10px;
  cursor: pointer;
}
button:hover { background: var(--hover); }
button.active { background: #000; color: #fff; }
button:disabled { color: #aaa; border-color: #ccc; cursor: default; }

input {
  font-family: inherit;
  font-size: 13px;
  border: 1px solid var(--line);
  padding: 5px 8px;
  background: #fff;
  color: #000;
}

.hidden { display: none !important; }
.dim { color: var(--dim); }
.mono { font-family: 'Roboto Mono', monospace; }

/* ---------- Login ---------- */
.overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: #fff; z-index: 100;
}
.login-box {
  border: 2px solid #000; padding: 28px 32px; width: 360px;
  display: flex; flex-direction: column; gap: 12px;
}
.login-box h1 { margin: 0; font-size: 26px; letter-spacing: 1px; }
.login-box .sub { margin: 0 0 8px; color: var(--dim); }
.login-box label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--dim); }
.login-box input { font-size: 15px; }
.login-box button { padding: 10px; font-weight: 700; letter-spacing: 1px; }
.login-box .hint { font-size: 11px; color: var(--dim); margin: 4px 0 0; }
.login-box a { color: #000; text-decoration: underline; }
.login-box .login-legal { margin-top: 8px; }
.login-box .login-legal a { color: var(--dim); }
.msg { min-height: 16px; font-size: 12px; color: #000; }

/* ---------- Top bar ---------- */
#topbar {
  height: 42px; border-bottom: 2px solid #000;
  display: flex; align-items: center; gap: 16px; padding: 0 12px;
}
.brand { font-weight: 700; letter-spacing: 1px; white-space: nowrap; }
.resources { display: flex; gap: 14px; flex: 1; overflow: hidden; flex-wrap: wrap; max-height: 40px; }
.res { white-space: nowrap; font-size: 12px; }
.res b { font-weight: 700; }
.res .full { color: #c00; }
.topright { display: flex; align-items: center; gap: 12px; }
.clock { font-family: 'Roboto Mono', monospace; font-size: 12px; }
.modes { display: flex; gap: 0; }
.modes .mode-btn { border-right: none; }
.modes .mode-btn:last-child { border-right: 1px solid #000; }

/* ---------- Main ---------- */
#main { display: flex; height: calc(100% - 42px); }
#stage { position: relative; flex: 1; overflow: hidden; }
#canvas { display: block; width: 100%; height: 100%; cursor: grab; background: #fff; }
#canvas.grabbing { cursor: grabbing; }
.stage-hint {
  position: absolute; left: 10px; top: 10px; z-index: 10;
}
.stage-hint-bar { display: flex; gap: 4px; }
.stage-hint-btn {
  font-size: 11px; color: var(--dim); background: #fff; border: 1px solid #ccc;
  padding: 3px 10px; cursor: pointer; font-style: italic; font-weight: 700;
}
.stage-hint-btn:hover { background: #f0f0f0; }
.stage-hint.open .stage-hint-bar .stage-hint-btn {
  border-bottom-color: #fff; margin-bottom: -1px; position: relative; z-index: 1;
}
.stage-hint-body {
  font-size: 12px; color: var(--dim); background: #fff; border: 1px solid #ccc;
  padding: 6px 10px; max-width: min(280px, 72vw); line-height: 1.5;
  white-space: pre-line;
}

.commandbar {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  border: 2px solid #000; background: #fff; padding: 6px 10px; width: min(560px, 80%);
}
.commandbar .prompt {
  font-family: 'Roboto Mono', monospace; font-weight: 700; cursor: pointer;
  border: 1px solid #000; background: #fff; padding: 4px 8px;
}
.commandbar .prompt:hover { background: #000; color: #fff; }
.commandbar input { flex: 1; border: none; outline: none; font-size: 15px; }

.cmd-ac {
  position: absolute; left: 0; right: 0; bottom: 100%; margin-bottom: 4px;
  border: 1px solid #000; background: #fff; max-height: 200px; overflow-y: auto;
  z-index: 75; font-family: 'Roboto Mono', monospace; font-size: 14px;
}
.cmd-ac-item {
  display: block; width: 100%; border: none; border-bottom: 1px solid #eee;
  background: #fff; color: #000; text-align: left; padding: 6px 10px; cursor: pointer;
}
.cmd-ac-item:last-child { border-bottom: none; }
.cmd-ac-item:hover, .cmd-ac-item.active { background: #000; color: #fff; }

/* ---------- Left sidebar (buttons that open modals) ---------- */
#leftbar { width: 116px; border-right: 2px solid #000; display: flex; flex-direction: column; }
.side-btn {
  border: none; border-bottom: 1px solid #000; background: #fff; color: #000;
  padding: 14px 10px; text-align: left; font-weight: 500; font-size: 14px;
}
a.side-btn { display: block; text-decoration: none; color: inherit; }
.side-btn-bottom { margin-top: auto; border-top: 1px solid #000; }
.side-btn:hover { background: #f0f0f0; }

/* ---------- Top-bar Menu dropdown ---------- */
.menu-wrap { position: relative; }
.menu-btn { font-weight: 500; }
.menu-drop {
  position: absolute; right: 0; top: 100%; margin-top: 2px; z-index: 60;
  border: 1px solid #000; background: #fff; min-width: 170px; display: flex; flex-direction: column;
}
.menu-item { border: none; border-bottom: 1px solid #000; background: #fff; color: #000; text-align: left; padding: 9px 12px; }
.menu-item:last-child { border-bottom: none; }
.menu-item:hover { background: #000; color: #fff; }

/* ---------- Cascading build menu (Win98 vibe) ---------- */
.build-menu, .bm-sub {
  position: absolute; z-index: 70; border: 1px solid #000; background: #fff; min-width: 188px;
}
.bm-title { font-weight: 700; padding: 6px 10px; border-bottom: 1px solid #000; font-family: 'Roboto Mono', monospace; }
.bm-row { display: flex; align-items: stretch; border-bottom: 1px solid #eee; position: relative; }
.bm-row:last-child { border-bottom: none; }
.bm-item { flex: 1; text-align: left; border: none; background: transparent; color: #000; padding: 7px 10px; display: flex; justify-content: space-between; gap: 8px; }
.bm-row:hover > .bm-item, .bm-row.open > .bm-item { background: #000; color: #fff; }
.bm-item.cant { color: #c00; }
.bm-info {
  border: none; border-left: 1px solid #eee; background: transparent; color: inherit;
  width: 26px; font-style: italic; font-weight: 700;
}
.bm-info-dot { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border: 1px solid currentColor; border-radius: 50%; font-size: 10px; }

/* ---------- Modal panels (ranks/fleets/intel content) ---------- */
.modal-panel { display: flex; flex-direction: column; width: 700px; max-width: 92vw; height: 64vh; max-height: 600px; }
.list, .rank-list { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px; border: 1px solid #000; }

.rank-search { border-bottom: 1px solid #000; }
.rank-search input { width: 100%; border: none; }
.rank-row { display: flex; justify-content: space-between; padding: 5px 4px; border-bottom: 1px solid #eee; font-size: 13px; cursor: pointer; }
.rank-row:hover { background: var(--hover); }
.rank-row .r { width: 28px; color: var(--dim); }
.rank-row .n { flex: 1; }
.rank-row .s { font-family: 'Roboto Mono', monospace; }
.rank-pager { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid #000; padding: 6px; font-size: 12px; }

.list .item { border-bottom: 1px solid #eee; padding: 6px 4px; font-size: 12px; }
.list .item .bar { height: 4px; background: #000; margin-top: 4px; }
.list .item .track { height: 4px; background: #ddd; margin-top: 4px; }

/* ---------- Modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(255,255,255,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  border: 2px solid #000; background: #fff; padding: 16px 18px;
  min-width: 300px; max-width: 760px; max-height: 80vh; overflow: auto;
}
.modal h2 { margin: 0 0 4px; font-size: 18px; }
.modal h3 { margin: 12px 0 4px; font-size: 14px; }
.modal .row { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px solid #eee; }
.modal .actions { display: flex; gap: 8px; margin-top: 14px; justify-content: flex-end; flex-wrap: wrap; }
.modal .close { position: absolute; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 16px; }
.cost-bad { color: #c00; }

/* inventory grid */
.inv-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; margin-top: 8px; }
.inv-cell {
  border: 1px solid #000; aspect-ratio: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-size: 9px; text-align: center; padding: 2px;
  overflow: hidden;
}
.inv-cell.empty { border-color: #ddd; }
.inv-cell[draggable="true"] { cursor: grab; }
.inv-cell.dragging { opacity: 0.45; }
.inv-cell.drop-target { border-color: #000; background: #f0f0f0; }
.inv-cell .q { font-family: 'Roboto Mono', monospace; font-weight: 700; font-size: 10px; }

/* unit picker for attacks */
.unit-pick { display: flex; align-items: center; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid #eee; }
.unit-pick input { width: 80px; }

/* ---------- Toast ---------- */
#toast { position: fixed; bottom: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 6px; }
.toast-item { border: 1px solid #000; background: #fff; padding: 8px 12px; font-size: 13px; max-width: 320px; }
.toast-item.err { border-color: #c00; color: #c00; }

/* ---------- Wiki ---------- */
.modal.wiki-modal {
  width: calc(100vw - 140px);
  max-width: none;
  max-height: calc(100vh - 64px);
}
.wiki h3 { border-bottom: 1px solid #000; padding-bottom: 2px; }
.wiki ul { padding-left: 1.25em; margin: 4px 0 0; }
.wiki li { overflow-wrap: break-word; line-height: 1.45; }
.wiki table { width: 100%; border-collapse: collapse; font-size: 12px; }
.wiki th, .wiki td { border: 1px solid #ccc; padding: 3px 6px; text-align: left; overflow-wrap: break-word; }
.wiki .kbd { font-family: 'Roboto Mono', monospace; border: 1px solid #000; padding: 0 4px; }

/* ---------- Toon select + character sheet + dungeons ---------- */
.side-btn-hot { font-weight: 700; }

.modal.toon-modal { width: calc(100vw - 140px); max-width: 1100px; max-height: calc(100vh - 64px); }
.toon-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin-top: 10px; }
.toon-card { border: 1px solid #000; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.toon-card canvas.toon-av { align-self: center; border: 1px solid #000; background: #fff; }
.toon-name { font-weight: 700; font-size: 15px; }
.toon-tag { font-style: italic; font-size: 12px; }
.toon-desc { font-size: 12px; line-height: 1.4; flex: 1; }
.toon-stats { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11px; }
.tstat { display: flex; gap: 4px; }
.toon-special { font-size: 11px; border-top: 1px solid #eee; padding-top: 6px; }
.toon-pick { margin-top: 4px; }

.toon-sheet .sheet-head { display: flex; gap: 12px; align-items: center; }
.toon-sheet .sheet-head canvas { border: 1px solid #000; background: #fff; }
.xpbar { width: 220px; max-width: 60vw; height: 8px; border: 1px solid #000; margin: 4px 0 2px; }
.xpfill { height: 100%; background: #000; }
.pts { margin: 10px 0; padding: 6px 10px; border: 1px dashed #000; font-size: 13px; }
.pts.has { border-style: solid; font-weight: 500; }
.attr-list { display: flex; flex-direction: column; gap: 4px; }
.attr-row { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid #eee; padding: 5px 2px; }
.attr-name { flex: 1; }
.attr-name b { font-size: 13px; }
.attr-name .dim { font-size: 11px; }
.attr-val { font-family: 'Roboto Mono', monospace; font-weight: 700; width: 28px; text-align: center; }
.attr-plus { width: 30px; font-weight: 700; font-size: 16px; line-height: 1; }

.dungeon-panel { width: 520px; max-width: 86vw; }
.dungeon-list { overflow-x: hidden; }
.dungeon-list .dungeon-row { display: flex; align-items: center; gap: 10px; }
.dungeon-row .dgn-main { flex: 1; min-width: 0; }
.dungeon-row .dgn-main > div { overflow-wrap: anywhere; }
.dungeon-row.locked { opacity: 0.55; }
.help-btn { font-weight: 700; }
.howto h3 { margin: 12px 0 4px; }
.howto ul { margin: 4px 0 0; padding-left: 1.2em; }
.howto li { line-height: 1.45; margin-bottom: 3px; }
.dgn-reward { font-size: 11px; }
.badge { font-size: 10px; font-weight: 700; border: 1px solid #000; padding: 0 5px; margin-left: 6px; vertical-align: middle; }
.badge.ok { background: #000; color: #fff; }
.badge.lock { color: #888; border-color: #888; }

/* ---------- Dungeon arena ---------- */
.arena { position: fixed; inset: 0; z-index: 40; background: #fff; }
#arena-canvas { display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.arena-btn {
  position: absolute; z-index: 41; border: 2px solid #000; background: #fff; color: #000;
  font-family: inherit; font-weight: 700; padding: 8px 14px; cursor: pointer;
}
.arena-btn:hover { background: #000; color: #fff; }
#arena-leave { top: 14px; right: 14px; }
#arena-help { top: 14px; left: 14px; }
.arena-special { bottom: 18px; right: 18px; min-width: 150px; text-align: center; font-family: 'Roboto Mono', monospace; }
.arena-special.ready { background: #000; color: #fff; }
.pvp-panel .pvp-status { margin-top: 6px; font-weight: 600; }
.pvp-banner {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font: 700 28px/1.2 'Roboto Mono', monospace; background: #fff; border: 2px solid #000;
  padding: 16px 28px; z-index: 2; pointer-events: none;
}
#pvp-leave { top: 14px; right: 14px; }

/* ---------- Dark mode = literally reverse the light theme ---------- */
body.dark { filter: invert(1); }
