body {
  background-color: green;
  font-family: Arial, Helvetica, sans-serif;
  margin: 0;
  padding: 20px;
}

.title {
  color: white;
  text-align: center;
  margin: 0;
}

/* Title + buttons row: 20px between the title and the button group. */
.header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

/* The group of title-bar buttons — 5px between neighbours. Reused by the
   Game Over popup so every title button appears there too. */
.title-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-wrap: wrap;
}

.mode-buttons {
  display: flex;
  gap: 5px; /* 5px between the mode buttons */
  justify-content: center;
}

/* Shared button look: rounded corners, bordered, with a hover roll-over. */
.mode-buttons button,
.howto-btn,
.info button,
.modal-box button {
  border-radius: 8px;
  border: 2px solid #146c43;
  background-color: #ffffff;
  color: #146c43;
  font-weight: bold;
  cursor: pointer;
  padding: 5px;   /* 5px padding on all sides */
  margin: 0;      /* spacing between buttons is set by their container's gap */
  transition: background-color 0.15s ease, color 0.15s ease,
              box-shadow 0.15s ease, transform 0.15s ease;
}

.mode-buttons button:hover,
.howto-btn:hover,
.info button:hover,
.modal-box button:hover {
  background-color: #146c43;
  color: #ffffff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
  transform: translateY(-2px);
}

.mode-buttons button:active,
.howto-btn:active,
.info button:active,
.modal-box button:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.mode-buttons button,
.howto-btn {
  font-size: 15px;
  padding: 5px;
}

/* Coloured title-bar buttons (base colour; the hover rule above still wins,
   since a class+pseudo-class selector outranks a single class). */
