:root {
  color-scheme: only light;
  --bg: #f7f0d8;
  --bg-2: #f6e4b5;
  --panel: rgba(255, 247, 230, 0.92);
  --panel-solid: #fff7e6;
  --accent: #ff7a59;
  --accent-2: #28b4a7;
  --accent-3: #f7c948;
  --ink: #2b2a2a;
  --muted: #5a5851;
  --card: #ffffff;
  --shadow: 0 18px 40px rgba(42, 33, 22, 0.25);
  --radius: 20px;
  --radius-sm: 12px;
  --table-green: #2e8f5b;
  --table-green-dark: #25714a;
  --text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe Print", "Lucida Sans", sans-serif;
  color: var(--ink);
  background: url('Hearts bgnd.png') no-repeat center center fixed;
  background-size: cover;
  min-height: 100vh;
  position: relative;
  touch-action: manipulation;
}

/* Dark overlay to improve text readability over the background */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.15) 0%,
    rgba(0, 0, 0, 0.25) 50%,
    rgba(0, 0, 0, 0.35) 100%
  );
  pointer-events: none;
  z-index: 0;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 6vw 10px;
  gap: 16px;
  position: relative;
  z-index: 1;
}

.brand__mark {
  display: flex;
  gap: 16px;
  align-items: center;
  background: rgba(255, 255, 255, 0.85);
  padding: 12px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.brand__label {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  text-transform: lowercase;
  letter-spacing: 0.08em;
}

.brand__label a {
  color: inherit;
  text-decoration: none;
}

.brand__label a:hover {
  text-decoration: underline;
}

h1 {
  margin: 0;
  font-size: clamp(1.7rem, 3vw, 2.6rem);
  color: var(--ink);
  text-shadow: var(--text-shadow);
}

.sm-badge {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: conic-gradient(from 120deg, var(--accent), var(--accent-3), var(--accent-2));
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
  text-transform: uppercase;
}

.rules-toggle {
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease;
}

.rules-toggle:hover {
  transform: translateY(-2px);
}

.rules {
  padding: 0 6vw;
  position: relative;
  z-index: 1;
}

.rules__inner {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 24px 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.rules h2,
.rules h3 {
  margin-top: 0;
  color: #2a3d45;
  text-shadow: var(--text-shadow);
}

.rules p,
.rules li {
  text-shadow: var(--text-shadow);
}

.table {
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr;
  gap: 20px;
  padding: 20px 5vw 40px;
  position: relative;
  z-index: 1;
}

.panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.panel--center {
  background: linear-gradient(145deg, rgba(46, 143, 91, 0.95), rgba(37, 113, 74, 0.95));
  color: #fff;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.15);
}

.panel--center::before {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: var(--radius);
  border: 2px dashed rgba(255, 255, 255, 0.3);
}

.panel--center > * {
  position: relative;
  z-index: 1;
}

/* Text shadow for center panel text */
.panel--center .status,
.panel--center .coach,
.panel--center .expert__advice {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.table-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.status {
  font-weight: 600;
}

.pass-info {
  font-size: 0.9rem;
  background: rgba(0, 0, 0, 0.2);
  padding: 6px 10px;
  border-radius: 999px;
}

.lead-suit {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  background: rgba(0, 0, 0, 0.25);
  padding: 6px 12px;
  border-radius: 999px;
}

/* Clockwise table layout:
 *        [Across - Player 2]
 *              (top)
 *   [Left]              [Right]
 * Player 1              Player 3
 *        [You - Player 0]
 *            (bottom)
 * Play order: You → Left → Across → Right → You
 */
.trick-area {
  display: grid;
  grid-template-areas:
    ".      top    ."
    "left   center right"
    ".      bottom .";
  grid-template-columns: 1fr auto 1fr;
  grid-template-rows: auto auto auto;
  gap: 12px;
  padding: 20px 0;
  justify-items: center;
  align-items: center;
  min-height: 320px;
}

.trick-slot {
  width: 100px;
  height: 140px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  text-align: center;
  gap: 4px;
  position: relative;
}

/* Position slots around the table clockwise */
#slot-0 { grid-area: bottom; } /* You - Bottom */
#slot-1 { grid-area: left; }   /* Vera - Left (clockwise from you) */
#slot-2 { grid-area: top; }    /* Marg - Across/Top */
#slot-3 { grid-area: right; }  /* Liz - Right */

/* Player position indicators */
.trick-slot::before {
  content: attr(data-position);
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
  font-weight: 600;
}

#slot-1::before { bottom: auto; top: 50%; right: -50px; left: auto; transform: translateY(-50%); }
#slot-3::before { bottom: auto; top: 50%; left: -50px; right: auto; transform: translateY(-50%); }
#slot-2::before { bottom: auto; top: -22px; }

/* Current turn highlight */
.trick-slot--active {
  border-color: var(--accent-3);
  box-shadow: 0 0 12px rgba(247, 201, 72, 0.5);
}

/* Clockwise arrow indicator in center */
.trick-area::before {
  content: "↻";
  grid-area: center;
  font-size: 2.5rem;
  color: rgba(255, 255, 255, 0.15);
  pointer-events: none;
}

.actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.coach {
  margin-top: 14px;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 14px;
  font-size: 0.95rem;
  line-height: 1.4;
  text-align: center;
}

.expert {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.expert__toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.expert__toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-3);
}

.expert__advice {
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px dashed rgba(255, 255, 255, 0.4);
  font-size: 0.9rem;
  line-height: 1.4;
}


button {
  font-family: inherit;
  border: none;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#passBtn {
  background: var(--accent-3);
}

#nextHandBtn,
#newGameBtn {
  background: var(--accent-2);
  color: #fff;
}

.player-card h2,
.hand h2,
.taken h2 {
  margin-top: 0;
  color: var(--ink);
  text-shadow: var(--text-shadow);
}

.scoreboard h3,
.history h3 {
  color: var(--ink);
  text-shadow: var(--text-shadow);
}

.name-entry {
  display: grid;
  gap: 10px;
}

.name-entry__row {
  display: flex;
  gap: 10px;
}

.name-entry input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid #d5c8a8;
  font-family: inherit;
}

