/* THE BLOCK — Rillaz Domino Club. Mobile first. */
:root {
  --bg: #0b0b0a;
  --charcoal: #141416;
  --surface: #1c1c1f;
  --surface-2: #26262a;
  --line: #34343a;
  --lime: #d0f902; /* sampled from the supplied logo */
  --lime-dim: #9fbf05;
  --amber: #f0a33c;
  --amber-soft: rgba(240, 163, 60, 0.16);
  --gold: #d6b25e;
  --text: #f3f3ef;
  --muted: #a7a7ad;
  --danger: #ff6b5b;
  --tile: #f4efe3;
  --tile-edge: #cfc6b0;
  --pip: #141414;
  --team0: var(--lime);
  --team1: var(--amber);
  --radius: 14px;
  --display: "Anton", "Impact", "Arial Narrow", sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--body);
  min-height: 100svh;
  overflow-x: hidden;
}
img { max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--lime); }
[hidden] { display: none !important; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--lime); color: #000; padding: 8px 12px; border-radius: 8px; z-index: 50; }
.skip:focus { left: 8px; }

:focus-visible { outline: 3px solid var(--lime); outline-offset: 2px; border-radius: 8px; }

.backdrop {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(240,163,60,0.10), transparent 60%),
    linear-gradient(180deg, rgba(11,11,10,0.55), rgba(11,11,10,0.92)),
    url("/art/scene/table-poster.jpg") center / cover no-repeat,
    var(--bg);
}
@media (min-aspect-ratio: 1/1) {
  .backdrop { background:
    radial-gradient(120% 70% at 50% 0%, rgba(240,163,60,0.10), transparent 60%),
    linear-gradient(180deg, rgba(11,11,10,0.6), rgba(11,11,10,0.93)),
    url("/art/scene/table-poster.jpg") center / cover no-repeat,
    var(--bg); }
}