.btn-blue     { background-color: lightblue; } /* How to Play — light blue      */
.btn-red      { background-color: #ffb3b3; }   /* Vs Comp     — light red       */
.btn-red-plus { background-color: #ff8080; }   /* Vs Comp+    — deeper red (hard)*/
.btn-green    { background-color: lightgreen; }/* High Scores — light green     */

/* Shared: tables use thick, collapsed cell borders. 10px above the hand
   (title -> hand) and 10px between the hand and the board (margins collapse). */
.hand-table,
.board {
  margin: 10px auto;
  border-collapse: collapse;
}

/* ---- Top table ---- */

/* 70px label cell holding the "P1"/"P2" heading (color set per player). */
.player-label {
  width: 70px;
  border: 4px solid black;
  background-color: white;
  text-align: center;
  vertical-align: middle;
}

.player-label h1 {
  margin: 0;
}

/* Empty spacer cell (15px), green like the background. */
.space-cell {
  width: 15px;
  border: 4px solid black;
  background-color: green;
}

/* Face-down draw cards: thin 10px light-blue slivers. */
.deck-card {
  width: 10px;
  height: 80px;
  border: 4px solid black;
  background-color: cornflowerblue; /* lighter blue */
}

/* A draw cell that has been drawn from — cleared to green. */
.deck-card.drawn {
  background-color: green;
}

/* Info cell: score lines and the End turn button (stacked). Kept compact so a
   third player's score line fits without making the whole top row taller. */
.info-cell {
  border: 4px solid black;
  background-color: white;
  vertical-align: middle;
  padding: 4px;
}

.info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;          /* tight vertical spacing between the scores and the button */
  line-height: 1.1;
  font-size: 13px;
  font-weight: bold;
  white-space: nowrap;
}

.info button {
  cursor: pointer;
  padding: 5px;
  font-size: 13px;
}

/* ---- Cards (face up) ---- */
.card {
  width: 60px;
  height: 80px;
  border: 4px solid black;
  background-color: white;
  text-align: center;
  vertical-align: middle;
  line-height: 80px;
  font-size: 20px;
  font-weight: bold;
  box-sizing: border-box;
  cursor: grab;
  user-select: none;
}

.card.red   { color: red; }
.card.black { color: black; }
.card.dragging { opacity: 0.4; }

/* Off-screen board-row replica used as the drag image for a whole group.
   It carries the .board class so cells match the real board exactly. */
.drag-image {
  position: absolute;
  top: -1000px;
  left: -1000px;
  margin: 0;
}

/* Ownership tint for cards resting on the board. */
.card.owner-p1 { background-color: #cfe0ff; } /* slightly blue  — P1 */
.card.owner-p2 { background-color: #ffd0d0; } /* slightly red   — P2 */
.card.owner-p3 { background-color: #d0f0d0; } /* slightly green — P3 */

/* Board card: rank+suit raised, black score beneath. */
.card.scored {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
  gap: 2px;
}

.card-face  { font-size: 18px; }
.card-score { font-size: 13px; color: black; font-weight: bold; }

/* A face-up hand slot in the top row. Stays green (empty) after its card is
   played to the board. */
.hand-slot {
  width: 60px;
  height: 80px;
  border: 4px solid black;
  background-color: green;
  text-align: center;
  vertical-align: middle;
  padding: 0;
}

/* ---- The board ---- */
.board td {
  position: relative; /* anchors the drag-highlight overlay */
  width: 60px;
  height: 80px;
  border: 4px solid black;
  background-color: green;
  text-align: center;
  vertical-align: middle;
  padding: 0;
}

/* Drag highlight over the single target cell — drawn on top of any card. */
.board td.valid::after,
.board td.invalid::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.board td.valid::after   { background-color: rgba(255, 255, 0, 0.5); }  /* yellow — valid */
.board td.invalid::after { background-color: rgba(255, 0, 0, 0.45); }   /* red — invalid */

/* A card sitting in a hand slot or board cell fills the cell (no extra border). */
.hand-slot .card,
.board td .card {
  width: 100%;
  height: 100%;
  border: none;
}

/* Face-down card (the computer's hidden hand): fills the slot in the same blue
   as the draw-deck cells, so it reads as the back of a card. */
.card-back {
  width: 100%;
  height: 100%;
  background-color: cornflowerblue;
  box-sizing: border-box;
}

/* ---- Hotseat "ready?" popup ---- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.hidden {
  display: none;
}

.modal-box {
  background: white;
  padding: 30px 40px;
  border-radius: 8px;
  text-align: center;
}

.modal-box p {
  font-size: 22px;
  margin: 0 0 20px;
}

.modal-box button {
  font-size: 18px;
  padding: 5px;
}

/* ---- How to Play popup ---- */
.howto-box {
  position: relative;
  background: #ffffff;
  color: #1a1a1a;
  text-align: left;
  max-width: 640px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px 28px;
  border-radius: 10px;
  line-height: 1.4;
}

.howto-box h2 {
  margin: 0 0 12px;
  text-align: center;
}

.howto-box h3 {
  margin: 18px 0 6px;
  color: #146c43;
  border-bottom: 1px solid #ddd;
  padding-bottom: 3px;
}

.howto-box p { margin: 8px 0; }
.howto-box ul { margin: 6px 0; padding-left: 20px; }
.howto-box li { margin: 3px 0; }

.howto-example {
  background: #f2f2f2;
  border-left: 3px solid #146c43;
  padding: 8px 12px;
  font-family: "Courier New", monospace;
  white-space: pre-wrap;
}

.howto-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: #666;
  cursor: pointer;
}

.howto-close:hover { color: #000; }

/* ---- High Scores popup ---- */
.hs-box {
  position: relative;
  background: #ffffff;
  color: #1a1a1a;
  text-align: center;
  max-width: 460px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px 28px;
  border-radius: 10px;
}

.hs-box h2 { margin: 0 0 14px; }

.hs-table {
  border-collapse: collapse;
  width: 100%;
  margin: 0 auto;
}

.hs-table th,
.hs-table td {
  border: 1px solid #ccc;
  padding: 6px 12px;
  text-align: center;
}

.hs-table th {
  background: #146c43;
  color: #ffffff;
}

.hs-table tbody tr:nth-child(odd) { background: #f2f2f2; }

.hs-empty { color: #555; }
