:root {
  color-scheme: dark;
  --bg: #080504;
  --bg-strong: #120907;
  --panel: #16100d;
  --panel-2: #211711;
  --ink: #fff5e7;
  --muted: #b8a997;
  --line: rgba(255, 245, 231, 0.14);
  --red: #f13222;
  --red-dark: #8f1f16;
  --cyan: #10b8ff;
  --cyan-dark: #0873ac;
  --gold: #e0a33b;
  --gold-dark: #84581d;
  --green: #0f5d42;
  --green-dark: #092e24;
  --cream: #fff4df;
  --danger: #ff655e;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  margin: 0;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
  background:
    radial-gradient(circle at 50% -10%, rgba(241, 50, 34, 0.22), transparent 30rem),
    linear-gradient(135deg, #050404 0%, #170b08 42%, #061d19 100%);
  overscroll-behavior: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  touch-action: manipulation;
}

.app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100dvh;
  min-height: 100dvh;
  width: min(100%, 430px);
  margin: 0 auto;
  overflow: hidden;
  border-inline: 1px solid rgba(255, 245, 231, 0.08);
  background:
    radial-gradient(circle at 50% 0%, rgba(224, 163, 59, 0.14), transparent 18rem),
    rgba(8, 5, 4, 0.5);
}

.topbar {
  position: relative;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 3rem 1fr 3rem;
  gap: 0.5rem;
  align-items: center;
  width: 100%;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 5, 4, 0.86);
  backdrop-filter: blur(16px);
}

.home-topbar {
  min-height: 3.85rem;
  border-bottom: 0;
  background: transparent;
  backdrop-filter: none;
}

.topbar.has-install {
  grid-template-columns: 3rem minmax(0, 1fr) 4.7rem;
}

.brand {
  display: inline-flex;
  width: fit-content;
  min-width: 0;
  align-items: center;
  justify-self: center;
  color: var(--ink);
  text-decoration: none;
}

.brand img {
  width: 4.25rem;
  height: 4.25rem;
  object-fit: contain;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.35));
}

.brand-docking img {
  animation: logoDock 440ms cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

.menu-toggle,
.topbar-spacer,
.topbar-empty {
  width: 2.75rem;
  height: 2.75rem;
}

.menu-toggle {
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 245, 231, 0.16);
  border-radius: 8px;
  color: var(--cream);
  background: rgba(255, 245, 231, 0.055);
  font-size: 1.15rem;
  font-weight: 900;
}

.home-topbar .menu-toggle {
  border-color: rgba(255, 245, 231, 0.12);
  background: rgba(0, 0, 0, 0.2);
}

.install-button {
  min-height: 2.45rem;
  border: 1px solid rgba(16, 184, 255, 0.42);
  border-radius: 8px;
  padding: 0 0.55rem;
  color: var(--cream);
  background: rgba(16, 184, 255, 0.12);
  font-size: 0.78rem;
  font-weight: 900;
}

.install-hint {
  display: grid;
  grid-column: 1 / -1;
  border: 1px solid rgba(224, 163, 59, 0.28);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.28);
  font-size: 0.84rem;
  line-height: 1.35;
}

.nav {
  display: grid;
  grid-column: 1 / -1;
  width: 100%;
  grid-template-columns: 1fr;
  gap: 0.45rem;
  align-items: center;
  margin-top: 0.45rem;
  border: 1px solid rgba(255, 245, 231, 0.12);
  border-radius: 8px;
  padding: 0.45rem;
  background: rgba(0, 0, 0, 0.24);
}

.menu-toggle,
.nav button,
.pill-button,
.ghost-button,
.primary-button,
.danger-button,
.score-button,
.filter-button {
  min-height: 2.5rem;
  border-radius: 8px;
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease;
}

