/* Poker da Galera · base.css
   "Salão VIP": near-black room, wine felt, graphite rails with a thin gold hairline, cream text.
   Tokens and shared components for every page (landing, table, panels). Mobile first. */

/* ------------------------------------------------------------------ tokens */
:root {
  /* room and surfaces */
  --bg: #0b0b0d;
  --surface: #141417;          /* panels */
  --surface-2: #18181b;        /* graphite rail, avatar discs */
  --surface-3: #1d1d21;        /* raised controls */
  --field: #0f0f12;            /* inputs, wells */
  --line: #26262b;
  --line-2: #34343b;

  /* felt */
  --felt-1: #5a1424;
  --felt-2: #2b0710;
  --felt-rail: #18181b;

  /* gold */
  --gold: #d4b06a;
  --gold-hi: #e6c98a;
  --gold-lo: #b8944f;
  --gold-ink: #1a1205;         /* text on gold */
  --gold-a10: rgba(212, 176, 106, .10);
  --gold-a16: rgba(212, 176, 106, .16);
  --gold-a28: rgba(212, 176, 106, .28);
  --gold-a45: rgba(212, 176, 106, .45);

  /* text */
  --ink: #eae3d2;
  --ink-2: #b4ad9e;            /* secondary, 7:1 on surface */
  --ink-3: #8f897c;            /* placeholder / hints, 4.9:1 on field */
  --ink-muted-btn: #ddd8cc;

  /* cards and signals */
  --card-face: #ffffff;
  --card-black: #111111;
  --card-red: #c0182b;
  --danger: #ff8a8a;
  --danger-bg: rgba(255, 138, 138, .08);
  --ok: #8fd19e;
  --muted-btn: #2a2a2e;

  /* type */
  --font-display: "Playfair Display", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-ui: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs-xs: .75rem;
  --fs-sm: .875rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.5rem;
  --fs-2xl: 2rem;

  /* shape, depth, motion */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-pill: 999px;
  --shadow-1: 0 2px 6px rgba(0, 0, 0, .45);
  --shadow-2: 0 14px 40px rgba(0, 0, 0, .8);
  --shadow-pop: 0 24px 64px -12px rgba(0, 0, 0, .9);
  --hairline: inset 0 0 0 1px var(--gold);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-io: cubic-bezier(.65, 0, .35, 1);
  --t-fast: 140ms;
  --t-med: 260ms;
  --t-slow: 520ms;

  --gutter: 16px;
  --tap: 48px;
  color-scheme: dark;
}

/* ------------------------------------------------------------------ reset */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--fs-md)/1.5 var(--font-ui);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.15; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; }
ul { margin: 0; padding: 0; list-style: none; }
[hidden] { display: none !important; }

a { color: var(--gold); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--gold-hi); }

