body {
  min-height: 100dvh;
  background:
    radial-gradient(120% 60% at 100% 0%, rgba(255, 138, 61, 0.1), transparent 60%),
    radial-gradient(100% 50% at 0% 100%, rgba(68, 199, 244, 0.08), transparent 60%),
    var(--bg);
}

body.offline::before {
  content: 'Нет связи, переподключаемся…';
  position: fixed;
  inset: 0 0 auto;
  z-index: 10;
  padding: 8px 16px;
  background: var(--red);
  color: #fff;
  text-align: center;
  font-size: 14px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 560px;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 16px 6px;
}

.brand {
  font-size: 17px;
  font-weight: 700;
}

.brand span {
  margin-left: 8px;
  color: var(--host);
  font-weight: 500;
}

#who {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.me {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 14px;
}

.me span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link {
  background: none;
  padding: 6px 0;
  color: var(--muted);
  font-size: 14px;
}

.avatar {
  flex: none;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px currentColor;
}

.avatar.guest {
  color: var(--guest);
}

.avatar.host {
  color: var(--host);
}

.avatar.letter {
  display: inline-grid;
  place-items: center;
  background: currentColor;
}

.avatar.letter {
  color: var(--bg);
}

.avatar.letter.guest {
  background: var(--guest);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--guest);
}

.avatar.letter.host {
  background: var(--host);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--host);
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 16px max(24px, env(safe-area-inset-bottom));
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 12px;
}

.screen.center {
  align-items: center;
  text-align: center;
  padding-top: 6vh;
}

h1 {
  margin: 0;
  font-size: clamp(26px, 7.4vw, 34px);
  line-height: 1.15;
  font-weight: 700;
}

.lead {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.fine {
  margin: 0;
  color: var(--faint);
  font-size: 13px;
  line-height: 1.5;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 22px;
  border-radius: 16px;
  background: var(--panel-2);
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.12s ease, background 0.2s ease;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn.big {
  width: 100%;
  min-height: 60px;
  background: var(--guest);
  color: #06222d;
  font-size: 18px;
}

.btn.twitch {
  width: 100%;
  background: var(--twitch);
  color: #fff;
}

.btn.ghost {
  background: transparent;
  box-shadow: inset 0 0 0 2px var(--line);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.notice {
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--panel);
  color: var(--muted);
  line-height: 1.45;
}

.notice.warn {
  background: rgba(255, 92, 122, 0.14);
  color: #ffc2cd;
}

.pill {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
}

.screen.center .pill {
  align-self: center;
}

.pill b {
  color: var(--text);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  animation: blink 1.4s infinite;
}

@keyframes blink {
  50% {
    opacity: 0.3;
  }
}

.icons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.icons .icon {
  width: 42px;
  height: 42px;
}

.icon {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 48px;
  height: 48px;
  padding: 6px;
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
}

.icon svg {
  width: 100%;
  height: 100%;
}

.games {
  display: grid;
  gap: 10px;
}

.game {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 4px 14px;
  align-items: center;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--panel);
  text-align: left;
  transition: transform 0.12s ease, background 0.2s ease;
}

.game:active:not(:disabled) {
  transform: scale(0.98);
}

.game .icon {
  grid-row: span 2;
  background: var(--bg-2);
}

.game.current {
  box-shadow: inset 0 0 0 2px var(--guest);
}

.gt {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 17px;
}

.gt small {
  color: var(--faint);
  font-size: 13px;
  white-space: nowrap;
}

.gr {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.place {
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: var(--guest-soft);
  color: var(--guest);
  font-size: 52px;
  font-weight: 800;
}

.chosen {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 8px 8px;
  border-radius: 999px;
  background: var(--panel);
  font-size: 16px;
}

.chosen .icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-2);
}

.invite h1 {
  color: var(--guest);
}

.ring {
  --p: 1;
  display: grid;
  place-items: center;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: conic-gradient(var(--guest) calc(var(--p) * 360deg), var(--panel-2) 0);
  transition: background 0.25s linear;
}

.ring .secs {
  display: grid;
  place-items: center;
  width: 124px;
  height: 124px;
  border-radius: 50%;
  background: var(--bg);
  font-size: 46px;
  font-weight: 800;
}

/* ---- the game itself --------------------------------------------------------------------------------------- */

.match {
  gap: 12px;
}

.versus {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}

.side {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.side b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side.guest b {
  color: var(--guest);
}

.side.host {
  justify-content: flex-end;
}

.side.host b {
  color: var(--host);
}

.sc {
  font-size: 22px;
  font-weight: 800;
}

.vs {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  padding: 0 18px;
  border-radius: 16px;
  background: var(--panel);
  font-size: 18px;
}

.status.mine {
  background: var(--guest-soft);
  box-shadow: inset 0 0 0 2px var(--guest);
}

.clock {
  font-family: var(--ui);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.clock.low {
  color: var(--red);
}

.info {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.board-wrap {
  width: min(100%, 62dvh);
  margin: 0 auto;
}

.resign {
  align-self: center;
  min-height: 44px;
  color: var(--muted);
}

.resign.armed {
  color: #fff;
  background: var(--red);
  box-shadow: none;
}

.outcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 16px;
  border-radius: 16px;
  background: var(--panel);
  text-align: center;
}

.outcome b {
  font-size: 26px;
}

.outcome span {
  color: var(--muted);
}

.outcome.win {
  background: rgba(255, 209, 102, 0.14);
  box-shadow: inset 0 0 0 2px var(--gold);
}

.outcome.win b {
  color: var(--gold);
}

.outcome.loss b {
  color: var(--host);
}

#toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 20;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--text);
  color: var(--bg);
  font-size: 15px;
  transform: translate(-50%, 150%);
  visibility: hidden;
  transition: transform 0.25s ease, visibility 0s 0.25s;
}

#toast.on {
  visibility: visible;
  transition: transform 0.25s ease;
  transform: translate(-50%, 0);
}

.board-wrap[data-game='sea'],
.board-wrap[data-game='bulls'] {
  width: 100%;
}

.board-wrap[data-game='balda'] {
  width: 100%;
}

.btn.wide {
  width: 100%;
}

a.inline {
  color: var(--guest);
}

h2.section {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mine {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  gap: 2px 12px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--guest-soft);
}

.mine b {
  color: var(--guest);
  font-size: 22px;
}

.mine .muted {
  grid-column: span 2;
  color: var(--muted);
  font-size: 14px;
}

.leaders {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.leaders ol {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.leaders li {
  display: grid;
  grid-template-columns: 26px 30px 1fr auto 34px;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--panel);
}

.leaders li b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaders .pl {
  color: var(--faint);
  text-align: center;
}

.leaders .p1 .pl {
  color: var(--gold);
}

.leaders .p2 .pl {
  color: #d9dde6;
}

.leaders .p3 .pl {
  color: #e0a26b;
}

.leaders .wdl {
  color: var(--faint);
  font-size: 13px;
}

.leaders .pts {
  text-align: right;
  font-size: 18px;
}
