/* Login screen on the phone. Values come from src/styles/tokens.css. */

.login {
  box-sizing: border-box;
  max-width: var(--phone-max-width);
  margin: 0 auto;
  padding: var(--space-5) max(var(--space-4), env(safe-area-inset-right))
    var(--space-7) max(var(--space-4), env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.login-home-link {
  display: inline-flex;
  align-items: center;
  align-self: start;
  min-height: var(--hit-min);
  color: var(--color-ink);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--weight-display);
  font-size: var(--text-title);
}

.login-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius);
  background: var(--color-surface);
}

.login-text {
  margin: 0;
  font-size: var(--text-large);
  overflow-wrap: anywhere;
}

.login-hint {
  margin: 0;
  color: var(--color-muted);
}

.login-checking {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-muted);
}

.login-button {
  display: inline-flex;
  box-sizing: border-box;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--hit-min);
  padding: var(--space-3) var(--space-5);
  border: 0;
  border-radius: var(--radius);
  background: var(--color-ink);
  color: var(--color-surface);
  font: inherit;
  font-weight: var(--weight-bold);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-out);
}

.login-button:active {
  transform: scale(var(--press-scale));
  transition: none;
}

.login-button:disabled {
  background: var(--color-sunken);
  color: var(--color-muted);
  cursor: progress;
}

.login-button-secondary {
  background: var(--color-sunken);
  color: var(--color-ink);
}

.login-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.login-avatar {
  flex: none;
  width: var(--hit-min);
  height: var(--hit-min);
  border-radius: var(--radius-round);
  object-fit: cover;
}

.login-avatar-letter {
  display: grid;
  place-items: center;
  background: var(--color-team-b-soft);
  font-family: var(--font-display);
  font-weight: var(--weight-display);
}
/* View styles: the Push/Pull mark gives visual feedback alongside the screen's text. */
.push-mark {
  width: 2em;
  height: 1em;
  flex: none;
  overflow: visible;
  vertical-align: middle;
}

.push-mark-left { fill: var(--color-team-a); transform-origin: 6px 6px; }
.push-mark-right { fill: var(--color-team-b); transform-origin: 18px 6px; }

.push-mark-entry .push-mark-left,
.push-mark-entry .push-mark-right {
  animation: push-mark-enter var(--duration) var(--ease-out) both;
}

.push-mark-entry .push-mark-left { --mark-travel: -6px; }
.push-mark-entry .push-mark-right { --mark-travel: 6px; }

.push-mark-loading .push-mark-left,
.push-mark-loading .push-mark-right {
  animation: push-mark-separate var(--duration-loading) ease-in-out infinite;
}

.push-mark-loading .push-mark-left { --mark-travel: -2px; }
.push-mark-loading .push-mark-right { --mark-travel: 2px; }

.push-mark-searching .push-mark-beam {
  fill: var(--color-team-b);
  animation: push-mark-sweep var(--duration-loading) ease-in-out infinite;
}

.push-mark-success .push-mark-left,
.push-mark-success .push-mark-right {
  animation: push-mark-settle var(--duration) var(--ease-out) both;
}

.push-mark-success .push-mark-left { --mark-travel: -4px; }
.push-mark-success .push-mark-right { --mark-travel: 4px; }

.push-mark-failure .push-mark-left,
.push-mark-failure .push-mark-right {
  animation: push-mark-shake var(--duration) var(--ease-out) both;
}

.push-mark-waiting .push-mark-left,
.push-mark-waiting .push-mark-right {
  animation: push-mark-separate var(--duration) var(--ease-out) both;
}

.push-mark-failure .push-mark-left { --mark-travel: -4px; }
.push-mark-failure .push-mark-right { --mark-travel: 4px; }
.push-mark-waiting .push-mark-left { --mark-travel: -2px; }
.push-mark-waiting .push-mark-right { --mark-travel: 2px; }

.push-mark-halo,
.push-mark-spark,
.push-mark-dots,
.push-mark-beam,
.push-mark-shimmer,
.push-mark-ring {
  opacity: 0;
}

.push-mark-shimmer {
  fill: var(--color-surface);
  animation: push-mark-glint var(--duration) ease-out;
}

.push-mark-ring {
  fill: none;
  stroke: var(--color-team-b);
  animation: push-mark-meet var(--duration-loading) ease-out infinite;
}

