:root {
  --felt: #0f5132;
  --felt-dark: #0a3a24;
  --ink: #f4f1e8;
  --muted: #b9c8bd;
  --card: #fffdf7;
  --card-ink: #1b1b1b;
  --red: #c0262d;
  --gold: #e3b341;
  --warn-bg: #fff3cd;
  --warn-ink: #5c4400;
  --err-bg: #f8d7da;
  --err-ink: #6b1a20;
  --panel: rgba(0, 0, 0, 0.28);
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Segoe UI", "Noto Sans Hebrew", "Arial Hebrew", Arial, sans-serif;
  color: var(--ink);
  background: radial-gradient(ellipse at center, var(--felt) 0%, var(--felt-dark) 100%) fixed;
  min-height: 100vh;
}
button { font: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
[hidden] { display: none !important; }
.muted { color: var(--muted); font-size: 0.9em; }

/* Top bar */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px; padding: 10px 16px; background: rgba(0, 0, 0, 0.35);
}
.topbar h1 { margin: 0; font-size: 1.35rem; }
.suits { font-size: 1rem; letter-spacing: 4px; margin-inline-start: 8px; }
.suits b { color: #ff6b6b; font-weight: normal; }
.mode-badge {
  background: rgba(255,255,255,0.12); color: var(--ink); border-radius: 999px;
  padding: 4px 12px; font-size: 0.85rem; font-weight: 600;
}

.screen { max-width: 1000px; margin: 0 auto; padding: 16px; }
.panel { background: var(--panel); border-radius: var(--radius); padding: 16px 20px; }
.panel h2 { margin-top: 0; }

/* Setup */
fieldset { border: 1px solid rgba(255,255,255,0.2); border-radius: var(--radius); margin: 0 0 14px; padding: 10px 14px; }
legend { padding: 0 6px; font-weight: 600; }
.open-tag {
  display: inline-block; font-weight: normal; font-size: 0.8rem; background: var(--warn-bg);
  color: var(--warn-ink); border-radius: 6px; padding: 1px 8px; margin-inline-start: 6px;
}
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices button, .actions button {
  border: 2px solid rgba(255,255,255,0.5); background: transparent; color: var(--ink);
  border-radius: 8px; padding: 8px 18px; min-width: 56px;
}
.choices button.selected { background: var(--ink); color: var(--felt-dark); border-color: var(--ink); font-weight: 700; }
button.primary { background: var(--gold); color: #2a1f00; border: 2px solid var(--gold); border-radius: 8px; padding: 8px 22px; font-weight: 700; }

/* Seats */
.seats { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.seat {
  background: var(--panel); border-radius: var(--radius); padding: 8px 14px; min-width: 150px;
  border: 2px solid transparent; text-align: center;
}
.seat.active { border-color: var(--gold); }
.seat .name { font-weight: 700; }
.seat .meta { color: var(--muted); font-size: 0.85rem; }
.seat .last { margin-top: 4px; font-size: 0.85rem; min-height: 1.2em; }
.seat .last .card-txt { font-weight: 700; direction: ltr; unicode-bidi: isolate; }
.seat .last .red { color: #ff8a8a; }
.seat.just-acted { animation: flash 1s ease-out; }
@keyframes flash { from { background: rgba(227,179,65,0.45); } to { background: var(--panel); } }
.seat { min-width: 190px; }
.dealer-chip { background: var(--gold); color: #2a1f00; border-radius: 999px; padding: 0 8px; font-size: 0.75rem; margin-inline-start: 4px; }

/* Center piles */
.center { display: flex; justify-content: center; gap: 48px; margin: 22px 0 10px; }
.pile { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pile-label { font-size: 0.9rem; color: var(--muted); }
.pile-count { font-size: 0.85rem; color: var(--muted); }

/* Cards */
.card {
  position: relative; width: 66px; height: 96px; border-radius: 8px; background: var(--card);
  color: var(--card-ink); border: 1px solid #cfc8b6; box-shadow: 0 2px 4px rgba(0,0,0,0.35);
  display: inline-flex; align-items: center; justify-content: center; padding: 0; flex: none;
  direction: ltr; user-select: none;
}
.card .corner { position: absolute; top: 4px; left: 6px; font-weight: 700; font-size: 0.95rem; line-height: 1; text-align: center; }
.card .pip { font-size: 2rem; }
.card.red { color: var(--red); }
.card.joker { background: linear-gradient(135deg, #fffdf7 0%, #f4e7c2 100%); }
.card.joker .pip { font-size: 0.8rem; font-weight: 800; letter-spacing: 1px; color: #6b2fa3; text-align: center; line-height: 1.2; }
.card.back {
  background: repeating-linear-gradient(45deg, #7a1f2b 0 6px, #94303c 6px 12px);
  border: 3px solid var(--card);
}
.card.empty { background: transparent; border: 2px dashed rgba(255,255,255,0.35); box-shadow: none; }
#hand .card:disabled { opacity: 1; cursor: default; } /* your hand stays readable when it is not your move */
button.card:not(:disabled):hover { transform: translateY(-3px); }
.card.selected { transform: translateY(-12px); outline: 3px solid var(--gold); }
.card.clickable { outline: 2px solid rgba(227,179,65,0.7); }

.hand { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; min-height: 100px; padding: 10px 0; }
.hand.small .card, .zone .card { width: 52px; height: 76px; }
.hand.small .card .pip, .zone .card .pip { font-size: 1.5rem; }

.status { text-align: center; min-height: 52px; }
#status-line { font-size: 1.05rem; margin-bottom: 6px; }
.notice { display: inline-block; border-radius: 8px; padding: 8px 14px; font-size: 0.95rem; max-width: 720px; }
.notice.error { background: var(--err-bg); color: var(--err-ink); }

.hand-area { background: var(--panel); border-radius: var(--radius); padding: 10px 12px; margin-top: 8px; }
.hand-title { text-align: center; font-weight: 700; }
.hand-hint { text-align: center; font-size: 0.8rem; color: var(--muted); }

/* Drag to arrange your hand */
#hand .card { touch-action: none; -webkit-touch-callout: none; } /* only the cards; the page still scrolls elsewhere */
#hand .card.drag-placeholder { opacity: 0.3; outline: 2px dashed var(--gold); transform: none; }
.card.drag-ghost { position: fixed; z-index: 20; pointer-events: none; margin: 0; transform: rotate(-3deg) scale(1.06); box-shadow: 0 10px 22px rgba(0,0,0,0.5); }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none; }
body.is-dragging #hand .card:hover { transform: none; }
.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }

/* Declare modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 16px; z-index: 10; }
.modal-box { background: var(--felt-dark); border: 1px solid rgba(255,255,255,0.25); border-radius: var(--radius); padding: 16px; width: 100%; max-width: 820px; }
.modal-box h2 { margin-top: 0; font-size: 1.15rem; }
.zones { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.zone { border: 2px dashed rgba(255,255,255,0.35); border-radius: var(--radius); padding: 8px; min-height: 120px; cursor: pointer; }
.zone.active { border-style: solid; border-color: var(--gold); background: rgba(227,179,65,0.08); }
.zone h3 { margin: 0 0 6px; font-size: 0.95rem; }
.zone .cards { display: flex; flex-wrap: wrap; gap: 4px; }
.pool-title { margin-top: 12px; color: var(--muted); }

/* Result */
.result-row { margin: 10px 0; }
.result-row .cards { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.meld-group { display: inline-flex; gap: 3px; padding: 4px; border-radius: 8px; background: rgba(255,255,255,0.08); margin-inline-end: 8px; }
.pts { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; font-size: 0.8rem; color: var(--muted); }
.pending { background: var(--warn-bg); color: var(--warn-ink); border-radius: 6px; padding: 2px 8px; font-size: 0.9rem; }
.double { color: var(--gold); font-weight: 700; }
.score { font-weight: 700; }

@media (max-width: 560px) {
  .card { width: 50px; height: 74px; }
  .card .pip { font-size: 1.45rem; }
  .card .corner { font-size: 0.8rem; }
  .center { gap: 28px; }
  .hand.small .card, .zone .card { width: 44px; height: 64px; }
}

.hand.small .card.joker .pip, .zone .card.joker .pip { font-size: 0.6rem; letter-spacing: 0; }
