:root {
  --felt: #14532d;
  --felt-2: #166534;
  --felt-3: #1d7a42;
  --ink: #1f2328;
  --paper: #fffdf7;
  --text: #f4f7f2;
  --muted: #b7d3c0;
  --gold: #f5c542;
  --danger: #e03131;
  --radius: 10px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--felt);
  color: var(--text);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100%;
}

button {
  font: inherit;
  border: 0;
  border-radius: var(--radius);
  padding: 12px 16px;
  background: var(--gold);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}
button.secondary { background: rgba(255,255,255,.14); color: var(--text); }
button.danger { background: var(--danger); color: #fff; }
button:disabled { opacity: .45; }
button.big { width: 100%; padding: 16px; font-size: 18px; }

input {
  font: inherit;
  width: 100%;
  padding: 14px;
  border-radius: var(--radius);
  border: 0;
  background: var(--paper);
  color: var(--ink);
  font-size: 18px;
}

/* ---------- home & lobby ---------- */
.home, .lobby {
  max-width: 420px;
  margin: 0 auto;
  padding: 32px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.home h1, .lobby h1 { margin: 0; font-size: 34px; text-align: center; }
.home .sub { margin: 0 0 12px; text-align: center; color: var(--muted); }
.home label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.or { text-align: center; color: var(--muted); margin-top: 10px; }
.join-row { display: flex; gap: 8px; }
.join-row input { text-transform: uppercase; letter-spacing: 6px; text-align: center; font-weight: 700; }
.join-row button { flex: 0 0 auto; }

.code {
  text-align: center;
  font-size: 56px;
  font-weight: 800;
  letter-spacing: 10px;
  background: rgba(0,0,0,.2);
  border-radius: var(--radius);
  padding: 10px;
}
.lobby .hint { text-align: center; color: var(--muted); margin: 0; }
.plist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.plist li { background: rgba(255,255,255,.08); border-radius: var(--radius); padding: 12px 14px; font-weight: 600; }

/* ---------- game layout ---------- */
.game { display: flex; flex-direction: column; min-height: 100dvh; padding-bottom: 210px; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: var(--felt-2);
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
  font-size: 14px;
}
.topbar .turn { flex: 1; font-weight: 700; font-size: 15px; }
.topbar button { padding: 6px 10px; font-size: 13px; }

.section { padding: 10px 16px 0; }
.section h2 { margin: 6px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }

.opp {
  background: rgba(0,0,0,.18);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 2px solid transparent;
}
.opp.active { border-color: var(--gold); }
.opp-head { display: flex; gap: 10px; align-items: center; font-size: 14px; }
.opp-head b { flex: 1; font-size: 16px; }
.offline { color: #ffb4b4; font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.chip {
  font-size: 12px; font-weight: 700; color: #fff;
  padding: 2px 8px; border-radius: 99px;
  text-shadow: 0 1px 1px rgba(0,0,0,.4);
}
.chip.full { outline: 2px solid var(--gold); }

.banner {
  margin: 10px 16px 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: rgba(245,197,66,.18);
  border: 1px solid rgba(245,197,66,.5);
  font-size: 14px;
}

.groups { display: flex; flex-wrap: wrap; gap: 8px; }
.group {
  background: rgba(0,0,0,.18);
  border-radius: var(--radius);
  padding: 6px;
  border-top: 5px solid var(--c);
}
.group.full { box-shadow: 0 0 0 2px var(--gold); }
.group .gh { font-size: 11px; font-weight: 700; margin-bottom: 4px; white-space: nowrap; }
.group .gcards { display: flex; gap: 3px; }
.empty { color: var(--muted); font-size: 14px; }

.bankrow { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.bankrow .total { font-weight: 800; margin-right: 6px; color: var(--gold); }
.coin {
  font-size: 12px; font-weight: 700; padding: 3px 7px; border-radius: 6px;
  background: #d8f0d2; color: #1b4d1b;
}

/* ---------- hand dock ---------- */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  background: var(--felt-2);
  box-shadow: 0 -3px 10px rgba(0,0,0,.3);
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
}
.dock .status { display: flex; align-items: center; gap: 10px; padding: 0 16px 8px; font-size: 14px; }
.dock .status span { flex: 1; font-weight: 700; }
.dock .status button { padding: 8px 14px; }
.hand { display: flex; gap: 8px; overflow-x: auto; padding: 4px 16px 6px; scroll-snap-type: x proximity; }
.hand .card { flex: 0 0 auto; scroll-snap-align: start; }

/* ---------- cards ---------- */
.card {
  position: relative;
  width: 84px; height: 118px;
  background: var(--paper);
  color: var(--ink);
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,.35);
  overflow: hidden;
  display: flex; flex-direction: column;
  font-size: 11px;
  cursor: pointer;
  user-select: none;
}
.card .band {
  min-height: 34px;
  padding: 4px 5px;
  color: #fff;
  font-weight: 800;
  font-size: 11px;
  line-height: 1.1;
  text-shadow: 0 1px 2px rgba(0,0,0,.5);
  display: flex; align-items: flex-end;
}
.card .body { flex: 1; padding: 4px 5px; display: flex; flex-direction: column; gap: 2px; }
.card .title { font-weight: 800; font-size: 12px; line-height: 1.1; }
.card .text { font-size: 9.5px; color: #555; line-height: 1.15; }
.card .val {
  position: absolute; right: 4px; bottom: 4px;
  font-weight: 800; font-size: 11px;
  background: #e8f5e3; color: #1b4d1b; border-radius: 99px; padding: 1px 5px;
}
.card .rentlist { font-size: 9px; color: #444; }
.card.k-money { background: #e2f3dc; }
.card.k-money .big { font-size: 26px; font-weight: 900; color: #1b4d1b; margin: auto; }
.card.k-action .band { background: #3b2f6b; }
.card.k-rent .band { background: #444; }
.card.sel { outline: 3px solid var(--gold); transform: translateY(-4px); }

.card.mini { width: 44px; height: 60px; font-size: 8px; }
.card.mini .band { min-height: 0; flex: 1; font-size: 8px; padding: 3px; align-items: flex-start; }
.card.mini .body { display: none; }
.card.mini .val { font-size: 8px; padding: 0 3px; right: 2px; bottom: 2px; }

.card.large { width: 150px; height: 210px; font-size: 14px; }
.card.large .band { min-height: 60px; font-size: 16px; padding: 8px; }
.card.large .title { font-size: 17px; }
.card.large .text { font-size: 13px; }
.card.large .rentlist { font-size: 12px; }
.card.large .val { font-size: 15px; padding: 2px 8px; }
.card.large.k-money .big { font-size: 48px; }

/* ---------- sheets / modals ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(0,0,0,.55);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 520px; max-height: 88dvh; overflow-y: auto;
  background: #0f3d22;
  border-radius: 16px 16px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px;
}
.sheet h3 { margin: 0; font-size: 20px; }
.sheet p { margin: 0; color: var(--muted); }
.sheet .center { display: flex; justify-content: center; }
.sheet .opts { display: flex; flex-direction: column; gap: 8px; }
.sheet .opts button { text-align: left; }
.sheet .pick { display: flex; flex-wrap: wrap; gap: 6px; }
.sheet .who { font-weight: 700; margin-top: 6px; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 6px; }

.log { font-size: 14px; display: flex; flex-direction: column; gap: 6px; }
.log div { border-bottom: 1px solid rgba(255,255,255,.08); padding-bottom: 6px; }

.winner { text-align: center; font-size: 28px; font-weight: 800; }

#toast {
  position: fixed; left: 16px; right: 16px; top: 16px; z-index: 50;
  background: #2b2b2b; color: #fff; padding: 12px 14px; border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,.4); text-align: center; font-weight: 600;
}
.card.mini.k-money .body { display: flex; padding: 2px; }
.card.mini.k-money .big { font-size: 12px; }
