* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: #1e1e24;
  color: #e8e8ea;
  min-height: 100vh;
}

header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  background: #26262e;
  border-bottom: 1px solid #3a3a44;
}

header h1 { font-size: 20px; margin: 0; }

nav { display: flex; gap: 8px; }

nav button {
  background: transparent;
  color: #b8b8c0;
  border: 1px solid transparent;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

nav button:hover { background: #32323c; }
nav button.active { background: #3a3a48; color: #fff; border-color: #505060; }

.badge {
  background: #d64545;
  color: #fff;
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 12px;
  margin-left: 4px;
}
.badge:empty { display: none; }

main { padding: 24px; }

#board-view {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  flex-wrap: wrap;
  /* Braetstoerrelse skalerer med vinduet: begraenset af bredden (plads til
     eval-bar + padding) OG hoejden, saa braettet altid er helt synligt. */
  --board-size: min(calc(100vw - 102px), 82vh);
}

#board-area {
  width: var(--board-size);
  display: flex;
  flex-direction: column;
  align-items: center;
}

#board-wrap {
  width: 100%;
}

#board {
  width: 100%;
  aspect-ratio: 1;
}

/* chessground kraever eksplicit stoerrelse paa cg-wrap */
#board .cg-wrap {
  width: 100%;
  height: 100%;
}

/* Skakbraet i chess.com-groen (lys/groen). Overstyrer chessground-temaet:
   lyse felter = baggrundsfarve, moerke felter = 2x2 SVG-flise der gentages. */
cg-board {
  background-color: #ebecd0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2 2'%3E%3Crect x='1' y='0' width='1' height='1' fill='%23779556'/%3E%3Crect x='0' y='1' width='1' height='1' fill='%23779556'/%3E%3C/svg%3E");
  background-size: 25% 25%;
}

#board-wrap.correct { outline: 4px solid #5aa85a; border-radius: 4px; }
#board-wrap.wrong { outline: 4px solid #d64545; border-radius: 4px; }

#eval-col {
  display: flex;
  flex-direction: column;
  align-self: flex-start;
  gap: 6px;
  width: 30px;
  height: var(--board-size);
}

#eval-bar {
  flex: 1;
  position: relative;
  background: #3d3d3d; /* sort side */
  border: 1px solid #505060;
  border-radius: 5px;
  overflow: hidden;
}

#eval-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 50%;
  background: #e8e8e8; /* hvid side */
  transition: height 0.4s ease;
}

/* Naar braettet vender sort nedad, vender baren med */
#eval-col.flipped #eval-fill {
  bottom: auto;
  top: 0;
}

#eval-label {
  text-align: center;
  font-size: 12px;
  color: #b8b8c0;
  font-variant-numeric: tabular-nums;
}

#panel {
  flex: 1;
  min-width: 280px;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: #26262e;
  border: 1px solid #3a3a44;
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 15px;
  line-height: 1.5;
}

.card.toggle-card {
  cursor: pointer;
}

.card.toggle-card:hover {
  border-color: #5d6f86;
  background: #2b2f39;
}

.card.small { font-size: 13px; color: #a0a0aa; }

.card.explanation {
  border-color: #5d6f86;
  background: #242b34;
  color: #d8e2ec;
}

.pv-line {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.pv-move {
  background: #303846;
  color: #d8e2ec;
  border: 1px solid #5d6f86;
  border-radius: 5px;
  padding: 2px 7px;
  cursor: pointer;
  font: inherit;
  line-height: 1.35;
}

.pv-move:hover {
  background: #3b4658;
}

.hidden { display: none !important; }

#feedback.good { border-color: #5aa85a; color: #8fd18f; }
#feedback.bad { border-color: #d64545; color: #e88; }

#panel-actions,
#nav-actions {
  display: flex;
  gap: 8px;
}

#panel-actions {
  flex-wrap: wrap;
}

#nav-actions {
  justify-content: center;
  align-items: center;
  width: 100%;
  margin-top: 14px;
  padding: 6px 0;
}

#panel-actions button,
#nav-actions button,
#opening-controls button,
#trending-controls button {
  background: #3a3a48;
  color: #e8e8ea;
  border: 1px solid #505060;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

#trending-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

#trending-controls .seg.active {
  background: #4a5a7a;
  border-color: #7a8db0;
  color: #fff;
}

#nav-actions button {
  min-width: 128px;
  padding: 10px 18px;
  background: #303846;
  border-color: #5d6f86;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  font-weight: 600;
}

#panel-actions button:hover,
#nav-actions button:hover,
#opening-controls button:hover {
  background: #46465a;
}

#nav-actions button:hover {
  background: #3b4658;
}

#panel-actions button:disabled,
#nav-actions button:disabled {
  opacity: 0.4;
  cursor: default;
  box-shadow: none;
}

#meta a { color: #7ab3e0; }

#opening-controls input {
  width: 60px;
  background: #1e1e24;
  color: #e8e8ea;
  border: 1px solid #505060;
  border-radius: 4px;
  padding: 4px 8px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  color: #d8e2ec;
}

.check-row input {
  width: 16px;
  height: 16px;
  accent-color: #5d6f86;
}

#stats-view table {
  border-collapse: collapse;
  margin-top: 12px;
}

#stats-view th, #stats-view td {
  border: 1px solid #3a3a44;
  padding: 6px 12px;
  text-align: left;
  font-size: 14px;
}

#stats-view th { background: #26262e; }

#stats-view h2 { margin-top: 28px; font-size: 17px; }