.nav button {
  min-width: 0;
  min-height: 2.7rem;
  padding: 0 0.75rem;
  border: 1px solid transparent;
  color: var(--muted);
  background: transparent;
  font-size: 0.94rem;
  font-weight: 850;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav button[aria-current="page"] {
  border-color: rgba(16, 184, 255, 0.48);
  color: var(--cream);
  background: rgba(16, 184, 255, 0.13);
}

.nav button:hover,
.pill-button:hover,
.ghost-button:hover,
.primary-button:hover,
.danger-button:hover,
.score-button:hover,
.filter-button:hover {
  transform: translateY(-1px);
}

.main {
  min-height: 0;
  height: 100%;
  width: min(100% - 1rem, 430px);
  margin: 0 auto;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.6rem 0 2rem;
  -webkit-overflow-scrolling: touch;
}

.workspace {
  display: grid;
  gap: 1rem;
}

.home-screen {
  display: grid;
  width: 100%;
  min-height: 100%;
  align-content: center;
  gap: 1.2rem;
  padding: 0 0 2rem;
}

.home-logo {
  display: grid;
  justify-items: center;
}

.home-logo img {
  width: min(18rem, 82vw);
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 18px 28px rgba(0, 0, 0, 0.48));
}

.home-copy {
  display: grid;
  gap: 0.35rem;
  text-align: center;
}

.home-copy h1 {
  margin: 0;
  color: var(--cream);
  font-size: 1.55rem;
  line-height: 1.08;
}

.home-copy p {
  margin: 0;
  color: var(--muted);
}

.home-actions {
  display: grid;
  width: 100%;
  gap: 0.75rem;
}

.home-active-list {
  display: grid;
  gap: 0.55rem;
}

.home-active-match {
  display: grid;
  gap: 0.18rem;
  min-height: 4.15rem;
  border: 1px solid rgba(16, 184, 255, 0.34);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  color: var(--cream);
  text-align: left;
  background:
    linear-gradient(135deg, rgba(16, 184, 255, 0.14), rgba(224, 163, 59, 0.09)),
    rgba(0, 0, 0, 0.22);
}

.home-active-match span,
.home-active-match small {
  color: var(--muted);
  line-height: 1.25;
}

.home-active-match span {
  font-size: 0.72rem;
  font-weight: 950;
  text-transform: uppercase;
}