.push-mark-halo {
  fill: none;
  stroke: var(--color-success);
  animation: push-mark-flash var(--duration) ease-out;
}

.push-mark-spark {
  stroke: var(--color-error);
  animation: push-mark-flash var(--duration) ease-out;
}

.push-mark-dots {
  fill: var(--color-muted);
  animation: push-mark-flash var(--duration) ease-out;
}

.push-mark-trace {
  fill: none;
  stroke-dasharray: 1;
  opacity: 0;
  animation: push-mark-trace var(--duration) var(--ease-out);
}

.push-mark-trace-left { stroke: var(--color-team-a); }
.push-mark-trace-right { stroke: var(--color-team-b); }

.push-mark-game-start .push-mark-left,
.push-mark-game-start .push-mark-right {
  animation: push-mark-flood var(--duration) var(--ease-out) both;
}

@keyframes push-mark-enter {
  0% { opacity: 0; transform: translateX(var(--mark-travel)) scale(0.9); }
  75% { opacity: 1; transform: scale(1.05); }
  100% { opacity: 1; transform: none; }
}

@keyframes push-mark-separate {
  50% { transform: translateX(var(--mark-travel)); opacity: 0.75; }
}

@keyframes push-mark-shake {
  25%, 60% { transform: translateX(var(--mark-travel)); }
  45% { transform: translateX(0); }
}

@keyframes push-mark-glint {
  70% { opacity: 0.4; }
}

@keyframes push-mark-meet {
  0%, 80% { opacity: 0; }
  90% { opacity: 0.75; }
}

@keyframes push-mark-sweep {
  0% { transform: translateX(-6px); }
  50% { opacity: 0.6; }
  100% { transform: translateX(6px); }
}

@keyframes push-mark-settle {
  0% { transform: translateX(var(--mark-travel)) scale(0.85); }
  60% { transform: scale(1.1); }
  100% { transform: none; }
}

@keyframes push-mark-flash {
  50% { opacity: 1; }
}

@keyframes push-mark-trace {
  0% { stroke-dashoffset: 1; opacity: 1; }
  65% { stroke-dashoffset: 0; opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 0; }
}

@keyframes push-mark-flood {
  0%, 40% { opacity: 0; }
  100% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .push-mark * { animation: none !important; }
}
/* View styles: status lines. Sizes follow the parent's font size, so the same line works on a phone and a TV. */
.status-message {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3) var(--space-4);
}

.status-message-text {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: 0;
}

.status-message-loading,
.status-message-waiting,
.status-message-searching,
.status-message-empty {
  color: var(--color-muted);
}

.status-message-success { color: var(--color-success); }
.status-message-error { color: var(--color-error); }

.status-message-retry {
  min-height: var(--hit-min);
  padding: var(--space-2) var(--space-4);
  border: 0;
  border-radius: var(--radius);
  background: var(--color-sunken);
  color: var(--color-ink);
  font: inherit;
  font-weight: var(--weight-bold);
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-out);
}

.status-message-retry:active {
  transform: scale(var(--press-scale));
  transition: none;
}
/* View styles: lay out the device choices and shared game board on the landing page. */

.home {
  display: grid;
  gap: var(--space-5);
  box-sizing: border-box;
  max-width: var(--phone-max-width);
  margin-inline: auto;
  padding: var(--space-5) max(var(--space-4), env(safe-area-inset-right))
    max(var(--space-5), env(safe-area-inset-bottom)) max(var(--space-4), env(safe-area-inset-left));
}

.home-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2) var(--space-3);
}

.home-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--hit-min);
  font: var(--weight-display) var(--text-body) / 1.25 var(--font-display);
}

.home-account {
  display: grid;
  justify-items: start;
  align-content: center;
  gap: var(--space-2);
  min-height: var(--hit-min);
  max-width: var(--phone-max-width);
}

.home-account .login-button {
  padding-inline: var(--space-3);
}

.home-hero,
.home-intro,
.home-choices {
  display: grid;
}

.home-hero {
  gap: var(--space-6);
}

.home-intro {
  align-content: center;
  gap: var(--space-4);
}

.home-title {
  display: grid;
  margin: 0;
  font: var(--weight-display) var(--text-hero) / 1.12 var(--font-display);
}

.home-lead {
  max-width: 42ch;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--color-muted);
}

.home-choices {
  gap: var(--space-3);
  max-width: var(--phone-max-width);
}

