/* The .NET client's look (bakeoff/spec/visuals.md sections 6.5, 9, 10): flat rounded panels,
   one font (Nunito), big numbers, visible focus, text size / high contrast / reduced motion. */

@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-display: swap;
  font-weight: 200 1000;
  src: url('fonts/nunito-latin-wght-normal-ba344451.woff2') format('woff2-variations');
}

:root {
  --scale: 1;
  --ui: rgba(18, 16, 26, 0.72);
  --ui-line: rgba(255, 255, 255, 0.08);
  --ui-text: #f4f2fa;
  --ui-dim: rgba(244, 242, 250, 0.62);
  --ui-key: rgba(255, 255, 255, 0.14);
  --focus: #7cc6ff;
  --bg: #24212f;
  color-scheme: dark;
}

:root.high-contrast {
  --ui: rgba(6, 5, 10, 0.95);
  --ui-line: rgba(255, 255, 255, 0.6);
  --ui-dim: rgba(255, 255, 255, 0.92);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ui-text);
  font-family: 'Nunito', system-ui, sans-serif;
  font-weight: 700;
  font-size: calc(var(--fs-base) * var(--scale));
  -webkit-tap-highlight-color: transparent;
}

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

#stage {
  position: fixed;
  inset: 0;
}

.stage-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

#app {
  position: fixed;
  inset: 0;
  overflow: auto;
}

/* ------------------------------------------------------------ loader */

#loader {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1em;
  background: var(--bg);
  z-index: 50;
}

.loader-title {
  font-size: 2.6em;
  font-weight: 900;
}

.loader-track {
  width: 16em;
  height: 0.5em;
  border-radius: 1em;
  background: var(--ui-key);
  overflow: hidden;
}

#loader-bar {
  width: 0;
  height: 100%;
  background: var(--ui-text);
  transition: width 0.15s;
}

#loader-text {
  color: var(--ui-dim);
}

/* ------------------------------------------------------------ corner, stats */

.corner {
  position: fixed;
  left: 0.8em;
  bottom: 0.5em;
  font-size: max(var(--fs-small), 0.72em);
  color: var(--ui-dim);
  pointer-events: none;
  z-index: 20;
}

.stats-btn {
  position: fixed;
  left: 0.8em;
  top: 0.6em;
  z-index: 30;
  padding: 0.2em 0.6em;
  border-radius: 0.6em;
  border: 1px solid var(--ui-line);
  background: var(--ui);
  font-size: max(var(--fs-small), 0.72em);
  font-weight: 900;
  cursor: pointer;
}

.stats {
  position: fixed;
  left: 0.8em;
  top: 2.4em;
  z-index: 30;
  padding: 0.6em 0.8em;
  border-radius: 0.8em;
  background: rgba(6, 5, 10, 0.88);
  border: 1px solid var(--ui-line);
  font-size: max(var(--fs-small), 0.72em);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  line-height: 1.35;
}

.stats table {
  border-collapse: collapse;
}

.stats td {
  padding: 0 0.4em;
}

.stats td:first-child {
  color: var(--ui-dim);
}

.stats td:last-child {
  text-align: right;
  font-weight: 900;
}

.hidden {
  display: none !important;
}

/* Read out by screen readers, never seen (#say in index.html). */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------ focus (always visible) */