.home-active-match strong {
  min-width: 0;
  color: var(--cream);
  font-size: 1.05rem;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.home-active-match small {
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.active-game-decision {
  display: grid;
  gap: 0.55rem;
  border: 1px solid rgba(224, 163, 59, 0.38);
  border-radius: 8px;
  padding: 0.8rem;
  background:
    linear-gradient(135deg, rgba(224, 163, 59, 0.14), rgba(16, 184, 255, 0.08)),
    rgba(0, 0, 0, 0.24);
}

.active-game-decision span {
  color: #ffe1a8;
  font-size: 0.78rem;
  font-weight: 950;
  text-transform: uppercase;
}

.active-game-decision strong {
  color: var(--cream);
  font-size: 1rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.active-game-decision div {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.home-game-button {
  display: grid;
  width: 100%;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.8rem;
  align-items: center;
  min-height: 5.4rem;
  border: 1px solid rgba(255, 245, 231, 0.16);
  border-radius: 8px;
  padding: 1rem;
  color: var(--ink);
  text-align: left;
  background:
    linear-gradient(135deg, rgba(241, 50, 34, 0.12), rgba(16, 184, 255, 0.08)),
    rgba(255, 245, 231, 0.045);
}

.simple-game-button {
  grid-template-columns: 1fr;
  justify-items: center;
  min-height: 4.8rem;
  padding: 1rem;
  font-size: 1.35rem;
  font-weight: 950;
  letter-spacing: 0;
  text-align: center;
}

.home-game-button strong,
.home-game-button small {
  display: block;
}

.home-game-button strong {
  color: var(--cream);
  font-size: 1.2rem;
}

.home-game-button small {
  margin-top: 0.18rem;
  color: var(--muted);
  line-height: 1.35;
}

.tool-panel,
.match-panel,
.metric,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), transparent),
    rgba(16, 10, 8, 0.82);
  box-shadow: var(--shadow);
}

.section-title h2 {
  margin: 0;
  color: var(--cream);
  font-size: 2.1rem;
  line-height: 1.05;
}

.section-title p,
.empty-state p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.tool-panel {
  display: grid;
  gap: 1rem;
  padding: 1rem;
}

.quick-start-workspace {
  min-height: 100%;
  padding-bottom: 5.5rem;
}

.quick-start-panel {
  display: grid;
  min-height: 100%;
  align-content: start;
  padding: 2.4rem 0 0;
}

.quick-start-form {
  gap: 1rem;
}

.start-bar {
  position: fixed;
  right: max(0.5rem, calc((100vw - 430px) / 2 + 0.5rem));
  bottom: 0;
  left: max(0.5rem, calc((100vw - 430px) / 2 + 0.5rem));
  z-index: 30;
  padding: 0.75rem 0 calc(0.75rem + env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, transparent, rgba(8, 5, 4, 0.92) 24%),
    rgba(8, 5, 4, 0.84);
  backdrop-filter: blur(14px);
}

.start-button {
  width: 100%;
  min-height: 3.35rem;
  font-size: 1.08rem;
}

.section-title {
  display: flex;
  gap: 1rem;
  align-items: end;
  justify-content: space-between;
}

.section-title p {
  max-width: 42rem;
}

.game-mark {
  display: grid;
  width: 2.4rem;
  height: 2.4rem;
  place-items: center;
  border: 1px solid rgba(255, 245, 231, 0.22);
  border-radius: 8px;
  color: var(--cream);
  background: rgba(0, 0, 0, 0.24);
  font-size: 1.1rem;
  font-weight: 900;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.field {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.field.full {
  grid-column: 1 / -1;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 2.9rem;
  border: 1px solid rgba(255, 245, 231, 0.16);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.28);
  outline: none;
  padding: 0 0.8rem;
  text-transform: none;
}

.field textarea {
  min-height: 5rem;
  padding-top: 0.7rem;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(16, 184, 255, 0.66);
  box-shadow: 0 0 0 3px rgba(16, 184, 255, 0.12);
}

.form-actions,
.backup-actions,
.history-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.match-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
  align-items: stretch;
}

.match-actions button {
  width: 100%;
  min-height: 2.8rem;
  padding-inline: 0.55rem;
}

.match-actions button[data-action="delete-match"] {
  grid-column: 1 / -1;
}

.form-actions.full {
  grid-column: 1 / -1;
}

.edit-match-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  border-block: 1px solid rgba(255, 245, 231, 0.12);
  padding: 0.9rem 0;
}

.primary-button,
.pill-button,
.ghost-button,
.danger-button,
.filter-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0 0.95rem;
  font-weight: 850;
}

.primary-button {
  color: #071111;
  background: linear-gradient(135deg, var(--gold), var(--cyan));
}

.pill-button {
  border: 1px solid rgba(16, 184, 255, 0.38);
  color: var(--cream);
  background: rgba(16, 184, 255, 0.12);
}

.ghost-button,
.filter-button {
  border: 1px solid rgba(255, 245, 231, 0.14);
  color: var(--ink);
  background: rgba(255, 245, 231, 0.055);
}

.filter-button[aria-pressed="true"] {
  border-color: rgba(224, 163, 59, 0.58);
  background: rgba(224, 163, 59, 0.14);
}

.danger-button {
  border: 1px solid rgba(255, 101, 94, 0.44);
  color: #ffd8d5;
  background: rgba(255, 101, 94, 0.12);
}

.match-panel {
  display: grid;
  gap: 1rem;
  padding: 1rem;
}

.status-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: flex-start;
}

.status-badge {
  display: inline-flex;
  min-height: 2rem;
  align-items: center;
  border: 1px solid rgba(255, 245, 231, 0.14);
  border-radius: 999px;
  padding: 0 0.7rem;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.24);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.status-badge.closed {
  border-color: rgba(224, 163, 59, 0.48);
  color: #ffe1a8;
  background: rgba(224, 163, 59, 0.1);
}

