/* ============================================================
   O DILEMA DO REI · Pergaminho Real & Intriga Medieval
   Dark fantasy elegante · mobile-first · CSS puro
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  /* Paleta do reino */
  --bg:            #12100e;   /* noite fosca */
  --bg-raise:      #1c1915;   /* superfície elevada */
  --card:          #26221c;   /* couro/pergaminho escuro */
  --card-deep:     #201c17;
  --gold:          #b89552;   /* bordas e brasões */
  --gold-bright:   #d9b877;
  --gold-dim:      #6e5a33;
  --ivory:         #f4efe6;   /* texto principal */
  --ivory-dim:     #b3aa99;   /* texto secundário */
  --ivory-faint:   #7d7565;   /* texto terciário */
  --crimson:       #9e2a2b;   /* sangue e perigo */
  --crimson-bright:#c53a3b;
  --emerald:       #2d6a4f;   /* ganho e sucesso */
  --emerald-bright:#40916c;
  --amber:         #e9c46a;   /* aviso / moedas */
  --azure:         #4ea8de;   /* informação / poder */

  --line:          color-mix(in oklab, var(--gold) 32%, transparent);
  --line-soft:     color-mix(in oklab, var(--gold) 16%, transparent);
  --tint-gold:     color-mix(in oklab, var(--gold) 12%, var(--card));
  --tint-crimson:  color-mix(in oklab, var(--crimson) 16%, var(--card));
  --tint-emerald:  color-mix(in oklab, var(--emerald) 16%, var(--card));

  --font-display:  'Cinzel', 'Georgia', serif;
  --font-body:     'Inter', system-ui, -apple-system, sans-serif;
  --font-quote:    'Lora', 'Georgia', serif;

  --radius:        14px;
  --radius-sm:     10px;
  --nav-h:         72px;
  --topbar-h:      60px;
  --shadow:        0 10px 30px rgba(0, 0, 0, .45);
  --press:         scale(.96);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ivory);
  min-height: 100dvh;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* Vinheta fosca sobre o fundo (sem brilho, apenas profundidade) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(120% 90% at 50% 0%, #1c1915 0%, #12100e 58%, #0c0a08 100%);
  z-index: -2;
}

/* Grão de pergaminho */
.grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
}

img, svg { display: block; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
ul, ol { list-style: none; }
em.opt { font-style: normal; color: var(--ivory-faint); font-weight: 400; }

/* ---------- Scrollbar do reino ---------- */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--gold-dim) var(--bg-raise);
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-raise); }
::-webkit-scrollbar-thumb {
  background: var(--gold-dim);
  border-radius: 8px;
  border: 2px solid var(--bg-raise);
}
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* ---------- Estrutura de telas ---------- */
.screen {
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 16px calc(28px + env(safe-area-inset-bottom));
  min-height: 100dvh;
  animation: screen-in .35s ease both;
}
.screen[hidden] { display: none; }

@keyframes screen-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.screen-app {
  padding: 0 0 calc(var(--nav-h) + 18px + env(safe-area-inset-bottom));
}
.app-main { padding: 16px 16px 8px; }
.tab-panel { animation: screen-in .28s ease both; }
.tab-panel[hidden] { display: none; }

/* ---------- Cartão de couro ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 color-mix(in oklab, var(--gold) 14%, transparent),
              0 4px 14px rgba(0, 0, 0, .35);
}

/* ---------- Títulos ---------- */
.section-title {
  font-family: var(--font-display);
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 26px 2px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line-soft);
}

.panel-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ivory);
  margin: 6px 2px 2px;
}
.panel-sub { color: var(--ivory-dim); font-size: .9rem; margin: 0 2px 16px; }

.empty-hint {
  color: var(--ivory-faint);
  font-size: .92rem;
  text-align: center;
  padding: 22px 12px;
  border: 1px dashed var(--line-soft);
  border-radius: var(--radius);
  margin-top: 10px;
}

.screen-hint {
  color: var(--ivory-dim);
  font-size: .92rem;
  margin: 14px 2px;
}

/* ============================================================
   LOBBY
   ============================================================ */
.lobby-hero { text-align: center; padding: 34px 0 10px; }
.lobby-crown { display: flex; justify-content: center; margin-bottom: 14px; }
.lobby-crown svg { filter: drop-shadow(0 4px 12px rgba(184, 149, 82, .25)); }

