:root {
  --ink: #f4eedf;
  --muted: #a8a293;
  --black: #0d0d0b;
  --panel: rgba(28, 27, 23, .92);
  --line: rgba(244, 238, 223, .14);
  --gold: #d8a83e;
  --gold-bright: #f2ca62;
  --red: #b84035;
  --accent: #d8a83e;
  --accent-bright: #f2ca62;
  --app-bg-start: #363026;
  --app-bg-mid: #151512;
  --app-bg-end: #090908;
  --card-back: #eee8db;
  --card-border: #ddd3bc;
  --card-text: #171713;
  --card-size-scale: 1;
  --motion-duration: .16s;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: radial-gradient(circle at 50% 15%, var(--app-bg-start) 0, var(--app-bg-mid) 42%, var(--app-bg-end) 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
}
.grain { position: fixed; inset: 0; opacity: .08; pointer-events: none; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.7'/%3E%3C/svg%3E"); }
main { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 54px; position: relative; }
header { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
header h1 { font: 700 clamp(23px, 3vw, 34px)/1 Georgia, serif; margin: 0; letter-spacing: -.04em; }
header h1 i, .brand-mark span { color: var(--gold); font-style: italic; }
header .ghost { margin-left: auto; }
.brand-mark { width: 48px; height: 56px; display: grid; place-items: center; border: 1px solid var(--gold); color: var(--ink); font: 700 18px Georgia, serif; transform: rotate(-2deg); }
.eyebrow { margin: 0 0 5px; color: var(--gold); font-size: 11px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
.panel { border: 1px solid var(--line); background: var(--panel); box-shadow: 0 24px 70px rgba(0,0,0,.32); backdrop-filter: blur(12px); }
.landing { min-height: 560px; display: grid; grid-template-columns: 1.3fr .7fr; align-items: center; gap: clamp(30px, 8vw, 110px); padding: clamp(32px, 7vw, 90px); overflow: hidden; position: relative; }
.landing::after { content: '♠'; position: absolute; right: 33%; bottom: -160px; color: rgba(216,168,62,.045); font-size: 480px; transform: rotate(12deg); }
.intro, .room-form { position: relative; z-index: 1; }
.kicker { color: var(--gold-bright); font-weight: 700; }
.intro h2 { margin: 12px 0 20px; font: 700 clamp(48px, 7vw, 88px)/.88 Georgia, serif; letter-spacing: -.06em; }
.intro h2 em { color: var(--gold); font-weight: 400; }
.intro > p:last-child { max-width: 500px; color: var(--muted); font-size: 17px; line-height: 1.65; }
.room-form { display: grid; gap: 14px; padding: 26px; background: rgba(7,7,6,.58); border-top: 2px solid var(--gold); }
label { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; }
input { width: 100%; margin-top: 8px; padding: 14px 15px; color: var(--ink); background: #11110f; border: 1px solid var(--line); border-radius: 3px; font: inherit; text-transform: none; }
input:focus { outline: 2px solid rgba(216,168,62,.5); border-color: var(--gold); }
button { padding: 13px 18px; border: 1px solid var(--line); border-radius: 3px; color: var(--ink); background: #292822; font: 800 12px/1 inherit; letter-spacing: .06em; text-transform: uppercase; cursor: pointer; transition: .18s ease; }
button:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--gold); }
button:disabled { opacity: .4; cursor: not-allowed; }
button.primary { color: #17150f; border-color: var(--accent); background: linear-gradient(135deg, var(--accent-bright), var(--accent)); }
button.ghost, a.ghost {
  background: transparent;
  color: inherit;
  text-decoration: none;
}
button.compact { padding: 8px 11px; }
.divider { display: flex; align-items: center; gap: 10px; color: #777266; font-size: 11px; }
.divider::before, .divider::after { content: ''; height: 1px; flex: 1; background: var(--line); }
.join-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.join-row input { margin: 0; text-transform: uppercase; font-weight: 800; letter-spacing: .18em; }
.hidden { display: none !important; }
.lobby { min-height: 480px; display: grid; grid-template-columns: .8fr 1.2fr; gap: 70px; padding: clamp(32px, 7vw, 80px); }
.lobby h2 { margin: 0 0 18px; color: var(--gold-bright); font: 700 clamp(50px, 8vw, 94px)/1 Georgia, serif; letter-spacing: .12em; }
.lobby h3 { margin-top: 0; }
.lobby-players { display: grid; gap: 8px; padding: 0; list-style: none; }
.lobby-players li { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; background: rgba(255,255,255,.035); border-left: 2px solid var(--gold); }
.muted { color: var(--muted); }
.game-topbar { display: flex; justify-content: space-between; align-items: center; padding: 0 4px 18px; }
.round-badge { padding: 8px 13px; border: 1px solid var(--line); }
.turn-label { color: var(--gold-bright); font-weight: 800; }
.opponents { min-height: 100px; display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.opponent { min-width: 120px; padding: 12px 15px; text-align: center; border: 1px solid var(--line); background: rgba(20,20,17,.75); }
.opponent.active { border-color: var(--gold); box-shadow: 0 0 25px rgba(216,168,62,.12); }
.opponent .count { margin-top: 5px; color: var(--muted); font-size: 12px; }
.role { display: inline-block; margin-left: 4px; color: var(--gold); font-size: 10px; text-transform: uppercase; }
.table { min-height: 300px; margin: 14px 0 24px; padding: 28px; display: grid; place-items: center; position: relative; background: radial-gradient(circle, rgba(75,70,52,.35), rgba(20,20,17,.94) 62%); }
.event-text { position: absolute; top: 20px; left: 20px; color: var(--muted); font-size: 13px; }
.action-hint { position: absolute; bottom: 18px; color: var(--gold-bright); font-size: 13px; font-weight: 700; }
.pile { min-width: 210px; min-height: 150px; display: flex; justify-content: center; align-items: center; }
.empty-pile { width: 105px; height: 145px; display: grid; place-items: center; border: 1px dashed #625d51; color: #716b5e; border-radius: 8px; }
.card { width: calc(92px * var(--card-size-scale)); height: calc(128px * var(--card-size-scale)); flex: 0 0 auto; padding: 9px; border: 1px solid var(--card-border); border-radius: 7px; color: var(--card-text); background: var(--card-back); box-shadow: 0 7px 17px rgba(0,0,0,.3); cursor: pointer; transition: transform var(--motion-duration) ease, box-shadow var(--motion-duration) ease; user-select: none; }
.card.red { color: var(--red); }
.card.selected { transform: translateY(-16px); box-shadow: 0 12px 22px rgba(216,168,62,.24); border: 2px solid var(--accent); }
.card .rank { font: 700 22px/1 Georgia, serif; }
.card .suit { font-size: 24px; }
.rank-request { position: relative; display: grid; place-items: center; align-content: center; gap: 7px; text-transform: uppercase; }
.rank-request .rank { font-size: 36px; }
.rank-request .any-suit { color: #6f695d; font-size: 9px; font-weight: 800; letter-spacing: .08em; }
.rank-request .request-count { position: absolute; top: 7px; right: 8px; color: var(--red); font-weight: 900; }
.pile .card + .card { margin-left: -55px; transform: rotate(2deg); }
.hand-heading { display: flex; justify-content: space-between; margin-bottom: 13px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.hand { display: flex; width: 100%; min-height: 150px; overflow: visible; padding: 18px 6px 6px; }
.hand .card { flex: 1 1 calc(92px * var(--card-size-scale)); min-width: 0; max-width: calc(92px * var(--card-size-scale)); position: relative; }
.hand .card + .card { margin-left: -1px; }
.hand .card .rank { font-size: clamp(15px, 2vw, 22px); }
.hand .card .suit { font-size: clamp(15px, 2vw, 24px); }
.hand .card:hover { transform: translateY(-9px); z-index: 2; }
.hand .card.selected:hover { transform: translateY(-16px); }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.intermission { margin: 6px 0 22px; padding: 16px; display: grid; gap: 10px; }
.intermission-header { color: var(--gold-bright); font-weight: 800; letter-spacing: .05em; }
.intermission .muted { color: #c8c0b0; }
.proposal-list { display: grid; gap: 8px; }
.proposal-item { padding: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.04); }
.proposal-item .proposal-id { color: #80786c; font-size: 11px; }
.proposal-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.proposal-compose { display: grid; gap: 8px; }
.proposal-input { width: 100%; padding: 10px; margin-top: 0; color: var(--ink); background: #11110f; border: 1px solid var(--line); border-radius: 3px; resize: vertical; font: inherit; }
.proposal-input:focus { outline: 2px solid rgba(216,168,62,.5); border-color: var(--gold); }
dialog { width: min(600px, calc(100% - 32px)); padding: 34px; color: var(--ink); background: #1b1a17; border: 1px solid var(--gold); box-shadow: 0 30px 90px #000; }
dialog::backdrop { background: rgba(0,0,0,.75); backdrop-filter: blur(4px); }
dialog h2 { font: 700 36px Georgia, serif; margin: 8px 0 22px; }
dialog li { margin-bottom: 13px; color: #cbc4b4; line-height: 1.5; }
.dialog-close { position: absolute; top: 12px; right: 12px; padding: 8px 11px; font-size: 20px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 10; max-width: 340px; padding: 14px 18px; color: #fff; background: var(--red); box-shadow: 0 12px 35px #000; }

/* Settings + theme controls */
.lobby-controls { margin-top: 10px; display: grid; gap: 8px; }
.room-theme-select { width: 100%; margin-top: 6px; background: #11110f; border: 1px solid var(--line); padding: 10px; color: var(--ink); }
.settings-grid { display: grid; gap: 12px; }
.checkbox { display: flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; font-size: 12px; }
.settings-grid input, .settings-grid select, .settings-grid button { margin-top: 6px; }

body[data-theme='classic-card-room'] {
  --app-bg-start: #363026;
  --app-bg-mid: #151512;
  --app-bg-end: #090908;
  --accent: #d8a83e;
  --accent-bright: #f2ca62;
}

body[data-theme='neon-nightlife'] {
  --app-bg-start: #2a082f;
  --app-bg-mid: #12071f;
  --app-bg-end: #080412;
  --accent: #ff7fd1;
  --accent-bright: #ffc2e8;
  --gold: #ff8dd6;
  --gold-bright: #ffd4f0;
}

body[data-theme='black-and-gold'] {
  --app-bg-start: #1a1206;
  --app-bg-mid: #090704;
  --app-bg-end: #030202;
  --accent: #d4af37;
  --accent-bright: #f1cf84;
  --gold: #f5c85f;
  --gold-bright: #ffe0a8;
}

body[data-theme='minimal-dark'] {
  --app-bg-start: #1f1f1f;
  --app-bg-mid: #171717;
  --app-bg-end: #101010;
  --accent: #a5a5a5;
  --accent-bright: #efefef;
  --gold: #dad8cf;
  --gold-bright: #ffffff;
}

body[data-theme='high-contrast'] {
  --app-bg-start: #000000;
  --app-bg-mid: #000000;
  --app-bg-end: #000000;
  --accent: #ffff00;
  --accent-bright: #ffffff;
  --ink: #ffffff;
  --muted: #e3da9a;
  --red: #ff4d4d;
  --card-border: #ffffff;
}

body[data-reduced-motion='on'] * { transition-duration: .001s !important; }
body[data-large-text='on'] { font-size: 115%; }
body[data-card-size='small'] { --card-size-scale: 0.84; }
body[data-card-size='medium'] { --card-size-scale: 1; }
body[data-card-size='large'] { --card-size-scale: 1.18; }
body[data-color-blind-suits='on'] .card .suit { font-weight: 800; }
body[data-card-back='standard'] { --card-back: #eee8db; }
body[data-card-back='linen'] { --card-back: #f8f4ea; }
body[data-card-back='midnight'] { --card-back: #dbe6ff; }
body[data-card-back='leaf'] { --card-back: #dcefd2; }

@media (max-width: 760px) {
  main { width: min(100% - 20px, 1180px); padding-top: 14px; }
  .landing, .lobby { grid-template-columns: 1fr; min-height: auto; gap: 28px; padding: 28px 20px; }
  .intro h2 { font-size: 52px; }
  .game-topbar { font-size: 12px; }
  .table { min-height: 250px; padding: 18px; }
  .opponents { gap: 6px; }
  .opponent { min-width: 96px; padding: 8px; font-size: 12px; }
  .card { width: 78px; height: 109px; }
  .hand .card + .card { margin-left: -1px; }
}
