:root {
  color-scheme: dark;
  --background: oklch(0 0 0);
  --foreground: oklch(0.985 0 0);
  --muted-foreground: oklch(0.708 0 0);
  --faint: oklch(0.5 0 0);
  --rule: color-mix(in oklch, var(--foreground) 18%, var(--background));
  --block-fill: color-mix(in oklch, var(--foreground) 6%, transparent);
  --block-hover: color-mix(in oklch, var(--foreground) 10%, transparent);
  --pressed: color-mix(in oklch, var(--foreground) 16%, transparent);
  --destructive: oklch(0.704 0.191 22.216);
  --radius: 0.625rem;
  --sans: -apple-system, BlinkMacSystemFont, "Geist Variable", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--sans);
  font-size: 0.875rem;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
}

canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }

.screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  overflow: auto;
  background: var(--background);
}

.panel {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--background);
  padding: 1.5rem;
}
.panel.narrow { width: min(22rem, 100%); max-height: 100%; overflow: auto; }
.panel.wide { width: min(64rem, 100%); }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.125rem; }
h3 { font-size: 0.8125rem; font-weight: 500; }

.tag { margin: 0.25rem 0 0; color: var(--muted-foreground); font-size: 0.8125rem; }

label {
  display: block;
  margin-top: 1.25rem;
  color: var(--muted-foreground);
  font-size: 0.75rem;
  font-weight: 500;
}

input {
  display: block;
  width: 100%;
  height: 2.25rem;
  margin-top: 0.375rem;
  padding-inline: 0.75rem;
  border: 1px solid var(--rule);
  border-radius: calc(var(--radius) * 0.8);
  background: transparent;
  color: var(--foreground);
  font: inherit;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
}
input::placeholder { color: var(--faint); }
input:focus-visible { border-color: var(--muted-foreground); }
#code { margin-top: 0; font-family: var(--mono); letter-spacing: 0.2em; text-transform: uppercase; }

button {
  height: 2rem;
  padding-inline: 0.75rem;
  border: 1px solid var(--rule);
  border-radius: calc(var(--radius) * 0.8);
  background: transparent;
  color: var(--foreground);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
}
button:hover:not(:disabled) { background: var(--block-hover); }
button:active:not(:disabled) { background: var(--pressed); }
button:focus-visible { outline: 2px solid var(--muted-foreground); outline-offset: 1px; }
button:disabled { opacity: 0.4; }
button.primary { border-color: transparent; background: var(--foreground); color: var(--background); }
button.primary:hover:not(:disabled) { background: var(--foreground); opacity: 0.9; }
#create { width: 100%; height: 2.25rem; margin-top: 0.75rem; }
#join { height: 2.25rem; }

.row { display: flex; gap: 0.5rem; align-items: center; }
.or { margin: 1.25rem 0 0.5rem; color: var(--faint); font-size: 0.75rem; }
#error { min-height: 1.25rem; margin: 0.75rem 0 0; color: var(--destructive); font-size: 0.8125rem; }

#lobby header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1.5rem; }
.code { display: flex; align-items: center; gap: 0.625rem; }
.code span { color: var(--muted-foreground); font-size: 0.75rem; }
.code strong {
  padding: 0.25rem 0.625rem;
  border-radius: calc(var(--radius) * 0.6);
  background: var(--block-fill);
  font: 500 0.9375rem var(--mono);
  letter-spacing: 0.18em;
}

#districts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 0.5rem;
  margin: 1.25rem 0;
}

.district {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.75rem 0.875rem;
  min-height: 7.5rem;
}
.district:not(.mine):not(.full):hover { background: var(--block-hover); }
.district.mine { background: var(--block-fill); border-color: color-mix(in oklch, var(--c) 55%, var(--rule)); }
.district.full:not(.mine) { opacity: 0.5; }
.district .head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; margin-bottom: 0.375rem; }
.district .dname { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; }
.district .dname i, #standings i, #victor i {
  flex: none;
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--c);
}
.district .trade { color: var(--faint); font-size: 0.75rem; }
.district .slot { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.8125rem; line-height: 1.6; }
.district .slot em { color: var(--muted-foreground); font-style: normal; }
.district .slot.empty, .district .slot.empty em { color: var(--faint); }
.district .roles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  margin-top: 0.5rem;
  padding: 2px;
  border-radius: calc(var(--radius) * 0.8);
  background: var(--block-fill);
}
.district .roles button { height: 1.625rem; border: 0; border-radius: calc(var(--radius) * 0.6); font-size: 0.75rem; color: var(--muted-foreground); }
.district .roles button.on { background: var(--foreground); color: var(--background); }
.district .desc { margin: 0.5rem 0 0; color: var(--muted-foreground); font-size: 0.75rem; min-height: 2.1rem; }
.district .peek { margin: 0.375rem 0 0; color: var(--faint); font-size: 0.75rem; }

#lobby footer { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.keys { display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem 0.875rem; margin: 0; color: var(--muted-foreground); font-size: 0.75rem; }
.keys b {
  margin-right: 0.375rem;
  padding: 0.0625rem 0.375rem;
  border: 1px solid var(--rule);
  border-radius: calc(var(--radius) * 0.5);
  color: var(--foreground);
  font: 500 0.6875rem var(--mono);
}
#hostbar { gap: 0.875rem; }
#hostbar > span { color: var(--faint); font-size: 0.75rem; }
#hostbar #start { padding-inline: 1.5rem; }

#sponsor {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  width: 13.5rem;
  padding: 0.75rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: color-mix(in oklch, var(--background) 82%, transparent);
  backdrop-filter: blur(8px);
}
#sponsor button { display: flex; align-items: center; width: 100%; margin-top: 0.375rem; gap: 0.5rem; text-align: left; }
#sponsor button b { font: 500 0.6875rem var(--mono); color: var(--faint); }
#sponsor button em { margin-left: auto; font: normal 0.75rem var(--mono); color: var(--muted-foreground); }
#sponsor button.on { background: var(--foreground); color: var(--background); border-color: transparent; }
#sponsor button.on b, #sponsor button.on em { color: inherit; }
#sponsor p { margin: 0.625rem 0 0; color: var(--faint); font-size: 0.6875rem; }
.favor { position: relative; height: 1.25rem; margin-top: 0.5rem; border-radius: calc(var(--radius) * 0.5); background: var(--block-fill); overflow: hidden; }
.favor i { position: absolute; inset: 0 auto 0 0; background: var(--pressed); }
.favor span { position: absolute; inset: 0; display: grid; place-items: center; font: 0.6875rem var(--mono); color: var(--muted-foreground); }

#end {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: color-mix(in oklch, var(--background) 70%, transparent);
  backdrop-filter: blur(3px);
}
#victor { display: flex; align-items: center; gap: 0.625rem; margin: 0.25rem 0 1rem; font-size: 1.5rem; }
#victor i { width: 0.75rem; height: 0.75rem; }
#standings { margin: 0 0 1rem; padding: 0; list-style: none; }
#standings li {
  display: grid;
  grid-template-columns: 1.25rem 1fr;
  gap: 0 0.5rem;
  padding: 0.3125rem 0;
  border-top: 1px solid var(--rule);
  font-size: 0.8125rem;
}
#standings li > b { font: 0.75rem/1.6 var(--mono); color: var(--faint); font-weight: 400; }
#standings li span { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; }
#standings li small { grid-column: 2; color: var(--muted-foreground); font-size: 0.75rem; }