[data-nav]:focus {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/* ------------------------------------------------------------ menus */

.menu {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  gap: 0.8em;
  padding: 1.2em 1em 2.2em;
}

.menu h1 {
  margin: 0;
  font-size: 3em;
  font-weight: 900;
}

.menu h2 {
  margin: 0;
  font-size: 1.7em;
  font-weight: 900;
}

.menu .lead {
  margin: -0.6em 0 0;
  color: var(--ui-dim);
}

.menu-list {
  display: flex;
  flex-direction: column;
  gap: 0.6em;
  width: min(22em, 90vw);
}

.big {
  display: flex;
  align-items: center;
  gap: 0.7em;
  padding: 0.8em 1.1em;
  border-radius: 0.8em;
  border: 1px solid var(--ui-line);
  background: var(--ui);
  font-size: 1.15em;
  font-weight: 900;
  text-align: left;
  cursor: pointer;
}

.big small {
  display: block;
  font-size: max(var(--fs-small), 0.65em);
  font-weight: 700;
  color: var(--ui-dim);
}

.big:disabled {
  opacity: 0.5;
  cursor: default;
}

.big svg {
  flex: none;
}

.panel {
  width: min(44em, 94vw);
  padding: 0.6em 1.1em;
  border-radius: 0.8em;
  border: 1px solid var(--ui-line);
  background: var(--ui);
}

.panel h3 {
  margin: 0 0 0.3em;
  font-size: max(var(--fs-small), 0.85em);
  font-weight: 900;
  color: var(--ui-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5em;
  margin: 0.25em 0;
}

.row > .label {
  min-width: 9em;
  color: var(--ui-dim);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.25em 0.75em;
  border-radius: 0.7em;
  border: 2px solid var(--ui-line);
  background: transparent;
  font-weight: 800;
  cursor: pointer;
}

.chip[aria-pressed='true'] {
  background: var(--ui-text);
  color: #1d1a26;
  border-color: transparent;
}

.chip:disabled {
  opacity: 0.45;
  cursor: default;
}

.chip .check {
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  border-radius: 0.25em;
  border: 0.14em solid currentColor;
}

.chip[aria-pressed='true'] .check {
  background: currentColor;
}

.count {
  min-width: 2em;
  text-align: center;
  font-size: 1.2em;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.note {
  color: var(--ui-dim);
  font-size: max(var(--fs-small), 0.85em);
}

.seats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
}

.seat {
  display: flex;
  flex-wrap: wrap;
  max-width: 100%;
  align-items: center;
  gap: 0.35em;
  padding: 0.25em 0.6em;
  border-radius: 0.6em;
  border-left: 0.3em solid var(--c);
  background: rgba(255, 255, 255, 0.05);
  font-size: max(var(--fs-small), 0.85em);
}

.seat span {
  color: var(--ui-dim);
}

.actions {
  display: flex;
  gap: 0.7em;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  padding: 0.6em 1.3em;
  border-radius: 0.7em;
  border: 2px solid var(--ui-line);
  background: transparent;
  font-weight: 900;
  cursor: pointer;
}

.btn.primary {
  background: var(--ui-text);
  color: #1d1a26;
  border-color: transparent;
}

.btn:disabled {
  opacity: 0.45;
}

.where {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12em), 1fr));
  gap: 0.7em;
  width: min(44em, 94vw);
}

.where .big {
  flex-direction: column;
  align-items: flex-start;
}

.where .big[aria-pressed='true'] {
  border: 2px solid var(--ui-text);
}

.code-input {
  width: 6em;
  padding: 0.4em 0.6em;
  border-radius: 0.6em;
  border: 2px solid var(--ui-line);
  background: rgba(0, 0, 0, 0.3);
  font-size: 1.6em;
  font-weight: 900;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-align: center;
}

kbd {
  display: inline-block;
  min-width: 1.4em;
  padding: 0.05em 0.4em;
  margin: 0 0.15em;
  border-radius: 0.35em;
  background: var(--ui-key);
  border-bottom: 0.12em solid rgba(0, 0, 0, 0.25);
  font: inherit;
  font-size: max(var(--fs-small), 0.78em);
  font-weight: 800;
  text-align: center;
}

.pb {
  display: inline-grid;
  place-items: center;
  min-width: 1.5em;
  height: 1.5em;
  padding: 0 0.35em;
  margin: 0 0.15em;
  border-radius: 1em;
  background: var(--ui-key);
  font-style: normal;
  font-size: max(var(--fs-small), 0.75em);
  font-weight: 900;
  vertical-align: 0.1em;
}

.pb.a {
  background: #3ddc84;
  color: #10261a;
}

.pb.b {
  background: #f2545b;
  color: #2a0f11;
}

.pb.x {
  background: #3d8bfd;
  color: #0d1a33;
}

.pb.y {
  background: #f7c548;
  color: #2b220a;
}

/* ------------------------------------------------------------ Polygone HUD (visuals.md 6.5) */

.pg-hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  user-select: none;
}

.pg-hud button,
.pg-hud .pg-dialog {
  pointer-events: auto;
}

.pg-tag {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  will-change: transform;
  font-weight: 900;
  font-size: max(var(--fs-small), 0.8em);
}

.pg-tag span {
  padding: 0.05em 0.5em;
  border-radius: 0.5em;
  background: var(--c);
  color: #1d1a26;
  white-space: nowrap;
}

.pg-tag i {
  width: 0;
  height: 0;
  border: 0.4em solid transparent;
  border-top-color: var(--c);
  border-bottom: 0;
}

.pg-token {
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 1.7em;
  height: 1.7em;
  border-radius: 50%;
  background: var(--ui);
  border: 2px solid var(--ui-text);
  font-size: 1.1em;
  will-change: transform;
}

