/* Hub screens. Values come from shared/tokens.css. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(120% 70% at 50% 25%, color-mix(in srgb, var(--felt) 88%, var(--chalk) 12%), transparent 70%),
    var(--felt);
  color: var(--chalk);
  font-family: var(--font);
  font-weight: var(--weight-text);
  font-size: var(--text-md);
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior: none;
}

button,
input {
  font: inherit;
  color: inherit;
}

h1,
h2,
p {
  margin: 0;
}

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

.app {
  min-height: 100dvh;
  display: flex;
  padding: env(safe-area-inset-top) calc(var(--gutter) + env(safe-area-inset-right))
    calc(var(--space-3) + env(safe-area-inset-bottom)) calc(var(--gutter) + env(safe-area-inset-left));
}

.screen {
  flex: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.stack {
  display: grid;
  gap: var(--space-3);
}

/* ---------- Buttons and inputs ---------- */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: var(--tap);
  padding: 0 var(--space-4);
  border: 0;
  border-radius: var(--radius-control);
  font-weight: var(--weight-bold);
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--dur-quick), box-shadow var(--dur-quick);
}

.btn.primary {
  background: var(--p1);
  color: var(--p1-ink);
  box-shadow: 0 5px 0 color-mix(in srgb, var(--p1) 55%, var(--felt-deep));
}

.btn.primary:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 color-mix(in srgb, var(--p1) 55%, var(--felt-deep));
}

.btn.secondary {
  background: transparent;
  color: var(--chalk);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--chalk) 40%, transparent);
}

.btn.secondary:active {
  background: var(--felt-deep);
}

.text-btn {
  min-height: var(--tap);
  padding: 0 var(--space-2);
  border: 0;
  background: none;
  color: var(--chalk-dim);
  font-size: var(--text-sm);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

input {
  width: 100%;
  min-height: var(--tap);
  padding: 0 var(--space-3);
  border: 2px solid transparent;
  border-radius: var(--radius-control);
  background: var(--felt-deep);
  font-size: var(--text-md);
}

input:focus {
  border-color: var(--chalk-dim);
  outline: none;
}

label {
  color: var(--chalk-dim);
}

.error {
  color: var(--chalk);
  font-size: var(--text-sm);
}

.note {
  color: var(--chalk-dim);
  text-align: center;
}

/* ---------- Brand ---------- */

.brand {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  text-align: center;
}

.brand h1 {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.01em;
}

.hello {
  color: var(--chalk-dim);
}

.logo {
  display: flex;
}

.logo-p1,
.logo-p2 {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-piece);
}

.logo-p1 {
  background: var(--p1);
}

.logo-p2 {
  margin-left: -18px;
  border: 14px solid var(--p2);
}

.actions {
  display: grid;
  gap: var(--space-3);
}

/* ---------- Home ---------- */

.join-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-2);
}

.join-row .btn {
  width: auto;
}

.code-input {
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  font-weight: var(--weight-bold);
}

.code-input::placeholder {
  letter-spacing: normal;
  font-weight: var(--weight-text);
  color: var(--chalk-dim);
  text-transform: none;
}

.settings {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid color-mix(in srgb, var(--chalk) 15%, transparent);
}

.swatches {
  display: flex;
}

.swatch {
  width: 44px;
  height: 44px;
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.swatch::before {
  content: '';
  width: 28px;
  height: 28px;
  border-radius: var(--radius-piece);
  background: var(--felt);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--chalk) 25%, transparent);
}

.swatch[aria-pressed='true']::before {
  box-shadow: 0 0 0 3px var(--chalk);
}

.version {
  color: var(--chalk-dim);
  font-size: var(--text-sm);
}

/* ---------- Room ---------- */

.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-2);
}

.top-row .text-btn {
  padding-left: 0;
}

.room-code {
  display: grid;
  gap: var(--space-2);
  justify-items: center;
  text-align: center;
}

.room-code .label {
  color: var(--chalk-dim);
}

.room-code .code {
  font-size: var(--text-code);
  font-weight: var(--weight-bold);
  letter-spacing: 0.18em;
  line-height: 1;
  margin-right: -0.18em;
}

.room-code .link {
  min-height: 36px;
  font-size: var(--text-sm);
  color: var(--chalk-dim);
  text-align: center;
}

/* Both phones in: the code and invite shrink to one line so the games show. */
.screen-room.is-compact .room-code {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-align: left;
}

.screen-room.is-compact .room-code .code {
  font-size: var(--text-lg);
  letter-spacing: 0.1em;
  margin-right: auto;
}

.screen-room.is-compact .room-code .btn {
  width: auto;
  padding-inline: var(--space-3);
}

.screen-room.is-compact .room-code .link {
  display: none;
}

.screen-room.is-compact .players {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
}

.players {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}

.players li {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.players .dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-piece);
  background: var(--chalk);
}

.players .waiting {
  color: var(--chalk-dim);
  padding-left: calc(10px + var(--space-2));
}
