/* Euchre — dark card-table theme. External stylesheet (no inline styles, per
   the site CSP). */

:root {
  --bg: #0c1a12;
  --bg2: #0f231a;
  --panel: #14281d;
  --panel2: #1b3527;
  --ink: #eaf7ef;
  --muted: #9cc3ad;
  --felt: radial-gradient(ellipse at 50% 42%, #1c8f5f 0%, #127a4d 52%, #0a5233 100%);
  --gold: #f5d76e;
  --accent: #57d08a;
  --blue: #6fb7ff;
  --danger: #ff6b81;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0,0,0,.4);
  --us: #58c9ff;
  --them: #ff8f6b;
}

* { box-sizing: border-box; }

/* The HTML `hidden` attribute must win over the display:flex on .modal/.banner
   below — otherwise toggling `hidden` in JS never actually hides them. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: linear-gradient(160deg, #07130d, #0b1d15 60%, #0a1712);
  color: var(--ink);
  min-height: 100vh;
}

/* ---- Top bar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  background: rgba(6,14,10,.82);
  border-bottom: 1px solid rgba(255,255,255,.06);
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 1.35rem; letter-spacing: .4px; }
.brand .sub { color: var(--muted); font-size: .8rem; }
.topbar-actions { display: flex; gap: 10px; }

.btn {
  border: none; cursor: pointer; border-radius: 999px;
  padding: 9px 16px; font-weight: 700; font-size: .9rem;
  font-family: inherit; color: #08210f;
  transition: transform .08s ease, filter .15s ease;
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.07); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn.big { padding: 12px 22px; font-size: 1rem; margin-top: 14px; }
.btn.metal-green { background: linear-gradient(180deg,#67e8a6,#2fb87a); color:#06321f; }
.btn.metal { background: linear-gradient(180deg,#cfe0ff,#9fbce8); color:#0b2038; }
.btn.ghost { background: rgba(255,255,255,.1); color: var(--ink); border:1px solid rgba(255,255,255,.16); }
.btn.order { background: linear-gradient(180deg,#ffd97a,#f0b429); color:#3a2600; }
.btn.pass  { background: linear-gradient(180deg,#b9c6d6,#8ea0b6); color:#1a2432; }
.btn.alone { background: linear-gradient(180deg,#ff9db0,#ef5f78); color:#3a0010; }
.btn.suit  { background:#fff; color:#111; font-size:1.15rem; padding:9px 15px; }
.btn.suit.red { color:#d61f3a; }

/* ---- Layout ---- */
.layout {
  display: grid; grid-template-columns: 1fr 300px; gap: 16px;
  max-width: 1180px; margin: 0 auto; padding: 16px;
}
.table-wrap { display: flex; flex-direction: column; gap: 12px; }

.scorebar {
  display: flex; align-items: center; justify-content: center; gap: 18px;
  font-weight: 800; font-size: 1.05rem;
}
.score-chip { display:flex; align-items:center; gap:8px; padding:6px 14px; border-radius:999px;
  background: var(--panel2); border:1px solid rgba(255,255,255,.08); }
.score-chip .lbl { font-size:.72rem; letter-spacing:.14em; text-transform:uppercase; color:var(--muted); }
.score-chip.us  .val { color: var(--us); }
.score-chip.them .val { color: var(--them); }
.score-chip .val { font-size:1.3rem; }
.score-hand { color: var(--muted); font-size:.85rem; font-weight:600; }

/* ---- Felt table ---- */
.felt {
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: 120px / 90px;
  background: var(--felt);
  box-shadow: inset 0 0 0 8px rgba(0,0,0,.28), inset 0 0 60px rgba(0,0,0,.35), var(--shadow);
  border: 3px solid #6b4a2a;
  overflow: hidden;
}
.seat { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 6px; width: 200px; }
.seat-north { top: 10px; left: 50%; transform: translateX(-50%); }
.seat-south { bottom: 8px; left: 50%; transform: translateX(-50%); }
.seat-west  { left: 8px; top: 50%; transform: translateY(-50%); }
.seat-east  { right: 8px; top: 50%; transform: translateY(-50%); }

.nameplate {
  display:flex; align-items:center; gap:8px;
  background: rgba(6,16,11,.7); border:1px solid rgba(255,255,255,.1);
  padding: 5px 12px; border-radius: 999px; font-weight:700; font-size:.9rem;
  box-shadow: 0 3px 8px rgba(0,0,0,.35);
}
.nameplate .emoji { font-size:1.15rem; }
.nameplate.turn { outline: 2px solid var(--gold); box-shadow: 0 0 16px rgba(245,215,110,.6); }
.nameplate.us   { border-color: rgba(88,201,255,.55); }
.nameplate.them { border-color: rgba(255,143,107,.55); }
.nameplate .tag { font-size:.68rem; color: var(--bg); background: var(--gold); border-radius:6px; padding:1px 5px; font-weight:800; }
.nameplate .tag.maker { background: var(--accent); }
.seat .sub2 { font-size:.68rem; color: rgba(255,255,255,.6); }
.nameplate.sitting { opacity:.5; }

/* opponents' face-down cards */
.mini-cards { display:flex; gap:-6px; }
.mini { width: 26px; height: 36px; border-radius: 5px; margin-left:-10px;
  background: repeating-linear-gradient(45deg,#2a4a8f,#2a4a8f 5px,#22407c 5px,#22407c 10px);
  border:1px solid rgba(255,255,255,.25); box-shadow: 0 2px 4px rgba(0,0,0,.4); }
.mini:first-child { margin-left: 0; }

/* played card near a seat */
.played { margin-top: 2px; }

/* ---- Center: trump / up-card / current trick ---- */
.center {
  position:absolute; top:50%; left:50%; transform: translate(-50%,-50%);
  display:flex; flex-direction:column; align-items:center; gap:8px; text-align:center;
}
.trump-badge {
  display:flex; align-items:center; gap:8px;
  background: rgba(6,16,11,.72); border:1px solid rgba(255,255,255,.14);
  padding:6px 14px; border-radius:999px; font-weight:800;
}
.trump-badge .sym { font-size:1.4rem; }
.trump-badge .sym.red { color:#ff5566; }
.trick-cards { display:flex; gap:6px; min-height: 76px; align-items:center; }
.center .up-label { font-size:.75rem; color: rgba(255,255,255,.85); }

/* ---- Cards ---- */
.card {
  width: 52px; height: 74px; border-radius: 8px; background: #fbfdff;
  color:#1a1a1a; display:flex; flex-direction:column; justify-content:space-between;
  padding:5px 6px; font-weight:800; box-shadow: 0 3px 8px rgba(0,0,0,.45);
  border:1px solid #d7deea; position:relative; user-select:none;
}
.card.sm { width: 42px; height: 60px; font-size:.85rem; }
.card .r { font-size:1rem; line-height:1; }
.card .s { font-size:1.35rem; align-self:flex-end; line-height:1; }
.card.sm .s { font-size:1.05rem; }
.card.red { color:#d61f3a; }
.card.trump { box-shadow: 0 0 0 2px var(--gold), 0 3px 8px rgba(0,0,0,.45); }

/* Your hand */
.hand { display:flex; justify-content:center; gap:10px; min-height: 96px; flex-wrap:wrap; padding: 4px; }
.hand .card { width: 62px; height: 88px; cursor: default; transition: transform .1s ease, box-shadow .1s ease; }
.hand .card .r { font-size:1.15rem; }
.hand .card .s { font-size:1.7rem; }
.hand .card.playable { cursor: pointer; box-shadow: 0 0 0 2px var(--accent), 0 6px 14px rgba(0,0,0,.5); }
.hand .card.playable:hover { transform: translateY(-8px); }
.hand .card.dim { opacity: .45; }
.hand.discard .card { cursor: pointer; }
.hand.discard .card:hover { transform: translateY(-8px); box-shadow: 0 0 0 2px var(--danger), 0 6px 14px rgba(0,0,0,.5); }

/* ---- Action bar ---- */
.actionbar {
  min-height: 58px; display:flex; align-items:center; justify-content:center; gap:10px;
  flex-wrap:wrap; background: var(--panel); border:1px solid rgba(255,255,255,.07);
  border-radius: var(--radius); padding: 12px;
}
.actionbar .phase { color: var(--muted); font-weight:700; margin-right: 6px; }
.actionbar .msg { color: var(--gold); font-weight:800; }
.actionbar .group { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.actionbar .prompt { font-weight:700; }
.alone-check { display:flex; align-items:center; gap:6px; color:var(--ink); font-weight:700; font-size:.85rem;
  background: rgba(255,255,255,.08); padding:7px 12px; border-radius:999px; cursor:pointer; }
.alone-check input { accent-color: var(--danger); }

/* ---- Side log ---- */
.side { background: var(--panel); border:1px solid rgba(255,255,255,.07); border-radius: var(--radius);
  padding: 14px; height: fit-content; position: sticky; top: 76px; }
.side-title { margin:0 0 10px; font-size: .95rem; letter-spacing:.06em; text-transform: uppercase; color: var(--muted); }
.log { list-style: none; margin:0; padding:0; display:flex; flex-direction:column; gap:6px;
  max-height: 62vh; overflow-y:auto; font-size:.86rem; }
.log li { padding:6px 9px; background: var(--bg2); border-radius:8px; border-left:3px solid transparent; color: #d5ecdf; }
.log li.hl { border-left-color: var(--gold); color: #fff; font-weight:700; }

/* ---- Banner (hand result / game over) ---- */
.banner {
  position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap: 14px; background: rgba(4,12,8,.72); backdrop-filter: blur(3px); z-index: 15; text-align:center;
}
.banner h2 { margin:0; font-size:1.8rem; }
.banner .big-msg { font-size:1.05rem; color: var(--gold); font-weight:800; max-width: 80%; }

/* ---- Modal ---- */
.modal { position: fixed; inset:0; z-index: 50; display:flex; align-items:center; justify-content:center;
  background: rgba(2,8,5,.72); padding: 20px; }
.modal-card { background: var(--panel); border:1px solid rgba(255,255,255,.1); border-radius: 18px;
  max-width: 640px; width: 100%; max-height: 88vh; overflow-y:auto; padding: 26px 28px; position: relative;
  box-shadow: var(--shadow); }
.modal-card h2 { margin-top: 0; }
.modal-card h3 { color: var(--accent); margin: 18px 0 6px; font-size: 1.02rem; }
.modal-card p, .modal-card li { color: #d7ecdf; line-height: 1.5; }
.modal-card ul { margin: 4px 0; padding-left: 20px; }
.modal-card .tip { background: rgba(87,208,138,.12); border-left:3px solid var(--accent); padding:10px 12px; border-radius:8px; }
.rules-table { width:100%; border-collapse:collapse; margin: 6px 0; }
.rules-table td { padding:7px 10px; border-bottom:1px solid rgba(255,255,255,.08); }
.rules-table td:last-child { text-align:right; color: var(--gold); font-weight:800; white-space:nowrap; }
.modal-close { position:absolute; top:12px; right:14px; background:none; border:none; color:#cdeede;
  font-size:1.8rem; line-height:1; cursor:pointer; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; }
  .seat { width: 150px; }
  .card { width: 46px; height: 66px; }
  .hand .card { width: 54px; height: 76px; }
}

