/* ==== Base layout ==== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

.site-header {
  padding: 0.75rem 1rem 0.5rem;
  background: #ffffff;
  border-bottom: 1px solid #ddd;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-small {
  width: 48px;
  height: auto;
}

.title-text h1 {
  margin: 0;
  font-size: 1.6rem;
}

.title-text .tagline {
  margin: 0.2rem 0 0;
  font-size: 0.9rem;
  color: #555;
}

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

.top-links a {
  color: #0066cc;
  text-decoration: none;
}

.top-links a:hover {
  text-decoration: underline;
}

.top-links .divider {
  margin: 0 0.35rem;
  color: #999;
}

.copyright {
  margin: 0.5rem 0 0;
  font-size: 0.75rem;
  color: #777;
}

main {
  padding: 0.75rem;
}

/* ==== Control panel ==== */
.control-panel {
  background: #ffffff;
  border-radius: 8px;
  padding: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  margin-bottom: 0.75rem;
}

.controls-primary,
.controls-secondary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.controls-primary {
  align-items: center;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid #eee;
  padding-bottom: 0.5rem;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
}

#startGameBtn {
  padding: 0.4rem 0.9rem;
  border-radius: 4px;
  border: 1px solid #196b24;
  background: #1f8a2f;
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}

#startGameBtn:hover {
  background: #166321;
}

.status-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.status-row.small {
  font-size: 0.85rem;
  color: #444;
}

.status-row .spacer {
  flex: 1;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.actions-row button {
  padding: 0.35rem 0.7rem;
  border-radius: 4px;
  border: 1px solid #ccc;
  background: #f3f3f3;
  cursor: pointer;
  font-size: 0.85rem;
}

.actions-row button:hover:not(:disabled) {
  background: #e4e4e4;
}

.actions-row button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ==== Card styles ==== */
.card {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  padding: 0.2rem 0.35rem;
  margin-left: 0.25rem;
  border-radius: 4px;
  border: 1px solid #bbb;
  background: #fff;
  font-size: 0.9rem;
}

.card.red {
  color: #b00020;
}

.card.placeholder {
  border-style: dashed;
  color: #888;
}

/* ==== Players / rows ==== */
.players-area {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.playerPanel {
  background: #ffffff;
  border-radius: 8px;
  padding: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.playerHeader {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.playerHeader h2 {
  margin: 0;
  font-size: 1rem;
}

.turnTag {
  font-size: 0.75rem;
  padding: 0.18rem 0.4rem;
  border-radius: 999px;
}

.turnTag.active {
  background: #e0f7e9;
  color: #196b24;
}

.turnTag.inactive {
  background: #f0f0f0;
  color: #666;
}

.rows {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.row {
  border-radius: 6px;
  border: 1px solid #ddd;
  padding: 0.35rem 0.45rem;
  background: #fafafa;
}

.row.complete-row {
  border-color: #196b24;
  box-shadow: 0 0 0 1px rgba(25, 107, 36, 0.35);
}

.row.king-wipe-target {
  border-style: dashed;
  border-color: #cc8800;
}

.row.move-source {
  border-style: dashed;
  border-color: #0066cc;
}

.rowHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
}

.rowHeader button {
  padding: 0.2rem 0.45rem;
  font-size: 0.75rem;
}

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

/* ==== Score & match panels ==== */
.score-panel,
.match-panel {
  background: #ffffff;
  border-radius: 8px;
  padding: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  margin-top: 0.75rem;
}

.score-panel h3,
.match-panel h3 {
  margin-top: 0;
  margin-bottom: 0.35rem;
}

.score-panel table,
.match-panel table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-top: 0.35rem;
}

.score-panel th,
.score-panel td,
.match-panel th,
.match-panel td {
  border: 1px solid #ddd;
  padding: 0.3rem 0.4rem;
  text-align: left;
}

.score-panel th,
.match-panel th {
  background: #f3f3f3;
}

.score-panel ul {
  margin: 0.35rem 0 0.35rem 1rem;
  padding-left: 1rem;
  font-size: 0.85rem;
}

/* Post-round buttons */
.postRoundActions {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.postRoundActions button {
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  border: 1px solid #ccc;
  background: #f5f5f5;
  cursor: pointer;
  font-size: 0.85rem;
}

.postRoundActions button:hover {
  background: #e6e6e6;
}

/* ==== Explainer video modal ==== */
.modal.hidden {
  display: none;
}

.modal.visible {
  display: flex;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
}

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

.modal-content {
  position: relative;
  z-index: 1;
  max-width: 640px;
  width: 92%;
  background: #ffffff;
  border-radius: 10px;
  padding: 0.75rem 0.9rem 0.9rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.modal-close {
  position: absolute;
  top: 0.35rem;
  right: 0.5rem;
  border: none;
  background: transparent;
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}

.modal h2 {
  margin: 0 0 0.4rem;
  font-size: 1.1rem;
}

.modal-intro,
.modal-note {
  font-size: 0.85rem;
  margin: 0.25rem 0;
  color: #555;
}

.modal video {
  width: 100%;
  max-height: 60vh;
  border-radius: 6px;
  margin-top: 0.35rem;
}

/* ==== Responsive tweaks ==== */
@media (max-width: 600px) {
  .controls-primary {
    flex-direction: column;
    align-items: flex-start;
  }

  .actions-row {
    flex-direction: column;
    align-items: stretch;
  }

  .playerHeader {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
  }
}

/* Updated logo size */
.logo-small {
  width: 64px;
  height: auto;
}

/* Better dropdown readability */
#numPlayers {
  color: #000 !important;
  font-weight: 600 !important;
  background-color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  border: 1px solid #555;
}