::selection { background: var(--gold); color: var(--gold-ink); }
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: var(--r-sm); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.num, .tabular { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ type helpers */
.display { font-family: var(--font-display); font-weight: 700; letter-spacing: .01em; }
.label {
  display: block;
  margin-bottom: 8px;
  color: var(--gold);
  font: 600 var(--fs-xs)/1.2 var(--font-ui);
  letter-spacing: .12em;
  text-transform: uppercase;
}
.label .opt { color: var(--ink-3); letter-spacing: .06em; font-weight: 500; text-transform: none; margin-left: 4px; }
.hint { margin-top: 8px; color: var(--ink-3); font-size: var(--fs-sm); line-height: 1.45; }
.code-chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  box-shadow: inset 0 0 0 1px var(--gold-a45);
  color: var(--gold);
  font: 600 var(--fs-sm)/1.6 var(--font-ui);
  letter-spacing: .18em;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ buttons */
.btn {
  --btn-bg: var(--surface-3);
  --btn-fg: var(--ink);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 20px;
  border: 0;
  border-radius: var(--r-md);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font: 600 var(--fs-md)/1 var(--font-ui);
  letter-spacing: .01em;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--t-fast) ease, box-shadow var(--t-fast) ease,
              color var(--t-fast) ease, transform var(--t-fast) ease, filter var(--t-fast) ease;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn:focus-visible { outline-offset: 3px; border-radius: var(--r-md); }

.btn-gold {
  --btn-fg: var(--gold-ink);
  background: linear-gradient(180deg, var(--gold-hi), var(--gold) 55%, var(--gold-lo));
  box-shadow: 0 1px 0 rgba(255, 255, 255, .25) inset, 0 8px 22px -10px rgba(212, 176, 106, .55);
  font-weight: 700;
}
.btn-gold:hover:not(:disabled) { filter: brightness(1.06); color: var(--gold-ink); }

.btn-outline {
  --btn-bg: var(--surface-3);
  --btn-fg: var(--gold);
  box-shadow: inset 0 0 0 1px var(--gold);
}
.btn-outline:hover:not(:disabled) { --btn-bg: #24221d; color: var(--gold-hi); box-shadow: inset 0 0 0 1px var(--gold-hi); }

.btn-muted { --btn-bg: var(--muted-btn); --btn-fg: var(--ink-muted-btn); }
.btn-muted:hover:not(:disabled) { --btn-bg: #333338; color: #fff; }

.btn-ghost { --btn-bg: transparent; --btn-fg: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { --btn-bg: var(--surface-3); color: var(--ink); }

.btn-lg { min-height: 54px; font-size: var(--fs-lg); border-radius: 12px; }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-block { width: 100%; }
.btn-icon { width: var(--tap); padding: 0; }
.btn-icon svg { width: 20px; height: 20px; }

/* loading: keeps the width, label fades, spinner on top */
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-color: var(--btn-fg) var(--btn-fg) transparent transparent;
  animation: pg-spin .7s linear infinite;
}
@keyframes pg-spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ fields */
.field { display: block; }
.field + .field, .field + .field-row, .field-row + .field, .field-row + .field-row { margin-top: 20px; }
.field-row { display: grid; grid-template-columns: 1fr; gap: 20px; }
.field-row > .field { margin: 0; }

.input {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--field);
  color: var(--ink);
  font: 500 var(--fs-md)/1.2 var(--font-ui);
  caret-color: var(--gold);
  transition: border-color var(--t-fast) ease, box-shadow var(--t-fast) ease, background-color var(--t-fast) ease;
}
.input::placeholder { color: var(--ink-3); opacity: 1; }
.input:hover { border-color: #45454d; }
.input:focus, .input:focus-visible { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-a28); border-radius: var(--r-md); }
.input[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(255, 138, 138, .18); }
.input.num { font-variant-numeric: tabular-nums; }
.input-short { max-width: 120px; }

.pair { display: flex; align-items: center; gap: 8px; }
.pair .input { min-width: 0; }
.pair-sep { color: var(--ink-3); font-weight: 500; }

.form-error {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 20px 0 0;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--danger-bg);
  color: var(--danger);
  font-size: var(--fs-sm);
  line-height: 1.45;
}
.form-error::before {
  content: "";
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 1px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='none' stroke='black' stroke-width='1.5'/%3E%3Cpath d='M8 4.5v4.2' stroke='black' stroke-width='1.6' stroke-linecap='round'/%3E%3Ccircle cx='8' cy='11.3' r='.95'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='7' fill='none' stroke='black' stroke-width='1.5'/%3E%3Cpath d='M8 4.5v4.2' stroke='black' stroke-width='1.6' stroke-linecap='round'/%3E%3Ccircle cx='8' cy='11.3' r='.95'/%3E%3C/svg%3E") center / contain no-repeat;
}
.form-error + .btn { margin-top: 16px; }

/* segmented control: <div class="seg"><label><input type=radio><span>…</span></label>…</div> */
.seg {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 12px;
  background: var(--field);
  box-shadow: inset 0 0 0 1px var(--line-2);
}
.seg label { position: relative; flex: 1 1 0; min-width: 0; }
.seg input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.seg span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 8px;
  border-radius: 9px;
  color: var(--ink-2);
  font: 500 var(--fs-sm)/1.15 var(--font-ui);
  text-align: center;
  transition: background-color var(--t-fast) ease, color var(--t-fast) ease, box-shadow var(--t-fast) ease;
  pointer-events: none;
}
.seg label:hover span { color: var(--ink); }
.seg input:checked + span { background: var(--gold-a16); color: var(--gold-hi); box-shadow: inset 0 0 0 1px var(--gold-a45); font-weight: 600; }
.seg input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 1px; }