.status-badge.tie {
  border-color: rgba(255, 245, 231, 0.24);
  color: var(--muted);
  background: rgba(255, 245, 231, 0.06);
}

.score-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.8rem;
}

.canastra-score-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.truco-score-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.score-card {
  display: grid;
  gap: 0.75rem;
  min-height: 17rem;
  padding: 0.9rem;
  border: 1px solid rgba(255, 245, 231, 0.14);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(15, 93, 66, 0.42), rgba(0, 0, 0, 0.2)),
    rgba(255, 245, 231, 0.04);
}

.score-card.leading {
  border-color: rgba(224, 163, 59, 0.52);
  box-shadow: inset 0 0 0 1px rgba(224, 163, 59, 0.2);
}

.score-card.tied {
  border-color: rgba(255, 245, 231, 0.2);
  box-shadow: none;
}

.score-card.warning {
  border-color: rgba(255, 101, 94, 0.52);
}

.score-card.marra {
  border-color: rgba(16, 184, 255, 0.64);
  background:
    linear-gradient(145deg, rgba(16, 184, 255, 0.22), rgba(224, 163, 59, 0.12)),
    rgba(255, 245, 231, 0.04);
  animation: pulseGlow 1200ms ease-in-out infinite alternate;
}

.score-card.mao11 {
  border-color: rgba(16, 184, 255, 0.7);
  background:
    linear-gradient(145deg, rgba(16, 184, 255, 0.18), rgba(224, 163, 59, 0.1)),
    rgba(255, 245, 231, 0.04);
  animation: pulseGlow 1200ms ease-in-out infinite alternate;
}

.canastra-score-grid .score-card {
  min-height: 9.8rem;
  gap: 0.5rem;
  padding: 0.75rem;
}

.truco-score-grid .score-card {
  min-height: 0;
  gap: 0.52rem;
  padding: 0.72rem;
}

.score-top {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}

.score-team-head {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 0.32rem;
  align-items: center;
}

.score-top h2 {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--cream);
  font-size: 1rem;
}

.truco-score-grid .score-top {
  min-height: 2.15rem;
  align-items: flex-start;
}

.truco-score-grid .score-top h2 {
  font-size: 0.98rem;
}

.truco-score-grid .score-top .status-badge {
  min-height: 1.65rem;
  padding: 0 0.44rem;
  font-size: 0.58rem;
}

.score-value-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

.truco-score-grid .score-value-row {
  min-height: 3rem;
  gap: 0.35rem;
}

.score-value {
  color: var(--cream);
  font-size: 4rem;
  font-weight: 950;
  line-height: 0.95;
}

.truco-score-grid .score-value {
  font-size: 3rem;
}

.mao11-badge {
  display: inline-flex;
  min-height: 2rem;
  align-items: center;
  border: 1px solid rgba(16, 184, 255, 0.58);
  border-radius: 999px;
  padding: 0 0.65rem;
  color: #bdefff;
  background: rgba(16, 184, 255, 0.12);
  font-size: 0.76rem;
  font-weight: 950;
  text-transform: uppercase;
}

.truco-score-grid .mao11-badge {
  min-height: 1.5rem;
  padding: 0 0.42rem;
  font-size: 0.58rem;
}

.canastra-score-grid .score-value {
  font-size: 2.65rem;
}