/* ── type ───────────────────────────────────────────── */
.h1, .h2, .h3, .title { font-family: var(--display); font-weight: 400; letter-spacing: 0.02em; margin: 0; }
.h1 { font-size: clamp(2.2rem, 8vw, 3.4rem); line-height: 1; }
.h2 { font-size: 1.6rem; line-height: 1.1; }
.h3 { font-size: 1.2rem; line-height: 1.15; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.center { text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.04em; }
.tagline { color: var(--muted); text-align: center; margin: 6px 0 14px; }
.lead { font-size: 1.1rem; color: var(--text); }

/* ── buttons ───────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2);
  font-weight: 600; cursor: pointer; text-decoration: none; width: 100%;
  transition: background .15s, border-color .15s, transform .08s;
}
.btn:hover { border-color: #55555c; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--lime); color: #0b0b0a; border-color: var(--lime); }
.btn-primary:hover { background: #dcff2e; border-color: #dcff2e; }
.btn-gold { background: var(--gold); color: #141006; border-color: var(--gold); }
.btn-danger { border-color: rgba(255,107,91,.5); color: #ffb3aa; }
.btn-xl { min-height: 56px; font-size: 1.08rem; }
.btn-sm { min-height: 40px; padding: 6px 12px; width: auto; }
.icon-btn {
  min-width: 44px; min-height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(20,20,22,.8); font-size: 1.2rem; cursor: pointer;
}
.link-btn { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 10px 6px; min-height: 44px; }
.chip {
  border: 1px solid var(--line); background: var(--charcoal); border-radius: 999px;
  padding: 8px 12px; min-height: 40px; white-space: nowrap; cursor: pointer; font-size: .9rem;
}
.chip:hover { border-color: var(--lime-dim); }
.pill { font-size: .8rem; padding: 4px 10px; border-radius: 999px; background: var(--amber-soft); color: var(--amber); border: 1px solid rgba(240,163,60,.4); }
.pill.bad { background: rgba(255,107,91,.14); color: #ffb3aa; border-color: rgba(255,107,91,.4); }

/* ── layout ─────────────────────────────────────────── */
.screen { min-height: 100svh; }
.narrow { width: min(560px, 100%); margin: 0 auto; padding: 16px 16px calc(24px + var(--safe-b)); display: flex; flex-direction: column; gap: 14px; }
.card { background: rgba(20,20,22,.88); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; backdrop-filter: blur(6px); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: rgba(11,11,10,.85); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.bar-title { flex: 1; min-width: 0; }
.bar-title p { margin: 0; }

/* ── welcome ───────────────────────────────────────── */
#screen-welcome { position: relative; display: flex; flex-direction: column; }
/* One continuous background layer for the whole welcome section (however tall it
   gets). The poster underneath is the loading / error / reduced-motion fallback;
   the video covers it once it plays. */
.hero {
  position: absolute; inset: 0; height: auto; overflow: hidden; z-index: 0;
  background: url("/art/scene/table-poster.jpg") center 40% / cover no-repeat, var(--bg);
}
.hero-video { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; object-position: center 40%; }
.hero-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(11,11,10,.38) 0%, rgba(11,11,10,.58) 50%, rgba(11,11,10,.74) 100%); }
/* The fixed site backdrop stays for the other screens but never shows through here. */
body:has(#screen-welcome:not([hidden])) .backdrop { display: none; }
.welcome { position: relative; z-index: 1; width: min(520px, 100%); margin: 0 auto; padding: 22px 16px calc(24px + var(--safe-b)); display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
.logo { display: block; width: min(300px, 70vw); height: auto; margin: 6px auto 0; filter: drop-shadow(0 6px 24px rgba(0,0,0,.6)); }
.logo-sm { width: min(200px, 50vw); }
.title { text-align: center; font-size: clamp(3rem, 15vw, 4.6rem); line-height: .9; margin-top: 4px; text-shadow: 0 4px 24px rgba(0,0,0,.7); }
.title span { display: block; }
.title small { display: block; font-family: var(--body); font-weight: 700; font-size: .95rem; letter-spacing: .32em; text-transform: uppercase; color: var(--gold); margin-top: 8px; }
.welcome .tagline { color: var(--text); font-weight: 600; text-shadow: 0 2px 10px rgba(0,0,0,.8); }
.welcome-card { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .92rem; }
.field input, .field textarea, .join input {
  min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: #0f0f11; padding: 10px 12px; font-size: 1rem; width: 100%;
}
.field textarea { resize: vertical; }
.field-error { color: #ffb3aa; margin: -4px 0 0; font-size: .9rem; }
.actions { display: flex; flex-direction: column; gap: 10px; }
.join { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.join .btn { width: auto; padding-inline: 20px; }
.invite { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--lime-dim); border-radius: 12px; background: rgba(208,249,2,.06); }
.invite p { margin: 0; }
.welcome-foot { display: flex; justify-content: center; align-items: center; gap: 4px; color: var(--muted); }
.fineprint { color: var(--muted); font-size: .82rem; text-align: center; margin: 0; }
.notice { border-color: rgba(240,163,60,.45); background: rgba(40,28,12,.85); }
.notice p { margin: 0 0 6px; }

/* ── lobby ─────────────────────────────────────────── */
.lobby-seats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lseat { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 10px; border-radius: var(--radius); border: 1px solid var(--line); background: rgba(20,20,22,.9); text-align: center; min-height: 168px; }
.lseat.you { border-color: var(--lime); }
.lseat .team-tag { position: absolute; top: 8px; left: 8px; }
.lseat .name { font-weight: 700; overflow-wrap: anywhere; }
.lseat .meta { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.lseat .btn { min-height: 40px; font-size: .9rem; }
.tag { font-size: .74rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); text-transform: uppercase; letter-spacing: .04em; }
.tag-bot { color: #c9c9ff; border-color: #5d5da8; background: #1d1d33; }
.tag-human { color: var(--muted); }
.tag-ready { color: #0b0b0a; background: var(--lime); border-color: var(--lime); }
.tag-wait { color: var(--muted); }
.tag-host { color: var(--gold); border-color: rgba(214,178,94,.6); }
.tag-away { color: var(--amber); border-color: rgba(240,163,60,.6); }
.team-tag { font-size: .74rem; font-weight: 800; letter-spacing: .05em; }
.team0 { color: var(--team0); }
.team1 { color: var(--team1); }
.lobby-actions { display: flex; flex-direction: column; gap: 10px; }
.host { display: flex; flex-direction: column; gap: 10px; }

/* ── portraits ─────────────────────────────────────── */
.portrait { width: 64px; height: 64px; border-radius: 50%; overflow: hidden; flex: none; position: relative; background: var(--surface-2); border: 2px solid var(--line); display: grid; place-items: center; }
.portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }
.portrait .mono-fallback { font-family: var(--display); font-size: 1.6rem; color: var(--lime); }
.portrait.sm { width: 44px; height: 44px; }
.portrait.sm .mono-fallback { font-size: 1.1rem; }
.portrait.team0 { border-color: rgba(208,249,2,.65); }
.portrait.team1 { border-color: rgba(240,163,60,.7); }
.portrait.turn { box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--lime); }
.portrait.offline img { filter: grayscale(1) brightness(.6); }

/* ── table ─────────────────────────────────────────── */
.screen-table { display: flex; flex-direction: column; height: 100svh; min-height: 0; overflow: hidden; }
.table-bar { gap: 8px; }
.scoreboard { flex: 1; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6px; min-width: 0; }
.score { display: flex; flex-direction: column; min-width: 0; }
.score.right { align-items: flex-end; text-align: right; }
.score .lbl { font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.score .num { font-family: var(--display); font-size: 1.7rem; line-height: 1; }
.score-mid { text-align: center; font-size: .75rem; color: var(--muted); line-height: 1.2; }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; background: rgba(240,163,60,.16); border-bottom: 1px solid rgba(240,163,60,.4); font-size: .92rem; }
.banner-muted { background: rgba(255,255,255,.05); border-color: var(--line); color: var(--muted); }

.table-layout {
  flex: 1; min-height: 0; display: grid; gap: 6px; padding: 6px 8px 0;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas: "left top right" "board board board" "me me me";
}
.slot-left { grid-area: left; }
.slot-top { grid-area: top; }
.slot-right { grid-area: right; }
.slot-me { grid-area: me; }
.board-wrap { grid-area: board; min-height: 0; display: flex; }
.board-felt {
  position: relative; flex: 1; min-height: 0; border-radius: 18px; overflow: hidden;
  background:
    radial-gradient(90% 70% at 50% 45%, rgba(240,163,60,.10), transparent 70%),
    radial-gradient(120% 100% at 50% 50%, #1f2a22 0%, #151c17 60%, #0f1411 100%);
  border: 1px solid rgba(214,178,94,.35);
  box-shadow: inset 0 0 40px rgba(0,0,0,.6), 0 10px 30px rgba(0,0,0,.45);
  display: flex; flex-direction: column;
}
.board { flex: 1; width: 100%; min-height: 0; display: block; }
.ends { display: flex; justify-content: space-between; gap: 8px; padding: 8px 10px 0; font-size: .85rem; color: var(--muted); }
.end-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: rgba(0,0,0,.45); border: 1px solid var(--line); }
.end-chip b { font-family: var(--display); font-size: 1.15rem; color: var(--text); font-weight: 400; }
.end-chip.target { border-color: var(--lime); box-shadow: 0 0 0 1px var(--lime); color: var(--text); }
.last-move { margin: 0; padding: 4px 10px 8px; min-height: 1.6em; font-size: .88rem; color: var(--muted); text-align: center; }
.empty-board { fill: var(--muted); font: 600 0.5px var(--body); }

.seat { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 12px; background: rgba(20,20,22,.82); border: 1px solid var(--line); min-width: 0; position: relative; }
.seat.compact { flex-direction: column; text-align: center; gap: 4px; padding: 6px 4px; }
.seat.is-turn { border-color: var(--lime); background: rgba(30,36,10,.9); }
.seat .who { min-width: 0; }
.seat .nm { font-weight: 700; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; display: block; }
.seat .sub { font-size: .72rem; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.turn-flag { display: inline-block; font-size: .68rem; font-weight: 800; letter-spacing: .06em; color: #0b0b0a; background: var(--lime); padding: 1px 6px; border-radius: 6px; }
.count-row { display: flex; gap: 2px; justify-content: center; margin-top: 2px; }
.count-row i { width: 6px; height: 11px; border-radius: 2px; background: var(--tile); opacity: .85; display: block; }
.bubble { position: absolute; left: 50%; top: -6px; transform: translate(-50%, -100%); background: var(--text); color: #0b0b0a; font-weight: 700; font-size: .8rem; padding: 5px 9px; border-radius: 10px; white-space: nowrap; z-index: 4; animation: pop .25s ease-out; pointer-events: none; }
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -5px; border: 5px solid transparent; border-top-color: var(--text); border-bottom: 0; transform: translateX(-50%); }
.slot-me .bubble { top: -4px; }

.dock { padding: 6px 8px calc(8px + var(--safe-b)); display: flex; flex-direction: column; gap: 6px; background: linear-gradient(180deg, transparent, rgba(11,11,10,.92) 18%); }
.turn-status { margin: 0; text-align: center; font-weight: 600; min-height: 1.4em; font-size: .95rem; }
.turn-status .you-turn { color: var(--lime); }
.hand { display: flex; gap: 6px; justify-content: center; flex-wrap: nowrap; overflow-x: auto; padding: 6px 2px 4px; scrollbar-width: thin; }
.htile { flex: none; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 9px; position: relative; transition: transform .14s ease, opacity .14s; }
.htile svg { display: block; width: 44px; height: 84px; }
.htile.legal { transform: translateY(-6px); }
.htile.legal::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -6px; height: 3px; border-radius: 3px; background: var(--lime); }
.htile.dim { opacity: .5; }
.htile.selected { transform: translateY(-14px); }
.htile.selected svg rect.face { stroke: var(--lime); stroke-width: 3; }
.htile[aria-disabled="true"] { cursor: default; }
.play-controls { display: flex; gap: 8px; justify-content: center; min-height: 0; }
.play-controls .btn { width: auto; flex: 1; max-width: 260px; }
.reactions { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }

/* overlays & dialogs */
.overlay { position: fixed; inset: 0; z-index: 20; display: grid; place-items: end center; background: rgba(0,0,0,.55); padding: 12px; }
.sheet { width: min(520px, 100%); max-height: 88svh; overflow: auto; background: var(--charcoal); border: 1px solid var(--line); border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 12px; animation: rise .25s ease-out; margin-bottom: var(--safe-b); }
.dialog { width: min(560px, calc(100% - 24px)); max-height: 88svh; border: 1px solid var(--line); border-radius: 18px; background: var(--charcoal); color: var(--text); padding: 0; }
.dialog-sm { width: min(380px, calc(100% - 24px)); }
.dialog::backdrop { background: rgba(0,0,0,.65); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--charcoal); }
.dialog-body { padding: 14px 16px 18px; }
.prose h3 { font-family: var(--display); font-weight: 400; font-size: 1.15rem; margin: 16px 0 6px; letter-spacing: .02em; color: var(--lime); }
.prose ul { padding-left: 1.2em; margin: 0; }
.prose li { margin: 4px 0; }
.share-canvas { width: 100%; height: auto; border-radius: 12px; border: 1px solid var(--line); background: #000; }

.hs-grid { display: grid; gap: 8px; }
.hs-row { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: center; padding: 8px 10px; border-radius: 10px; background: var(--surface); }
.hs-tiles { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.hs-tiles svg { width: 34px; height: 17px; }
.hs-points { font-family: var(--display); font-size: 1.3rem; }
.hs-headline { font-size: 1.05rem; margin: 0; }

/* results */
.win-title { text-align: center; }
.final-score { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; text-align: center; }
.final-score .big { font-family: var(--display); font-size: 3.4rem; line-height: 1; }
.final-score .vs { color: var(--muted); }
.table-scroll { overflow-x: auto; }
.hands-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.hands-table th, .hands-table td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.hands-table td.num, .hands-table th.num { text-align: right; }
.results-actions { display: flex; flex-direction: column; gap: 10px; }
.winner-glow { animation: glow 1.6s ease-in-out 2; }

.toast { position: fixed; left: 50%; bottom: calc(16px + var(--safe-b)); transform: translateX(-50%); z-index: 40; background: var(--text); color: #0b0b0a; font-weight: 700; padding: 10px 16px; border-radius: 12px; max-width: calc(100% - 32px); text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.toast.err { background: #ffd2cc; }

/* board tile animation */
.placed-new { animation: slam .32s cubic-bezier(.2,.9,.3,1.2); transform-box: fill-box; transform-origin: center; }
.deal-in { animation: deal .36s ease-out both; }

@keyframes slam { 0% { transform: scale(1.35); opacity: 0; } 60% { transform: scale(.96); opacity: 1; } 100% { transform: scale(1); } }
@keyframes deal { from { transform: translateY(26px) rotate(-6deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pop { from { transform: translate(-50%, -80%) scale(.8); opacity: 0; } to { transform: translate(-50%, -100%) scale(1); opacity: 1; } }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes glow { 0%,100% { text-shadow: 0 0 0 transparent; } 50% { text-shadow: 0 0 22px rgba(208,249,2,.75); } }

/* ── larger screens: real table layout ─────────────── */
@media (min-width: 900px) and (min-height: 600px) {
  .table-layout {
    grid-template-columns: 170px 1fr 170px;
    grid-template-rows: auto 1fr auto;
    grid-template-areas: ". top ." "left board right" ". me .";
    padding: 10px 16px 0; gap: 10px;
  }
  .slot-left, .slot-right { align-self: center; }
  .slot-top, .slot-me { justify-self: center; width: min(340px, 100%); }
  .seat.compact { padding: 12px 8px; }
  .htile svg { width: 54px; height: 104px; }
  .dock { align-items: center; }
  .reactions { justify-content: center; }
  .portrait.sm { width: 56px; height: 56px; }
}
@media (min-width: 900px) {
  .narrow { padding-top: 28px; }
}
@media (max-height: 640px) and (max-width: 899px) {
  .htile svg { width: 38px; height: 72px; }
  .reactions { display: none; }
}

/* reduced motion: the OS setting or the in-game toggle */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .hero-video { display: none; } /* .hero's own poster background shows instead */
}
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation: none !important; transition: none !important; }
.reduce-motion .hero-video { display: none; }