/* switch: <label class="switch"><input type=checkbox><span class="switch-track"></span><span class="switch-text">…</span></label> */
.switch { display: inline-flex; align-items: center; gap: 12px; min-height: 40px; cursor: pointer; position: relative; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  position: relative;
  flex: none;
  width: 44px;
  height: 26px;
  border-radius: var(--r-pill);
  background: var(--muted-btn);
  box-shadow: inset 0 0 0 1px var(--line-2);
  transition: background-color var(--t-med) var(--ease-out);
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--ink-2);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .5);
  transition: transform var(--t-med) var(--ease-out), background-color var(--t-med) ease;
}
.switch input:checked + .switch-track { background: var(--gold-a28); box-shadow: inset 0 0 0 1px var(--gold-a45); }
.switch input:checked + .switch-track::after { transform: translateX(18px); background: var(--gold); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--gold); outline-offset: 2px; }
.switch-text { color: var(--ink); font-weight: 600; }

/* avatar picker: radio grid of 16 emoji animals (built by ui.js) */
.avatar-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; }
/* narrow phones: 6 per row keeps every avatar a ≥ 44 px touch target */
@media (max-width: 399px) { .avatar-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; } }
.avatar-opt { position: relative; }
.avatar-opt input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.avatar-opt span {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line-2);
  font-size: clamp(1.15rem, 5.4vw, 1.5rem);
  line-height: 1;
  pointer-events: none;
  transition: box-shadow var(--t-fast) ease, transform var(--t-med) var(--ease-out), background-color var(--t-fast) ease;
}
.avatar-opt:hover span { box-shadow: inset 0 0 0 1px var(--gold-a45); }
.avatar-opt input:checked + span {
  background: radial-gradient(circle at 50% 40%, var(--felt-1), var(--felt-2));
  box-shadow: inset 0 0 0 1.5px var(--gold), 0 4px 12px -4px rgba(212, 176, 106, .5);
  transform: scale(1.08);
}
.avatar-opt input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ------------------------------------------------------------------ panels */
.panel {
  position: relative;
  padding: 20px 16px;
  border-radius: 16px;
  background: linear-gradient(180deg, #17171b, var(--surface) 140px);
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow-2);
}
.panel-head { margin-bottom: 24px; }
.panel-head h2 { font: 600 var(--fs-xl)/1.15 var(--font-display); color: var(--ink); letter-spacing: .005em; }
.panel-head p { margin-top: 6px; color: var(--ink-2); font-size: var(--fs-sm); }

/* felt: the table surface, also used as decoration on landing and idle table */
.felt {
  position: relative;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, var(--felt-1), var(--felt-2) 72%);
  border: 10px solid var(--felt-rail);
  box-shadow: inset 0 0 0 1px var(--gold), var(--shadow-2);
}
.felt-logo {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: var(--gold);
  opacity: .5;
  font: 700 var(--fs-sm)/1 var(--font-display);
  letter-spacing: .24em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ------------------------------------------------------------------ modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: end center;
  padding: var(--gutter);
  padding-bottom: max(var(--gutter), env(safe-area-inset-bottom));
  background: rgba(6, 6, 8, .72);
  -webkit-backdrop-filter: blur(6px);
          backdrop-filter: blur(6px);
  overflow-y: auto;
  animation: pg-fade var(--t-med) ease both;
}
.modal {
  position: relative;
  width: 100%;
  max-width: 440px;
  max-height: calc(100dvh - 2 * var(--gutter));
  overflow-y: auto;
  padding: 24px 20px 20px;
  border-radius: 18px;
  background: linear-gradient(180deg, #19191d, var(--surface) 120px);
  box-shadow: inset 0 0 0 1px var(--gold-a28), var(--shadow-pop);
  animation: pg-rise var(--t-slow) var(--ease-out) both;
}
.modal-head { margin-bottom: 20px; }
.modal-head h2 { font: 600 var(--fs-xl)/1.15 var(--font-display); }
.modal-head p { margin-top: 6px; color: var(--ink-2); font-size: var(--fs-sm); }
.modal-close { position: absolute; top: 10px; right: 10px; }
.modal-actions { display: flex; gap: 10px; margin-top: 24px; }
.modal-actions .btn { flex: 1; }
.modal-foot { margin-top: 16px; text-align: center; }
@media (min-width: 640px) {
  .modal-backdrop { place-items: center; }
  .modal { padding: 28px; }
}

/* ------------------------------------------------------------------ toast */
.toasts {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(420px, calc(100% - 2 * var(--gutter)));
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  background: #1f1f24;
  box-shadow: inset 0 0 0 1px var(--gold-a28), 0 12px 32px -8px rgba(0, 0, 0, .85);
  color: var(--ink);
  font: 500 var(--fs-sm)/1.4 var(--font-ui);
  pointer-events: auto;
  animation: pg-toast-in var(--t-med) var(--ease-out) both;
}
.toast::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }
.toast-error { box-shadow: inset 0 0 0 1px rgba(255, 138, 138, .35), 0 12px 32px -8px rgba(0, 0, 0, .85); }
.toast-error::before { background: var(--danger); }
.toast.is-leaving { animation: pg-toast-out 200ms ease both; }
@keyframes pg-toast-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@keyframes pg-toast-out { to { opacity: 0; transform: translateY(6px); } }

