/* TINC web client — minimal functional styling */

* { box-sizing: border-box; }

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

body {
  display: flex;
  flex-direction: column;
  background: #1b1d22;
  color: #e6e6e6;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

.hidden { display: none !important; }

.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; }

/* ---------- top bar ---------- */

#topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: #14161a;
  border-bottom: 1px solid #2c2f36;
}

#topbar h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 2px;
}

#topbar h1 small {
  font-size: 11px;
  letter-spacing: 0;
  color: #8b93a1;
  margin-left: 6px;
}

.conn {
  margin-left: auto;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid #2c2f36;
}

.conn-off { color: #d98b8b; background: #2a1e1e; }
.conn-on  { color: #8fd694; background: #1d2a1e; }
.conn-wait{ color: #d9c98b; background: #2a281e; }

/* ---------- main ---------- */

main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- lobby ---------- */

#lobby {
  flex: 1 1 auto;
  overflow: auto;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  justify-content: center;
  gap: 16px;
  padding: 24px 16px;
}

.card {
  background: #22252b;
  border: 1px solid #2f333b;
  border-radius: 8px;
  padding: 16px;
  width: 380px;
  max-width: 100%;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 15px;
  color: #b9c1cf;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.card hr {
  border: none;
  border-top: 1px solid #2f333b;
  margin: 14px 0;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.help ul { margin: 0 0 10px; padding-left: 18px; color: #b9c1cf; }
.help li { margin-bottom: 3px; }

/* ---------- controls ---------- */

button {
  background: #333944;
  color: #e6e6e6;
  border: 1px solid #454d5a;
  border-radius: 5px;
  padding: 7px 12px;
  font: inherit;
  cursor: pointer;
}

button:hover:not(:disabled) { background: #3d4451; }
button:active:not(:disabled) { background: #2b313a; }
button:disabled { opacity: .45; cursor: default; }

button.primary {
  background: #3b6ea5;
  border-color: #4b82bd;
}
button.primary:hover { background: #477fbb; }

button.small { padding: 4px 8px; font-size: 12px; }

input, select {
  background: #191b20;
  color: #e6e6e6;
  border: 1px solid #454d5a;
  border-radius: 5px;
  padding: 7px 8px;
  font: inherit;
}

input { flex: 1 1 140px; min-width: 0; }

label { color: #b9c1cf; }

kbd {
  background: #191b20;
  border: 1px solid #454d5a;
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 5px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px;
}

.hint { color: #8b93a1; font-size: 12px; margin: 4px 0; }

.msg { margin-top: 10px; min-height: 20px; font-size: 13px; color: #d9c98b; }
.msg.error { color: #e59090; }
.msg.ok { color: #8fd694; }

/* ---------- game layout ---------- */

#game {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  gap: 12px;
  padding: 12px;
}

.board-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
}

#board {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #202329;
  border: 1px solid #2f333b;
  border-radius: 8px;
  touch-action: manipulation;
}

#info {
  flex: 0 0 250px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.turn {
  font-size: 17px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 6px;
  background: #22252b;
  border: 1px solid #2f333b;
  text-align: center;
}

.turn.mine { background: #1d2a1e; border-color: #3c5c3f; color: #a8e0ac; }
.turn.theirs { background: #26232b; border-color: #4a4257; color: #c4b6d6; }
.turn.over { background: #2a2320; border-color: #6a5340; color: #e8c79a; }

.status { min-height: 18px; font-size: 13px; color: #d9c98b; text-align: center; }
.status.error { color: #e59090; }

.panel {
  background: #22252b;
  border: 1px solid #2f333b;
  border-radius: 6px;
  padding: 10px;
}

.panel h3 {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #8b93a1;
}

.kv {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 0;
  font-size: 13px;
}

.kv span { color: #8b93a1; }
.kv b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }

.panel.actions { display: flex; gap: 8px; }
.panel.actions button { flex: 1 1 0; }

/* ---------- replay controls ---------- */

.replay-controls {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.replay-controls button { flex: 1 1 0; padding: 5px 4px; }

.log-line.current {
  background: #33404f;
  color: #eef1f6;
  border-radius: 3px;
}

.move-log {
  max-height: 240px;
  overflow-y: auto;
  font: 12px 'Menlo', 'Consolas', 'DejaVu Sans Mono', monospace;
  background: #181a1f;
  border-radius: 4px;
  padding: 6px 8px;
  line-height: 1.6;
  color: #c8ccd4;
}
.log-line { white-space: nowrap; }
.log-line.black { color: #8b93a1; }

.cap-row { margin-bottom: 6px; }
.cap-label { display: block; font-size: 11px; color: #8b93a1; }

.caps { display: flex; flex-wrap: wrap; gap: 4px; min-height: 24px; margin-top: 3px; }

.cap {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

.cap.white { background: #f2f0e9; color: #1a1a1a; border: 1px solid #8d8d8d; }
.cap.black { background: #4a4a55; color: #e8e8e8; border: 1px solid #b9b9c4; }
.cap-sprite { width: 18px; height: 18px; image-rendering: pixelated; }

/* ---------- legend ---------- */

.legend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: #b9c1cf; }

.sw {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid #00000055;
  vertical-align: -2px;
}

.sw-normal  { background: #3cc85a; }
.sw-capture { background: #dc4040; }
.sw-stack   { background: #3c78e6; }
.sw-unstack { background: #e6c832; }

/* ---------- rules / help modal ---------- */

#rulesOverlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(8, 9, 12, 0.72);
}

/* Column layout: only .rules-body scrolls, so the "Got it" button stays
   parked at the bottom of the card instead of floating over the text. */
.rules-card {
  background: #22252b;
  border: 1px solid #3a3f49;
  border-radius: 10px;
  box-shadow: 0 12px 40px #000a;
  padding: 20px 22px;
  width: 600px;
  max-width: 100%;
  max-height: 80vh;
  color: #e6e6e6;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.rules-body {
  overflow-y: auto;
  min-height: 0;
  /* room for the scrollbar so it never overlaps the text */
  padding-right: 6px;
}

.rules-card h2 {
  margin: 0 0 6px;
  font-size: 17px;
  letter-spacing: 1px;
  color: #eef1f6;
}

.rules-card h3 {
  margin: 18px 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #8b93a1;
  border-bottom: 1px solid #2f333b;
  padding-bottom: 4px;
}

.rules-lead { margin: 0; color: #b9c1cf; }

.rules-card ul { margin: 0; padding-left: 18px; color: #c8ccd4; }
.rules-card li { margin-bottom: 4px; }

.rules-pieces { margin: 0; }
.rules-pieces dt {
  font-weight: 700;
  color: #a8c8ee;
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.rules-pieces dt:first-child { margin-top: 0; }
.rules-icon {
  width: 56px;
  height: 56px;
  image-rendering: pixelated;
  vertical-align: middle;
}
.rules-pieces dd {
  margin: 2px 0 0;
  color: #c8ccd4;
}

.rules-actions {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #2f333b;
}

.rules-actions button { min-width: 110px; }

/* ---------- move type popup ---------- */

#moveMenu {
  position: absolute;
  z-index: 20;
  background: #22252b;
  border: 1px solid #4b82bd;
  border-radius: 6px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 4px 14px #0008;
}

#moveMenu button { padding: 4px 10px; font-size: 12px; text-align: left; }

/* ---------- toast ---------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #3a2323;
  color: #ffdada;
  border: 1px solid #6d3b3b;
  border-radius: 6px;
  padding: 8px 14px;
  z-index: 30;
  max-width: 80vw;
}

/* ---------- narrow screens ---------- */

@media (max-width: 720px) {
  body { overflow: auto; }
  #game { flex-direction: column; }
  .board-wrap { min-height: 60vh; }
  #info { flex: 0 0 auto; }
}