.lobby-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(1.9rem, 7vw, 2.6rem);
  letter-spacing: .04em;
  color: var(--gold-bright);
  text-shadow: 0 2px 18px rgba(184, 149, 82, .22);
}
.lobby-sub {
  font-family: var(--font-quote);
  font-style: italic;
  color: var(--ivory-dim);
  margin-top: 6px;
  font-size: .98rem;
}

.campaign-form { margin-top: 26px; }
.field-row { display: flex; gap: 10px; }
.field-row input { flex: 1; min-width: 0; }

.campaign-list { display: flex; flex-direction: column; gap: 12px; }
.campaign-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 6px 6px;
  width: 100%;
  text-align: left;
  transition: border-color .2s ease;
}
.campaign-item:hover { border-color: var(--gold); }

.campaign-open {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 10px;
  text-align: left;
  transition: transform .12s ease;
}
.campaign-open:active { transform: var(--press); }

.campaign-seal {
  width: 46px; height: 46px;
  flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--tint-gold);
  border: 1px solid var(--line);
  color: var(--gold-bright);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
}
.campaign-info { flex: 1; min-width: 0; }
.campaign-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ivory);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.campaign-meta { font-size: .8rem; color: var(--ivory-dim); margin-top: 2px; }
.campaign-meta b { color: var(--gold); font-weight: 600; }

.campaign-go { color: var(--gold); flex: none; }
.campaign-del {
  flex: none;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 10px;
  color: var(--ivory-faint);
  transition: color .15s, background .15s;
}
.campaign-del:hover { color: var(--crimson-bright); background: var(--tint-crimson); }

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--topbar-h);
  padding: 10px 12px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: color-mix(in oklab, var(--bg-raise) 92%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-soft);
}
.screen > .topbar { margin: -20px -16px 0; }
.screen-app > .topbar { margin: 0; }

.topbar-titles { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar-kicker {
  font-size: .68rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ivory-faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-title {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--gold-bright);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-badge {
  flex: none;
  font-size: .78rem;
  font-weight: 700;
  color: var(--gold);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--tint-gold);
  font-variant-numeric: tabular-nums;
}

.icon-btn {
  flex: none;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 12px;
  color: var(--ivory-dim);
  border: 1px solid transparent;
  transition: color .15s, background .15s, transform .1s;
}
.icon-btn:hover { color: var(--gold-bright); background: var(--tint-gold); }
.icon-btn:active { transform: var(--press); }

.privacy-btn .eye-closed { display: none; }
body.privacy .privacy-btn { color: var(--amber); border-color: var(--line); background: var(--tint-gold); }
body.privacy .privacy-btn .eye-open { display: none; }
body.privacy .privacy-btn .eye-closed { display: block; }

/* ---------- Modo privacidade ---------- */
.secret, .secret-text { transition: filter .25s ease; }
body.privacy .secret {
  filter: blur(9px);
  user-select: none;
}
body.privacy .secret-text { filter: blur(6px); }
body.privacy .secret-text:focus { filter: none; } /* ao editar, o dono vê */

/* ============================================================
   BRASÕES (escudos)
   ============================================================ */
.crest {
  --crest-color: var(--gold);
  --crest-size: 46px;
  width: var(--crest-size);
  height: calc(var(--crest-size) * 1.12);
  flex: none;
  position: relative;
  background: var(--gold);
  clip-path: polygon(0 0, 100% 0, 100% 62%, 50% 100%, 0 62%);
  display: grid; place-items: center;
}
.crest::before {
  content: '';
  position: absolute;
  inset: 2px;
  background: color-mix(in oklab, var(--crest-color) 78%, #12100e);
  clip-path: polygon(0 0, 100% 0, 100% 62%, 50% 100%, 0 62%);
}
.crest-glyph {
  position: relative;
  font-size: calc(var(--crest-size) * .44);
  line-height: 1;
  margin-top: calc(var(--crest-size) * -.12);
  filter: saturate(1.1);
}
.crest-lg { --crest-size: 62px; }

/* ============================================================
   SELEÇÃO DE CASA
   ============================================================ */
.house-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
@media (min-width: 560px) { .house-grid { grid-template-columns: repeat(3, 1fr); } }

.house-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 12px 14px;
  text-align: center;
  transition: transform .12s ease, border-color .2s ease, box-shadow .2s ease;
  animation: card-in .4s ease both;
}
.house-card:nth-child(1)  { animation-delay: .02s; }
.house-card:nth-child(2)  { animation-delay: .05s; }
.house-card:nth-child(3)  { animation-delay: .08s; }
.house-card:nth-child(4)  { animation-delay: .11s; }
.house-card:nth-child(5)  { animation-delay: .14s; }
.house-card:nth-child(6)  { animation-delay: .17s; }
.house-card:nth-child(7)  { animation-delay: .20s; }
.house-card:nth-child(8)  { animation-delay: .23s; }
.house-card:nth-child(9)  { animation-delay: .26s; }
.house-card:nth-child(10) { animation-delay: .29s; }
.house-card:nth-child(11) { animation-delay: .32s; }
.house-card:nth-child(12) { animation-delay: .35s; }

@keyframes card-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

.house-card:not(.is-taken):hover {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--line), 0 8px 22px rgba(0, 0, 0, .4);
}
.house-card:not(.is-taken):active { transform: var(--press); }