.name-entry__note {
  margin: 0;
  color: var(--muted);
}

.player-list,
#scoreList,
#winnerList {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
}

.player-chip {
  display: flex;
  justify-content: space-between;
  background: #fff;
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 600;
  align-items: center;
  gap: 10px;
}

.player-chip span {
  color: var(--muted);
}

.scoreboard,
.history {
  margin-top: 18px;
}

.hand__cards {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.card {
  width: 70px;
  height: 100px;
  border-radius: 12px;
  background: var(--card);
  border: 2px solid #e5d8b8;
  box-shadow: 0 8px 16px rgba(34, 34, 34, 0.15);
  display: grid;
  align-content: space-between;
  padding: 8px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card--face {
  position: relative;
  padding: 8px;
  font-family: "Georgia", "Times New Roman", serif;
}

.card__corner {
  position: absolute;
  display: grid;
  justify-items: center;
  line-height: 1;
  font-size: 0.85rem;
}

.card__corner--tl {
  top: 6px;
  left: 6px;
}

.card__corner--br {
  bottom: 6px;
  right: 6px;
  transform: rotate(180deg);
}

.card__corner-suit {
  font-size: 0.8rem;
}

.card__center {
  display: grid;
  place-items: center;
  font-size: 2rem;
  opacity: 0.85;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 20px rgba(34, 34, 34, 0.2);
}

.card--disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.card__suit {
  font-size: 1.2rem;
}

.card__rank {
  font-size: 1.1rem;
}

.card--back {
  background: linear-gradient(135deg, #ff9b6b, #ff5f6d);
  color: #fff;
  border: none;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.card--mini {
  width: 38px;
  height: 54px;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
}

.back-stack {
  display: flex;
  gap: 4px;
  align-items: center;
}

.player-meta {
  display: grid;
  gap: 4px;
  justify-items: end;
}

.hand-count {
  font-size: 0.8rem;
  color: var(--muted);
}

.card--selected {
  outline: 3px solid var(--accent-2);
}

.card--red {
  color: #d22c2c;
}

.taken__pile {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.taken__player {
  display: grid;
  gap: 6px;
  padding: 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.6);
}

.taken__player-name {
  font-weight: 700;
  font-size: 0.9rem;
}

.taken__cards {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pile-card {
  width: 46px;
  height: 64px;
  border-radius: 8px;
  background: #fff;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  border: 1px solid #e2d4b0;
}

.footer {
  text-align: center;
  padding: 18px;
  color: #fff;
  position: relative;
  z-index: 1;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.footer p {
  background: rgba(0, 0, 0, 0.4);
  display: inline-block;
  padding: 10px 24px;
  border-radius: 999px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

@media (max-width: 1100px) {
  .table {
    grid-template-columns: 1fr;
  }
  .panel--center {
    order: -1;
  }
}

/* Mobile responsive trick area */
@media (max-width: 600px) {
  .trick-area {
    gap: 8px;
    padding: 15px 0;
    min-height: 280px;
  }

  .trick-slot {
    width: 75px;
    height: 105px;
    font-size: 0.85rem;
  }

  .trick-slot .card {
    width: 55px;
    height: 78px;
  }

  .trick-slot::before {
    font-size: 0.65rem;
    bottom: -18px;
  }

  #slot-1::before { right: -40px; }
  #slot-3::before { left: -40px; }
  #slot-2::before { top: -18px; }

  .trick-area::before {
    font-size: 1.8rem;
  }
}
