/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --felt: #2a4a1e;
  --felt-mid: #1e3815;
  --felt-dark: #131f0d;
  --gold: #c8a84b;
  --gold-light: #e2c97a;
  --gold-dim: rgba(200,168,75,0.2);
  --ivory: #f4eed8;
  --ivory-dim: rgba(244,238,216,0.55);
  --red: #9b1c1c;
  --ink: #120d04;
  --panel: rgba(0,0,0,0.38);
  --border: rgba(200,168,75,0.18);
  --card-w: 68px;
  --card-h: 102px;
  /* variant accent — overridden per variant */
  --accent: var(--gold);
  --accent2: #4a7a9b;
}

body {
  font-family: 'EB Garamond', Georgia, serif;
  background: #0f0d07;
  color: var(--ivory);
  height: 100vh; overflow: hidden;
}
#app { width: 100vw; height: 100vh; position: relative; }
.screen { position: absolute; inset: 0; display: none; }
.screen.active { display: flex; }

/* ══ VARIANT SELECTION ══════════════════════════════════════════════════════ */

#screen-variant {
  align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 40% 30%, #1a1205 0%, #050804 100%);
}
.variant-bg {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(200,168,75,0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 50%, rgba(42,74,30,0.15) 0%, transparent 50%);
  pointer-events: none;
}
.variant-center { position: relative; z-index: 1; text-align: center; width: 100%; max-width: 820px; padding: 2rem; }

.main-logo { margin-bottom: 3rem; }
.main-logo-title {
  font-family: 'Cinzel', serif; font-size: 5rem; font-weight: 900;
  color: var(--gold); letter-spacing: 0.08em; line-height: 1;
  text-shadow: 0 0 60px rgba(200,168,75,0.25);
}
.main-logo-sub {
  font-style: italic; color: var(--ivory-dim); font-size: 1.1rem; margin-top: 0.3rem;
  letter-spacing: 0.05em;
}

.variant-cards {
  display: flex; gap: 0; align-items: center; justify-content: center; flex-wrap: wrap;
}

.variant-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 14px; padding: 2rem 2.2rem;
  width: 300px; cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, background 0.2s, box-shadow 0.2s;
  position: relative; text-align: center;
}
.variant-card:hover {
  transform: translateY(-6px);
  border-color: var(--gold);
  background: rgba(200,168,75,0.07);
  box-shadow: 0 16px 40px rgba(0,0,0,0.5), 0 0 0 1px rgba(200,168,75,0.3);
}

.vc-suits { font-size: 2rem; letter-spacing: 0.2em; margin-bottom: 0.8rem; }
.vc-name { font-family: 'Cinzel', serif; font-size: 1.2rem; color: var(--gold); margin-bottom: 0.3rem; }
.vc-desc { font-size: 0.85rem; color: var(--ivory-dim); margin-bottom: 1.2rem; font-style: italic; }
.vc-contracts { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1.2rem; }
.vc-contracts span {
  font-size: 0.82rem; color: var(--ivory-dim);
  background: rgba(255,255,255,0.04); border: 1px solid var(--border);
  border-radius: 4px; padding: 0.25rem 0.6rem;
}
.vc-badge {
  display: inline-block; font-size: 0.7rem; font-family: 'Cinzel', serif;
  background: rgba(200,168,75,0.15); color: var(--gold);
  border: 1px solid rgba(200,168,75,0.3); border-radius: 20px;
  padding: 0.2rem 0.8rem; letter-spacing: 0.08em;
}
.vc-badge.bayerisch { background: rgba(30,56,21,0.4); color: #8aba7e; border-color: rgba(100,180,80,0.3); }

.variant-divider {
  font-style: italic; color: var(--ivory-dim); opacity: 0.4;
  font-size: 0.9rem; padding: 0 2rem;
}

/* ══ LOBBY ═══════════════════════════════════════════════════════════════════ */

#screen-lobby {
  align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, #1c1208 0%, #08100a 100%);
}
.lobby-bg {
  position: absolute; inset: 0;
  background-image: repeating-linear-gradient(
    45deg, transparent, transparent 50px,
    rgba(200,168,75,0.02) 50px, rgba(200,168,75,0.02) 51px
  );
  pointer-events: none;
}
.lobby-center { position: relative; z-index: 1; text-align: center; width: 100%; max-width: 420px; padding: 2rem; }