.house-card-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--ivory);
}
.house-card-motto {
  font-family: var(--font-quote);
  font-style: italic;
  font-size: .76rem;
  color: var(--ivory-dim);
  line-height: 1.35;
}
.house-card-status {
  margin-top: 2px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
}
.house-card:not(.is-taken) .house-card-status {
  color: var(--emerald-bright);
  background: var(--tint-emerald);
  border: 1px solid color-mix(in oklab, var(--emerald) 45%, transparent);
}
.house-card.is-taken { opacity: .82; }
.house-card.is-taken .house-card-status {
  color: var(--amber);
  background: color-mix(in oklab, var(--amber) 12%, var(--card));
  border: 1px solid color-mix(in oklab, var(--amber) 35%, transparent);
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.house-card.is-mine {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold), 0 8px 24px rgba(184, 149, 82, .15);
  opacity: 1;
}
.house-release {
  position: absolute;
  top: 8px; right: 8px;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 9px;
  color: var(--ivory-faint);
  background: color-mix(in oklab, var(--bg) 55%, transparent);
  border: 1px solid var(--line-soft);
  transition: color .15s, border-color .15s;
}
.house-release:hover { color: var(--crimson-bright); border-color: var(--crimson); }

/* ============================================================
   BOTÕES & CAMPOS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 12px 22px;
  border-radius: 12px;
  font-weight: 700;
  font-size: .95rem;
  letter-spacing: .02em;
  border: 1px solid transparent;
  transition: transform .1s ease, filter .15s ease, background .15s ease;
  user-select: none;
}
.btn:active { transform: var(--press); }
.btn-block { width: 100%; }

.btn-gold {
  background: var(--gold);
  color: #1c1508;
  box-shadow: 0 4px 14px rgba(184, 149, 82, .25);
}
.btn-gold:hover { filter: brightness(1.1); }

.btn-crimson {
  background: var(--crimson);
  color: var(--ivory);
  border-color: color-mix(in oklab, var(--crimson-bright) 60%, transparent);
  box-shadow: 0 4px 16px rgba(158, 42, 43, .3);
  font-family: var(--font-display);
  letter-spacing: .06em;
}
.btn-crimson:hover { filter: brightness(1.15); }

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ivory-dim);
}
.btn-ghost:hover { color: var(--ivory); border-color: var(--gold); }
.btn-danger-text { color: var(--crimson-bright); margin-top: 26px; width: 100%; }
.btn-danger-text:hover { border-color: var(--crimson); color: var(--crimson-bright); }

.btn[disabled] { opacity: .5; pointer-events: none; }

.field-label {
  display: block;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 18px 2px 8px;
}
.campaign-form .field-label { margin-top: 0; }

input[type="text"], input[type="number"], textarea, select {
  width: 100%;
  background: var(--card-deep);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  min-height: 50px;
  color: var(--ivory);
  font-size: 1rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
input::placeholder, textarea::placeholder { color: var(--ivory-faint); }
input:focus, textarea:focus, select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--gold) 22%, transparent);
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%23b89552' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}
select option { background: var(--card-deep); color: var(--ivory); }

/* ============================================================
   ABA 1 · MEU BIOMBO
   ============================================================ */
.house-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px;
  border-color: color-mix(in oklab, var(--banner-color, var(--gold)) 55%, var(--line));
}
.house-banner-text { min-width: 0; }
.house-name {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: .03em;
  color: var(--ivory);
}
.house-motto {
  font-family: var(--font-quote);
  font-style: italic;
  color: var(--gold-bright);
  font-size: .92rem;
  margin-top: 2px;
}

