:root {
  color-scheme: dark;
  --bg: #0d0b14;
  --bg-raised: #16131f;
  --bg-card: #1d1929;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f3effc;
  --muted: #a49db9;
  --accent: #8d6bff;
  --accent-hover: #a088ff;
  --danger: #ff7a8e;
  --glass: rgba(16, 13, 25, 0.74);
  --font: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent-hover);
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 6px;
  padding: 0.1em 0.4em;
}

/* ------------------------------------------------------------ home */

.site-header {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.header-nav form {
  margin: 0;
}

.header-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: 500 14px var(--font);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.header-link:hover,
.header-link:focus-visible {
  color: var(--text);
}

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

.header-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 16ch;
}

.avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex: none;
}

.avatar-initial {
  display: inline-grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 520px) {
  .header-name {
    display: none;
  }
}

/* Too narrow for the wordmark and the account links: keep the logo, and keep
   the name for screen readers. */
@media (max-width: 400px) {
  .brand span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.brand .logo {
  width: 30px;
  height: 30px;
  color: var(--accent);
}

.home {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}

.hero {
  padding: 32px 0 56px;
  max-width: 720px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent-hover);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: clamp(36px, 7vw, 64px);
  line-height: 1.02;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.lede {
  margin: 20px 0 0;
  color: var(--muted);
  font-size: clamp(17px, 2.2vw, 20px);
  max-width: 600px;
  text-wrap: pretty;
}

.home h2 {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 650;
  color: var(--muted);
}

.game-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.game-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.game-card:hover,
.game-card:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(141, 107, 255, 0.55);
  outline: none;
}

.game-thumb {
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  font-size: 56px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
}

.game-meta {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.game-meta h3 {
  margin: 0;
  font-size: 17px;
}

.game-meta p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  flex: 1;
}

.game-meta span {
  color: var(--muted);
  font-size: 13px;
  opacity: 0.8;
}

.hue-0 { background: linear-gradient(135deg, hsl(0 72% 58%), hsl(30 80% 50%)); }
.hue-1 { background: linear-gradient(135deg, hsl(30 80% 55%), hsl(55 85% 48%)); }
.hue-2 { background: linear-gradient(135deg, hsl(60 70% 45%), hsl(95 60% 40%)); }
.hue-3 { background: linear-gradient(135deg, hsl(95 55% 45%), hsl(140 60% 36%)); }
.hue-4 { background: linear-gradient(135deg, hsl(140 55% 42%), hsl(170 70% 34%)); }
.hue-5 { background: linear-gradient(135deg, hsl(170 65% 40%), hsl(195 75% 40%)); }
.hue-6 { background: linear-gradient(135deg, hsl(195 75% 48%), hsl(220 70% 50%)); }
.hue-7 { background: linear-gradient(135deg, hsl(220 70% 58%), hsl(245 65% 55%)); }
.hue-8 { background: linear-gradient(135deg, hsl(250 70% 62%), hsl(275 60% 50%)); }
.hue-9 { background: linear-gradient(135deg, hsl(275 60% 58%), hsl(305 55% 48%)); }
.hue-10 { background: linear-gradient(135deg, hsl(305 60% 55%), hsl(335 70% 52%)); }
.hue-11 { background: linear-gradient(135deg, hsl(335 75% 58%), hsl(360 75% 55%)); }

.empty {
  border: 1px dashed var(--line);
  border-radius: 16px;
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
}

.empty p {
  margin: 4px 0;
}

/* ------------------------------------------------------------ shared controls */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: 600 14px var(--font);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.11);
}

.btn:focus-visible,
.chip:focus-visible,
.tabs a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent-hover);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-small {
  min-height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

.btn-danger {
  color: var(--danger);
}

.btn-icon {
  width: 18px;
  height: 18px;
}

input[type='text'],
input[type='email'],
input[type='password'],
input:not([type]),
select {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: 15px var(--font);
}

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

.fine {
  color: var(--muted);
  font-size: 13px;
}

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

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 20px;
  white-space: nowrap;
}

.badge-live {
  background: rgba(12, 163, 12, 0.18);
  color: #7ee07e;
}

.badge-live::before {
  content: '● ';
}

.badge-public {
  background: rgba(12, 163, 12, 0.18);
  color: #7ee07e;
}