.home-choice {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  box-sizing: border-box;
  min-height: var(--hit-min);
  padding: var(--space-3);
  border-radius: var(--radius);
  background: var(--color-sunken);
  color: var(--color-ink);
  font-weight: var(--weight-bold);
  text-decoration: none;
}

.home-choice-primary {
  background: var(--color-ink);
  color: var(--color-surface);
}

.home-choice:hover,
.home-choice:active,
.home-extras a:active {
  text-decoration: underline;
  text-decoration-thickness: var(--focus-offset);
}

.home-choice-arrow {
  margin-inline-start: auto;
}

.home-choice > .icon {
  font-size: var(--text-large);
}

.home-extras {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-5);
}

.home-extras a {
  display: inline-flex;
  align-items: center;
  min-height: var(--hit-min);
  color: var(--color-ink);
}

.home-preview {
  display: grid;
  gap: var(--space-3);
  min-width: 0;
  margin: 0;
  padding: var(--space-4);
  border-radius: var(--radius);
  background: var(--color-surface);
}

.home-preview-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-3);
}

.home-preview-header > span {
  font: var(--weight-display) var(--text-body) / 1.25 var(--font-display);
}

.home-teams {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.home-preview-copy {
  margin: 0;
  color: var(--color-muted);
  text-wrap: pretty;
}

@media (45rem <= width < 60rem) and (orientation: landscape) {
  .home {
    max-width: calc(var(--phone-max-width) * 2);
    padding-inline: max(var(--space-5), env(safe-area-inset-left)) max(var(--space-5), env(safe-area-inset-right));
  }

  .home-hero {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: center;
    gap: var(--space-5);
  }
}

@media (min-width: 60rem) {
  .home {
    grid-template-rows: auto 1fr auto;
    gap: var(--space-6);
    min-height: 100svh;
    max-width: calc(var(--phone-max-width) * 4);
    padding: var(--space-6) var(--tv-safe);
  }

  .home-hero {
    align-self: center;
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
    align-items: center;
    gap: var(--space-7);
  }

  .home-title {
    font-size: max(var(--text-hero), var(--tv-title));
  }

  .home-account {
    justify-items: end;
  }

  .home-preview {
    padding: var(--space-5);
  }
}

@media (min-width: 80rem) and (orientation: landscape) {
  .home,
  .home-logo,
  .home-preview-header > span,
  .home-choice > .icon {
    font-size: var(--tv-text);
  }

  .home-title {
    font-size: var(--tv-score);
  }

  .home-choice {
    padding: var(--space-3) var(--space-4);
  }
}
/* View styles: the board's canvas fills its box at the board's own shape. The drawing itself is in boardPainter.js. */
.game-board {
  width: 100%;
  aspect-ratio: var(--columns) / var(--rows);
}

.game-board-canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: var(--radius);
  background: var(--color-board);
}
/* View styles: team chips. Orange gets ink text and blue gets white text (design.md, Colour). */
.team-chip {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius);
  font-weight: var(--weight-bold);
  white-space: nowrap;
}

.team-chip-a {
  background: var(--color-team-a);
  color: var(--color-team-a-ink);
}

.team-chip-b {
  background: var(--color-team-b);
  color: var(--color-team-b-ink);
}
/* Weather check on the TV. Sizes use the TV scale so it reads from the sofa. Values come from src/styles/tokens.css. */

.weather {
  box-sizing: border-box;
  max-width: calc(var(--phone-max-width) * 2);
  margin-inline: auto;
  padding: var(--space-5) max(var(--space-4), var(--tv-safe));
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  font-size: var(--tv-text);
}

.weather-header {
  display: grid;
  gap: var(--space-2);
}

.weather-header a {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  min-height: var(--hit-min);
  color: var(--color-ink);
}

.weather-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--weight-display);
  font-size: var(--tv-title);
  text-wrap: balance;
}

.weather-lead,
.weather-message {
  margin: 0;
  color: var(--color-muted);
}

.weather-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.weather-label {
  font-weight: var(--weight-bold);
}

.weather-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.weather-input {
  box-sizing: border-box;
  flex: 1 1 16ch;
  min-width: 0;
  min-height: var(--hit-min);
  padding: var(--space-3) var(--space-4);
  border: 0;
  border-radius: var(--radius);
  background: var(--color-sunken);
  color: var(--color-ink);
  font: inherit;
}