.pg-top {
  position: absolute;
  top: 1.1em;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pg-round {
  font-weight: 900;
  font-size: 1.5em;
  text-shadow: 0 0.1em 0.4em rgba(0, 0, 0, 0.35);
  white-space: nowrap;
}

.pg-round span {
  color: var(--ui-dim);
  font-size: max(var(--fs-small), 0.7em);
}

.pg-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  margin-top: 0.4em;
  padding: 0.35em 1em;
  border-radius: 1em;
  background: var(--ui);
  border: 2px solid var(--c, transparent);
  font-weight: 800;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(-0.4em) scale(0.95);
  transition:
    opacity 0.2s,
    transform 0.2s;
}

.pg-banner.show {
  opacity: 1;
  transform: none;
}

.pg-banner b {
  font-weight: 900;
  font-size: 1.15em;
}

/* The ability icon in the Siegeometry banner takes the seat's colour (as today's game). */
.pg-banner .icon {
  display: grid;
  color: var(--c);
}

.pg-count {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  font-size: 6em;
  font-weight: 900;
  text-shadow: 0 0.06em 0.3em rgba(0, 0, 0, 0.45);
  opacity: 0;
}

.pg-count.show {
  animation: pg-count 0.9s ease-out forwards;
}

@keyframes pg-count {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.5);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  75% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
  }
}

.pg-feed {
  position: absolute;
  top: 3.6em;
  right: 1.4em;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.3em;
  font-size: max(var(--fs-small), 0.8em);
  font-weight: 800;
}

.pg-feed-line {
  display: flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.2em 0.7em;
  border-radius: 0.7em;
  background: var(--ui);
  transition: opacity 0.5s;
}

.pg-feed-line span {
  color: var(--ui-dim);
}

.pg-feed-line.gone {
  opacity: 0;
}

.pg-panel {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.7em;
  /* Never wider than half the screen (big text on a phone); #72 must 6 brings the small-screen HUD. */
  width: min(14em, 50vw - 2em);
}

/* TV text is bigger (28 px): narrower cards and the round line closer to the top keep the HUD
   about as big as before, so visuals.md's framing still fits between them. */
@media (min-width: 1800px) {
  .pg-panel {
    width: min(11em, 50vw - 2em);
  }

  .pg-top {
    top: 0.4em;
  }

  .pg-hud .pg-pause-btn {
    top: calc(0.4em + var(--sa-t, 0px));
  }
}

:root.tv .pg-panel {
  width: min(11em, 50vw - 2em);
}

:root.tv .pg-top {
  top: 0.4em;
}

:root.tv .pg-hud .pg-pause-btn {
  top: calc(0.4em + var(--sa-t, 0px));
}

/* Four cards a side (7–8 players): tighter cards, so the column fits a 720p screen at 150 % text. */
.pg-panel:has(> :nth-child(4)) {
  gap: 0.4em;
  font-size: max(var(--fs-small), 0.9em);
}

.pg-panel:has(> :nth-child(4)) .pg-card {
  padding-top: 0.4em;
  padding-bottom: 0.4em;
}

.pg-left {
  left: 1.4em;
}

.pg-right {
  right: 1.4em;
}

.pg-card {
  display: flex;
  gap: 0.75em;
  align-items: center;
  padding: 0.7em 0.9em;
  border-radius: 0.8em;
  background: var(--ui);
  border: 1px solid var(--ui-line);
  border-left: 0.3em solid var(--c);
  transition: opacity 0.3s;
}

.pg-card.out {
  opacity: 0.4;
}

.pg-card-icon svg {
  display: block;
  width: 1.7em;
  height: 1.7em;
}

/* Tessellate's tile pattern (#72 build 20), a small badge on the shape's corner. */
.pg-card-icon {
  position: relative;
}

.pg-hud .pg-card-icon .tg-pattern svg.tile-pattern {
  position: absolute;
  right: -0.35em;
  bottom: -0.35em;
  width: 0.95em;
  height: 0.95em;
  border-radius: 0.15em;
  box-shadow: 0 0 0 0.1em var(--ui);
}

.pg-card-body {
  min-width: 0;
}

/* A long name plus its tag ("Yellow Pyramid" + "Keys 2") wraps the tag to the next line
   instead of cutting either off. */
.pg-card-name {
  font-weight: 800;
  overflow-wrap: anywhere;
}

.pg-you {
  display: inline-block;
  white-space: nowrap;
  margin-left: 0.3em;
  padding: 0 0.45em;
  border-radius: 0.4em;
  background: var(--c);
  color: #1d1a26;
  font-size: max(var(--fs-small), 0.72em);
  font-weight: 900;
  vertical-align: 0.15em;
}

.pg-card-sub {
  color: var(--ui-dim);
  font-size: max(var(--fs-small), 0.72em);
  font-weight: 700;
}