.score-meta {
  min-height: 1.5rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.truco-score-grid .score-meta {
  min-height: 1.1rem;
  font-size: 0.76rem;
  line-height: 1.25;
}

.canastra-score-grid .score-meta {
  font-size: 0.78rem;
  line-height: 1.25;
}

.quick-score {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}

.quick-score.truco-quick-score {
  grid-template-columns: 1fr;
  gap: 0.36rem;
}

.quick-score-pair,
.quick-score-stack {
  display: grid;
  gap: 0.36rem;
}

.quick-score-pair {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.quick-score-stack {
  grid-template-columns: 1fr;
}

.score-button {
  min-height: 2.55rem;
  border: 1px solid rgba(255, 245, 231, 0.16);
  color: var(--cream);
  background: rgba(0, 0, 0, 0.24);
  font-weight: 900;
}

.truco-quick-score .score-button {
  min-height: 2.15rem;
  font-size: 0.92rem;
}

.score-button.positive {
  border-color: rgba(16, 184, 255, 0.32);
}

.score-button.negative {
  border-color: rgba(255, 101, 94, 0.34);
  color: #ffd6d3;
}

.score-button:disabled,
.primary-button:disabled,
.ghost-button:disabled,
.danger-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.canastra-round-form {
  display: grid;
  gap: 0.65rem;
  border: 1px solid rgba(16, 184, 255, 0.24);
  border-radius: 8px;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.22);
}

.canastra-round-form > strong {
  color: var(--cream);
  font-size: 1rem;
}

.round-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.series-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(224, 163, 59, 0.26);
  border-radius: 8px;
  padding: 0.58rem 0.72rem;
  background: rgba(224, 163, 59, 0.08);
}

.series-round {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
}

.series-dots {
  display: flex;
  flex-shrink: 0;
  gap: 0.24rem;
  justify-content: center;
}

.score-series-dots {
  justify-content: flex-start;
}

.series-dot {
  width: 0.58rem;
  height: 0.58rem;
  border: 1px solid rgba(255, 245, 231, 0.32);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.24);
}

.series-dot.filled {
  border-color: rgba(16, 184, 255, 0.82);
  background: linear-gradient(135deg, var(--gold), var(--cyan));
  box-shadow: 0 0 12px rgba(16, 184, 255, 0.28);
}

.finish-celebration {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(224, 163, 59, 0.54);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(241, 50, 34, 0.24), rgba(16, 184, 255, 0.14)),
    rgba(0, 0, 0, 0.32);
  box-shadow: 0 0 0 1px rgba(224, 163, 59, 0.12), var(--shadow);
}

.finish-celebration {
  display: grid;
  gap: 0.55rem;
  justify-items: center;
  padding: 0.75rem;
  text-align: center;
  animation: finishPop 460ms ease-out both;
}

.finish-celebration img {
  width: 4.75rem;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.36));
}

.finish-celebration span {
  display: block;
  color: #ffe1a8;
  font-size: 0.78rem;
  font-weight: 950;
  text-transform: uppercase;
}

.finish-celebration strong {
  display: block;
  margin-top: 0.12rem;
  color: var(--cream);
  font-size: 1.25rem;
  line-height: 1.1;
}

