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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Nunito", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 18px;
  background: radial-gradient(circle at top left, #2f80ed 0, #151929 40%, #05030a 100%);
  color: #f7f9ff;
}

body {
  display: flex;
}

.app-shell {
  display: flex;
  flex-direction: column;
  flex: 1;
  max-width: 1650px;
  margin: 0 auto;
  padding: 16px;
  gap: 12px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 14px;
  background: linear-gradient(120deg, rgba(35, 67, 154, 0.9), rgba(116, 63, 217, 0.9));
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: conic-gradient(from 140deg, #ff9a3c, #ffe15d, #ff5b7b, #ff9a3c);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Baloo 2", cursive;
  font-weight: 800;
  color: #1b1025;
  font-size: 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.brand-text h1 {
  margin: 0;
  font-family: "Baloo 2", cursive;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #facc15; /* dark yellow for Screw Your Buddy title */
}

.tagline {
  margin: 0;
  font-size: 18px;
  opacity: 0.9;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.btn {
  border: none;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease, color 0.12s ease;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}

.btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.btn-primary {
  background: linear-gradient(135deg, #ff9a3c, #ffe15d);
  color: #1b1025;
}

.btn-accent {
  background: linear-gradient(135deg, #00e1ff, #2f80ed);
  color: #05030a;
}

.btn-ghost {
  background: rgba(11, 18, 42, 0.2);
  color: #f7f9ff;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.btn-full-width {
  width: 100%;
}

.btn.small {
  padding: 6px 10px;
  font-size: 16px;
}

#nextTrickBtn {
  position: absolute;
  bottom: 14px;
  right: 22px;
  transform: translate(32px, 32px);
  background: #020617;
  border-radius: 999px;
  border: 3px solid #facc15;
  color: #facc15;
  font-weight: 700;
  font-size: 20px;
  padding: 16px 36px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.7);
  z-index: 3;
}

#nextTrickBtn:disabled {
  opacity: 0.4;
  box-shadow: none;
}

.main-layout {
  display: grid;
  grid-template-columns: minmax(300px, 350px) minmax(0, 1.8fr);
  gap: 14px;
  flex: 1;
  min-height: 0;
}

.left-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.panel.card,
.table-surface,
.log-panel {
  background: radial-gradient(circle at top left, rgba(31, 51, 107, 0.9), rgba(7, 9, 20, 0.96));
  border-radius: 18px;
  padding: 14px 14px 16px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Quick Match panel: compact to leave room for Game Log */
.left-panel .rules-panel.panel.card {
  padding: 10px 12px 12px;
  flex-shrink: 0;
}

.left-panel .rules-panel h2 {
  margin: 0 0 4px;
  font-size: 1.1rem;
}

.left-panel .rules-panel .panel-subtitle {
  margin: 0 0 6px;
  font-size: 14px;
  opacity: 0.9;
}

.left-panel .rules-panel .setup-form {
  gap: 6px;
  margin-bottom: 8px;
}

.left-panel .rules-panel .field {
  gap: 2px;
  font-size: 15px;
}

.left-panel .rules-panel select,
.left-panel .rules-panel input[type="text"] {
  padding: 4px 8px;
  font-size: 15px;
}

.left-panel .rules-panel .game-status-box {
  margin-top: 8px;
  padding: 10px 12px;
}

.left-panel .rules-panel .info-row {
  font-size: 15px;
}

.left-panel .rules-panel .bidding-controls {
  margin-top: 8px;
  padding-top: 8px;
  gap: 6px;
}

.panel h2 {
  margin: 0 0 6px;
  font-family: "Baloo 2", cursive;
}

.panel-subtitle {
  margin: 0 0 10px;
  font-size: 18px;
  opacity: 0.9;
}

.setup-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 18px;
}

.field span {
  opacity: 0.9;
}

select,
input[type="text"] {
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 6px 10px;
  background: rgba(3, 8, 24, 0.8);
  color: #f7f9ff;
  font-family: inherit;
  font-size: 18px;
}

select:focus-visible,
input[type="text"]:focus-visible {
  outline: 2px solid #00e1ff;
  outline-offset: 1px;
}

.game-status-box {
  margin-top: 14px;
  padding: 16px 18px;
  border-radius: 14px;
  background: linear-gradient(145deg, #1e3a5f 0%, #2d1b4e 50%, #1a4d3c 100%);
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    0 6px 20px rgba(0, 0, 0, 0.35);
}

.info-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 0;
}

.info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 18px;
}

.info-label {
  opacity: 0.85;
}

.info-value {
  font-weight: 600;
}

.bidding-controls {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed rgba(255, 255, 255, 0.25);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.table-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.scorecard-wrap {
  display: flex;
  justify-content: center;
  flex-shrink: 0;
}

.scorecard-wrap .scorecard-panel {
  max-width: 800px;
  width: 100%;
}

.table-surface {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: radial-gradient(circle at center, #18412f, #071810, #040908);
  flex: 1;
  min-height: 200px;
}

.table-surface::before {
  content: "";
  position: absolute;
  inset: 10%;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.06);
  pointer-events: none;
}

.trump-display {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 200px;
  height: 200px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.trump-card {
  width: 110px;
  height: 150px;
  border-radius: 18px;
  background: radial-gradient(circle at top, #fff7e1, #f6d67a);
  color: #7a4b00;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.7);
  border: 3px solid #fbbf24;
}

.trump-card.red {
  color: #b91c1c;
}

.trump-card .rank {
  font-size: 26px;
  font-weight: 800;
}

.trump-card.trump-unknown .rank {
  font-size: 52px;
  font-weight: 800;
}

.trump-card .suit {
  font-size: 28px;
}

.trump-card.trump-unknown .suit {
  display: none;
}

.trump-word-ring {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(249, 250, 251, 0.45);
}

.trump-word-ring span {
  position: absolute;
}

.trump-top {
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
}

.trump-bottom {
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%) rotate(180deg);
}

.trump-left {
  left: -4px;
  top: 50%;
  transform: translateY(-50%) rotate(-90deg);
}

.trump-right {
  right: -4px;
  top: 50%;
  transform: translateY(-50%) rotate(90deg);
}

.player-row {
  display: flex;
  justify-content: center;
}

.player-row.bottom {
  margin-top: auto;
}

.player-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.player-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
}

.player-header.vertical {
  flex-direction: column;
}

.player-name {
  font-weight: 600;
}

.player-score {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  font-size: 11px;
}

.books-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.books-row.vertical {
  flex-direction: column;
}

.books-label {
  font-size: 10px;
  opacity: 0.85;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.books-pile {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 18px;
}

.books-card {
  width: 18px;
  height: 24px;
  border-radius: 4px;
  background: repeating-linear-gradient(
      135deg,
      #111827,
      #111827 3px,
      #4b5563 3px,
      #4b5563 6px
    );
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(15, 23, 42, 0.7);
}

.bid-row,
.bid-label,
.bid-value {
  display: none;
}

.middle-row {
  display: grid;
  grid-template-columns: 1fr minmax(0, 1.4fr) 1fr;
  align-items: center;
  gap: 8px;
}

.side {
  align-items: center;
}

.side.left {
  align-items: flex-start;
  margin-left: 10px;
}

.side.right {
  align-items: flex-end;
  margin-right: -40px;
}

.side.right .hand-compact.vertical {
  margin-right: -160px;
}

.side.left .hand-compact.vertical {
  margin-left: 130px;
}

.side.left .hand-compact.vertical .card-chip,
.side.right .hand-compact.vertical .card-chip {
  transform: rotate(90deg);
  transform-origin: center;
}

.side.left .hand-compact.vertical .card-chip.selectable:hover,
.side.right .hand-compact.vertical .card-chip.selectable:hover {
  transform: rotate(90deg) translateY(-6px) scale(1.03);
}

.hand {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  justify-content: center;
  padding: 4px;
}

.hand-compact {
  opacity: 0.9;
}

.hand.vertical {
  flex-direction: column;
  gap: 2px;
}

.hand.vertical .card-chip {
  margin-top: -24px;
}

.hand.vertical .card-chip:first-child {
  margin-top: 0;
}

.card-chip {
  width: 68px;
  height: 96px;
  border-radius: 12px;
  background: linear-gradient(145deg, #fafafa, #d2d6dc);
  color: #111827;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 5px 4px;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.5);
  cursor: default;
  position: relative;
  transform-origin: center;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease, opacity 0.12s ease;
}

.card-chip .rank {
  font-size: 26px;
}

.card-chip .suit {
  font-size: 28px;
}

.card-chip .corner {
  align-self: flex-start;
  font-size: 16px;
}

.card-chip.red {
  color: #b91c1c;
}

.card-chip.back {
  background-image: url("assets/card-back-pattern.png");
  background-size: cover;
  background-position: center;
  color: #f9fafb;
}

.card-chip.joker-big,
.card-chip.joker-small {
  padding: 0;
  overflow: hidden;
}

.card-chip .joker-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: inherit;
}

/* Big Joker: image fills the whole card (no letterboxing) */
.card-chip.joker-big .joker-img {
  object-fit: cover;
  object-position: center;
}

/* Little Joker: full image centered and visible (no cropping) */
.card-chip.joker-small .joker-img {
  object-fit: contain;
  object-position: center;
}

.card-chip.selectable {
  cursor: pointer;
}

.card-chip.selectable:hover {
  transform: translateY(-6px) scale(1.03);
  box-shadow: 0 16px 26px rgba(0, 0, 0, 0.65);
  filter: brightness(1.05);
}

.card-chip.played {
  transform: translateY(0) scale(1.02);
}

.trick-area {
  position: absolute;
  inset: 22% 26%;
}

.trick-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  position: absolute;
}

.trick-slot[data-seat="0"] {
  bottom: 0;
  left: 50%;
  transform: translate(-50%, 32px);
}

.trick-slot[data-seat="2"] {
  top: 0;
  left: 50%;
  transform: translate(-50%, -32px);
}

.trick-slot[data-seat="1"] {
  left: 0;
  top: 50%;
  transform: translateY(-50%);
}

.trick-slot[data-seat="3"] {
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

.trick-info {
  text-align: center;
  font-size: 18px;
  margin-bottom: 6px;
}

.trick-name {
  font-weight: 700;
  margin-bottom: 4px;
}

.trick-meta {
  display: flex;
  gap: 10px;
  justify-content: center;
  opacity: 0.85;
}

.dealer-chip {
  display: inline-flex;
  width: 20px;
  height: 20px;
  margin-left: 6px;
  border-radius: 50%;
  border: 2px solid #fbbf24;
  background: radial-gradient(circle at top, #facc15, #b45309);
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.8), 0 4px 10px rgba(0, 0, 0, 0.7);
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  color: #111827;
  animation: spin-chip 3s linear infinite;
}

.dealer-chip::before {
  content: "D";
}

@keyframes spin-chip {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.card-slot {
  width: 76px;
  height: 108px;
  border-radius: 12px;
  border: 2px dashed rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.card-slot.filled {
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.32);
  background: rgba(15, 23, 42, 0.6);
}

.log-panel {
  font-size: 14px;
  overflow: hidden;
}

.log-panel h2 {
  margin: 0 0 6px;
  font-family: "Baloo 2", cursive;
}

.log-list {
  max-height: 120px;
  overflow-y: auto;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.log-entry {
  font-size: 18px;
  opacity: 0.9;
}

.log-entry span {
  font-weight: 600;
}

.left-panel .log-panel {
  flex: 1;
  min-height: 120px;
  display: flex;
  flex-direction: column;
}

.left-panel .log-list {
  max-height: none;
  flex: 1;
  min-height: 100px;
}

.scorecard-panel {
  font-size: 13px;
  overflow: hidden;
}

.scorecard-panel h2 {
  margin: 0 0 6px;
  font-family: "Baloo 2", cursive;
}

.scorecard-table {
  border-radius: 10px;
  background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.8), rgba(3, 7, 18, 0.95));
  padding: 6px 16px;
}

.scorecard-totals,
.scorecard-sandbags,
.scorecard-header,
.score-row {
  display: grid;
  grid-template-columns: 60px repeat(4, minmax(0, 1fr));
  align-items: center;
  gap: 24px;
}

.scorecard-totals {
  margin-bottom: 4px;
}

.totals-label {
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: 14px;
  opacity: 0.98;
}

.total-box {
  display: inline-block;
  min-width: 32px;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(22, 163, 74, 0.2);
  border: 1px solid rgba(22, 163, 74, 0.6);
  font-size: 16px; /* two steps up from 12px sandbag font */
  font-weight: 700;
  font-style: italic;
  color: #22c55e;
}

.scorecard-sandbags {
  margin-bottom: 2px;
}

.sandbags-label {
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: 12px;
  opacity: 0.95;
}

.sandbag-box {
  display: inline-block;
  min-width: 22px;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(251, 191, 36, 0.2);
  border: 1px solid rgba(251, 191, 36, 0.4);
  font-size: 12px;
  font-weight: 700;
  color: #fbbf24;
}

.scorecard-header {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.9;
  margin-bottom: 4px;
  gap: 8px;
}

.scorecell {
  text-align: center;
}

.hand-col {
  text-align: left;
}

.player-col {
  font-weight: 700;
  color: #f97316;
  font-size: 13px;
}

.scorecard-body {
  max-height: 120px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.score-row {
  font-size: 12px;
}

.score-row:nth-child(2n) {
  background: rgba(15, 23, 42, 0.7);
}

.score-row .scorecell {
  padding: 2px 0;
}

.score-value {
  font-weight: 600;
  color: #e5e7eb;
}

.score-total {
  display: block;
  font-size: 10px;
  color: #9ca3af;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 17, 0.74);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.modal {
  max-width: 420px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.modal-header h2 {
  margin: 0;
  font-family: "Baloo 2", cursive;
}

.icon-btn {
  border: none;
  background: transparent;
  color: #f9fafb;
  font-size: 18px;
  cursor: pointer;
}

.modal-body {
  font-size: 13px;
  line-height: 1.4;
  overflow-y: auto;
  padding-right: 4px;
}

.rules-list {
  padding-left: 18px;
}

.rules-list li {
  margin-bottom: 6px;
}

.modal-footer {
  margin-top: 10px;
}

/* Larger, wider How to Play rules modal only */
#rulesModal .modal {
  max-width: 680px;
}

#rulesModal .modal-body {
  font-size: 16px;
  line-height: 1.5;
}

#rulesModal .rules-list li {
  margin-bottom: 8px;
}

.game-over-modal {
  text-align: center;
  padding: 28px 24px;
}

.game-over-winner {
  font-family: "Baloo 2", cursive;
  font-size: 2.25rem;
  font-weight: 800;
  color: #facc15;
  text-shadow:
    0 0 0 3px #000,
    0 0 0 4px #000,
    2px 2px 0 #000,
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000;
  margin-bottom: 24px;
  line-height: 1.2;
}

.game-over-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .app-shell {
    padding: 10px;
  }

  .main-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }

  .table-panel .table-surface {
    min-height: 260px;
  }
}

@media (max-width: 640px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .player-row.bottom .hand {
    flex-wrap: wrap;
  }

  .card-chip {
    width: 48px;
    height: 68px;
  }

  .card-slot {
    width: 56px;
    height: 80px;
  }
}