.badge-private {
  background: rgba(141, 107, 255, 0.2);
  color: var(--accent-hover);
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.game-links .badge {
  margin-left: 4px;
  vertical-align: 1px;
}

.setting {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
  margin: 0 0 12px;
}

.setting-text {
  flex: 1 1 320px;
  min-width: 0;
}

.setting-text p {
  margin: 0;
}

.setting-state {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px !important;
  font-weight: 600;
}

.setting form {
  margin: 0;
}

/* ------------------------------------------------------------ sign in */

.auth {
  display: grid;
  place-items: start center;
  padding: 48px 16px 80px;
}

.auth-card {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--bg-raised);
}

.auth-card h1 {
  margin: 0 0 8px;
  font-size: 24px;
  letter-spacing: -0.01em;
}

.auth-card > p {
  margin: 0 0 20px;
}

.auth-card form {
  margin: 12px 0 0;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.form-error {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 122, 142, 0.12);
  color: #ffb3bf;
  font-size: 14px;
}

/* ------------------------------------------------------------ dashboard */

.dash {
  max-width: 1120px;
  margin: 0 auto;
  padding: 8px 16px 80px;
  --series-1: #8d6bff; /* validated on the card surface (#16131f): lightness, chroma, >= 3:1 */
  --series-1-hover: #b3a0ff;
  --grid: rgba(255, 255, 255, 0.07);
  --baseline: rgba(255, 255, 255, 0.16);
}

.crumbs {
  margin: 0 0 4px;
  font-size: 14px;
}

.crumbs a {
  color: var(--muted);
  text-decoration: none;
}

.crumbs a:hover {
  color: var(--text);
}

.dash-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 16px;
}

.dash-head h1 {
  margin: 0;
  font-size: clamp(24px, 4vw, 32px);
  letter-spacing: -0.02em;
}

.dash-head p {
  margin: 4px 0 0;
  font-size: 14px;
}

.tabs {
  display: flex;
  gap: 4px;
  margin: 0 0 24px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tabs a {
  padding: 10px 12px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.tabs a:hover {
  color: var(--text);
}

.tabs a[aria-current='page'] {
  border-bottom-color: var(--accent);
  color: var(--text);
}

@media (max-width: 520px) {
  .tabs {
    gap: 0;
  }
  .tabs a {
    padding: 10px 8px;
    font-size: 13px;
  }
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
}

.chip {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.chip:hover {
  color: var(--text);
}

.chip[aria-current='true'] {
  border-color: transparent;
  background: rgba(141, 107, 255, 0.2);
  color: var(--text);
}

.card {
  margin: 0 0 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg-raised);
  min-width: 0;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 16px;
  letter-spacing: -0.005em;
}

.card > p {
  margin: 0 0 12px;
  font-size: 14px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin: 0 0 16px;
}

.card-grid .card {
  margin: 0;
}

.notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  margin: 0 0 16px;
  padding: 16px 20px;
  border: 1px solid rgba(141, 107, 255, 0.35);
  border-radius: 16px;
  background: rgba(141, 107, 255, 0.08);
}

.notice p {
  margin: 0;
  max-width: 60ch;
}

.flash {
  margin: 0 0 16px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(12, 163, 12, 0.14);
  color: #b9f0b9;
  font-size: 14px;
}

.flash-error {
  background: rgba(255, 122, 142, 0.12);
  color: #ffb3bf;
}

/* game list */
.dash-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg-raised);
  overflow: hidden;
}

.dash-list li + li {
  border-top: 1px solid var(--line);
}

.dash-row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  padding: 16px 20px;
  color: inherit;
  text-decoration: none;
}

.dash-row:hover,
.dash-row:focus-visible {
  background: rgba(255, 255, 255, 0.03);
  outline: none;
}

.dash-row-main,
.dash-row-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  font-size: 14px;
}

.dash-row-main strong {
  font-size: 16px;
}

.dash-row-main span,
.dash-row-stat span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-row-stat .badge {
  align-self: flex-start;
}

@media (max-width: 640px) {
  .dash-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

/* stat tiles */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 0 0 16px;
}

.tile {
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg-raised);
}

.tile p {
  margin: 0;
}

.tile-label {
  color: var(--muted);
  font-size: 14px;
}