.weather-button {
  min-height: var(--hit-min);
  padding: var(--space-3) var(--space-5);
  border: 0;
  border-radius: var(--radius);
  background: var(--color-ink);
  color: var(--color-surface);
  font: inherit;
  font-weight: var(--weight-bold);
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-out);
}

.weather-button:active {
  transform: scale(var(--press-scale));
  transition: none;
}

.weather-button:disabled {
  background: var(--color-sunken);
  color: var(--color-muted);
  cursor: not-allowed;
}

.weather-button-secondary {
  background: var(--color-sunken);
  color: var(--color-ink);
}

.weather-status .weather-message {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.weather-error {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
}

.weather-error .weather-message {
  color: var(--color-error);
}

.weather-card {
  padding: var(--space-5);
  border-radius: var(--radius);
  background: var(--color-surface);
}

.weather-city {
  margin: 0 0 var(--space-4);
  overflow-wrap: anywhere;
  font-family: var(--font-display);
  font-weight: var(--weight-display-light);
  font-size: var(--tv-title);
}

.weather-facts {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.weather-fact {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.weather-fact-icon {
  font-size: var(--tv-title);
  color: var(--color-ink);
}

@media (min-width: 80rem) and (orientation: landscape) {
  .weather {
    padding-block: var(--tv-safe);
  }
}
/* View styles: the sound button, a secondary button that follows the parent's font size (phone or TV). */
.sound-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--hit-min);
  padding: var(--space-2) var(--space-4);
  border: 0;
  border-radius: var(--radius);
  background: var(--color-sunken);
  color: var(--color-ink);
  font: inherit;
  font-weight: var(--weight-bold);
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-out);
}

.sound-toggle:active {
  transform: scale(var(--press-scale));
  transition: none;
}
/* View styles: the demo board, scoreboard and keyboard guide. */
.demo {
  box-sizing: border-box;
  display: grid;
  gap: var(--space-3);
  max-width: calc(var(--phone-max-width) * 2);
  margin-inline: auto;
  padding: var(--space-4) var(--tv-safe) var(--space-6);
}

.demo-intro,
.demo-playfield,
.demo-guide {
  display: grid;
  min-width: 0;
  gap: var(--space-3);
}

.demo-header {
  display: grid;
  gap: var(--space-1);
}

.demo-links {
  display: flex;
  flex-wrap: wrap;
  column-gap: var(--space-5);
}

.demo-links a {
  display: inline-flex;
  align-items: center;
  min-height: var(--hit-min);
  color: var(--color-ink);
}

.demo-header p,
.demo-weather {
  max-width: 42ch;
  overflow-wrap: anywhere;
}

.demo h1,
.demo h2,
.demo p {
  margin: 0;
}

.demo h1,
.demo h2 {
  font-family: var(--font-display);
  font-weight: var(--weight-display);
}

.demo h1 { font-size: var(--text-title); }
.demo h2 { font-size: var(--text-large); }

.demo-score,
.demo-actions,
.demo-round {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.demo-score {
  font-size: var(--text-large);
}

.demo-team {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-small);
}

.demo-a {
  background: var(--color-team-a);
  color: var(--color-team-a-ink);
}

.demo-b {
  background: var(--color-team-b);
  color: var(--color-team-b-ink);
}

.demo-arena {
  position: relative;
  border-radius: var(--radius);
}

.demo-weather,
.demo-weather-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.demo-weather {
  align-items: start;
  flex-direction: column;
}

.demo-weather-form input,
.demo-weather-form button {
  box-sizing: border-box;
  min-height: var(--hit-min);
  max-width: 100%;
  padding-inline: var(--space-3);
  border: 0;
  border-radius: var(--radius);
  background: var(--color-sunken);
  color: var(--color-ink);
  font: inherit;
}

.demo-weather-form input { width: 16ch; }
.demo-weather-form button:not(:disabled) { cursor: pointer; }
.demo-weather-form button:disabled { color: var(--color-muted); }


.demo-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--space-4);
  text-align: center;
  font-weight: var(--weight-bold);
}

.demo-overlay[role="status"] {
  inset: auto 0 0;
  background: var(--color-sunken);
  border-radius: 0 0 var(--radius) var(--radius);
}

