
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #111827;
  color: #e5e7eb;
}

#app {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

h1, h2, h3, h4 {
  margin-top: 0;
}

.subtitle {
  color: #9ca3af;
}

.primary,
.secondary,
button {
  border: none;
  cursor: pointer;
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 1rem;
}

.primary {
  background: #2563eb;
  color: #f9fafb;
}

.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.secondary {
  background: #374151;
  color: #e5e7eb;
}

button {
  background: #374151;
  color: #e5e7eb;
}

button:hover:not(:disabled) {
  filter: brightness(1.1);
}

button:active:not(:disabled) {
  filter: brightness(0.9);
}

.setup-group {
  margin: 1rem 0;
}

.setup-group label {
  margin-right: 0.75rem;
}

.rolloff .panel {
  margin-top: 0.75rem;
}

.first-player-choices {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

.manual-choice,
.roll-choice {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid #374151;
  background: #111827;
  cursor: pointer;
  font-size: 0.95rem;
}

.pill input {
  accent-color: #2563eb;
}

.panel {
  background: #111827;
  border: 1px solid #374151;
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  margin-top: 0.5rem;
}

.setup-actions {
  margin-top: 1.5rem;
  display: flex;
  gap: 0.75rem;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.scores {
  display: flex;
  gap: 1rem;
}

.scores h3 {
  margin-bottom: 0.25rem;
}

.game-layout {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  grid-template-rows: auto auto;
  gap: 1rem;
}

.board-section {
  grid-column: 1 / 2;
  grid-row: 1 / 2;
}

.controls-section {
  grid-column: 2 / 3;
  grid-row: 1 / 2;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.log-section {
  grid-column: 1 / 3;
  grid-row: 2 / 3;
}

.log {
  height: 200px;
  overflow-y: auto;
  background: #020617;
  border-radius: 0.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid #1f2937;
  font-size: 0.9rem;
}

.log p {
  margin: 0.1rem 0;
}

.log .log-ts {
  color: #93c5fd;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.log .log-msg {
  color: #e5e7eb;
}

.board-wrapper {
  margin-bottom: 0.75rem;
}

.board-row {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.square {
  min-width: 2rem;
  padding: 0.25rem 0.4rem;
  text-align: center;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  border: 1px solid #34d399;
  background: #059669;
  color: #022c22;
  cursor: pointer;
}

.square.covered {
  background: #111827;
  border-color: #4b5563;
  color: #e5e7eb;
}

.square.advantage {
  background: #facc15;
  border-color: #f59e0b;
  color: #1f2937;
  box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.4);
}


.square.advantage.covered {
  background: #facc15;
  border-color: #f59e0b;
  color: #1f2937;
}

.square.selected {
  outline: 2px solid #eab308;
}

.square.disabled {
  opacity: 0.4;
  cursor: default;
}

.btn-group {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.hint {
  font-size: 0.8rem;
  color: #9ca3af;
}

.bottom-bar {
  margin-top: 1rem;
  display: flex;
  justify-content: flex-end;
}

#dice-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

#dice-area p,
#move-area p,
#turn-info p {
  margin: 0.25rem 0;
}

.computer-reason {
  margin-top: 0.75rem;
  padding: 0.65rem 0.8rem;
  border-radius: 0.65rem;
  border: 1px dashed #60a5fa;
  background: #0b1224;
}

.computer-reason.hidden {
  display: none;
}

.computer-reason .reason-label {
  margin: 0;
  font-size: 0.85rem;
  color: #93c5fd;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

#lbl-computer-reason {
  margin: 0.3rem 0 0 0;
  color: #e0f2fe;
  line-height: 1.35;
}

#turn-info {
  margin-top: 0.5rem;
}

#screen-end .panel {
  margin: 1rem 0;
}

#screen-end .actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

@media (max-width: 768px) {
  .game-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }

  .controls-section {
    grid-column: 1 / 2;
    grid-row: 2 / 3;
  }

  .log-section {
    grid-row: 3 / 4;
  }

  .top-bar {
    flex-direction: column;
    gap: 0.75rem;
  }
}




.game-layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.board-section {

}

.controls-under-boards {

}

.log-section {
}


.boards-wrapper {
  margin-top: 0.5rem;
}

.board-wrapper {
  margin-bottom: 0.75rem;
}

.board-row {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.square {
  min-width: 2rem;
  padding: 0.25rem 0.4rem;
  text-align: center;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  border: 1px solid #34d399;
  background: #059669;
  color: #022c22;
  cursor: default;
}

.square.covered {
  background: #111827;
  border-color: #4b5563;
  color: #e5e7eb;
}


#dice-area p {
  margin: 0.25rem 0;
}

#dice-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}


.log {
  height: 200px;
  overflow-y: auto;
  background: #020617;
  border-radius: 0.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid #1f2937;
  font-size: 0.9rem;
}

.log p {
  margin: 0.1rem 0;
}


.modal.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #020617;
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  width: min(420px, 90vw);
  border: 1px solid #374151;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.modal-move-type {
  margin: 0.5rem 0;
}

.modal-move-type label {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-right: 0.75rem;
}

.modal-options {
  margin: 0.5rem 0;
}

.modal-options select {
  width: 100%;
  padding: 0.3rem 0.4rem;
  border-radius: 0.4rem;
  border: 1px solid #4b5563;
  background: #020617;
  color: #e5e7eb;
}

.modal-buttons {
  justify-content: flex-end;
}

.rewind-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid #4b5563;
  border-radius: 0.5rem;
  padding: 0.5rem;
  background: #020617;
}

.rewind-item {
  padding: 0.3rem 0.4rem;
  border-radius: 0.35rem;
  cursor: pointer;
}

.rewind-item:hover {
  background: #1f2937;
}

.rewind-item.selected {
  background: #2563eb;
  color: #f9fafb;
}

.panel.small {
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

.preview-boards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

#rewind-preview .board-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
}

#rewind-preview .square {
  min-width: 1.75rem;
  padding: 0.25rem;
  font-size: 0.8rem;
}

@media (max-width: 768px) {
  .top-bar {
    flex-direction: column;
    gap: 0.75rem;
  }
}




.manual-dice-mode {
  margin: 0.5rem 0 0.75rem 0;
}

.manual-dice-mode label {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-right: 0.75rem;
}

.manual-dice-rows {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.manual-dice-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.manual-dice-row > span {
  min-width: 3rem;
  font-size: 0.9rem;
  color: #e5e7eb;
}

.manual-die {
  border-radius: 0.5rem;
  border: 1px solid #4b5563;
  background: #020617;
  padding: 0.25rem 0.5rem;
  min-width: 2.2rem;
  text-align: center;
  cursor: pointer;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.9rem;
}

.manual-die.selected {
  border-color: #eab308;
  background: #1f2937;
  box-shadow: 0 0 0 1px #eab308;
}

.manual-die:hover {
  filter: brightness(1.1);
}




.dice-picker {
  display: flex;
  gap: 1rem;
  margin: 0.75rem 0;
}

.die-column p {
  margin: 0 0 0.25rem 0;
}

.dice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.25rem;
}

.die-face {
  border: 1px solid #4b5563;
  border-radius: 0.375rem;
  padding: 0.3rem 0.5rem;
  background: #020617;
  color: #e5e7eb;
  cursor: pointer;
  font-size: 0.9rem;
}

.die-face.selected {
  outline: 2px solid #eab308;
}

@media (max-width: 640px) {
  .dice-picker {
    flex-direction: column;
  }
}

.manual-die.selected {
  outline: 2px solid #333;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.4);
  transform: translateY(-1px);
}
