:root {
  --felt: #1d6b45;
  --felt-deep: #11482d;
  --wood: #3a2416;
  --wood-light: #6b4630;
  --gold: #e6c36a;
  --ink: #1c1915;
  --paper: #f7f1e4;
  --red: #c0392b;
  --muted: #d5e6da;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow-x: hidden;
  background: var(--wood);
  color: var(--paper);
  font-family: "Segoe UI", "PT Sans", sans-serif;
  -webkit-text-size-adjust: 100%;
}

button, input { font: inherit; }

#app { min-height: 100%; }

.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.wrap { width: 100%; max-width: 480px; margin: 0 auto; }

.lobby, .wait {
  padding: 16px 14px calc(20px + env(safe-area-inset-bottom));
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(230, 195, 106, 0.18), transparent 50%),
    linear-gradient(180deg, #245c3c, var(--felt-deep) 40%, #10281c);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 22px;
}

.brand-logo {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  object-fit: cover;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
  flex: 0 0 auto;
}

.mark {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  object-fit: cover;
}

h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(32px, 9vw, 40px);
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.02em;
}

.sub { margin: 4px 0 0; color: var(--gold); font-size: 14px; overflow-wrap: anywhere; }

.lead {
  margin: 0 0 18px;
  line-height: 1.45;
  max-width: 36rem;
}

label { display: block; font-size: 13px; margin-bottom: 6px; color: var(--muted); }

input[type="text"] {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.22);
  color: white;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 16px;
}

.stack { display: flex; flex-direction: column; gap: 10px; }

.btn {
  border: 0;
  border-radius: 14px;
  padding: 14px 16px;
  background: var(--gold);
  color: #2a2112;
  font-weight: 700;
  cursor: pointer;
}

.btn.ghost {
  background: transparent;
  color: var(--paper);
  border: 1px solid rgba(255, 255, 255, 0.28);
}

.btn:disabled { opacity: 0.45; cursor: default; }

.row { display: flex; gap: 8px; align-items: center; }
.row .btn { flex: 1; }
.row input { flex: 1; width: auto; margin: 0; }

.note { margin-top: 18px; font-size: 13px; color: var(--muted); line-height: 1.4; }

.toast {
  margin-top: 12px;
  background: rgba(192, 57, 43, 0.9);
  color: white;
  border-radius: 10px;
  padding: 10px 12px;
}

.code-hero {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(40px, 16vw, 64px);
  letter-spacing: 0.12em;
  margin: 12px 0;
  overflow-wrap: anywhere;
}

.table-screen {
  min-height: 100dvh;
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.08), transparent 36%),
    linear-gradient(180deg, #278255, var(--felt) 30%, var(--felt-deep));
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
}

.play-screen {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-bottom: 0;
}

.table-main {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
}

.table-dock {
  flex: 0 0 auto;
  padding-bottom: calc(6px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(17, 72, 45, 0), rgba(10, 36, 22, 0.92) 28%);
}

.topbar, .statusline, .deckline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar strong { font-family: Georgia, serif; font-size: 22px; }
.brand-inline { display: flex; align-items: center; gap: 8px; }
.quiet { color: var(--muted); font-size: 13px; }

.linkish {
  background: transparent;
  color: var(--gold);
  border: 0;
  padding: 6px;
  cursor: pointer;
}

.opponent {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  margin-top: 6px;
}

.backs { display: flex; }

