/* ============================================================================
   5er Watten — Wirtshaus-Stil
   ========================================================================= */
:root {
  --bg: #1f3a2c;
  --table: #2e5a3f;
  --table-edge: #1a3527;
  --gold: #d4a64c;
  --gold-dim: #a8822f;
  --cream: #f4ecd6;
  --cream-dim: #c9bfa3;
  --red: #b04a3a;
  --black: #1a1a1a;
  --shadow: rgba(0, 0, 0, 0.45);
  --accent: #f0c869;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: "Georgia", "Cambria", serif;
  background:
    radial-gradient(ellipse at center, var(--table) 0%, var(--table-edge) 75%, var(--bg) 100%);
  color: var(--cream);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  padding: 24px;
}

.screen.active {
  display: flex;
}

h1, h2, h3, h4 {
  font-family: "Palatino Linotype", "Book Antiqua", serif;
  color: var(--gold);
  margin: 0 0 12px;
  letter-spacing: 0.04em;
}

h1 {
  font-size: 3rem;
  text-align: center;
  text-shadow: 0 2px 4px var(--shadow);
}

.subtitle {
  text-align: center;
  color: var(--cream-dim);
  margin-bottom: 32px;
  font-style: italic;
}

/* ─── Formulare ─────────────────────────────────────────────────────────── */
.card-form {
  max-width: 360px;
  margin: 0 auto;
  background: rgba(0, 0, 0, 0.25);
  padding: 24px;
  border-radius: 8px;
  border: 1px solid var(--gold-dim);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9rem;
  color: var(--cream-dim);
}

input {
  background: var(--cream);
  color: var(--black);
  border: 1px solid var(--gold-dim);
  border-radius: 4px;
  padding: 10px;
  font-size: 1rem;
  font-family: inherit;
  text-transform: none;
}

#input-code {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  text-align: center;
  font-weight: bold;
}

button {
  background: var(--gold);
  color: var(--black);
  border: none;
  border-radius: 4px;
  padding: 12px 16px;
  font-size: 1rem;
  font-family: inherit;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}

button:hover:not(:disabled) {
  background: var(--accent);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  background: var(--cream-dim);
  color: #555;
  cursor: not-allowed;
}

button.ghost {
  background: transparent;
  color: var(--cream-dim);
  border: 1px solid var(--cream-dim);
}

button.small {
  padding: 4px 10px;
  font-size: 0.85rem;
}

.divider {
  text-align: center;
  color: var(--cream-dim);
  font-style: italic;
  margin: 8px 0;
}

.error {
  color: var(--red);
  text-align: center;
  margin-top: 12px;
  min-height: 1.2em;
  font-weight: bold;
}

.hint {
  color: var(--cream-dim);
  text-align: center;
  font-style: italic;
}

/* ─── Lobby ─────────────────────────────────────────────────────────────── */
.lobby-code {
  text-align: center;
  font-size: 1.5rem;
  margin: 16px 0;
}

.lobby-code strong {
  color: var(--gold);
  font-size: 2rem;
  letter-spacing: 0.3em;
  margin-left: 8px;
}

.player-list {
  list-style: none;
  padding: 0;
  max-width: 360px;
  margin: 16px auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-list li {
  background: rgba(0, 0, 0, 0.25);
  padding: 10px 16px;
  border-radius: 4px;
  border-left: 4px solid var(--gold-dim);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.player-list li.host {
  border-left-color: var(--gold);
}

.player-list li .badges {
  display: flex;
  gap: 6px;
}

#screen-lobby button {
  max-width: 360px;
  margin: 8px auto;
}

/* ─── Spieltisch ────────────────────────────────────────────────────────── */
#screen-game {
  padding: 12px;
  height: 100vh;
  overflow: hidden;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 8px;
}

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

.badge {
  background: rgba(0, 0, 0, 0.4);
  color: var(--cream);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.85rem;
  border: 1px solid var(--gold-dim);
}