.demo-start {
  min-height: var(--hit-min);
  padding-inline: var(--space-4);
  border: 0;
  border-radius: var(--radius);
  background: var(--color-ink);
  color: var(--color-surface);
  cursor: pointer;
  font: inherit;
  font-weight: var(--weight-bold);
}

.demo-start:active {
  transform: scale(var(--press-scale));
}

.demo-keys {
  display: grid;
  gap: var(--space-2);
}

.demo-keys ul {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16ch), 1fr));
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.demo-keys li {
  display: grid;
  gap: var(--space-1);
  padding: var(--space-2);
  border-radius: var(--radius-small);
  background: var(--color-surface);
}

.demo-keys li span {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.demo-keys kbd {
  padding-inline: var(--space-1);
  border-radius: var(--radius-small);
  background: var(--color-sunken);
  font-family: var(--font-numbers);
}

@media (min-width: 45rem) and (orientation: landscape) {
  .demo {
    max-width: calc(var(--phone-max-width) * 3);
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    grid-template-areas:
      "intro playfield"
      "guide playfield";
    grid-template-rows: auto 1fr;
    align-items: start;
    column-gap: var(--space-5);
  }

  .demo-intro { grid-area: intro; }
  .demo-playfield { grid-area: playfield; }
  .demo-guide { grid-area: guide; }
}

@media (min-width: 60rem) and (orientation: landscape) {
  .demo-keys ul {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 80rem) and (orientation: landscape) {
  .demo,
  .demo-score,
  .demo h2 {
    font-size: var(--tv-text);
  }

  .demo h1 { font-size: var(--tv-title); }
}
/* View styles: keep controller touches inside the landscape play area. */
.controller {
  --controller-safe-left: env(safe-area-inset-left, 0px);
  --controller-safe-right: env(safe-area-inset-right, 0px);
  --controller-safe-top: env(safe-area-inset-top, 0px);
  --controller-safe-bottom: env(safe-area-inset-bottom, 0px);
  position: fixed;
  inset: 0;
  box-sizing: border-box;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--color-bg);
  color: var(--color-ink);
}

.controller:fullscreen {
  width: 100%;
  height: 100%;
}

.controller-portrait,
.controller-setup {
  box-sizing: border-box;
  margin: 0;
  padding: var(--space-4);
  text-align: center;
}

.controller-portrait {
  display: grid;
  height: 100%;
  place-items: center;
  font-size: var(--text-title);
  font-weight: var(--weight-bold);
}

.controller-landscape { display: none; }

@media (orientation: landscape) {
  .controller-portrait { display: none; }

  .controller-setup {
    display: grid;
    gap: var(--space-2);
    justify-items: center;
    align-content: safe center;
    height: 100%;
    overflow-y: auto;
    padding-top: max(var(--space-4), env(safe-area-inset-top));
    padding-right: max(var(--space-4), env(safe-area-inset-right));
    padding-bottom: max(var(--space-4), env(safe-area-inset-bottom));
    padding-left: max(var(--space-4), env(safe-area-inset-left));
  }

  .controller-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
  }
}

.controller-setup h1,
.controller-setup p { margin: 0; }
.controller-setup h1 { font-size: var(--text-title); }
.controller-setup a { color: inherit; }

.controller-setup button {
  min-height: var(--hit-min);
  padding-inline: var(--space-4);
  border: 0;
  border-radius: var(--radius);
  background: var(--color-ink);
  color: var(--color-surface);
  font: inherit;
  font-weight: var(--weight-bold);
  cursor: pointer;
}

.controller-stick {
  position: relative;
}

.controller-stick-ring,
.controller-stick-thumb {
  position: absolute;
  box-sizing: border-box;
  border-radius: var(--radius-round);
  pointer-events: none;
}

.controller-stick-ring {
  /* Keep the drawing clear of cutouts without shrinking the touch zone. */
  --ring-clearance: calc(var(--controller-button) / 2 + var(--space-3));
  left: clamp(calc(var(--controller-safe-left) + var(--ring-clearance)),
    var(--stick-x, 50%), calc(100% - var(--ring-clearance)));
  top: clamp(calc(var(--controller-safe-top) + var(--ring-clearance)),
    var(--stick-y, 50%), calc(100% - var(--controller-safe-bottom) - var(--ring-clearance)));
  width: var(--controller-button);
  height: var(--controller-button);
  translate: -50% -50%;
  border: var(--space-1) solid var(--color-ink);
  background: var(--color-sunken);
}

