:root {
  color-scheme: dark;
  --felt: #0f4a3a;
  --felt-deep: #082820;
  --ink: #f8f4e8;
  --muted: #b9c8bd;
  --line: rgba(248, 244, 232, 0.16);
  --gold: #e1b64b;
  --red: #c94d3f;
  --panel: rgba(5, 18, 15, 0.78);
  --panel-solid: #10251f;
  --shadow: rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(120deg, rgba(15, 74, 58, 0.96), rgba(8, 40, 32, 0.98)),
    repeating-linear-gradient(45deg, rgba(255,255,255,0.03) 0 1px, transparent 1px 12px);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.app-shell {
  width: min(100%, 560px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  align-items: stretch;
}

.screen {
  width: 100%;
  min-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.hidden {
  display: none !important;
}

.landing {
  justify-content: center;
}

.brand-block,
.menu-header,
.topbar,
.game-topbar,
.opponent-zone {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: clamp(76px, 18%, 104px);
  max-height: 104px;
  object-fit: contain;
  flex: 0 0 auto;
  filter: drop-shadow(0 12px 18px var(--shadow));
}

.small-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  line-height: 1.05;
  letter-spacing: 0;
}

h1 {
  font-size: 2.75rem;
}

h2 {
  font-size: 1.75rem;
}

.lead {
  margin: 0;
  max-width: 34rem;
  font-size: 1.1rem;
  line-height: 1.5;
  color: var(--ink);
}

.notice,
.status-text,
small {
  color: var(--muted);
}

.notice,
.status-text {
  margin: 0;
  line-height: 1.45;
}

.action-row,
.menu-links {
  display: flex;
  gap: 10px;
}

.wrap {
  flex-wrap: wrap;
}

.primary,
.secondary,
.ghost,
.link-button {
  min-height: 46px;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 800;
}

.primary {
  color: #172019;
  background: var(--gold);
  box-shadow: 0 12px 24px var(--shadow);
}

.secondary {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--line);
}

.compact {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.88rem;
}

.ghost,
.link-button {
  color: var(--ink);
  background: transparent;
}

.link-button {
  align-self: flex-start;
  padding: 0;
  min-height: 32px;
  color: var(--gold);
}

.wide {
  width: 100%;
}

.topbar,
.game-topbar {
  min-height: 48px;
  justify-content: space-between;
}

.form-panel,
.profile-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 46px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 0 12px;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.22);
  outline: none;
}

input:focus {
  border-color: var(--gold);
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: #ffb4aa;
}

.stats-strip,
.profile-grid,
.scoreboard {
  display: grid;
  gap: 10px;
}

.stats-strip {
  grid-template-columns: repeat(3, 1fr);
}

.profile-grid,
.scoreboard {
  grid-template-columns: repeat(2, 1fr);
}

.stats-strip > div,
.profile-grid > div,
.score-cell {
  min-height: 74px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.18);
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.stats-strip span,
.profile-grid span,
.score-cell strong {
  font-size: 1.55rem;
  line-height: 1;
}

.pulse {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  margin-top: auto;
  align-self: center;
  border: 4px solid var(--gold);
  border-top-color: transparent;
  animation: spin 1s linear infinite;
}

#matchmaking-screen {
  justify-content: center;
  text-align: center;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.game {
  gap: 12px;
}

.connection-pill {
  min-width: 108px;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  text-align: center;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.18);
}

.connection-pill.connected {
  color: #c8f7d2;
}

.opponent-zone {
  justify-content: space-between;
  min-height: 70px;
  padding: 12px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.opponent-zone strong,
.opponent-zone small {
  display: block;
}

.card-count {
  color: var(--gold);
  font-weight: 800;
}

.table-zone {
  min-height: 190px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at center, rgba(225, 182, 75, 0.14), transparent 62%),
    var(--panel-solid);
  padding: 12px;
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  align-items: stretch;
}

.vira,
.playing-card {
  border-radius: 8px;
  border: 1px solid rgba(20, 25, 22, 0.22);
  background: #fff7e6;
  color: #141914;
  box-shadow: 0 8px 16px var(--shadow);
}

.vira {
  min-height: 104px;
  align-self: center;
  display: grid;
  place-items: center;
  font-size: 1.55rem;
  font-weight: 900;
}

.tricks {
  display: grid;
  gap: 8px;
}

.trick-row {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.mini-card {
  min-width: 42px;
  min-height: 42px;
  border-radius: 6px;
  background: #fff7e6;
  color: #141914;
  display: grid;
  place-items: center;
  font-weight: 900;
}

.hand-zone {
  min-height: 98px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.playing-card {
  min-height: 92px;
  font-size: 1.45rem;
  font-weight: 900;
}

.danger {
  color: #fff4f1;
  background: var(--red);
}

.fairness-panel {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  display: grid;
  gap: 10px;
}

.fairness-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.fairness-heading strong,
.fairness-heading small {
  display: block;
}

.proof-grid {
  display: grid;
  grid-template-columns: 94px minmax(0, 1fr);
  gap: 8px 10px;
  align-items: start;
}

.proof-grid span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

code {
  color: #fff7d0;
  overflow-wrap: anywhere;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.78rem;
}

.hand-proofs {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.45;
}

.hand-proofs details {
  margin-top: 5px;
}

.hand-proofs summary {
  cursor: pointer;
  color: var(--gold);
  font-weight: 800;
}

.verified {
  color: #c8f7d2;
}

.failed {
  color: #ffb4aa;
}

@media (max-width: 390px) {
  .app-shell {
    padding: 14px;
  }

  .screen {
    min-height: calc(100vh - 28px);
  }

  h1 {
    font-size: 2.25rem;
  }

  .brand-logo {
    width: 72px;
    max-height: 72px;
  }

  .table-zone {
    grid-template-columns: 58px 1fr;
  }
}