.celebration-actions {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

.celebration-actions .ghost-button,
.celebration-actions .danger-button {
  min-height: 2.65rem;
  padding: 0 0.42rem;
  font-size: 0.84rem;
}

.timeline {
  display: grid;
  gap: 0.55rem;
}

.event-row,
.history-row,
.rank-row,
.game-stat-row {
  display: grid;
  gap: 0.5rem;
  align-items: center;
  border: 1px solid rgba(255, 245, 231, 0.1);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.event-row {
  grid-template-columns: 1fr;
  min-height: 3.3rem;
  padding: 0.65rem 0.75rem;
}

.event-row.edit-round {
  align-items: stretch;
}

.canastra-event .mini-button {
  width: fit-content;
}

.mini-button {
  min-height: 2.1rem;
  padding-inline: 0.75rem;
}

.event-row strong,
.history-row strong,
.rank-row strong,
.game-stat-row strong {
  color: var(--cream);
}

.event-row span,
.history-row span,
.rank-row span,
.game-stat-row span {
  color: var(--muted);
  font-size: 0.86rem;
}

.delta {
  display: inline-flex;
  min-width: 3.2rem;
  min-height: 2rem;
  align-items: center;
  justify-self: start;
  justify-content: center;
  border-radius: 999px;
  color: var(--cream);
  background: rgba(16, 184, 255, 0.14);
  font-weight: 950;
}

.delta.negative {
  background: rgba(255, 101, 94, 0.14);
}

.delta.round {
  background: rgba(224, 163, 59, 0.16);
}

.history-layout,
.stats-layout,
.backup-layout {
  display: grid;
  gap: 1rem;
}

.history-tools {
  justify-content: space-between;
}

.search-field {
  min-width: min(100%, 18rem);
}

.history-list,
.rank-list,
.game-stat-list {
  display: grid;
  gap: 0.65rem;
}

.history-row {
  grid-template-columns: 1fr;
  min-height: 5.2rem;
  padding: 0.75rem;
}

.history-main {
  display: grid;
  gap: 0.3rem;
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: flex-start;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.metric {
  min-height: 7rem;
  padding: 0.9rem;
}

.metric strong {
  display: block;
  color: var(--cream);
  font-size: 2.2rem;
  line-height: 1;
}

.metric span {
  display: block;
  margin-top: 0.55rem;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
}

.rank-row,
.game-stat-row {
  grid-template-columns: auto minmax(0, 1fr) auto;
  min-height: 3.5rem;
  padding: 0.65rem 0.75rem;
}

.rank-number {
  display: grid;
  width: 2.2rem;
  height: 2.2rem;
  place-items: center;
  border: 1px solid rgba(224, 163, 59, 0.42);
  border-radius: 999px;
  color: #ffe2a9;
  background: rgba(224, 163, 59, 0.12);
  font-weight: 950;
}

.backup-card {
  display: grid;
  gap: 0.8rem;
}

.empty-state {
  display: grid;
  min-height: 13rem;
  place-items: center;
  padding: 1.25rem;
  text-align: center;
}

.empty-state img {
  width: 8rem;
  max-width: 45%;
  height: auto;
  object-fit: contain;
  margin-bottom: 0.6rem;
}

.toast {
  position: fixed;
  right: max(1rem, calc((100vw - 430px) / 2 + 1rem));
  bottom: 1rem;
  z-index: 40;
  display: none;
  max-width: min(26rem, calc(100vw - 2rem));
  min-height: 3rem;
  align-items: center;
  border: 1px solid rgba(16, 184, 255, 0.34);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  color: var(--cream);
  background: rgba(6, 19, 18, 0.94);
  box-shadow: var(--shadow);
}

@keyframes pulseGlow {
  from {
    box-shadow: 0 0 0 1px rgba(224, 163, 59, 0.12), var(--shadow);
  }
  to {
    box-shadow: 0 0 0 1px rgba(224, 163, 59, 0.32), 0 18px 44px rgba(241, 50, 34, 0.28);
  }
}

@keyframes finishPop {
  0% {
    opacity: 0;
    transform: scale(0.94);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes logoDock {
  0% {
    opacity: 0.98;
    transform: translateY(10.8rem) scale(3.65);
  }
  68% {
    opacity: 1;
    transform: translateY(-0.18rem) scale(0.92);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.toast.visible {
  display: flex;
}

.noscript {
  display: grid;
  min-height: 100vh;
  place-items: center;
  align-content: center;
  gap: 0.75rem;
  padding: 2rem;
  text-align: center;
}

.noscript img {
  width: 12rem;
}

.hidden {
  display: none !important;
}

.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;
}

@media (max-width: 920px) {
  .topbar {
    position: relative;
    grid-template-columns: 3rem 1fr 3rem;
  }

  .nav {
    grid-template-columns: 1fr;
  }

  .nav button {
    padding-inline: 0.75rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .main {
    width: min(100% - 1rem, 430px);
    padding-top: 0.6rem;
  }

  .brand img {
    width: 4.25rem;
    height: 4.25rem;
  }

  .tool-panel,
  .match-panel {
    padding: 0.75rem;
  }

  .nav {
    gap: 0.45rem;
  }

  .nav button {
    min-height: 2.7rem;
    padding-inline: 0.75rem;
    font-size: 0.94rem;
  }

  .section-title h2 {
    font-size: 1.55rem;
  }

  .form-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .history-row,
  .event-row {
    grid-template-columns: 1fr;
  }

  .status-stack,
  .history-actions {
    justify-content: flex-start;
  }

  .score-value {
    font-size: 3.15rem;
  }

  .truco-score-grid,
  .canastra-score-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-score {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