.vault-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.counter-card { padding: 16px 12px 12px; text-align: center; }
.counter-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 6px;
}
.counter-icon { display: grid; place-items: center; }
.coin-icon { color: var(--amber); }
.power-icon { color: var(--azure); }
.counter-label {
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ivory-dim);
}
.counter-value {
  display: block;
  font-size: 3rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  color: var(--ivory);
}
.counter-value.bump { animation: bump .22s ease; }
@keyframes bump {
  40% { transform: scale(1.14); color: var(--gold-bright); }
}

.counter-btns {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 10px;
}
.step-btn {
  min-height: 48px;
  border-radius: 10px;
  border: 1px solid var(--line-soft);
  background: var(--card-deep);
  color: var(--ivory-dim);
  font-weight: 800;
  font-size: .95rem;
  font-variant-numeric: tabular-nums;
  transition: transform .08s ease, background .15s, color .15s, border-color .15s;
  user-select: none;
  touch-action: manipulation;
}
.step-btn:active { transform: scale(.92); }
.step-btn:hover { border-color: var(--gold); color: var(--ivory); }
.step-btn.step-plus {
  background: var(--tint-gold);
  border-color: var(--line);
  color: var(--gold-bright);
}
.step-btn.step-plus:hover { background: color-mix(in oklab, var(--gold) 22%, var(--card)); }

.dynasty-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.total-card { padding: 16px; text-align: center; position: relative; }
.total-prestige { background: var(--tint-emerald); border-color: color-mix(in oklab, var(--emerald) 45%, transparent); }
.total-greed    { background: var(--tint-crimson); border-color: color-mix(in oklab, var(--crimson) 45%, transparent); }
.total-label {
  display: block;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--ivory-dim);
}
.total-value {
  display: block;
  font-size: 2.5rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}
.total-prestige .total-value { color: #7cc9a5; }
.total-greed .total-value { color: #e08a8b; }
.edit-link {
  font-size: .78rem;
  font-weight: 600;
  color: var(--ivory-faint);
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 6px 10px;
  border-radius: 8px;
}
.edit-link:hover { color: var(--gold-bright); }

.notes-card { padding: 14px; }
.notes-card textarea {
  border: 0;
  background: transparent;
  padding: 4px;
  min-height: 110px;
  box-shadow: none;
  font-family: var(--font-quote);
  font-size: .98rem;
}
.notes-card textarea:focus { box-shadow: none; }
.notes-foot { display: flex; justify-content: flex-end; margin-top: 6px; }
.notes-status { font-size: .74rem; color: var(--ivory-faint); transition: color .2s; }
.notes-status.saving { color: var(--amber); }
.notes-status.saved  { color: var(--emerald-bright); }

/* ============================================================
   ABA 2 · ENCERRAR REI
   ============================================================ */
.reign-form { padding: 6px 16px 18px; }
.reign-form .field-label:first-child { margin-top: 14px; }

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.seg-option { position: relative; }
.seg-option input { position: absolute; opacity: 0; inset: 0; }
.seg-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
  background: var(--card-deep);
  color: var(--ivory-dim);
  font-weight: 700;
  cursor: pointer;
  transition: all .15s ease;
}
.seg-option input:checked + span {
  border-color: var(--gold);
  background: var(--tint-gold);
  color: var(--gold-bright);
  box-shadow: 0 0 0 1px var(--gold);
}
.seg-option input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }
.seg-option:active span { transform: var(--press); }

.reign-scores { display: flex; flex-direction: column; gap: 10px; }
.score-row {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--card-deep);
  padding: 12px;
}
.score-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.score-head .crest { --crest-size: 30px; }
.score-house { flex: 1; min-width: 0; }
.score-house-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .92rem;
  color: var(--ivory);
  display: block;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.score-player { font-size: .72rem; color: var(--ivory-faint); }

