:root {
  --Background: #0B0B0C;
  --Surface: #161618;
  --SurfaceRaised: #1F1F22;
  --SurfaceMine: #2A2A2E;
  --Hairline: rgba(255, 255, 255, 0.08);
  --HairlineStrong: rgba(255, 255, 255, 0.16);
  --Text: #F2F2F4;
  --TextMuted: #8E8E93;
  --TextFaint: #48484C;
  --Accent: #0A84FF;
  --Radius: 6px;
  --Font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--Background);
  color: var(--Text);
  font-family: var(--Font);
  -webkit-text-size-adjust: 100%;
}

body {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

[hidden] {
  display: none !important;
}

button {
  font: inherit;
  color: inherit;
  -webkit-touch-callout: none;
}

button:focus-visible {
  outline: 1px solid var(--HairlineStrong);
  outline-offset: 2px;
}

.Game {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: calc(24px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
}

.Top {
  text-align: center;
}

.Title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.Status {
  margin: 6px 0 0;
  min-height: 1.4em;
  color: var(--TextMuted);
  font-size: 15px;
}

.Board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  flex-shrink: 0;
  width: min(84vw, 360px);
  aspect-ratio: 1;
}

.Cell {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: var(--Surface);
  border: 1px solid var(--Hairline);
  border-radius: var(--Radius);
  font-size: clamp(36px, 12vw, 56px);
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 120ms ease;
}

.Cell:active,
.Cell.Pressed {
  background: var(--SurfaceRaised);
}

.Board.Pad .Cell {
  font-size: clamp(26px, 8vw, 36px);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.Board.Over .Cell {
  color: var(--TextMuted);
}

.Board.Over .Cell.Win {
  color: var(--Text);
  background: var(--SurfaceRaised);
}

.Scores {
  display: flex;
  gap: 20px;
  color: var(--TextMuted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.Scores strong {
  color: var(--Text);
  font-weight: 500;
}

.Button {
  padding: 10px 18px;
  background: var(--Surface);
  border: 1px solid var(--Hairline);
  border-radius: var(--Radius);
  font-size: 15px;
  cursor: pointer;
  touch-action: manipulation;
}

.Button:active {
  background: var(--SurfaceRaised);
}

.Footer {
  margin: 8px 0 0;
  padding: 10px 18px;
  color: var(--TextFaint);
  font-size: 11px;
  touch-action: none;
}

.Private {
  overflow: hidden;
}

.Shell {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--Background);
}

.Stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

.Panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(100% - 32px, 420px);
  margin: auto;
  padding: 20px;
  background: var(--Surface);
  border: 1px solid var(--Hairline);
  border-radius: var(--Radius);
  animation: Fade 160ms ease both;
}

.PanelTitle {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.PanelText {
  margin: 0;
  color: var(--TextMuted);
  font-size: 14px;
  line-height: 1.45;
}

.LinkBox {
  margin: 0;
  padding: 10px 12px;
  background: var(--Background);
  border: 1px solid var(--Hairline);
  border-radius: 4px;
  color: var(--TextMuted);
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
}

.Actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.Action {
  flex: 1;
  min-width: 96px;
  padding: 11px 14px;
  background: var(--SurfaceRaised);
  border: 1px solid var(--Hairline);
  border-radius: var(--Radius);
  font-size: 15px;
  cursor: pointer;
  touch-action: manipulation;
}

.Action:active {
  background: var(--SurfaceMine);
}

.Action.Quiet {
  background: transparent;
  color: var(--TextMuted);
}

.Chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  animation: Fade 160ms ease both;
}

.ChatBar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 8px 12px 8px 64px;
  border-bottom: 1px solid var(--Hairline);
}

.ChatTitle {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
}

.Verified {
  color: var(--Accent);
  font-size: 12px;
}

.Connection {
  color: var(--TextMuted);
  font-size: 12px;
}

.End {
  padding: 6px 12px;
  background: var(--Surface);
  border: 1px solid var(--Hairline);
  border-radius: 4px;
  color: var(--TextMuted);
  font-size: 13px;
  cursor: pointer;
  touch-action: manipulation;
}

.Log {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  padding: 16px 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.Message {
  max-width: 78%;
  padding: 8px 12px;
  border: 1px solid var(--Hairline);
  border-radius: var(--Radius);
  font-size: 15px;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  animation: Fade 140ms ease both;
}

.Mine {
  align-self: flex-end;
  background: var(--SurfaceMine);
}

.Theirs {
  align-self: flex-start;
  background: var(--Surface);
}

.Notice {
  align-self: center;
  padding: 4px 0;
  color: var(--TextMuted);
  font-size: 12px;
}

.Composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: var(--Background);
  border-top: 1px solid var(--Hairline);
}

.Input {
  flex: 1;
  min-height: 40px;
  max-height: 140px;
  padding: 9px 12px;
  background: var(--Surface);
  border: 1px solid var(--Hairline);
  border-radius: var(--Radius);
  color: var(--Text);
  font: 16px/1.35 var(--Font);
  resize: none;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}

.Input:focus {
  border-color: var(--HairlineStrong);
}

.Input::placeholder {
  color: var(--TextFaint);
}

.Send {
  height: 40px;
  padding: 0 16px;
  background: var(--Accent);
  border: 0;
  border-radius: var(--Radius);
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.Send:disabled {
  opacity: 0.4;
  cursor: default;
}

.Corner {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 5;
  width: 56px;
  height: calc(52px + env(safe-area-inset-top));
  touch-action: manipulation;
}

.Shield {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: var(--Background);
}

@keyframes Fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