.controller-stick-thumb {
  inset: calc(var(--controller-button) / 4);
  background: var(--color-ink);
}

.controller-actions {
  display: grid;
  grid-template: repeat(2, minmax(0, 1fr)) / repeat(2, minmax(0, 1fr));
  padding-block: max(var(--space-3), var(--controller-safe-top)) max(var(--space-3), var(--controller-safe-bottom));
  padding-inline: 0 max(var(--space-3), var(--controller-safe-right));
}

.controller-action {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: var(--hit-min);
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--color-ink);
  font: inherit;
  font-weight: var(--weight-bold);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.controller-action-face {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: var(--space-1);
  width: var(--controller-button);
  height: var(--controller-button);
  border-radius: var(--radius-round);
  background: var(--color-sunken);
  transition: transform var(--duration-fast) var(--ease-out);
  pointer-events: none;
}

.controller-action .icon { font-size: var(--text-title); }

.controller-action[data-held="true"] .controller-action-face {
  transform: scale(var(--press-scale));
  background: var(--color-ink);
  color: var(--color-surface);
  transition: none;
}
/* View styles: a team's seats on the team's soft colour. A filled seat pops in once (design.md, Game feel). */
.team-roster {
  display: grid;
  align-content: start;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius);
}

.team-roster-a { background: var(--color-team-a-soft); }
.team-roster-b { background: var(--color-team-b-soft); }

.team-roster-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.team-roster-count {
  color: var(--color-muted);
  font-weight: var(--weight-bold);
}

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

.team-roster-seat {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--hit-min);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
}

.team-roster-filled {
  background: var(--color-surface);
  font-weight: var(--weight-bold);
}

.team-roster-open {
  color: var(--color-muted);
}

.team-roster-avatar {
  display: grid;
  flex: none;
  place-items: center;
  width: 1.75em;
  aspect-ratio: 1;
  border-radius: var(--radius-round);
  font-family: var(--font-display);
  font-weight: var(--weight-display);
  animation: pop var(--duration-effect) var(--ease-out);
}

.team-roster-a .team-roster-avatar { background: var(--color-team-a); color: var(--color-team-a-ink); }
.team-roster-b .team-roster-avatar { background: var(--color-team-b); color: var(--color-team-b-ink); }

.team-roster-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-roster-you {
  margin-inline-start: auto;
  padding: 0 var(--space-2);
  border-radius: var(--radius-small);
  background: var(--color-sunken);
}
/* View styles: room code boxes on sunken fill. They scale with the parent's font size (TV: --tv-score, phone: --text-hero). */
.room-code {
  display: flex;
  gap: var(--space-2);
  margin: 0;
}

.room-code-box {
  display: grid;
  place-items: center;
  min-width: 1.3em;
  padding: var(--space-2);
  border-radius: var(--radius);
  background: var(--color-sunken);
  font-weight: var(--weight-bold);
  line-height: 1.1;
}

.room-code-empty .room-code-box {
  color: var(--color-muted);
}
/* View styles: the four room code boxes on the phone (design.md, Components: Inputs). */
.room-code-input {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.room-code-input-label {
  margin-bottom: var(--space-2);
  padding: 0;
  font-weight: var(--weight-bold);
}

.room-code-input-boxes {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-2);
  max-width: calc(var(--hit-min) * 6);  /* four chunky boxes, not stretched across a wide phone */
}

.room-code-input-box {
  box-sizing: border-box;
  width: 100%;
  min-height: calc(var(--hit-min) * 1.5);
  border: 0;
  border-radius: var(--radius);
  background: var(--color-sunken);
  color: var(--color-ink);
  font-size: var(--text-hero);
  font-weight: var(--weight-bold);
  text-align: center;
  text-transform: uppercase;
  caret-color: transparent;
}

.room-code-input-box:focus-visible {
  background: var(--color-surface);
}

.room-code-input-box[aria-invalid="true"] {
  color: var(--color-error);
}

.room-code-input-box:disabled {
  color: var(--color-muted);
}
/* View styles: TV score bar (design.md, Components: Score bar). Uses only the TV text sizes. */
.score-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius);
  background: var(--color-surface);
  font-size: var(--tv-text);
}

.score-bar-team {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-width: 0;
}

.score-bar-team-b {
  justify-content: end;
}

