:root {
  --bg: #102019;
  --felt: #173b2d;
  --felt-2: #20513c;
  --panel: #f5efe2;
  --ink: #1c2420;
  --muted: #66746d;
  --gold: #c69233;
  --red: #b73534;
  --green: #2f7d48;
  --acorn: #7b5635;
  --bell: #bd8b21;
  --line: rgba(28, 36, 32, 0.18);
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: radial-gradient(circle at 50% 10%, #2f5c45, var(--bg) 62%); }
button, input { font: inherit; }
button { border: 0; cursor: pointer; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.app { min-height: 100vh; }
.screen { min-height: 100vh; padding: 24px; }
.hidden { display: none !important; }

.menu-screen, .online-screen { display: grid; place-items: center; align-content: center; gap: 18px; }
.brand-mark svg { width: min(42vw, 220px); fill: #ead7a3; stroke: #402e1c; stroke-width: 5; filter: drop-shadow(0 18px 22px rgba(0,0,0,.28)); }
h1 { margin: 0; color: #fff6d7; font-size: clamp(64px, 12vw, 140px); line-height: .82; letter-spacing: 0; }
h2, h3, p { margin-top: 0; }
.subtitle { color: #dce9df; font-size: clamp(17px, 2vw, 23px); text-align: center; max-width: 620px; }
.panel { width: min(94vw, 560px); background: var(--panel); border: 1px solid rgba(255,255,255,.5); border-radius: 8px; box-shadow: var(--shadow); padding: 22px; }
.menu-panel { display: grid; gap: 14px; }
.field-label { display: block; font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 8px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; border: 1px solid var(--line); border-radius: 8px; background: #e8dfcf; }
.segmented button { min-height: 48px; border-radius: 6px; color: var(--ink); background: transparent; font-weight: 800; }
.segmented button.is-active { background: #244f3a; color: #fff; }
.primary, .secondary, .plain { min-height: 48px; border-radius: 7px; font-weight: 850; padding: 0 18px; }
.primary { background: #244f3a; color: white; }
.secondary { background: #dec895; color: #332719; border: 1px solid #b99752; }
.plain { background: transparent; color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.status { color: var(--muted); min-height: 24px; }
input { width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 7px; padding: 0 12px; background: #fffaf0; color: var(--ink); }
.online-panel { display: grid; gap: 12px; }
.online-grid, .join-row, .dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.room-code { padding: 16px; border-radius: 8px; background: #173b2d; color: #fff6d7; font-size: 28px; font-weight: 900; text-align: center; letter-spacing: .12em; }

.game-screen { display: grid; grid-template-rows: auto 1fr auto; gap: 12px; padding: 14px; color: #f6f0df; }
.topbar, .actionbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; background: rgba(9, 18, 14, .72); border: 1px solid rgba(255,255,255,.12); border-radius: 8px; padding: 10px 14px; backdrop-filter: blur(12px); }
.topbar h2 { margin: 0; font-size: 24px; color: #fff6d7; }
.topbar p { margin: 2px 0 0; color: #d7e2da; }
.lives { display: flex; gap: 6px; align-items: center; min-width: 120px; justify-content: end; }
.life { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #d6bd7a; background: transparent; }
.life.full { background: #b73534; border-color: #f0c1a2; }
.table { position: relative; display: grid; grid-template-rows: 1fr auto 1fr; min-height: 0; border-radius: 8px; background: linear-gradient(135deg, rgba(255,255,255,.06), transparent), radial-gradient(circle at center, var(--felt-2), var(--felt)); border: 1px solid rgba(255,255,255,.14); box-shadow: inset 0 0 80px rgba(0,0,0,.25); overflow: hidden; }
.table:before { content: ""; position: absolute; inset: 18px; border: 2px solid rgba(237, 209, 145, .28); border-radius: 50%; pointer-events: none; }
.opponent-area, .player-area { display: grid; align-content: center; gap: 10px; padding: 18px; min-width: 0; position: relative; z-index: 1; }
.player-label { display: flex; justify-content: center; align-items: center; gap: 10px; color: #f8ecd1; font-weight: 850; }
.player-label strong { min-width: 32px; min-height: 32px; border-radius: 999px; display: grid; place-items: center; background: rgba(0,0,0,.24); }
.opponent-hand, .player-hand { display: flex; justify-content: center; align-items: center; min-width: 0; }
.player-hand { overflow-x: auto; padding: 8px 0 16px; }
.center-area { display: flex; justify-content: center; gap: clamp(18px, 4vw, 56px); align-items: center; position: relative; z-index: 1; }
.card, .pile { width: clamp(86px, 12vw, 128px); aspect-ratio: 5 / 7; border-radius: 8px; box-shadow: 0 12px 22px rgba(0,0,0,.28); }
.card { position: relative; flex: 0 0 auto; margin-left: clamp(-26px, -2.2vw, -12px); background: #fffaf0; color: var(--ink); border: 1px solid #d5c7aa; transition: transform .14s ease, box-shadow .14s ease; }
.card:first-child { margin-left: 0; }
.card.playable { box-shadow: 0 0 0 3px rgba(237, 209, 145, .75), 0 12px 22px rgba(0,0,0,.28); }
.card.playable:hover { transform: translateY(-14px); }
.card-back { background: repeating-linear-gradient(45deg, #263952, #263952 8px, #1d2b3f 8px, #1d2b3f 16px); border: 2px solid #d6bd7a; margin-left: -52px; }
.card-back:first-child { margin-left: 0; }
.card-corner { position: absolute; top: 9px; left: 9px; display: grid; gap: 2px; justify-items: center; font-weight: 950; }
.card-rank { font-size: 22px; line-height: 1; }
.card-center { position: absolute; inset: 0; display: grid; place-items: center; }
.suit-svg { width: 42px; height: 42px; }
.card-center .suit-svg { width: 58px; height: 58px; }
.card.red { color: var(--red); } .card.green { color: var(--green); } .card.acorn { color: var(--acorn); } .card.bell { color: var(--bell); }
.pile { display: grid; place-items: center; color: #fff8dc; border: 2px solid rgba(255,255,255,.28); background: rgba(0,0,0,.18); }
.draw-pile { font-size: 26px; font-weight: 950; background: repeating-linear-gradient(45deg, #263952, #263952 10px, #1d2b3f 10px, #1d2b3f 20px); }
.discard-pile { background: transparent; border: 0; box-shadow: none; }
.actionbar { justify-content: center; }
.actionbar button { min-width: min(44vw, 240px); }
.modal { border: 0; border-radius: 8px; padding: 0; background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(0,0,0,.55); }
.modal form { width: min(92vw, 460px); padding: 22px; }
.suit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.suit-choice { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 74px; border: 1px solid var(--line); background: #fffaf0; }

@media (max-width: 740px) {
  .screen { padding: 12px; }
  .online-grid, .join-row, .dialog-actions { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; }
  .lives { min-width: 0; }
  .card, .pile { width: clamp(72px, 19vw, 94px); }
  .card-back { margin-left: -48px; }
  .card-rank { font-size: 18px; }
  .card-center .suit-svg { width: 44px; height: 44px; }
}
