/* Layout: coluna única de telemóvel; cabeçalho, energia em 24 células, cartões de ação, navegação fixa em baixo. */
:root {
  --bg: #E9EDF5;
  --surface: #F8FAFD;
  --surface-2: #DDE4F0;
  --ink: #1A2240;
  --muted: #59627F;
  --line: #C3CCE0;
  --primary: #2A55E0;
  --on-primary: #FFFFFF;
  --energy: #E89A00;
  --energy-off: #CBD3E4;
  --good: #188A5E;
  --bad: #B3321F;
  --skin: #E8B98F;
  --hair: #3B2A20;
  --win: #F6E7A8;
  --pix-dark: #1A2240;
  --road: #9AA4C0;
  --roadline: #E9EDF5;
  --font-display: 'Pixelify Sans', 'Courier New', monospace;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11162A; --surface: #1A2140; --surface-2: #232C52; --ink: #E7ECFB; --muted: #9AA5C9;
    --line: #2F3A66; --primary: #7F9CFF; --on-primary: #0E1330; --energy: #FFC53D; --energy-off: #2B345C;
    --good: #4CD3A0; --bad: #FF8E7A; --skin: #D9A67D; --hair: #8C6A55;
    --win: #FFD966; --pix-dark: #0A0E1F; --road: #2A3158; --roadline: #5A6597;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11162A; --surface: #1A2140; --surface-2: #232C52; --ink: #E7ECFB; --muted: #9AA5C9;
  --line: #2F3A66; --primary: #7F9CFF; --on-primary: #0E1330; --energy: #FFC53D; --energy-off: #2B345C;
  --good: #4CD3A0; --bad: #FF8E7A; --skin: #D9A67D; --hair: #8C6A55;
  --win: #FFD966; --pix-dark: #0A0E1F; --road: #2A3158; --roadline: #5A6597;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--font-body);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 16px 84px;
}
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; padding: 0; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; text-wrap: balance; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

.wrap { max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }

/* Cabeçalho */
.top { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: center; }
.avatar { grid-row: span 2; }
.av-skin { fill: var(--skin); } .av-hair { fill: var(--hair); } .av-legs { fill: var(--ink); } .av-pip { fill: var(--energy); }
.who { min-width: 0; }
.who h1 { font-size: 1.5rem; line-height: 1.1; overflow-wrap: anywhere; }
.sub { color: var(--muted); font-size: .85rem; }
.stats { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 4px; }
.stats div { background: var(--surface); border: 2px solid var(--line); border-radius: 4px; padding: 8px; min-width: 0; }
.stats dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.stats dd { font-family: var(--font-display); font-size: 1.05rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* Energia */
.energy { background: var(--surface); border: 2px solid var(--ink); border-radius: 4px; padding: 12px; box-shadow: 0 3px 0 var(--ink); }
.energy-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.energy h2 { font-size: 1.1rem; }
.energy-num { font-family: var(--font-display); font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.cells { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; }
.cell { height: 14px; background: var(--energy-off); border-radius: 2px; }
.cell.on { background: var(--energy); }
.cell.next { background: var(--energy-off); outline: 2px solid var(--energy); outline-offset: -2px; animation: blink 1.6s steps(2) infinite; }
@keyframes blink { 50% { outline-color: transparent; } }
.hint { color: var(--muted); font-size: .82rem; margin-top: 6px; font-variant-numeric: tabular-nums; }
.energy .hint { margin-top: 8px; }

/* Aviso */
.toast { min-height: 2.6em; padding: 8px 12px; border-radius: 4px; font-size: .9rem; border: 2px solid var(--line); background: var(--surface); }
.toast.ok { border-color: var(--good); }
.toast.bad { border-color: var(--bad); }
.toast.empty { visibility: hidden; }

/* Cartões */
.stack { display: flex; flex-direction: column; gap: 10px; }
.card { background: var(--surface); border: 2px solid var(--line); border-radius: 4px; padding: 12px; display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.card-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.card h3 { font-size: 1.1rem; }
.card p { color: var(--muted); font-size: .88rem; }
.card p strong { color: var(--ink); }
.eyebrow { font-size: .72rem !important; letter-spacing: .1em; text-transform: uppercase; font-weight: 600; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .82rem !important; color: var(--ink) !important; }
.cost { color: var(--energy); font-weight: 600; }
.lock { color: var(--bad) !important; font-size: .82rem !important; }
.note { color: var(--muted); font-size: .88rem; }
.btn-col { display: flex; flex-direction: column; gap: 8px; }

.btn { min-height: 44px; padding: 8px 14px; border: 2px solid var(--ink); border-bottom-width: 4px; border-radius: 4px; background: var(--surface); cursor: pointer; font-weight: 600; white-space: nowrap; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; }
.btn small { font-weight: 400; font-size: .7rem; }
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.danger { background: var(--bad); color: var(--bg); }
.btn:active:not(:disabled) { transform: translateY(2px); border-bottom-width: 2px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.bar { height: 12px; background: var(--surface-2); border-radius: 2px; overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; background: var(--good); }

/* Listas */
.log h2, .ladder h2, .board h2 { font-size: 1.1rem; margin-bottom: 8px; }
.log ul { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.log li { font-size: .85rem; color: var(--muted); border-left: 3px solid var(--line); padding-left: 8px; }
.ladder ol, .board ol { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.ladder li { display: flex; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 4px; background: var(--surface); border: 2px solid var(--line); font-size: .9rem; }
.ladder li.done { color: var(--muted); }
.ladder li.here { border-color: var(--primary); font-weight: 600; }
.board li { display: grid; grid-template-columns: 2.2em 1fr auto; gap: 8px; align-items: center; padding: 9px 10px; border-radius: 4px; background: var(--surface); border: 2px solid var(--line); }
.board li.me { border-color: var(--primary); background: var(--surface-2); font-weight: 600; }
.board .pos { font-family: var(--font-display); font-size: 1.1rem; }
.board .nm { min-width: 0; overflow-wrap: anywhere; }
.board .pt { font-variant-numeric: tabular-nums; }

/* Cidade: ruas = espaços entre edifícios, com traço central */
.city { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 16px; background: var(--road); border: 2px solid var(--ink); border-radius: 4px; }
.building { position: relative; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px 8px; background: var(--surface); border: 2px solid var(--ink); border-bottom-width: 4px; border-radius: 4px; cursor: pointer; text-align: center; }
.building:nth-child(odd)::before { content: ""; position: absolute; top: 0; bottom: 0; right: -11px; border-right: 3px dashed var(--roadline); }
.building:last-child:nth-child(odd) { grid-column: 1 / -1; }
.building:last-child:nth-child(odd)::before { display: none; }
.building:nth-child(-n+12)::after { content: ""; position: absolute; left: 0; right: 0; bottom: -13px; border-bottom: 3px dashed var(--roadline); }
.building:active { transform: translateY(2px); border-bottom-width: 2px; }
.art { max-width: 100%; height: auto; }
.art .siren-r { fill: #E04A3F; } .art .siren-b { fill: #3F7BE0; }
.art .win { fill: var(--win); } .art .dark { fill: var(--pix-dark); } .art .cross { fill: #fff; } .art .awn { fill: var(--surface); }
.b-name { font-family: var(--font-display); font-size: .95rem; line-height: 1.15; text-wrap: balance; max-width: 100%; overflow-wrap: anywhere; }
.b-tag { font-size: .72rem; line-height: 1.25; color: var(--muted); padding: 2px 6px; border: 2px solid var(--line); border-radius: 3px; overflow-wrap: anywhere; }
.b-tag.you { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.b-tag.ok { border-color: var(--good); color: var(--good); }
.b-tag.lock { border-color: var(--bad); color: var(--bad); }
.chips-rank { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.rank-chip { font-size: .7rem; font-weight: 600; line-height: 1.2; padding: 2px 6px; border: 2px solid var(--primary); color: var(--primary); border-radius: 3px; }
.rank-chip.crime { border-color: var(--bad); color: var(--bad); }
.rank-card .bar i { background: var(--primary); }
.rank-card.crime .bar i { background: var(--bad); }
.rank-card.crime .eyebrow { color: var(--bad); }
.crimes { display: flex; flex-direction: column; gap: 8px; }
.crimes h2 { font-size: 1.1rem; }
.bank-form .card-main { gap: 8px; }
.field-label { font-weight: 600; font-size: .88rem; }
.field { width: 100%; min-height: 46px; padding: 8px 12px; font: inherit; color: var(--ink); background: var(--bg); border: 2px solid var(--ink); border-radius: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 36px; padding: 4px 10px; font-size: .82rem; font-weight: 600; background: var(--surface-2); border: 2px solid var(--line); border-radius: 4px; cursor: pointer; }
.row-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.risk { color: var(--muted) !important; }
.price { font-weight: 600; }
.shop, .inventory { display: flex; flex-direction: column; gap: 8px; }
.shop h2, .inventory h2 { font-size: 1.1rem; }
.inventory ul { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.inventory li { display: flex; justify-content: space-between; gap: 8px; padding: 8px 10px; background: var(--surface); border: 2px solid var(--line); border-radius: 4px; font-size: .9rem; }
.arrest { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; margin-top: 4vh; padding: 20px 16px; background: var(--surface); border: 2px solid var(--bad); border-bottom-width: 5px; border-radius: 4px; }
.arrest .art, .intro .art { width: 96px; height: 96px; }
.arrest .eyebrow { color: var(--bad); }
.arrest h1 { font-size: 2rem; line-height: 1.05; color: var(--bad); }
.intro { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; margin-top: 4vh; padding: 20px 16px; background: var(--surface); border: 2px solid var(--line); border-bottom-width: 5px; border-radius: 4px; }
.intro h1 { font-size: 1.7rem; line-height: 1.1; text-wrap: balance; }
.arrest-text { max-width: 34ch; text-wrap: balance; }
.arrest-rows { align-self: stretch; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.arrest-rows div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 10px; background: var(--bg); border: 2px solid var(--line); border-radius: 4px; }
.arrest-rows dt { color: var(--muted); }
.arrest-rows dd { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; min-width: 0; overflow-wrap: anywhere; }
.arrest-rows .loss { color: var(--bad); }
.arrest .btn { align-self: stretch; }
.place-head { display: flex; align-items: center; gap: 12px; }
.place-head h2 { font-size: 1.2rem; min-width: 0; }
.btn.back { flex-direction: row; min-height: 40px; }

/* Boas-vindas */
.welcome { max-width: 420px; margin: 8vh auto 0; display: flex; flex-direction: column; gap: 14px; }
.welcome h1 { font-size: 2.2rem; line-height: 1.05; }
.welcome p { color: var(--muted); }
.welcome form { display: flex; flex-direction: column; gap: 8px; }
.welcome label { font-weight: 600; }
.welcome h2 { font-size: 1.2rem; margin-top: 4px; }
.auth-error { color: var(--bad); font-weight: 600; font-size: .9rem; }
.welcome input { min-height: 46px; padding: 8px 12px; font: inherit; color: var(--ink); background: var(--surface); border: 2px solid var(--ink); border-radius: 4px; }

/* Navegação */
.nav { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 2px solid var(--ink); padding-bottom: env(safe-area-inset-bottom, 0px); }
.nav-in { max-width: 520px; margin: 0 auto; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding-left: max(8px, env(safe-area-inset-left, 0px)); padding-right: max(8px, env(safe-area-inset-right, 0px)); }
.nav button { background: none; border: 0; min-height: 56px; font-weight: 600; font-size: .85rem; color: var(--muted); cursor: pointer; border-top: 4px solid transparent; }
.nav button[aria-current="page"] { color: var(--ink); border-top-color: var(--primary); }

@media (max-width: 380px) {
  .card { flex-direction: column; align-items: stretch; }
  .btn-col { flex-direction: row; }
  .btn { white-space: normal; }
}
@media (prefers-reduced-motion: reduce) { .cell.next { animation: none; } }

/* Escolha de língua (PT / EN) */
.lang { display: flex; gap: 8px; align-self: flex-end; }
.lang .chip { min-width: 48px; }
.lang .chip.on { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }

/* Casino & card games */
:root { --felt: #17604A; --felt-edge: #7A4A24; --felt-ink: #F4F1E4; --felt-seat: #0F4636; --gold: #FFD257; --card-face: #FFFFFF; --card-ink: #151A2E; --card-red: #C0231F; --card-back: #9B2F3F; }
.sub-back { align-self: flex-start; }
.lobby { display: flex; flex-direction: column; gap: 12px; padding: 12px; background: var(--surface); border: 2px solid var(--line); border-radius: 4px; }
.lobby h2 { font-size: 1.3rem; }
.lobby ol { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.lobby li { display: flex; justify-content: space-between; gap: 8px; padding: 9px 10px; border: 2px solid var(--primary); border-radius: 4px; font-weight: 600; overflow-wrap: anywhere; }
.lobby li.empty { border: 2px dashed var(--line); color: var(--muted); font-weight: 400; }
.lobby .dots i { font-style: normal; animation: fade 1.4s steps(2) infinite; }
@keyframes fade { 50% { opacity: .2; } }
.table-head .sub { margin: 0; }
.felt { display: flex; flex-direction: column; gap: 10px; padding: 8px; background: var(--felt); color: var(--felt-ink); border: 6px solid var(--felt-edge); border-radius: 22px; }
.opponents { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-areas: "b c d" "a . e"; gap: 6px; }
.opponents .s1 { grid-area: a; } .opponents .s2 { grid-area: b; } .opponents .s3 { grid-area: c; } .opponents .s4 { grid-area: d; } .opponents .s5 { grid-area: e; }
.seat { position: relative; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; background: var(--felt-seat); border: 2px solid transparent; border-radius: 8px; text-align: center; font-size: .72rem; line-height: 1.25; }
.seat.turn, .hero-seat.turn { border-color: var(--gold); }
.seat.winner, .hero-seat.winner { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.seat.folded .seat-name, .seat.folded .seat-chips, .hero-seat.folded .hero-cards { opacity: .5; }
.seat-name { font-weight: 600; font-size: .8rem; max-width: 100%; overflow-wrap: anywhere; }
.dealer { display: inline-block; width: 16px; height: 16px; margin-right: 4px; border-radius: 50%; background: var(--card-face); color: var(--card-ink); font-size: .65rem; line-height: 16px; text-align: center; vertical-align: 1px; }
.seat-cards { display: flex; gap: 2px; height: 36px; }
.seat-chips { font-variant-numeric: tabular-nums; }
.seat-status { color: var(--gold); font-weight: 600; min-height: 1.25em; }
.seat-bet { padding: 0 6px; border-radius: 9px; background: var(--gold); color: var(--card-ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.middle { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pot { font-family: var(--font-display); font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.board-cards { display: flex; justify-content: center; gap: 4px; max-width: 100%; }
.pc { flex: none; width: 26px; height: 36px; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; background: var(--card-face); color: var(--card-ink); border-radius: 3px; line-height: 1; }
.pc b { font-size: .8rem; } .pc i { font-style: normal; font-size: .85rem; }
.pc.red { color: var(--card-red); }
.pc.big { width: 46px; height: 64px; border-radius: 5px; }
.pc.big b { font-size: 1.2rem; } .pc.big i { font-size: 1.5rem; }
.pc.back { background: repeating-linear-gradient(45deg, var(--card-back) 0 3px, var(--card-face) 3px 4px); border: 2px solid var(--card-face); }
.pc.slot { background: transparent; border: 2px dashed rgba(244, 241, 228, .3); }
.hero-seat { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 8px; background: var(--felt-seat); border: 2px solid transparent; border-radius: 10px; }
.hero-cards { display: flex; gap: 4px; }
.hero-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: .85rem; }
.actions { display: flex; flex-direction: column; gap: 8px; min-height: 160px; }
.turn-line { text-align: center; color: var(--muted); font-weight: 600; }
.turn-line.you { color: var(--ink); }
.raise-box { display: flex; flex-direction: column; gap: 8px; }
.raise-box .chips { justify-content: space-between; }
.raise-box .chip { flex: 1; }
.raise-box input { width: 100%; height: 32px; accent-color: var(--primary); }
.poker-btns { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.poker-btns .btn { white-space: normal; text-align: center; padding-inline: 6px; font-variant-numeric: tabular-nums; }
.result { padding: 10px 12px; background: var(--surface); border: 2px solid var(--line); border-radius: 4px; text-align: center; font-weight: 600; }
.result.mine { border-color: var(--good); color: var(--good); }
@media (prefers-reduced-motion: reduce) { .lobby .dots i { animation: none; } }

/* Sueca */
.sueca-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 0 4px; font-size: .78rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.sueca-bar > span:first-child { display: flex; align-items: center; gap: 6px; }
.sueca-bar > span:last-child { text-align: right; }
.opponents.sueca-opps { grid-template-areas: "l p r"; }
.sueca-opps .q3 { grid-area: l; } .sueca-opps .q2 { grid-area: p; } .sueca-opps .q1 { grid-area: r; }
.mini-cards { display: flex; justify-content: center; height: 18px; padding-left: 6px; }
.mini-cards i { width: 11px; height: 18px; margin-left: -6px; border: 1px solid var(--card-face); border-radius: 2px; background: var(--card-back); }
.trick { display: grid; grid-template-columns: repeat(3, 46px); grid-template-areas: ". p ." "l . r" ". m ."; justify-content: center; gap: 2px 8px; }
.spot { display: flex; border-radius: 5px; }
.spot.q0 { grid-area: m; } .spot.q1 { grid-area: r; } .spot.q2 { grid-area: p; } .spot.q3 { grid-area: l; }
.spot.best { box-shadow: 0 0 0 3px var(--gold); }
.hero-seat.sueca-hero { flex-direction: column; gap: 6px; }
.sueca-hero .hero-info { flex-direction: row; gap: 10px; align-items: center; }
.sueca-hand { display: grid; grid-template-columns: repeat(5, 46px); justify-content: center; gap: 8px 6px; min-height: 136px; align-content: start; }
.card-btn { display: flex; padding: 0; border: 0; background: none; border-radius: 5px; cursor: pointer; }
.card-btn:disabled { cursor: default; }
.card-btn.off { opacity: .4; }
.card-btn:not(:disabled) { transform: translateY(-3px); box-shadow: 0 3px 0 var(--gold); }
.actions.sueca-actions { min-height: 0; }


/* Sprites em pixel art (folhas de 2 imagens) */
.spr { display: block; flex: none; background-repeat: no-repeat; background-size: 200% 100%; image-rendering: pixelated; animation: frames 1.2s steps(1) infinite; }
@keyframes frames { 0% { background-position: 0 0; } 50% { background-position: 100% 0; } }
.spr.bld { width: 100%; max-width: 256px; aspect-ratio: 4 / 3; border: 2px solid var(--ink); border-radius: 3px; }
.spr.avatar { width: 56px; height: 84px; }
.spr.inside { width: 100%; aspect-ratio: 8 / 3; border: 2px solid var(--ink); border-radius: 4px; }
.place-head + .inside { margin-bottom: 0; }
.intro .spr.bld, .arrest .spr.inside { align-self: stretch; margin: 0 auto; }
.city .building { padding: 6px 6px 8px; }
.fx { position: fixed; left: 50%; z-index: 20; pointer-events: none; padding: 4px 12px; font: 600 1.3rem var(--font-display); background: var(--surface); border: 2px solid currentColor; border-radius: 4px; opacity: 0; animation: rise 1.7s ease-out forwards; }
.fx.good { color: var(--good); } .fx.bad { color: var(--bad); } .fx.info { color: var(--primary); } .fx.energy { color: var(--ink); }
@keyframes rise { 0% { opacity: 0; transform: translate(-50%, 16px); } 15%, 70% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -44px); } }
.hud, .view { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.hud:empty { display: none; }
/* Computador: estado à esquerda, cidade ou local à direita */
@media (min-width: 920px) {
  .wrap.split { max-width: 1080px; display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 20px; align-items: start; }
  .split .hud { position: sticky; top: 16px; }
  .split .city { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .split .city .building::before, .split .city .building::after { display: none; }
  .split .view > .inside { max-height: none; }
}
@media (prefers-reduced-motion: reduce) { .spr { animation: none; } .fx { animation: none; opacity: 1; } }