.tile-value {
  margin-top: 4px !important;
  font-size: 32px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.tile-note {
  margin-top: 6px !important;
  color: var(--muted);
  font-size: 13px;
}

/* column chart: one series, bars sized by --v (0..1 of the top tick) */
.chart {
  margin: 0;
}

.chart-body {
  display: flex;
  gap: 8px;
}

.chart-y {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 3.5em;
  height: 200px;
  padding-top: 20px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.chart-y span {
  line-height: 0;
}

.chart-plot {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 200px;
  padding-top: 20px;
}

.chart-grid {
  position: absolute;
  inset: 20px 0 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.chart-grid i {
  height: 1px;
  background: var(--grid);
}

.chart-grid i:last-child {
  background: var(--baseline);
}

.chart-cols {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
  border-radius: 4px;
}

.chart-cols:focus-visible {
  outline: 2px solid var(--accent-hover);
  outline-offset: 4px;
}

.chart-col {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  height: 100%;
  cursor: default;
}

.chart-bar {
  display: block;
  width: 100%;
  max-width: 24px;
  height: calc(var(--v) * 100%);
  border-radius: 4px 4px 0 0;
  background: var(--series-1);
}

.chart-col.is-active .chart-bar,
.chart-col:hover .chart-bar {
  background: var(--series-1-hover);
}

.chart-cap {
  margin-bottom: 4px;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.chart-x {
  display: flex;
  gap: 2px;
  margin: 6px 0 0 calc(3.5em + 8px);
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.chart-x span {
  flex: 1;
  min-width: 0;
  overflow: visible;
  text-align: center;
  white-space: nowrap;
}

.chart-tip {
  position: fixed;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #221d31;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 10px));
  white-space: nowrap;
}

.chart-tip strong {
  font-size: 14px;
}

.chart-tip span {
  color: var(--muted);
  font-size: 12px;
}

.chart-tip[hidden] {
  display: none;
}

.table-view {
  margin-top: 12px;
  font-size: 14px;
}

.table-view summary {
  color: var(--muted);
  cursor: pointer;
}

/* ranked breakdowns: label, then a thin bar with its value at the tip */
.bars {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bars li {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.bars-label {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bars-meter {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bars-fill {
  width: calc(var(--v) * (100% - 4em));
  min-width: 2px;
  height: 8px;
  border-radius: 0 4px 4px 0;
  background: var(--series-1);
}

.bars-value {
  color: var(--muted);
  font-size: 13px;
}

/* errors */
.errors {
  list-style: none;
  margin: 0;
  padding: 0;
}

.errors li + li {
  border-top: 1px solid var(--line);
}

.errors summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 0;
  cursor: pointer;
  list-style: none;
}

.errors summary::-webkit-details-marker {
  display: none;
}

.errors summary .muted {
  font-size: 13px;
}

.error-message {
  align-self: flex-start;
  max-width: 100%;
  overflow-wrap: anywhere;
  color: #ffb3bf;
}

.code {
  margin: 0 0 12px;
  padding: 12px 14px;
  overflow-x: auto;
  border-radius: 10px;
  background: var(--bg);
  font: 13px/1.55 var(--mono);
  white-space: pre;
}

/* tables and forms */
.table-wrap {
  margin: 0 0 16px;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  padding: 8px 12px 8px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.table td {
  padding: 10px 12px 10px 0;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

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

.table .actions {
  text-align: right;
  white-space: nowrap;
}

.table .actions > * + * {
  margin-left: 8px;
}

.table .actions form {
  display: inline;
}

.table code.value {
  display: inline-block;
  max-width: 32ch;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
  white-space: nowrap;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin: 0 0 8px;
}

.inline-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 180px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.inline-form label.grow {
  flex: 1;
}

/* ------------------------------------------------------------ play page */

body.play {
  height: 100dvh;
  overflow: hidden;
  background: #000;
}

#ow-game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #000;
}

/* corner cluster: menu button, chat button, chat panel */
.ow-hud {
  position: fixed;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  pointer-events: none;
  max-width: 100vw;
}

.ow-hud > * {
  pointer-events: auto;
}

.ow-pos-top-left { top: env(safe-area-inset-top); left: env(safe-area-inset-left); align-items: flex-start; }
.ow-pos-top-right { top: env(safe-area-inset-top); right: env(safe-area-inset-right); align-items: flex-end; }
.ow-pos-bottom-left { bottom: env(safe-area-inset-bottom); left: env(safe-area-inset-left); align-items: flex-start; flex-direction: column-reverse; }
.ow-pos-bottom-right { bottom: env(safe-area-inset-bottom); right: env(safe-area-inset-right); align-items: flex-end; flex-direction: column-reverse; }

.ow-bar {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 12px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
}

.ow-icon-btn {
  position: relative;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.ow-icon-btn[hidden] {
  display: none;
}

.ow-icon-btn svg {
  width: 20px;
  height: 20px;
}

.ow-menu-btn svg {
  width: 22px;
  height: 22px;
  color: var(--accent-hover);
}

.ow-icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.ow-icon-btn:focus-visible,
.ow-btn:focus-visible,
.ow-range:focus-visible {
  outline: 2px solid var(--accent-hover);
  outline-offset: 2px;
}

.ow-chat-btn[aria-pressed='true'] {
  background: rgba(141, 107, 255, 0.22);
}

.ow-badge {
  position: absolute;
  top: 1px;
  right: 1px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.ow-badge[hidden] {
  display: none;
}

.ow-chat {
  width: min(360px, calc(100vw - 20px));
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 12px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  overflow: hidden;
  transition: opacity 0.5s ease;
}

.ow-chat[hidden] {
  display: none;
}

.ow-chat.ow-chat-idle {
  opacity: 0;
  pointer-events: none;
}

.ow-chat-log {
  list-style: none;
  margin: 0;
  padding: 8px 12px;
  max-height: min(28vh, 220px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  scrollbar-width: thin;
}

.ow-chat-log:empty {
  display: none;
}

.ow-chat-line b {
  font-weight: 650;
  margin-right: 6px;
}

.ow-chat-system {
  color: var(--muted);
  font-style: italic;
}

.ow-chat-form {
  margin: 0;
  border-top: 1px solid var(--line);
}

.ow-chat-log:empty + .ow-chat-form {
  border-top: 0;
}

.ow-chat-input {
  width: 100%;
  padding: 9px 12px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font: 14px var(--font);
}

.ow-chat-input::placeholder {
  color: var(--muted);
}

/* menu */
.ow-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(6, 4, 12, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.ow-backdrop[hidden] {
  display: none;
}

.ow-menu {
  width: min(480px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}

.ow-menu-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.ow-menu-head h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.ow-byline {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.ow-chip {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(141, 107, 255, 0.2);
  color: var(--accent-hover);
  font-size: 12px;
  font-weight: 600;
}

.ow-close {
  flex: none;
  margin: -6px -6px 0 0;
}

.ow-card {
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.ow-card h3 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ow-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ow-range {
  flex: 1;
  min-width: 0;
  accent-color: var(--accent);
}

.ow-range-value {
  min-width: 4ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 14px;
}

.ow-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.ow-switch input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.ow-switch input:disabled + span {
  color: var(--muted);
}

.ow-players {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.ow-players li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
}

.ow-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}

.ow-player-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ow-tag {
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 12px;
  line-height: 20px;
}

.ow-muted {
  color: var(--muted);
}

.ow-menu-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.ow-btn {
  flex: 1 1 120px;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: 600 14px var(--font);
  text-decoration: none;
  cursor: pointer;
}

.ow-btn:hover {
  background: rgba(255, 255, 255, 0.11);
}

.ow-btn svg {
  width: 18px;
  height: 18px;
}

.ow-btn-small {
  flex: none;
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.ow-btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

.ow-btn-primary:hover {
  background: var(--accent-hover);
}

.ow-btn-danger {
  color: var(--danger);
}

.ow-you {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.ow-toast {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  left: 50%;
  z-index: 12;
  max-width: min(460px, calc(100vw - 32px));
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  font-size: 14px;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, -8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

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

/* loading card shown until the game's page has loaded */
.ow-loading {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: grid;
  place-items: center;
  background: var(--bg);
  transition: opacity 0.35s ease;
}

.ow-loading.ow-hidden {
  opacity: 0;
  pointer-events: none;
}

.ow-loading-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--muted);
}

.ow-loading-inner p {
  margin: 0;
}

.ow-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: ow-spin 0.8s linear infinite;
}

@keyframes ow-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 520px) {
  .ow-icon-btn {
    width: 40px;
    height: 40px;
  }
  .ow-menu {
    padding: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation-duration: 0.001s !important;
  }
}