.score-bar-score {
  display: inline-block;
  font-family: var(--font-display);
  font-size: var(--tv-score);
  font-weight: var(--weight-display);
  line-height: 1;
  animation: pop var(--duration-effect) var(--ease-out);
}

.score-bar-middle {
  display: grid;
  justify-items: center;
  gap: var(--space-1);
}

.score-bar-title {
  color: var(--color-muted);
  font-weight: var(--weight-bold);
}

.score-bar-timer {
  display: inline-block;
  font-size: var(--tv-title);
  font-weight: var(--weight-bold);
  line-height: 1;
}

.score-bar-warning {
  color: var(--color-warning);
  animation: pop var(--duration-effect) var(--ease-out);
}
/* View styles: the countdown sits in the middle of its parent, which needs position: relative. */
.countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.countdown-value {
  display: grid;
  place-items: center;
  min-width: 1.4em;
  aspect-ratio: 1;
  padding: var(--space-4);
  border-radius: var(--radius-round);
  background: var(--color-surface);
  font-family: var(--font-display);
  font-size: calc(var(--tv-score) * 2);
  font-weight: var(--weight-display);
  line-height: 1;
  animation: countdown-in var(--duration-effect) var(--ease-out) both;
}

@keyframes countdown-in {
  from {
    opacity: 0;
    transform: scale(calc(var(--pop-scale) * 1.5));
  }
}
/* View styles: the component gallery, a dev page laid out like the home page. */
.gallery {
  box-sizing: border-box;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-5);
  max-width: calc(var(--phone-max-width) * 3);
  margin-inline: auto;
  padding: var(--space-5) var(--space-4) var(--space-7);
}

.gallery-header {
  display: grid;
  gap: var(--space-2);
}

.gallery-nav {
  display: flex;
  flex-wrap: wrap;
  column-gap: var(--space-5);
}

.gallery-nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--hit-min);
  color: var(--color-ink);
}

.gallery h1,
.gallery h2,
.gallery p {
  margin: 0;
}

.gallery h1,
.gallery h2 {
  font-family: var(--font-display);
  font-weight: var(--weight-display);
}

.gallery h1 {
  font-size: var(--text-hero);
  text-wrap: balance;
}
.gallery h2 { font-size: var(--text-large); }

.gallery-header p,
.gallery-note {
  max-width: 60ch;
  color: var(--color-muted);
}

.gallery-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius);
  background: var(--color-surface);
}

.gallery-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.gallery-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: var(--space-4);
}

.gallery-form {
  display: grid;
  gap: var(--space-2);
}

/* TV samples use the TV text size, so they look like they will on the shared screen. */
.gallery-tv {
  font-size: var(--tv-text);
}

.gallery-tv .room-code {
  font-size: var(--tv-score);
}

.gallery-board {
  position: relative;
}

.gallery-row button {
  min-height: var(--hit-min);
  padding: var(--space-2) var(--space-4);
  border: 0;
  border-radius: var(--radius);
  background: var(--color-sunken);
  color: var(--color-ink);
  font: inherit;
  font-weight: var(--weight-bold);
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-out);
}

.gallery-row button:disabled {
  color: var(--color-muted);
  cursor: not-allowed;
}

.gallery-row button:active:not(:disabled) {
  transform: scale(var(--press-scale));
  transition: none;
}

.gallery-row button[aria-pressed="true"] {
  background: var(--color-ink);
  color: var(--color-surface);
}

.gallery-sound-team {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.gallery-sound-team select {
  min-height: var(--hit-min);
  padding-inline: var(--space-3);
  border: 0;
  border-radius: var(--radius);
  background: var(--color-sunken);
  color: var(--color-ink);
  font: inherit;
}

.gallery h3 {
  margin: 0;
  font-size: var(--text-body);
}

/* Stack the TV score bar sample so it can also be tried on a narrow phone. */
@media (max-width: 37.5rem) {
  .gallery-tv .score-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "middle middle"
      "team-a team-b";
    gap: var(--space-3);
    padding-inline: 0;
  }

  .gallery-tv .score-bar-middle {
    grid-area: middle;
    text-align: center;
  }

  .gallery-tv .score-bar-team {
    grid-area: team-a;
    gap: var(--space-2);
  }

  .gallery-tv .score-bar-team-b {
    grid-area: team-b;
  }
}