.badge.gold {
  background: var(--gold);
  color: var(--black);
}

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

.totals .total-chip {
  background: rgba(0, 0, 0, 0.4);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.85rem;
  border: 1px solid var(--gold-dim);
  display: flex;
  gap: 6px;
  align-items: center;
}

.totals .total-chip strong {
  color: var(--gold);
}

.totals .total-chip.dealer {
  border-color: var(--gold);
  box-shadow: 0 0 6px rgba(212, 166, 76, 0.5);
}

.totals .total-chip.partner {
  background: rgba(212, 166, 76, 0.2);
}

.totals .total-chip.offline {
  opacity: 0.4;
  text-decoration: line-through;
}

.totals .total-chip.turn::before {
  content: "▶";
  color: var(--accent);
}

/* ─── Tisch ─────────────────────────────────────────────────────────────── */
.table {
  flex: 1;
  position: relative;
  border-radius: 50%/8%;
  background:
    radial-gradient(ellipse at center, #3a6e4f 0%, var(--table) 60%, var(--table-edge) 100%);
  border: 6px solid var(--gold-dim);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.5), 0 6px 16px var(--shadow);
  margin: 8px 0;
  overflow: hidden;
  min-height: 320px;
}

.seats {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.seat {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: auto;
  transform: translate(-50%, -50%);
}

.seat .seat-name {
  background: rgba(0, 0, 0, 0.55);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.85rem;
  border: 1px solid var(--gold-dim);
  white-space: nowrap;
}

.seat.turn .seat-name {
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}

.seat.dealer .seat-name::after {
  content: " 🎴";
}

.seat.partner .seat-name {
  background: rgba(212, 166, 76, 0.35);
}

.seat.offline .seat-name {
  opacity: 0.4;
}

.seat .opponent-cards {
  display: flex;
  gap: -16px;
}

.seat .mini-card {
  width: 28px;
  height: 40px;
  background: linear-gradient(135deg, #6b1a1a, #3a0a0a);
  border: 1px solid var(--gold);
  border-radius: 3px;
  margin-left: -14px;
  box-shadow: 0 1px 3px var(--shadow);
}

.seat .mini-card:first-child {
  margin-left: 0;
}

.trick-area {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 80%;
  max-width: 480px;
}

.trick {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
  min-height: 120px;
  align-items: center;
}

.trick .trick-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.trick .trick-card .order-num {
  position: absolute;
  top: -10px;
  left: -10px;
  background: var(--gold);
  color: var(--black);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: bold;
  z-index: 2;
}

.trick .trick-card .player-tag {
  font-size: 0.7rem;
  color: var(--cream-dim);
  margin-top: 4px;
  white-space: nowrap;
}

.trick-info {
  text-align: center;
  color: var(--cream-dim);
  font-style: italic;
  font-size: 0.9rem;
  min-height: 1.2em;
}

.last-trick-banner {
  background: rgba(212, 166, 76, 0.9);
  color: var(--black);
  padding: 8px 16px;
  border-radius: 4px;
  font-weight: bold;
  text-align: center;
  position: absolute;
  top: -50px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  animation: pop 0.3s ease;
}

@keyframes pop {
  from { transform: translate(-50%, -10px) scale(0.8); opacity: 0; }
  to { transform: translate(-50%, 0) scale(1); opacity: 1; }
}

/* ─── Karten ────────────────────────────────────────────────────────────── */
.card {
  width: 64px;
  height: 92px;
  background: var(--cream);
  color: var(--black);
  border-radius: 5px;
  border: 1px solid var(--gold-dim);
  box-shadow: 0 2px 6px var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 4px;
  font-size: 0.9rem;
  position: relative;
  transition: transform 0.15s, box-shadow 0.15s;
}

.card.large {
  width: 76px;
  height: 108px;
  font-size: 1rem;
}

.card .corner {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-weight: bold;
  line-height: 1;
}

.card .corner.tr {
  align-self: flex-end;
  transform: rotate(180deg);
}

.card .center {
  text-align: center;
  font-size: 1.6rem;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card.suit-herz, .card.suit-schell {
  color: var(--red);
}

.card.welli {
  background: linear-gradient(135deg, #f7e5a8, #d4a64c);
  color: var(--black);
}

.card.welli .center {
  font-size: 1.4rem;
}

.hand-card {
  cursor: pointer;
  margin-left: -20px;
}

.hand-card:first-child {
  margin-left: 0;
}

.hand-card:hover {
  transform: translateY(-12px);
  box-shadow: 0 6px 12px var(--shadow);
  z-index: 10;
}

.hand-card.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.hand-card.disabled:hover {
  transform: none;
  box-shadow: 0 2px 6px var(--shadow);
}

.hand-card.face-down {
  background: linear-gradient(135deg, #6b1a1a, #3a0a0a);
  border-color: var(--gold);
  cursor: default;
}

.hand-card.face-down:hover {
  transform: none;
}

/* ─── Hand-Area ─────────────────────────────────────────────────────────── */
.hand-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px 0 8px;
}

.hand {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 110px;
  padding-left: 20px;
}

.action-area {
  min-height: 48px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.action-area .info {
  color: var(--cream-dim);
  font-style: italic;
  text-align: center;
}

.action-area .info.highlight {
  color: var(--accent);
  font-weight: bold;
  font-style: normal;
}

/* ─── Modal ─────────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

.modal-card {
  background: var(--bg);
  border: 2px solid var(--gold);
  border-radius: 8px;
  padding: 24px;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.ansage-section {
  margin-bottom: 16px;
}

.ansage-section h4 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.suit-row, .rank-row, .tricks-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.suit-btn, .rank-btn, .trick-btn {
  background: rgba(0, 0, 0, 0.3);
  color: var(--cream);
  border: 1px solid var(--gold-dim);
  padding: 8px 12px;
  font-size: 0.9rem;
}

.suit-btn.selected, .rank-btn.selected, .trick-btn.selected {
  background: var(--gold);
  color: var(--black);
  border-color: var(--gold);
}

.rank-btn.welli {
  background: linear-gradient(135deg, #f7e5a8, #d4a64c);
  color: var(--black);
  border-color: var(--gold);
}

.ansage-summary {
  background: rgba(0, 0, 0, 0.3);
  padding: 12px;
  border-radius: 4px;
  margin: 16px 0;
  text-align: center;
  font-size: 1rem;
  border: 1px solid var(--gold-dim);
}

.ansage-summary.empty {
  color: var(--cream-dim);
  font-style: italic;
}

/* ─── Round End / Game End Overlay ─────────────────────────────────────── */
.overlay-card {
  background: rgba(0, 0, 0, 0.55);
  border: 2px solid var(--gold);
  border-radius: 8px;
  padding: 16px 24px;
  margin-top: 12px;
  max-width: 600px;
  width: 100%;
}

.overlay-card h3 {
  text-align: center;
  margin-bottom: 12px;
}

.score-table {
  width: 100%;
  border-collapse: collapse;
}

.score-table td, .score-table th {
  padding: 4px 8px;
  border-bottom: 1px solid var(--gold-dim);
  text-align: left;
}

.score-table td.num {
  text-align: right;
  font-weight: bold;
  color: var(--gold);
}

.score-table tr.winner td {
  color: var(--accent);
  font-weight: bold;
}

/* ─── Mode-Picker (Home-Screen) ────────────────────────────────────────── */
.mode-picker h4 {
  margin: 8px 0 6px;
  font-size: 0.95rem;
}

.mode-row {
  display: flex;
  gap: 8px;
}

.mode-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  background: rgba(0, 0, 0, 0.3);
  color: var(--cream);
  border: 1px solid var(--gold-dim);
  padding: 10px 12px;
  font-size: 0.95rem;
  text-align: left;
}

.mode-btn small {
  font-size: 0.75rem;
  color: var(--cream-dim);
  font-weight: normal;
}

.mode-btn.selected {
  background: var(--gold);
  color: var(--black);
  border-color: var(--gold);
}

.mode-btn.selected small {
  color: rgba(0, 0, 0, 0.7);
}

.watten4-options {
  background: rgba(0, 0, 0, 0.2);
  padding: 12px;
  border-radius: 4px;
  border: 1px dashed var(--gold-dim);
}

.watten4-options input[type="range"] {
  width: 100%;
  accent-color: var(--gold);
}

.bidcap-row {
  display: flex;
  gap: 6px;
}

.bidcap-btn {
  flex: 1;
  background: rgba(0, 0, 0, 0.3);
  color: var(--cream);
  border: 1px solid var(--gold-dim);
  padding: 8px 12px;
  font-size: 0.9rem;
}

.bidcap-btn.selected {
  background: var(--gold);
  color: var(--black);
  border-color: var(--gold);
}

/* ─── Team-Färbung (4er) ───────────────────────────────────────────────── */
:root {
  --team-0: #d4a64c;        /* Gold-ish */
  --team-0-soft: rgba(212, 166, 76, 0.25);
  --team-1: #5cb3a8;        /* Teal */
  --team-1-soft: rgba(92, 179, 168, 0.25);
}

.team-chip {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 6px;
}

.team-chip.team-0 { background: var(--team-0); }
.team-chip.team-1 { background: var(--team-1); }

.seat.team-0 .seat-name { border-color: var(--team-0); }
.seat.team-1 .seat-name { border-color: var(--team-1); }
.seat.my-team .seat-name { box-shadow: 0 0 8px rgba(255, 255, 255, 0.2); }

.total-chip.team-0 { border-left: 4px solid var(--team-0); }
.total-chip.team-1 { border-left: 4px solid var(--team-1); }

.team-total {
  background: rgba(0, 0, 0, 0.4);
  padding: 6px 14px;
  border-radius: 4px;
  border: 2px solid;
  font-size: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 80px;
}

.team-total.team-0 { border-color: var(--team-0); }
.team-total.team-1 { border-color: var(--team-1); }
.team-total.my-team {
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.15);
}
.team-total .label {
  font-size: 0.7rem;
  color: var(--cream-dim);
}
.team-total .value {
  font-weight: bold;
  font-size: 1.3rem;
  color: var(--gold);
}
.team-total.striche::after {
  content: "gestrichen";
  font-size: 0.7rem;
  color: var(--red);
  font-style: italic;
}

/* ─── Bid-Banner ───────────────────────────────────────────────────────── */
.bid-banner {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  background: var(--bg);
  border: 2px solid var(--gold);
  border-radius: 8px;
  padding: 16px 24px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
  animation: bid-slide-down 0.25s ease-out;
}

@keyframes bid-slide-down {
  from { top: 0; opacity: 0; }
  to { top: 80px; opacity: 1; }
}

.bid-banner.hidden {
  display: none;
}

.bid-banner-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 280px;
}

.bid-banner-content strong {
  font-size: 1.1rem;
  color: var(--gold);
  text-align: center;
}

.bid-response-buttons {
  display: flex;
  gap: 12px;
}

.bid-response-buttons.hidden {
  display: none;
}

button.gold-strong {
  background: var(--accent);
  color: var(--black);
  font-weight: bold;
}

button.ghost-strong {
  background: rgba(176, 74, 58, 0.85);
  color: var(--cream);
  border: 1px solid var(--red);
}

/* ─── Vergangene Stiche (4er, alle 5 Stiche bleiben sichtbar) ─────────── */
.past-tricks {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  pointer-events: none;
}

.past-trick-pile {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--gold-dim);
  border-radius: 4px;
  padding: 3px 6px;
  display: flex;
  gap: 2px;
  align-items: center;
}

.past-trick-pile .pile-cards {
  display: flex;
}

.past-trick-pile .pile-mini {
  width: 22px;
  height: 30px;
  background: var(--cream);
  border-radius: 2px;
  margin-left: -12px;
  border: 1px solid var(--gold-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: bold;
}

.past-trick-pile .pile-mini:first-child {
  margin-left: 0;
}

.past-trick-pile .pile-mini.suit-herz,
.past-trick-pile .pile-mini.suit-schell {
  color: var(--red);
}

.past-trick-pile .pile-mini.welli {
  background: linear-gradient(135deg, #f7e5a8, #d4a64c);
}

.past-trick-pile .pile-winner {
  font-size: 0.65rem;
  color: var(--cream-dim);
  margin-left: 4px;
}

/* ─── Trump-Reveal-Modal ──────────────────────────────────────────────── */
.reveal-cards {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin: 20px 0;
  flex-wrap: wrap;
}

.reveal-card-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.reveal-card-slot .label {
  font-size: 0.85rem;
  color: var(--cream-dim);
}

.reveal-card-slot .label.suit {
  color: var(--gold);
  font-weight: bold;
}

.reveal-card-slot.hidden-card .card {
  background: linear-gradient(135deg, #6b1a1a, #3a0a0a);
  border-color: var(--gold);
}

/* ─── Blind-Indikator ─────────────────────────────────────────────────── */
.badge.blind {
  background: rgba(176, 74, 58, 0.3);
  border-color: var(--red);
  color: var(--cream);
  font-style: italic;
}

.seat.blind .seat-name::before {
  content: "👁️‍🗨️ ";
}

/* ─── Trick-Zoom-Modal ─────────────────────────────────────────────────── */
.trick-zoom-content {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  margin: 20px 0;
}

.trick-zoom-content .trick-card {
  flex: 0 0 auto;
}

.trick-zoom-content .trick-card.winner-card {
  outline: 3px solid var(--accent);
  border-radius: 8px;
  padding: 4px;
}

.past-trick-pile {
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  pointer-events: auto;
}

.past-trick-pile:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

.past-trick-pile.team-winner-0 { border-left: 3px solid var(--team-0); }
.past-trick-pile.team-winner-1 { border-left: 3px solid var(--team-1); }

/* ─── Lobby Reorder ────────────────────────────────────────────────────── */
.player-list li .reorder-arrows {
  display: flex;
  flex-direction: column;
  margin-left: 8px;
  gap: 1px;
}

.player-list li .reorder-arrows button {
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--gold-dim);
  padding: 1px 6px;
  font-size: 0.7rem;
  cursor: pointer;
  line-height: 1;
}

.player-list li .reorder-arrows button:hover {
  background: rgba(212, 166, 76, 0.2);
}

.player-list li .reorder-arrows button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ─── Negotiation-Card ─────────────────────────────────────────────────── */
.negotiation-panel {
  background: rgba(0, 0, 0, 0.4);
  border: 2px solid var(--gold);
  border-radius: 8px;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 480px;
  margin: 0 auto;
}

.negotiation-panel h4 {
  text-align: center;
  margin: 0;
  font-size: 1rem;
}

.negotiation-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.negotiation-buttons button {
  flex: 1;
  min-width: 100px;
  font-size: 0.95rem;
  padding: 8px 12px;
}

.negotiation-panel .talon-info {
  font-size: 0.8rem;
  color: var(--cream-dim);
  text-align: center;
  font-style: italic;
}

.outcome-banner {
  background: var(--gold);
  color: var(--black);
  padding: 4px 12px;
  border-radius: 12px;
  font-weight: bold;
  font-size: 0.85rem;
  display: inline-block;
}

/* ─── Responsiv ────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  h1 { font-size: 2rem; }
  .card { width: 52px; height: 76px; font-size: 0.8rem; }
  .card .center { font-size: 1.3rem; }
  .hand-card { margin-left: -28px; }
  .table { min-height: 280px; }
  .seat .seat-name { font-size: 0.75rem; padding: 3px 8px; }
}