.lobby-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.btn-back {
  background: rgba(255,255,255,0.06); border: 1px solid var(--border);
  color: var(--ivory-dim); border-radius: 6px; padding: 0.4rem 0.8rem;
  font-family: 'EB Garamond', serif; font-size: 0.85rem; cursor: pointer;
  transition: all 0.2s;
}
.btn-back:hover { background: rgba(255,255,255,0.1); color: var(--ivory); }
.lobby-variant-badge {
  font-family: 'Cinzel', serif; font-size: 0.7rem; letter-spacing: 0.08em;
  background: var(--gold-dim); color: var(--gold);
  border: 1px solid rgba(200,168,75,0.3); border-radius: 20px; padding: 0.2rem 0.9rem;
}

.logo { margin-bottom: 1.8rem; }
.logo-title { font-family: 'Cinzel', serif; font-size: 3rem; font-weight: 900; color: var(--gold); line-height: 1; }
.logo-suits { font-size: 1.6rem; letter-spacing: 0.2em; margin-top: 0.2rem; }

.lobby-card {
  background: rgba(255,255,255,0.03); border: 1px solid var(--border);
  border-radius: 10px; padding: 1.6rem; backdrop-filter: blur(8px); margin-bottom: 1rem;
}
.tab-group { display: flex; gap: 0.5rem; margin-bottom: 1.2rem; }
.tab {
  flex: 1; padding: 0.55rem; background: transparent; border: 1px solid var(--border);
  border-radius: 5px; color: var(--ivory-dim); font-family: 'EB Garamond', serif;
  font-size: 1rem; cursor: pointer; transition: all 0.2s;
}
.tab.active, .tab:hover { background: var(--gold); color: var(--ink); border-color: var(--gold); }
.tab-content { display: none; flex-direction: column; gap: 0.7rem; }
.tab-content.active { display: flex; }

.inp {
  width: 100%; padding: 0.65rem 0.9rem;
  background: rgba(255,255,255,0.05); border: 1px solid var(--border);
  border-radius: 5px; color: var(--ivory); font-family: 'EB Garamond', serif; font-size: 1.05rem;
  outline: none; transition: border-color 0.2s;
}
.inp:focus { border-color: var(--gold); }
.inp::placeholder { color: rgba(244,238,216,0.28); }
.inp-code { letter-spacing: 0.3em; text-transform: uppercase; font-weight: 600; text-align: center; }