.score-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.score-field { display: flex; flex-direction: column; gap: 5px; }
.score-field-label {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.score-field.prestige .score-field-label { color: #7cc9a5; }
.score-field.greed .score-field-label { color: #e08a8b; }
.score-stepper { display: flex; align-items: stretch; gap: 5px; }
.score-stepper .step-btn { min-height: 44px; flex: none; width: 44px; font-size: 1.1rem; }
.score-stepper input {
  min-height: 44px;
  padding: 8px 4px;
  text-align: center;
  font-weight: 800;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
  appearance: textfield;
}
.score-stepper input::-webkit-outer-spin-button,
.score-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.check-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--card-deep);
  cursor: pointer;
  font-size: .88rem;
  color: var(--ivory-dim);
  min-height: 50px;
}
.check-row input[type="checkbox"] {
  appearance: none;
  flex: none;
  width: 26px; height: 26px;
  border-radius: 7px;
  border: 2px solid var(--gold-dim);
  background: var(--bg);
  display: grid; place-items: center;
  cursor: pointer;
  transition: all .15s;
}
.check-row input[type="checkbox"]:checked {
  background: var(--gold);
  border-color: var(--gold);
}
.check-row input[type="checkbox"]:checked::after {
  content: '';
  width: 12px; height: 7px;
  border-left: 2.5px solid #1c1508;
  border-bottom: 2.5px solid #1c1508;
  transform: rotate(-45deg) translateY(-1px);
}
.check-row input[type="checkbox"]:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.score-sign { margin-top: 10px; }
.score-sign span { font-size: .82rem; }

#btn-end-reign { margin-top: 20px; }

/* ============================================================
   ABA 3 · CRÔNICAS & RANKING
   ============================================================ */
.ranking-card { padding: 6px 0; overflow: hidden; margin-bottom: 8px; }
.ranking-table { width: 100%; border-collapse: collapse; }
.ranking-table th {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--gold);
  text-align: left;
  padding: 12px 10px 8px;
  border-bottom: 1px solid var(--line-soft);
}
.ranking-table th.num, .ranking-table td.num { text-align: right; }
.ranking-table td {
  padding: 11px 10px;
  border-bottom: 1px solid color-mix(in oklab, var(--gold) 8%, transparent);
  font-size: .92rem;
  vertical-align: middle;
}
.ranking-table tr:last-child td { border-bottom: 0; }
.ranking-table td.num {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  font-size: 1rem;
}
.ranking-table td.num.pos { color: #7cc9a5; }
.ranking-table td.num.neg { color: #e08a8b; }
.ranking-table td.num.zero { color: var(--ivory-faint); }

.rank-house { display: flex; align-items: center; gap: 10px; min-width: 0; }
.rank-pos {
  flex: none;
  width: 22px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .85rem;
  color: var(--ivory-faint);
  text-align: center;
}
.rank-pos.p1 { color: var(--gold-bright); }
.rank-pos.p2 { color: #c9c9d1; }
.rank-pos.p3 { color: #c08552; }
.rank-house .crest { --crest-size: 28px; }
.rank-names { min-width: 0; }
.rank-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .9rem;
  color: var(--ivory);
  display: block;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rank-player {
  font-size: .7rem;
  color: var(--ivory-faint);
  display: block;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ranking-table tr.is-mine td { background: color-mix(in oklab, var(--gold) 8%, transparent); }
.ranking-table tr.is-mine .rank-name { color: var(--gold-bright); }
.rank-signed { display: inline-flex; align-items: center; gap: 5px; justify-content: flex-end; }
.rank-signed svg { color: var(--gold); }

/* ---------- Linha do tempo ---------- */
.timeline { position: relative; padding-left: 22px; display: flex; flex-direction: column; gap: 14px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 7px; top: 8px; bottom: 8px;
  width: 2px;
  background: var(--line-soft);
}
.reign-item { position: relative; animation: card-in .35s ease both; }
.reign-item::before {
  content: '';
  position: absolute;
  left: -21px; top: 22px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 2px var(--gold-dim);
}
.reign-card { padding: 14px 14px 12px; }
.reign-head { display: flex; align-items: flex-start; gap: 10px; }
.reign-num {
  flex: none;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: .78rem;
  color: var(--gold);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 8px;
  background: var(--tint-gold);
  white-space: nowrap;
}
.reign-king-wrap { flex: 1; min-width: 0; }
.reign-king {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ivory);
  overflow-wrap: anywhere;
}
.reign-date { font-size: .72rem; color: var(--ivory-faint); margin-top: 1px; }
.reign-del {
  flex: none;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 9px;
  color: var(--ivory-faint);
  transition: color .15s, background .15s;
}
.reign-del:hover { color: var(--crimson-bright); background: var(--tint-crimson); }

.reign-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .74rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-soft);
  color: var(--ivory-dim);
  background: var(--card-deep);
}
.tag-abdicou { color: var(--amber); border-color: color-mix(in oklab, var(--amber) 40%, transparent); }
.tag-morreu  { color: #e08a8b; border-color: color-mix(in oklab, var(--crimson) 55%, transparent); }
.tag-winner  { color: var(--gold-bright); border-color: var(--line); }
.tag-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }

.reign-scores-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.score-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .74rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 4px 9px;
  border-radius: 8px;
  background: var(--card-deep);
  border: 1px solid color-mix(in oklab, var(--gold) 10%, transparent);
  color: var(--ivory-dim);
}
.score-chip b { font-weight: 800; }
.score-chip .p-pos { color: #7cc9a5; }
.score-chip .p-neg { color: #e08a8b; }
.score-chip .p-zero { color: var(--ivory-faint); }
.score-chip .signed-mark { color: var(--gold); }
.reign-notes {
  margin-top: 10px;
  font-family: var(--font-quote);
  font-style: italic;
  font-size: .85rem;
  color: var(--ivory-dim);
  border-left: 2px solid var(--line);
  padding-left: 10px;
}

/* ============================================================
   NAVEGAÇÃO INFERIOR
   ============================================================ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 680px;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: color-mix(in oklab, var(--bg-raise) 96%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: var(--nav-h);
  color: var(--ivory-faint);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .04em;
  position: relative;
  transition: color .18s ease;
}
.nav-btn::before {
  content: '';
  position: absolute;
  top: 0; left: 22%; right: 22%;
  height: 2px;
  background: var(--gold);
  border-radius: 0 0 3px 3px;
  transform: scaleX(0);
  transition: transform .22s ease;
}
.nav-btn.is-active { color: var(--gold-bright); }
.nav-btn.is-active::before { transform: scaleX(1); }
.nav-btn:active { transform: scale(.94); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: end center;
  padding: 16px;
}
.modal-root[hidden] { display: none; }
@media (min-width: 560px) { .modal-root { place-items: center; } }

.modal-scrim {
  position: absolute;
  inset: 0;
  background: rgba(8, 6, 4, .74);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fade-in .2s ease both;
}
@keyframes fade-in { from { opacity: 0; } }

.modal-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: 22px 20px 18px;
  animation: modal-in .26s cubic-bezier(.2, .9, .3, 1.2) both;
  box-shadow: var(--shadow);
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(26px) scale(.97); }
  to   { opacity: 1; transform: none; }
}
.modal-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--gold-bright);
  margin-bottom: 6px;
}
.modal-body { color: var(--ivory-dim); font-size: .94rem; }
.modal-body .field-label { margin-top: 14px; }
.modal-body p + p { margin-top: 8px; }
.modal-body .modal-house-line {
  display: flex; align-items: center; gap: 12px;
  margin: 12px 0 2px;
}
.modal-body .modal-house-line strong {
  font-family: var(--font-display);
  color: var(--ivory);
  font-size: 1.05rem;
}
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.modal-actions .btn { flex: 1; min-height: 50px; padding: 12px 14px; }

/* ============================================================
   TOASTS
   ============================================================ */
.toast-root {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: min(92vw, 420px);
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-radius: 12px;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: .9rem;
  font-weight: 600;
  color: var(--ivory);
  animation: toast-in .28s cubic-bezier(.2, .9, .3, 1.2) both;
}
.toast.out { animation: toast-out .25s ease both; }
.toast-success { border-color: color-mix(in oklab, var(--emerald) 60%, transparent); }
.toast-success .toast-dot { background: var(--emerald-bright); }
.toast-error { border-color: color-mix(in oklab, var(--crimson) 70%, transparent); }
.toast-error .toast-dot { background: var(--crimson-bright); }
.toast-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--gold); flex: none; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(14px) scale(.96); }
  to   { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(10px) scale(.96); }
}

/* ============================================================
   RESPONSIVO & ACESSIBILIDADE
   ============================================================ */
@media (min-width: 700px) {
  .screen { padding-left: 24px; padding-right: 24px; }
  .screen > .topbar { margin-left: -24px; margin-right: -24px; }
  .app-main { padding: 20px 24px 8px; }
  .counter-value { font-size: 3.4rem; }
}

@media (max-width: 360px) {
  .counter-btns { gap: 4px; }
  .step-btn { font-size: .85rem; }
  .house-grid { gap: 8px; }
}

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}