.back {
  width: 36px;
  height: 50px;
  margin-right: -18px;
  border-radius: 5px;
  background:
    repeating-linear-gradient(135deg, #7d1d2e 0 6px, #f0d48a 6px 8px);
  border: 1px solid #f0d48a;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}

.deckline { margin: 8px 0; min-height: 78px; }

.deck-wrap { display: flex; align-items: center; gap: 8px; }

.deck {
  width: 52px;
  height: 74px;
  border-radius: 7px;
  background: #6e1c2b;
  border: 1px solid var(--gold);
  color: var(--gold);
  display: grid;
  place-items: center;
  font-weight: 700;
}

.trump-slot .card { transform: rotate(-8deg); }

.table-zone {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-content: center;
  justify-content: center;
  min-height: 120px;
  padding: 8px 0 12px;
}

.pair { position: relative; width: 64px; height: 96px; }

.pair .card { width: 52px; height: 74px; margin: 0; }

.pair .card.defense {
  position: absolute;
  left: 12px;
  top: 12px;
}

.hint {
  text-align: center;
  font-size: 15px;
  margin: 4px 0 8px;
  min-height: 1.3em;
}

.actions { display: flex; gap: 8px; justify-content: center; margin-bottom: 4px; }
.actions .btn { flex: 1; min-width: 0; max-width: 180px; }

.hand {
  display: flex;
  justify-content: safe center;
  align-items: flex-end;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding: 10px 4px 8px;
  scroll-snap-type: x proximity;
}

.hand .card {
  scroll-snap-align: center;
  flex: 0 0 auto;
  width: 58px;
  height: 82px;
  margin-left: -20px;
}

.hand .card:first-child { margin-left: 0; }

.card {
  width: 58px;
  height: 82px;
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.22);
  position: relative;
  padding: 4px 6px;
  text-align: left;
  cursor: pointer;
}

.card.red { color: var(--red); }
.card.dim { filter: saturate(0.7) brightness(0.92); cursor: default; }
.card.playable { outline: 2px solid var(--gold); transform: translateY(-6px); }
.card.static { cursor: default; }

.corner { display: flex; flex-direction: column; font-weight: 800; line-height: 1; font-size: 16px; }
.corner i { font-style: normal; font-size: 14px; }
.pip {
  position: absolute;
  right: 8px;
  bottom: 6px;
  font-size: 28px;
  line-height: 1;
}

.result {
  margin: 8px auto 10px;
  max-width: 420px;
  background: rgba(16, 28, 20, 0.88);
  border: 1px solid var(--gold);
  border-radius: 16px;
  padding: 14px;
  text-align: center;
}

.result p { margin: 0 0 10px; font-size: 18px; }
.result .row { flex-wrap: wrap; }
.result .row .btn { flex: 1 1 120px; }

.rules {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.rules article {
  background: #143226;
  color: var(--paper);
  width: min(560px, 100%);
  border-radius: 18px 18px 0 0;
  padding: 18px 18px 28px;
  max-height: 80dvh;
  overflow: auto;
}

.rules h2 { font-family: Georgia, serif; margin: 0 0 8px; }
.rules ul { margin: 0 0 12px; padding-left: 18px; line-height: 1.45; }

.games { display: flex; flex-direction: column; gap: 10px; }

.game-card {
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.22);
  color: white;
  border-radius: 16px;
  padding: 14px 16px;
  cursor: pointer;
}

.game-card b { display: block; font-family: Georgia, serif; font-size: 22px; }
.game-card span { color: var(--gold); font-size: 14px; }

.ad-carousel { margin-top: 16px; }
.ad-viewport { overflow: hidden; border-radius: 16px; }
.ad-track { display: flex; transition: transform 0.45s ease; }
.ad-dots { display: flex; justify-content: center; gap: 8px; margin-top: 8px; }
.ad-dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
}
.ad-dot.on { background: var(--gold); }

.ad {
  display: flex;
  flex: 0 0 100%;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  box-sizing: border-box;
  min-height: 148px;
  padding: 12px;
  border-radius: 16px;
  background: #0f172a;
  border: 1px solid rgba(0, 180, 255, 0.4);
  color: #e8eef7;
}

.ad-main { display: flex; gap: 10px; align-items: center; min-width: 0; }

.ad-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: white;
  background: linear-gradient(135deg, #00b4ff, #ff6b00);
}

.ad-z3 { border-color: rgba(245, 197, 66, 0.55); }
.ad-z3 .ad-mark { background: linear-gradient(135deg, #f5c542, #e07a1a); color: #1a1204; }
.ad-azs { border-color: rgba(46, 160, 90, 0.55); }
.ad-azs .ad-mark { background: linear-gradient(135deg, #1f8f4e, #0d3b24); font-size: 13px; }
.ad-copy { flex: 1; min-width: 0; }
.ad-copy strong { display: block; font-size: 15px; line-height: 1.25; }
.ad .quiet { color: #9fb0c3; font-size: 12px; line-height: 1.35; }
.ad-actions { display: flex; gap: 8px; }
.ad-btn { flex: 1; padding: 10px 8px; border-radius: 12px; text-decoration: none; text-align: center; }

.back.big { width: 68px; height: 96px; margin: 0; }

.mem-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.mem-grid .card,
.mem-grid .back {
  width: 100%;
  height: auto;
  aspect-ratio: 5 / 7;
  margin: 0;
  padding: 3px;
}

.scoreline { display: flex; justify-content: space-between; margin: 8px 0; }

@media (min-width: 800px) {
  .lobby, .wait { padding-top: 64px; align-items: center; }
  .brand-logo { width: 76px; height: 76px; }
  .table-screen { padding: 18px 28px 12px; }
  .card { width: 78px; height: 110px; }
  .hand .card { width: 78px; height: 110px; margin-left: -28px; }
  .pair { width: 96px; height: 128px; }
  .pair .card { width: 72px; height: 102px; }
}