.pg-card-stats {
  display: flex;
  align-items: center;
  gap: 0.7em;
  margin-top: 0.2em;
  font-size: max(var(--fs-small), 0.85em);
  color: var(--ui-dim);
}

.pg-card-stats b {
  color: var(--ui-text);
  font-weight: 900;
}

.pg-card-stats .pips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25em;
}

.pg-card-stats .pips i {
  width: 0.7em;
  height: 0.7em;
  border-radius: 50%;
  border: 0.14em solid var(--ui-dim);
}

.pg-card-stats .pips i.on {
  background: var(--c);
  border-color: var(--ui-text);
}

.pg-card-stats .status {
  font-weight: 900;
  color: var(--ui-text);
}

.pg-card-stats .powers {
  display: flex;
  gap: 0.2em;
  color: var(--ui-text);
}

.pg-hints {
  position: absolute;
  bottom: 1.1em;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25em 1.1em;
  width: max-content;
  max-width: 70vw;
  font-size: max(var(--fs-small), 0.72em);
  font-weight: 700;
  color: var(--ui-dim);
}

.pg-hints b {
  color: var(--ui-text);
}

.pg-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(10, 8, 16, 0.45);
  pointer-events: auto;
  animation: pg-fade 0.25s ease-out;
}

@keyframes pg-fade {
  from {
    opacity: 0;
  }
}

.pg-dialog {
  min-width: 22em;
  max-width: 90vw;
  padding: 1.6em 2em;
  border-radius: 1.1em;
  background: var(--ui);
  border: 1px solid var(--ui-line);
  box-shadow: 0 1.5em 4em rgba(0, 0, 0, 0.35);
  text-align: center;
}

.pg-dialog h2 {
  margin: 0;
  font-size: 2.4em;
  font-weight: 900;
}

.pg-why {
  margin: 0.2em 0 1em;
  color: var(--ui-dim);
  font-weight: 700;
}

.pg-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.2em;
  text-align: left;
}

.pg-table th {
  font-size: max(var(--fs-small), 0.72em);
  color: var(--ui-dim);
  font-weight: 800;
  padding: 0.3em 0.5em;
}

.pg-table td {
  padding: 0.4em 0.5em;
  border-top: 1px solid var(--ui-line);
  font-weight: 700;
}

.pg-table td svg {
  display: block;
}

.pg-table .name {
  font-weight: 900;
}

.pg-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.pg-actions {
  display: flex;
  gap: 0.7em;
  justify-content: center;
  margin-top: 1em;
  flex-wrap: wrap;
}

.pg-pause-btn {
  position: absolute;
  top: 1.2em;
  right: 1.4em;
  display: flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.35em 0.8em;
  border-radius: 0.7em;
  border: 1px solid var(--ui-line);
  background: var(--ui);
  font-size: max(var(--fs-small), 0.8em);
  font-weight: 900;
  cursor: pointer;
  pointer-events: auto;
}

/* ------------------------------------------------------------ reduced motion (setting or OS) */

.reduced-motion .pg-overlay,
.reduced-motion .pg-count.show {
  animation: none;
}

.reduced-motion .pg-count.show {
  opacity: 1;
  transform: translate(-50%, -50%);
}

.reduced-motion .pg-banner,
.reduced-motion #loader-bar {
  transition: none;
}

/* ------------------------------------------------------------ menus: wide Players screen, spinner */

.menu.wide .columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 26em), 1fr));
  gap: 0.6em 1em;
  width: min(60em, 96vw);
}

.menu.wide .columns > div {
  display: flex;
  flex-direction: column;
  gap: 0.6em;
}

.menu.wide .panel {
  width: 100%;
}

.row.wrap {
  flex-wrap: wrap;
}

.chip.small {
  margin-left: auto;
  padding: 0.1em 0.6em;
  font-size: max(var(--fs-small), 0.8em);
}

.seat .chip.small {
  color: var(--ui-text);
}

.spinner {
  width: 2.4em;
  height: 2.4em;
  border-radius: 50%;
  border: 0.3em solid var(--ui-line);
  border-top-color: var(--ui-text);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}

.reduced-motion .spinner {
  animation-duration: 3s;
}

/* ------------------------------------------------------------ online: code chip, toast, waiting room */

.code-chip {
  position: absolute;
  top: 2.6em;
  left: 1.1em;
  padding: 0.35em 0.8em;
  border-radius: 0.7em;
  border: 1px solid var(--ui-line);
  background: var(--ui);
  font-size: max(var(--fs-small), 0.8em);
  font-weight: 800;
  letter-spacing: 0.03em;
}