.btn {
  padding: 0.65rem 1.4rem; border: none; border-radius: 5px;
  font-family: 'Cinzel', serif; font-size: 0.9rem; font-weight: 700;
  cursor: pointer; transition: all 0.2s;
}
.btn-primary { background: var(--gold); color: var(--ink); box-shadow: 0 3px 12px rgba(200,168,75,0.2); }
.btn-primary:hover { background: var(--gold-light); transform: translateY(-1px); }
.btn-pass { background: rgba(155,28,28,0.75); color: var(--ivory); border: 1px solid rgba(180,50,50,0.5); font-size: 0.85rem; }
.btn-pass:hover { background: #b83333; }

.error-msg { color: #e07070; font-style: italic; min-height: 1.1em; font-size: 0.88rem; margin-top: 0.25rem; }

.rules-toggle { color: var(--gold); opacity: 0.6; cursor: pointer; font-style: italic; font-size: 0.88rem; transition: opacity 0.2s; user-select: none; }
.rules-toggle:hover { opacity: 1; }
.rules-box {
  display: none; text-align: left;
  background: rgba(0,0,0,0.45); border: 1px solid var(--border);
  border-radius: 8px; padding: 1rem 1.3rem; margin-top: 0.5rem;
  font-size: 0.87rem; line-height: 1.65;
}
.rules-box h3 { font-family: 'Cinzel', serif; color: var(--gold); margin-bottom: 0.5rem; font-size: 1rem; }
.rules-box h4 { color: var(--gold-light); margin: 0.65rem 0 0.25rem; font-size: 0.87rem; }
.rules-box ul { padding-left: 1.1rem; }
.rules-box li { margin-bottom: 0.22rem; }

/* ══ WAITING ═════════════════════════════════════════════════════════════════ */

#screen-waiting {
  align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, #1e3815 0%, #080f06 100%);
}
.waiting-variant { font-family: 'Cinzel', serif; font-size: 0.75rem; color: var(--gold); opacity: 0.6; letter-spacing: 0.1em; margin-bottom: 0.5rem; }
.waiting-center { text-align: center; }
.waiting-center h2 { font-family: 'Cinzel', serif; font-size: 1.8rem; color: var(--gold); margin-bottom: 1rem; }
.room-code-display {
  font-family: 'Cinzel', serif; font-size: 2rem; color: var(--ivory);
  background: rgba(200,168,75,0.08); border: 2px solid var(--gold);
  display: inline-block; padding: 0.4rem 2rem; border-radius: 6px;
  letter-spacing: 0.35em; margin-bottom: 1.6rem;
}
.waiting-players { display: flex; gap: 0.7rem; flex-wrap: wrap; justify-content: center; margin-bottom: 1.5rem; }
.waiting-player {
  background: rgba(255,255,255,0.05); border: 1px solid var(--border);
  border-radius: 7px; padding: 0.6rem 1.2rem; font-size: 0.95rem;
}
.waiting-player.host { border-color: var(--gold); color: var(--gold); }
.waiting-hint { color: var(--ivory-dim); font-style: italic; font-size: 0.83rem; margin-top: 0.8rem; }

/* ══ GAME LAYOUT ═════════════════════════════════════════════════════════════ */

#screen-game { display: none; }
#screen-game.active { display: flex; }
.game-layout { display: grid; grid-template-columns: 185px 1fr 185px; width: 100%; height: 100%; }

/* ── Sidebars ── */
.sidebar-left, .sidebar-right {
  background: var(--panel); padding: 0.8rem;
  display: flex; flex-direction: column; gap: 0.75rem; overflow-y: auto;
}
.sidebar-left { border-right: 1px solid var(--border); }
.sidebar-right { border-left: 1px solid var(--border); }

.variant-pill {
  font-family: 'Cinzel', serif; font-size: 0.65rem; letter-spacing: 0.1em;
  color: var(--gold); background: rgba(200,168,75,0.1);
  border: 1px solid rgba(200,168,75,0.25); border-radius: 20px;
  padding: 0.2rem 0.6rem; text-align: center;
}

.contract-panel {
  background: rgba(200,168,75,0.06); border: 1px solid var(--border);
  border-radius: 7px; padding: 0.75rem;
}
.contract-dots { display: flex; gap: 4px; margin-bottom: 0.5rem; flex-wrap: wrap; }
.cdot {
  width: 10px; height: 10px; border-radius: 50%;
  background: rgba(255,255,255,0.1); border: 1px solid var(--border); transition: all 0.3s;
}
.cdot.done { background: var(--gold); }
.cdot.active { background: var(--ivory); box-shadow: 0 0 5px var(--ivory); }

.contract-name { font-family: 'Cinzel', serif; font-size: 0.88rem; color: var(--gold); margin-bottom: 0.25rem; }
.contract-desc { font-size: 0.72rem; color: var(--ivory-dim); line-height: 1.45; }

.score-panel { flex: 1; }
.panel-title { font-family: 'Cinzel', serif; font-size: 0.75rem; color: var(--gold); opacity: 0.7; margin-bottom: 0.4rem; letter-spacing: 0.06em; }
.score-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.28rem 0; border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 0.85rem; gap: 0.3rem;
}
.score-row.me { color: var(--gold-light); }
.score-row.active-turn { color: #8eff8e; }
.score-row.lorum-done { opacity: 0.35; text-decoration: line-through; }
.score-pts { font-family: monospace; white-space: nowrap; }
.badge { font-size: 0.58rem; background: rgba(200,168,75,0.12); color: var(--gold); padding: 1px 3px; border-radius: 3px; margin-left: 2px; }
.trick-counter { font-size: 0.72rem; color: var(--ivory-dim); text-align: center; }

/* ── Table ── */
.table-area { display: flex; flex-direction: column; overflow: hidden; }
.table-view { display: flex; flex-direction: column; flex: 1; align-items: center; justify-content: space-between; padding: 0.8rem; }

.table-felt {
  flex: 1; width: 100%; border-radius: 40%;
  background: radial-gradient(ellipse at center, var(--felt) 0%, var(--felt-mid) 55%, var(--felt-dark) 100%);
  border: 5px solid var(--felt-dark);
  box-shadow: inset 0 0 50px rgba(0,0,0,0.5), 0 0 0 2px rgba(200,168,75,0.18);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  position: relative; min-height: 240px; max-height: 370px;
}

#opponent-areas { position: absolute; inset: 0; pointer-events: none; }
.opponent-zone { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.opponent-zone.top    { top: 8px;  left: 50%; transform: translateX(-50%); }
.opponent-zone.left   { left: 8px; top: 50%;  transform: translateY(-50%); }
.opponent-zone.right  { right: 8px; top: 50%; transform: translateY(-50%); }
.opp-name { font-size: 0.72rem; color: var(--ivory-dim); background: rgba(0,0,0,0.4); padding: 2px 7px; border-radius: 9px; }
.opp-name.active { color: #8eff8e; }
.opp-cards { display: flex; }
.card-back {
  width: 26px; height: 40px; border-radius: 3px; margin-left: -8px;
  background: linear-gradient(140deg, #1e0d30, #2a0808);
  border: 1px solid rgba(200,168,75,0.3);
  background-image: repeating-linear-gradient(45deg, rgba(200,168,75,0.07) 0, rgba(200,168,75,0.07) 1px, transparent 1px, transparent 6px);
  box-shadow: 1px 1px 3px rgba(0,0,0,0.5);
}

.trick-area { display: flex; gap: 6px; align-items: center; justify-content: center; flex-wrap: wrap; z-index: 1; }
.trick-card-wrap { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.trick-player-lbl { font-size: 0.58rem; color: var(--ivory-dim); }

.turn-indicator {
  font-family: 'Cinzel', serif; font-size: 0.85rem; color: var(--gold);
  animation: pulse 1.6s ease-in-out infinite; text-align: center; min-height: 1.2em;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }

.hand-area { width: 100%; display: flex; justify-content: center; align-items: flex-end; min-height: 115px; }
.hand-cards { display: flex; align-items: flex-end; }
.hand-cards .card { margin: 0 -14px; }
.hand-cards .card:first-child { margin-left: 0; }
.hand-cards .card:last-child  { margin-right: 0; }
.hand-cards .card:hover { z-index: 10; }

/* ── Playing Card ── */
.card {
  width: var(--card-w); height: var(--card-h);
  background: var(--ivory); border-radius: 6px; border: 1px solid #cec6ae;
  box-shadow: 2px 3px 7px rgba(0,0,0,0.4);
  display: flex; flex-direction: column; padding: 3px 4px;
  cursor: pointer; transition: transform 0.15s, box-shadow 0.15s;
  position: relative; user-select: none; color: var(--ink); flex-shrink: 0;
}
.card.red { color: var(--red); }
.card.playable:hover { transform: translateY(-11px) scale(1.04); box-shadow: 3px 8px 18px rgba(0,0,0,0.5); }
.card.selected { transform: translateY(-15px); border-color: var(--gold); box-shadow: 0 6px 20px rgba(200,168,75,0.5); }
.card.not-playable { opacity: 0.4; cursor: default; filter: grayscale(25%); }
.card-corner { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.card-corner .rank { font-size: 0.88rem; font-family: 'Cinzel', serif; font-weight: 700; }
.card-corner .sym  { font-size: 0.62rem; }
.card-corner-br { position: absolute; bottom: 3px; right: 4px; transform: rotate(180deg); }
.card-center { flex: 1; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; }

/* ── Lorum Board ── */
.lorum-layout { display: flex; flex-direction: column; width: 100%; height: 100%; gap: 0.5rem; }
.lorum-board {
  flex: 1; display: grid; gap: 5px; padding: 0.7rem;
  background: var(--felt-dark); border-radius: 10px;
  border: 2px solid rgba(200,168,75,0.15);
  overflow-y: auto;
}
.lorum-row {
  display: flex; align-items: center; gap: 4px;
  background: rgba(0,0,0,0.18); border-radius: 5px; padding: 4px 8px;
  min-height: 55px;
}
.lorum-row-label { font-size: 1.2rem; width: 28px; flex-shrink: 0; text-align: center; }
.lorum-row-cards { display: flex; gap: 3px; flex-wrap: wrap; flex: 1; align-items: center; }
.lorum-slot {
  width: 40px; height: 54px; border-radius: 4px;
  border: 1px dashed rgba(200,168,75,0.2); background: rgba(255,255,255,0.02);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.55rem; color: var(--ivory-dim);
}
.lorum-placed {
  width: 40px; height: 54px; border-radius: 4px;
  background: var(--ivory); border: 1px solid #c0b890;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: 'Cinzel', serif; gap: 1px; box-shadow: 1px 2px 4px rgba(0,0,0,0.3); flex-shrink: 0;
}
.lorum-placed.red { color: var(--red); }
.lorum-placed .p-rank { font-weight: 700; font-size: 0.82rem; line-height: 1; }
.lorum-placed .p-sym  { font-size: 0.75rem; }

.lorum-bottom { display: flex; flex-direction: column; align-items: center; padding: 0.3rem; gap: 0.3rem; }
.lorum-bottom .hand-area { min-height: 100px; }

/* ── Chat ── */
.chat-box { display: flex; flex-direction: column; height: 100%; }
.chat-messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; padding-bottom: 0.3rem; scrollbar-width: thin; scrollbar-color: rgba(200,168,75,0.25) transparent; }
.chat-msg { font-size: 0.78rem; color: var(--ivory); opacity: 0.78; padding: 2px 0; border-bottom: 1px solid rgba(255,255,255,0.04); word-break: break-word; line-height: 1.4; }
.chat-msg.sys { color: var(--gold); opacity: 0.6; font-style: italic; }
.chat-input-row { display: flex; gap: 4px; margin-top: 0.5rem; }
.chat-inp { flex: 1; padding: 0.42rem 0.5rem; background: rgba(255,255,255,0.04); border: 1px solid var(--border); border-radius: 4px; color: var(--ivory); font-family: inherit; font-size: 0.8rem; outline: none; }
.chat-inp:focus { border-color: var(--gold); }
.chat-send { padding: 0.42rem 0.6rem; background: var(--gold); color: var(--ink); border: none; border-radius: 4px; cursor: pointer; font-size: 0.85rem; }

/* ── Overlays ── */
.overlay-wrap { position: absolute; inset: 0; background: rgba(0,0,0,0.78); display: flex; align-items: center; justify-content: center; }
.overlay-card {
  background: linear-gradient(140deg, #1a2e10, #0a1208);
  border: 1px solid var(--gold); border-radius: 12px;
  padding: 2rem 2.5rem; text-align: center; min-width: 300px; max-width: 420px;
}
.overlay-card h2 { font-family: 'Cinzel', serif; color: var(--gold); margin-bottom: 1.2rem; font-size: 1.4rem; }
.s-row { display: flex; justify-content: space-between; gap: 2rem; padding: 0.32rem 0; font-size: 1rem; border-bottom: 1px solid rgba(255,255,255,0.07); }
.s-row.winner { color: var(--gold); font-weight: bold; }
.hint-text { margin-top: 0.8rem; font-style: italic; opacity: 0.4; font-size: 0.83rem; }
.trophy { font-size: 3.5rem; margin-bottom: 0.4rem; }

#screen-scoring.active, #screen-gameover.active { display: flex; z-index: 50; }