@keyframes pg-fade { from { opacity: 0; } }
@keyframes pg-rise { from { opacity: 0; transform: translateY(24px) scale(.985); } }

/* ------------------------------------------------------------------ notice page (not found, errors) */
.page-notice { display: grid; place-items: center; padding: 32px var(--gutter); }
.notice { width: 100%; max-width: 440px; display: flex; flex-direction: column; align-items: center; gap: 28px; }
.notice-logo {
  color: var(--gold);
  font: 700 var(--fs-lg)/1 var(--font-display);
  letter-spacing: .16em;
  text-transform: uppercase;
  text-decoration: none;
}
.notice-card {
  width: 100%;
  padding: 28px 20px 20px;
  border-radius: 18px;
  background: linear-gradient(180deg, #19191d, var(--surface) 120px);
  box-shadow: inset 0 0 0 1px var(--gold-a28), var(--shadow-pop);
}
.notice-card h1 { font: 600 var(--fs-2xl)/1.1 var(--font-display); margin-bottom: 12px; }
.notice-card p { color: var(--ink-2); }
.notice-card .notice-small { margin-top: 10px; font-size: var(--fs-sm); color: var(--ink-3); }
.notice-card .btn { margin-top: 24px; }

/* ------------------------------------------------------------------ table page shell
   Containers #topbar #table #actions #side; table.css (Task 10) owns the full layout. */
.page-mesa { overflow: hidden; }
.shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-areas: "top" "table" "actions";
  height: 100vh;
  height: 100dvh;
}
.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 8px var(--gutter);
  padding-top: max(8px, env(safe-area-inset-top));
  border-bottom: 1px solid #1f1f23;
}
.topbar-logo {
  color: var(--gold);
  font: 700 var(--fs-sm)/1 var(--font-display);
  letter-spacing: .16em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
}
.table-area { grid-area: table; position: relative; display: grid; place-items: center; min-height: 0; padding: 24px var(--gutter); overflow: hidden; }
.actions-area { grid-area: actions; }
@media (max-width: 480px) {
  .topbar .btn-label { display: none; }
  .topbar .btn-sm:has(svg) { width: 40px; min-height: 40px; padding: 0; }
}
.side-area { display: none; }
.felt-idle { width: min(88vw, 900px); aspect-ratio: 1.9; max-height: 100%; }
@media (max-width: 640px) {
  .felt-idle { width: min(78vw, 360px); aspect-ratio: .62; }
  .felt-idle .felt-logo { transform: translate(-50%, -50%) rotate(-90deg); }
}

/* ------------------------------------------------------------------ motion preferences */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0ms !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .btn.is-loading::after { animation-duration: 1.4s !important; animation-iteration-count: infinite !important; }
}

@media (min-width: 480px) {
  .panel { padding: 28px 24px; }
  .field-row { grid-template-columns: 1fr 1fr; }
}
