:root {
  --ink: #171717;
  --panel: #efe6c8;
  --panel-dark: #2d2a2a;
  --edge: #6b5635;
  --green: #40a040;
  --water: #4080c8;
  --r: #c84040;
  --c: #4040c8;
  --i: #c8c840;
  --p1: #4aa3ff;
  --p2: #ff9f43;
  --p3: #5cd65c;
  --p4: #e056fd;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #141414;
  color: #f7f0d8;
  font-family: "Courier New", ui-monospace, monospace;
  image-rendering: pixelated;
}

button,
input {
  font: inherit;
}

#app {
  display: grid;
  grid-template-rows: 52px 1fr;
  width: 100vw;
  height: 100vh;
}

#topbar {
  display: grid;
  grid-template-columns: 150px repeat(4, minmax(110px, 1fr)) 120px;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: #242424;
  border-bottom: 4px solid #000;
  box-shadow: inset 0 -2px 0 #565656;
}

.brand {
  padding: 8px 10px;
  background: #d4c07a;
  color: #202020;
  font-weight: 900;
  text-align: center;
  text-shadow: 1px 1px #fff4bc;
  border: 2px solid #000;
}

.stat,
.room {
  min-width: 0;
  display: grid;
  gap: 2px;
  padding: 5px 8px;
  background: #111;
  border: 2px solid #595959;
}

.stat span,
.room span {
  color: #bdb79f;
  font-size: 11px;
  text-transform: uppercase;
}

.stat strong,
.room strong {
  color: #fff8d8;
  font-size: 15px;
  white-space: nowrap;
}

#gameShell {
  min-height: 0;
  display: grid;
  grid-template-columns: 82px minmax(300px, 1fr) 280px;
  background: #0f0f0f;
}

#toolbar {
  overflow-y: auto;
  padding: 8px;
  background: #252525;
  border-right: 4px solid #000;
}

.tool {
  width: 62px;
  height: 52px;
  margin: 0 0 7px;
  display: grid;
  place-items: center;
  gap: 1px;
  background: #ddd0a8;
  color: #151515;
  border: 2px solid #0a0a0a;
  box-shadow: inset 2px 2px 0 #fff2c7, inset -2px -2px 0 #7c6d4b;
  cursor: pointer;
}

.tool span {
  font-size: 17px;
  font-weight: 900;
  line-height: 1;
}

.tool small {
  font-size: 10px;
}

.tool:hover,
.tool.active {
  transform: translateY(-1px);
  background: #fff2b2;
  box-shadow: inset 2px 2px 0 #fff, inset -2px -2px 0 #a37b2b, 0 2px 0 #000;
}

.tool.zone-r {
  background: var(--r);
  color: #fff;
}

.tool.zone-c {
  background: var(--c);
  color: #fff;
}

.tool.zone-i {
  background: var(--i);
  color: #222;
}

.tool.danger {
  background: #cf5b4d;
  color: #fff;
}

#viewport {
  position: relative;
  overflow: hidden;
  min-width: 0;
  background: #000;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  image-rendering: pixelated;
}

#sidebar {
  overflow-y: auto;
  padding: 10px;
  background: #242424;
  border-left: 4px solid #000;
}

.panel {
  background: var(--panel);
  color: #161616;
  border: 3px solid #111;
  box-shadow: inset 2px 2px 0 #fff6ce, inset -2px -2px 0 #7b6842;
}

.panel.compact {
  padding: 10px;
  margin-bottom: 10px;
}

.panel h1,
.panel h2 {
  margin: 0 0 8px;
  line-height: 1;
  letter-spacing: 0;
}

.panel h1 {
  font-size: 30px;
}

.panel h2 {
  font-size: 16px;
  text-transform: uppercase;
}

.rciRow,
.kv,
.taxLine {
  display: grid;
  grid-template-columns: 22px 1fr 48px;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  font-size: 13px;
}

.kv {
  grid-template-columns: 1fr auto;
  border-top: 1px solid rgba(0, 0, 0, 0.22);
}

meter {
  width: 100%;
  height: 16px;
}

.taxLine {
  grid-template-columns: 40px 1fr 44px;
  margin-bottom: 6px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.segmented button {
  height: 34px;
  color: #111;
  background: #d1c28b;
  border: 2px solid #111;
  cursor: pointer;
}

.segmented button.active {
  background: #58b85d;
}

#playersList {
  display: grid;
  gap: 6px;
}

.playerRow {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  gap: 6px;
  align-items: center;
  padding: 4px 0;
  border-top: 1px solid rgba(0, 0, 0, 0.18);
}

.swatch {
  width: 14px;
  height: 14px;
  border: 2px solid #111;
}

#lobby {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.52);
  z-index: 3;
}

#lobby.hidden {
  display: none;
}

#lobby .panel {
  width: min(430px, calc(100vw - 32px));
  padding: 18px;
}

#lobbyText {
  margin: 0 0 12px;
  color: #222;
}

#slots {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.slot {
  padding: 8px;
  border: 2px solid #111;
  background: #f6edca;
}

#wright {
  position: absolute;
  left: 16px;
  bottom: 16px;
  width: min(470px, calc(100% - 32px));
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: #f3e7bc;
  color: #111;
  border: 3px solid #111;
  box-shadow: 0 4px 0 #000, inset 2px 2px 0 #fff8d0;
  z-index: 2;
}

.wrightFace {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  background: #6bb45f;
  border: 3px solid #111;
  color: #fff;
  font-size: 30px;
  font-weight: 900;
}

#wrightText {
  margin: 0;
  font-size: 14px;
  line-height: 1.35;
}

@media (max-width: 900px) {
  #app {
    grid-template-rows: 86px 1fr;
  }

  #topbar {
    grid-template-columns: repeat(3, 1fr);
  }

  .brand {
    grid-column: span 1;
  }

  #gameShell {
    grid-template-columns: 70px 1fr;
  }

  #sidebar {
    position: absolute;
    right: 0;
    top: 86px;
    bottom: 0;
    width: 230px;
    opacity: 0.94;
    pointer-events: none;
  }

  .panel.compact {
    padding: 8px;
  }

  .tool {
    width: 52px;
  }
}