.code-chip b {
  font-weight: 900;
  letter-spacing: 0.15em;
}

.toast {
  position: absolute;
  top: 5.6em;
  left: 50%;
  transform: translate(-50%, -0.4em);
  padding: 0.4em 1em;
  border-radius: 0.8em;
  border: 1px solid var(--ui-line);
  background: var(--ui);
  font-size: max(var(--fs-small), 0.85em);
  font-weight: 800;
  max-width: min(40em, 92vw);
  width: max-content;
  text-align: center;
  z-index: 5;
  opacity: 0;
  transition:
    opacity 0.2s,
    transform 0.2s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.reduced-motion .toast {
  transition: none;
}

/* The link dropped mid-match: the frozen match stays, with this note over it until it is back. */
.reconnect {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 0.8em;
  max-width: min(36em, 92vw);
  width: max-content;
  padding: 0.8em 1.2em;
  border-radius: 0.9em;
  border: 1px solid var(--ui-line);
  background: var(--ui);
  font-weight: 800;
  z-index: 5;
  pointer-events: none;
}

.spinner.small {
  flex: none;
  width: 1.4em;
  height: 1.4em;
  border-width: 0.2em;
}

.pg-dialog.lobby {
  max-width: min(48em, 94vw);
}

.lobby-body {
  display: flex;
  gap: 1.4em;
  align-items: flex-start;
  text-align: left;
}

.lobby-qr .qr {
  display: block;
  width: 11em;
  height: 11em;
  border-radius: 0.5em;
}

.lobby-cover {
  width: 11em;
  min-height: 11em;
  flex: none;
  /* Solid, as the QR code's white tile was: the game behind the see-through dialog stays out. */
  background: rgb(18, 16, 26);
}

.lobby-code-row {
  justify-content: flex-start;
}

.lobby-info {
  min-width: 0;
  flex: 1;
}

.lobby-code {
  font-size: 3.2em;
  font-weight: 900;
  letter-spacing: 0.25em;
  line-height: 1;
}

.lobby-link {
  font-size: max(var(--fs-small), 0.8em);
  color: var(--ui-dim);
  word-break: break-all;
}

.lobby-link b {
  color: var(--ui-text);
}

/* The note when phones can reach no link (#70): words, so break only between words. */
.lobby-link.lobby-lan {
  word-break: normal;
  overflow-wrap: anywhere;
}

.lobby-seats {
  list-style: none;
  margin: 0.4em 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25em;
  font-size: max(var(--fs-small), 0.85em);
}

.lobby-seats li {
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.2em 0.5em;
  border-left: 0.25em solid var(--c, transparent);
  border-radius: 0.3em;
  background: var(--ui-key);
}

.lobby-seats em {
  margin-left: auto;
  font-style: normal;
  color: var(--ui-dim);
}

.lobby-seats em.on {
  color: #3ddc84;
  font-weight: 900;
}

/* ------------------------------------------------------------ Siegeometry (visuals.md 7.2, 7.4, 7.7) */

.sg-label {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  will-change: transform;
}

.sg-count {
  font-weight: 900;
  font-size: 1.55em;
  line-height: 1;
  color: #ffffff;
  text-shadow:
    0 0.08em 0.25em rgba(0, 0, 0, 0.55),
    0 0 0.1em rgba(0, 0, 0, 0.55);
  font-variant-numeric: tabular-nums;
}

.sg-label.neutral .sg-count {
  opacity: 0.72;
  font-size: 1.25em;
}

.high-contrast .sg-count {
  text-shadow:
    0 0 0.12em #000,
    0 0 0.12em #000,
    0 0 0.3em #000;
  -webkit-text-stroke: 0.04em #000;
}

.high-contrast .sg-label.neutral .sg-count {
  opacity: 1;
}

/* High contrast: knocked-out players stay readable (the status line says "Out"), and the hints
   and the round line get a solid backing. */
.high-contrast .pg-card.out {
  opacity: 0.8;
}

.high-contrast .pg-hints,
.high-contrast .pg-round,
.high-contrast .sg-timer {
  color: #fff;
  text-shadow:
    0 0 0.25em #000,
    0 0 0.1em #000;
}

.sg-progress {
  display: none;
  width: 2.4em;
  height: 0.28em;
  margin-top: 0.2em;
  border-radius: 1em;
  background: linear-gradient(90deg, #ffffff calc(var(--p, 0) * 100%), rgba(255, 255, 255, 0.25) 0);
}

.sg-label.upgrading .sg-progress {
  display: block;
}

.sg-timer {
  font-weight: 900;
  font-size: 2.1em;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0.1em 0.4em rgba(0, 0, 0, 0.35);
}

.sg-timer.warn {
  color: #ff6b6b;
}

.sg-meter {
  display: flex;
  align-items: center;
  gap: 0.35em;
  margin-top: 0.3em;
  font-size: max(var(--fs-small), 0.72em);
  font-weight: 800;
  color: var(--ui-dim);
}

.sg-meter .icon {
  display: grid;
  color: var(--c);
}

.sg-meter .bar {
  flex: 1;
  height: 0.45em;
  border-radius: 1em;
  background: var(--ui-key);
  overflow: hidden;
}

.sg-meter .bar i {
  display: block;
  height: 100%;
  width: calc(var(--m, 0) * 100%);
  background: var(--c);
  border-radius: inherit;
}

.sg-meter .ready {
  display: none;
}

.sg-meter.full .ready {
  display: inline;
  color: var(--ui-text);
}

.sg-meter.full .bar {
  display: none;
}

.sg-meter.full .icon,
.sg-meter.active .icon {
  animation: sg-glow 0.9s ease-in-out infinite alternate;
}

@keyframes sg-glow {
  to {
    transform: scale(1.25);
    filter: drop-shadow(0 0 0.3em var(--c));
  }
}

.sg-bottom {
  position: absolute;
  bottom: 1.1em;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55em;
}

.sg-bottom .pg-hints {
  position: static;
  transform: none;
}

.sg-fraction {
  display: flex;
  gap: 0.35em;
  padding: 0.35em;
  border-radius: 0.9em;
  background: var(--ui);
  border: 1px solid var(--ui-line);
  pointer-events: auto;
}

.sg-pill {
  font-weight: 900;
  color: var(--ui-dim);
  background: transparent;
  border: 0;
  border-radius: 0.6em;
  padding: 0.35em 0.8em;
  cursor: pointer;
}

.sg-pill kbd {
  margin-right: 0.45em;
}

.sg-pill.on {
  background: var(--ui-text);
  color: #1d1a26;
}

.sg-pill.on kbd {
  background: rgba(0, 0, 0, 0.12);
}

.sg-ability {
  display: flex;
  align-items: center;
  gap: 0.35em;
  margin-left: 0.4em;
  font-weight: 900;
  color: var(--ui-dim);
  background: transparent;
  border: 2px dashed var(--ui-line);
  border-radius: 0.6em;
  padding: 0.3em 0.7em;
  cursor: pointer;
  opacity: 0.55;
}

.sg-ability .icon {
  display: grid;
}

.sg-ability.ready {
  color: #1d1a26;
  background: #f7c548;
  border-style: solid;
  border-color: transparent;
  opacity: 1;
}

.sg-token {
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 1.6em;
  height: 1.6em;
  border-radius: 50%;
  background: var(--c);
  color: #1d1a26;
  font-size: max(var(--fs-small), 0.9em);
  box-shadow: 0 0.15em 0.4em rgba(0, 0, 0, 0.4);
  will-change: transform;
}

.sg-float {
  position: absolute;
  left: 0;
  top: 0;
  font-weight: 900;
  font-size: 1.1em;
  color: var(--c);
  text-shadow:
    0 0.06em 0 rgba(0, 0, 0, 0.45),
    0 0 0.25em rgba(0, 0, 0, 0.35);
}

/* The text animates, not .sg-float: a scale on the placed box would scale its translate too. */
.sg-float > span {
  display: block;
  animation: sg-float 1s ease-out forwards;
}

.sg-float::before {
  content: '';
}

@keyframes sg-float {
  from {
    opacity: 1;
    translate: 0 0;
    scale: 1.2;
  }
  to {
    opacity: 0;
    translate: 0 -160%;
    scale: 0.9;
  }
}

.reduced-motion .sg-float > span {
  animation-duration: 0.6s;
}

.sg-cursor {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  will-change: transform;
}

.sg-cursor-ring {
  position: absolute;
  left: -1.3em;
  top: -1.3em;
  width: 2.6em;
  height: 2.6em;
  border-radius: 50%;
  border: 0.22em solid var(--c);
  box-shadow:
    0 0 0 0.12em rgba(0, 0, 0, 0.35),
    inset 0 0 0 0.12em rgba(0, 0, 0, 0.25);
  transition: transform 0.12s;
}

.sg-cursor.aiming .sg-cursor-ring {
  transform: scale(0.8);
  border-style: dashed;
}

.sg-cursor-icon {
  position: absolute;
  left: 1em;
  top: -2.2em;
  filter: drop-shadow(0 0.1em 0.15em rgba(0, 0, 0, 0.5));
}

.sg-cursor-icon svg {
  width: 1.1em;
  height: 1.1em;
}

.sg-cursor-amount {
  position: absolute;
  left: 1.5em;
  top: 0.6em;
  padding: 0 0.4em;
  border-radius: 0.4em;
  background: var(--c);
  color: #1d1a26;
  font-size: max(var(--fs-small), 0.7em);
  font-weight: 900;
  white-space: nowrap;
}

.sg-cursor.lost .sg-cursor-ring {
  border-style: dotted;
  opacity: 0.5;
}

.sg-cursor.out {
  display: none;
}

.sg-build {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2em;
  min-width: 12em;
  /* Beside its building and whole on screen: js/common.ts placeBeside (#70). */
  max-width: calc(100vw - 8px);
  max-height: calc(100vh - 8px);
  overflow-y: auto;
  padding: 0.4em;
  border-radius: 0.8em;
  background: var(--ui);
  border: 1px solid var(--ui-line);
  border-left: 0.3em solid var(--c);
  box-shadow: 0 0.6em 1.6em rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  will-change: transform;
}

.sg-build-item {
  display: flex;
  justify-content: space-between;
  gap: 1em;
  font-size: max(var(--fs-small), 0.85em);
  font-weight: 800;
  background: transparent;
  border: 0;
  border-radius: 0.5em;
  padding: 0.4em 0.6em;
  cursor: pointer;
  text-align: left;
}

.sg-build-item .cost {
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
}

.sg-build-item.on {
  background: var(--c);
  color: #1d1a26;
}

.sg-build-item.off {
  opacity: 0.4;
  cursor: not-allowed;
}

.reduced-motion .sg-meter .icon {
  animation: none;
}

/* ------------------------------------------------------------ Tessellate HUD (games/tessellate/src/view/tessellate.css) */

.tg-clock {
  font-weight: 900;
  font-size: 2em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0.1em 0.4em rgba(0, 0, 0, 0.35);
}

.tg-clock.warn {
  color: #ff6b6b;
}

.high-contrast .tg-clock {
  color: #fff;
  text-shadow:
    0 0 0.25em #000,
    0 0 0.1em #000;
}

.high-contrast .tg-clock.warn {
  color: #ff8a8a;
}

.tg-share {
  display: flex;
  align-items: center;
  gap: 0.4em;
  width: 100%;
  margin-top: 0.15em;
}

.tg-share .bar {
  flex: 1;
  height: 0.5em;
  min-width: 4em;
  border-radius: 1em;
  background: var(--ui-key);
  overflow: hidden;
}

.tg-share .bar i {
  display: block;
  height: 100%;
  width: calc(var(--p, 0) * 100%);
  background: var(--c);
  border-radius: 1em;
  transition: width 0.25s;
}

.tg-share b {
  font-variant-numeric: tabular-nums;
  min-width: 2.6em;
  text-align: right;
}

.tg-card .pg-card-body {
  flex: 1;
}

.reduced-motion .tg-share .bar i {
  transition: none;
}

/* ------------------------------------------------------------ narrow screens (#70, #72)
   Less than 36 lines of text wide (data-fit='narrow', js/layout.ts: a phone, a small tablet, a
   split window, or 200 % text on a TV), the menus and dialogs must fit the width: labels go
   above their buttons, chips wrap, panels and dialogs use the whole width, and headings get
   smaller. The text size setting is kept as chosen; only the layout gives way. */
:root[data-fit='narrow'] .menu {
  gap: 0.6em;
  padding: 2.4em 0.5em 1.6em;
}

:root[data-fit='narrow'] .menu h1 {
  font-size: 2.2em;
}

:root[data-fit='narrow'] .menu h2 {
  font-size: 1.4em;
}

:root[data-fit='narrow'] .menu-list,
:root[data-fit='narrow'] .menu.wide .columns,
:root[data-fit='narrow'] .panel {
  width: 100%;
}

:root[data-fit='narrow'] .panel {
  padding: 0.5em 0.7em;
}

:root[data-fit='narrow'] .row {
  gap: 0.4em;
}

:root[data-fit='narrow'] .row > .label {
  flex: 1 1 100%;
  min-width: 0;
}

:root[data-fit='narrow'] .chip {
  flex-wrap: wrap;
  max-width: 100%;
  text-align: left;
}

:root[data-fit='narrow'] .big {
  gap: 0.5em;
  padding: 0.6em 0.8em;
  font-size: 1.05em;
}

:root[data-fit='narrow'] .actions {
  gap: 0.5em;
}

:root[data-fit='narrow'] .btn {
  padding: 0.55em 1em;
}

:root[data-fit='narrow'] .pg-dialog {
  min-width: 0;
  width: 94vw;
  max-width: 94vw;
  max-height: 92vh;
  overflow-y: auto;
  padding: 1em 0.9em;
  /* Opaque: on a small screen the HUD behind would show through the text. */
  background: rgba(18, 16, 26, 0.97);
}

:root[data-fit='narrow'] .pg-dialog h2 {
  font-size: 1.4em;
}

:root[data-fit='narrow'] .lobby-body {
  flex-direction: column;
  align-items: center;
  gap: 0.6em;
}

:root[data-fit='narrow'] .lobby-qr .qr {
  width: 8em;
  height: 8em;
}

:root[data-fit='narrow'] .lobby-link b {
  word-break: break-all;
}

:root[data-fit='narrow'] .pg-table {
  font-size: max(var(--fs-small), 0.85em);
}

:root[data-fit='narrow'] .pg-table th,
:root[data-fit='narrow'] .pg-table td {
  padding-left: 0.2em;
  padding-right: 0.2em;
  overflow-wrap: anywhere;
}

:root[data-fit='narrow'] .lobby-cover {
  width: auto;
  min-height: 0;
  align-self: stretch;
}

:root[data-fit='narrow'] .lobby-code-row {
  justify-content: center;
}

:root[data-fit='narrow'] .lobby-code {
  font-size: 2.4em;
}

/* ------------------------------------------------------------ screen readers only */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* "Describe the board" (#70): unseen until it has the focus (Tab, or a screen reader moving to
   it), then a small HUD pill top left; the I key does the same while playing. */
.board-describe:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.board-describe:focus {
  position: fixed;
  left: calc(var(--sa-l, 0px) + 12px);
  top: calc(var(--sa-t, 0px) + 12px);
  z-index: 30;
  padding: 0.45em 0.9em;
  border-radius: 0.9em;
  background: var(--ui);
  border: 2px solid var(--ui-text);
  color: var(--ui-text);
  font: inherit;
  font-weight: 800;
  white-space: nowrap;
  max-width: calc(100vw - var(--sa-l, 0px) - var(--sa-r, 0px) - 24px);
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: auto;
}

/* No keyboard on a touch screen: no I key on the pill; small phones get the small text size. */
@media (pointer: coarse) {
  .board-describe kbd {
    display: none;
  }
}

@media (max-width: 599px) and (orientation: portrait) {
  .board-describe:focus {
    font-size: var(--fs-small);
  }
}

/* ------------------------------------------------------------ hold Back to leave (#72 should 23) */

/* The ring fills with --hold (0…1, set by C# each frame while Ⓑ, Esc or a phone's Ⓑ is held). */
.hold-ring {
  position: fixed;
  left: 50%;
  /* Low on the screen, over the match's hint bar (none on the pause menu: Quit fills there). */
  bottom: calc(3vh + var(--safe-bottom, 0px));
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 0.7em;
  max-width: min(92vw, 34em);
  padding: 0.6em 1.1em 0.6em 0.6em;
  border-radius: 2.4em;
  background: rgba(18, 16, 26, 0.92);
  border: 2px solid var(--ui-line);
  box-shadow: 0 0.4em 1.6em rgba(0, 0, 0, 0.45);
  transform: translateX(-50%);
  pointer-events: none;
  animation: hold-ring-in 0.15s ease-out both;
}

.hold-ring-dial {
  position: relative;
  flex: none;
  width: 3.2em;
  height: 3.2em;
}

.hold-ring-dial svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.hold-ring-dial circle {
  fill: none;
  stroke-width: 5;
}

.hold-ring-track {
  stroke: var(--ui-key);
}

.hold-ring-fill {
  stroke: #f2545b;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: calc(1 - var(--hold, 0));
}

.hold-ring-glyph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.hold-ring-glyph .pb,
.hold-ring-glyph kbd {
  margin: 0;
}

.hold-ring-text {
  font-weight: 800;
}

@keyframes hold-ring-in {
  from {
    opacity: 0;
    transform: translateX(-50%) scale(0.85);
  }
}

/* A phone or small screen on its side: the waiting room's buttons fill the bottom, so the ring
   docks at the top (on the pause menu the Quit button fills instead of the ring). */
@media (max-height: 500px) {
  .hold-ring {
    top: calc(2vh + var(--safe-top, 0px));
    bottom: auto;
  }
}

.reduced-motion .hold-ring {
  animation: none;
}

.high-contrast .hold-ring {
  background: #000;
  border-color: #fff;
}
