/* One stylesheet for the hall and the game page. System fonts, light by default, dark when the
   device asks for it. */
:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2128;
  --muted: #667080;
  --line: #dfe3e8;
  --accent: #2f6fed;
  --accent-text: #ffffff;
  --notice-bg: #fff6dc;
  --notice-text: #6b4e00;
  --stage: #0e1116;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --surface: #1a1f26;
    --text: #e6e9ee;
    --muted: #96a0ad;
    --line: #2b323c;
    --accent: #5b8ff5;
    --accent-text: #0b1220;
    --notice-bg: #3a3115;
    --notice-text: #f3dc9a;
    --stage: #07090c;
  }
}

* {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    15px/1.5 system-ui,
    -apple-system,
    "PingFang SC",
    "Microsoft YaHei",
    sans-serif;
}
[hidden] {
  display: none !important;
}
a {
  color: inherit;
}

.top {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.top .brand {
  display: block;
  max-width: 1132px;
  margin: 0 auto;
  padding: 14px 16px;
  font-size: 17px;
  font-weight: 650;
  text-decoration: none;
}
main {
  max-width: 1132px;
  margin: 0 auto;
  padding: 20px 16px 56px;
}
h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.3;
}
h2 {
  margin: 28px 0 12px;
  font-size: 15px;
  font-weight: 650;
  color: var(--muted);
}
p {
  margin: 0;
}
.muted {
  color: var(--muted);
}
.empty {
  padding: 22px 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}
.notice {
  margin: 0 0 16px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--notice-bg);
  color: var(--notice-text);
}

/* Buttons and fields */
.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.button:hover,
button:hover {
  border-color: var(--accent);
}
.button.primary,
button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}
.button[aria-disabled="true"],
button:disabled {
  border-color: var(--line);
  background: transparent;
  color: var(--muted);
  cursor: default;
  pointer-events: none;
}
input[type="text"] {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Hall: game cards */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}
.card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
}
.card:hover {
  border-color: var(--accent);
}
.cover {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16 / 9;
  background: hsl(var(--hue, 220) 45% 46%);
  color: #ffffff;
  font-size: 44px;
  font-weight: 700;
}
.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px 14px;
}
.card-name {
  font-size: 16px;
  font-weight: 650;
}
.card-description {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: auto;
  padding-top: 6px;
  color: var(--muted);
  font-size: 13px;
}
.tag {
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
}

/* Room lists */
.rooms {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.room {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
}
.room + .room {
  border-top: 1px solid var(--line);
}
.room-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-weight: 550;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.room-phase,
.room-watching,
.room-players {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.room-players {
  min-width: 34px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Game page */
.title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: 16px;
}
.title-row .about {
  flex: 1;
  min-width: 220px;
}
.title-row .about p {
  margin-top: 4px;
  color: var(--muted);
}
.nick {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}
.nick input {
  width: 150px;
}
.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.bar .where {
  color: var(--muted);
}
.bar .invite {
  display: flex;
  flex: 1;
  gap: 8px;
  min-width: 240px;
}
.bar .invite input {
  flex: 1;
  min-width: 0;
  color: var(--muted);
}
.stage {
  position: relative;
  width: 100%;
  max-width: 1100px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--stage);
}
/* Fullscreen: the browser's own, or (where it has none) the stage over the whole window. */
.stage:fullscreen,
.stage.fill {
  max-width: none;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
}
.stage.fill {
  position: fixed;
  inset: 0;
  z-index: 50;
}
.stage-exit {
  display: none;
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  opacity: 0.85;
}
.stage.fill .stage-exit {
  display: inline-flex;
}
/* Before a game runs the stage is only a hint, so the room list stays in view. */
.stage.idle {
  aspect-ratio: auto;
  min-height: 132px;
}
.stage iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.stage-idle {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  color: #aab3c0;
  text-align: center;
}
.stage-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--stage);
  color: #e6ebf2;
}
.loading-box {
  width: min(360px, 100%);
  text-align: center;
}
.loading-text {
  font-weight: 600;
}
.loading-track {
  height: 6px;
  margin: 14px 0 10px;
  overflow: hidden;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.14);
}
.loading-bar {
  width: 0;
  height: 100%;
  border-radius: 3px;
  background: #6ea8ff;
  transition: width 0.2s linear;
}
.loading-detail {
  min-height: 1.4em;
  color: #aab3c0;
  font-size: 13px;
}

@media (max-width: 560px) {
  main {
    padding-top: 16px;
  }
  .nick,
  .nick input {
    width: 100%;
  }
  .nick span {
    white-space: nowrap;
  }
  .bar > button,
  .bar > .button {
    flex: 1;
  }
  /* A row keeps its buttons: how many watch is the first thing to give way. */
  .room {
    gap: 8px;
  }
  .room-watching {
    display: none;
  }
}

/* Which region the page is in, and a way to another. */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  /* The bar spans the window; what is in it keeps to the page's width. */
  padding-inline: max(16px, calc((100% - 1100px) / 2));
}
.top .brand {
  margin: 0;
  padding-inline: 0;
}
.regions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.regions select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.3rem 0.5rem;
}
.region-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