@media (min-width: 60rem) {
  .gallery {
    padding: var(--space-6) var(--tv-safe) var(--space-7);
  }

  .gallery-section {
    padding: var(--space-5);
  }
}
/* Design tokens: every colour, font, size and duration the Views use. Decisions in docs/design.md. */

:root {
  /* Colour */
  --color-bg: #FFF6EA;
  --color-surface: #FFFFFF;
  --color-sunken: #F7E8D5;
  --color-ink: #2A2134;
  --color-muted: #6D6377;
  --color-line: #EBDCC8;

  --color-team-a: #FF5A1F;      /* never use as a text colour (too light) */
  --color-team-a-ink: #2A2134;  /* text on Team A */
  --color-team-a-soft: #FFE3D6;
  --color-team-b: #2D5BFF;
  --color-team-b-ink: #FFFFFF;  /* text on Team B */
  --color-team-b-soft: #DFE6FF;

  --color-board: #FFFCF6;
  --color-board-dot: #E3CFB3;
  --color-apple: #2A2134;

  --color-success: #17703D;
  --color-warning: #8F5400;
  --color-error: #C62828;

  /* Fonts */
  --font-display: "Unbounded", "Arial Black", system-ui, sans-serif;
  --font-text: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, sans-serif;
  --font-numbers: var(--font-text);   /* use together with font-variant-numeric: tabular-nums */
  --font-icons: "Material Symbols Rounded";
  --weight-regular: 400;
  --weight-bold: 700;
  --weight-display: 800;
  --weight-display-light: 500;

  /* Type scale: phone */
  --text-small: 14px;
  --text-body: 16px;
  --text-large: 20px;
  --text-title: 24px;
  --text-hero: 32px;

  /* Type scale: TV (24px at 1920px wide, the minimum for body text on a TV) */
  --tv-text: clamp(18px, 1.25vw, 48px);
  --tv-title: clamp(28px, 2.5vw, 96px);
  --tv-score: clamp(36px, 3.75vw, 144px);
  --tv-safe: 5vw;

  /* Spacing (4px steps) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Shape and depth: flat fills, no shadows */
  --radius: 10px;
  --radius-small: 6px;
  --radius-round: 999px;
  --shadow: none;
  --focus-ring: 3px solid var(--color-ink);
  --focus-offset: 2px;

  /* Board: snake blocks are inset in their cell and rounded */
  --tile-inset: 8%;
  --tile-radius: 24%;

  /* Motion: snappy */
  --duration-fast: 120ms;
  --duration: 180ms;
  --duration-loading: 900ms;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);

  /* Effects for game events (docs/design.md, "Game feel") */
  --duration-effect: 420ms;     /* bursts, pops and shakes: shorter than two ticks */
  --pop-scale: 1.25;            /* a number that just changed grows to this, then settles */
  --shake-distance: 6px;        /* how far the board moves when a snake crashes */
  --burst-distance: 90%;        /* how far apple burst dots fly, measured in cells */

  /* Touch */
  --hit-min: 48px;
  --phone-max-width: 480px;
  --controller-button: 72px;
  --controller-gap: 16px;
  --press-scale: 0.92;
  /* Controller behaviour, read in JS with getComputedStyle(document.documentElement).getPropertyValue(...) */
  --press-vibration-ms: 20;     /* navigator.vibrate length for a button press */
  --stick-dead-zone: 0.12;      /* share of the stick ring that counts as idle */
}

/* Reduced motion: every animation becomes instant */
@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-fast: 0ms;
    --duration: 0ms;
    --duration-loading: 0ms;
    --duration-effect: 0ms;
    --pop-scale: 1;
    --shake-distance: 0px;
    --burst-distance: 0%;
  }
}

/* Shared base styles that every View relies on */
body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-text);
  font-size: var(--text-body);
  line-height: 1.45;
}

:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

.icon {
  font-family: var(--font-icons);
  font-weight: normal;
  font-style: normal;
  line-height: 1;
  letter-spacing: normal;
  white-space: nowrap;
  font-feature-settings: "liga";
  -webkit-font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
}

.numbers {
  font-family: var(--font-numbers);
  font-variant-numeric: tabular-nums;
}

/* Text for screen readers only, e.g. a room code spelled out letter by letter */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Shared effect: something that just changed grows once and settles (design.md, Game feel).
   Replay it by giving the element a new React key, e.g. key={score}. */
@keyframes pop {
  40% { transform: scale(var(--pop-scale)); }
}
