:root {
  --canvas: #f3f5f2;
  --paper: #ffffff;
  --ink: #182321;
  --muted: #69736f;
  --rule: #d5dbd6;
  --soft-rule: #e9ede9;
  --yellow: #f2b43a;
  --yellow-soft: #fff3cc;
  --coral: #d94f43;
  --coral-soft: #fde9e6;
  --green: #26745c;
  --green-soft: #dceee6;
  --blue: #2d6172;
  --line-red: #e23b32;
  --shadow: 0 18px 50px rgba(24, 35, 33, 0.09);
  color: var(--ink);
  background: var(--canvas);
  font-family: "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--canvas);
}

button,
input,
summary {
  font: inherit;
}

button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(45, 97, 114, 0.28);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

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

.button,
.segment,
.icon-button {
  border: 1px solid var(--rule);
  border-radius: 5px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, background-color 150ms ease;
}

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  font-size: 14px;
}

.button:hover,
.segment:hover,
.icon-button:hover,
.game-menu summary:hover {
  border-color: var(--ink);
}

.button:active,
.segment:active,
.icon-button:active {
  transform: translateY(1px);
}

.button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.button-primary {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.lobby-screen {
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  overflow: hidden;
  background-color: var(--canvas);
}

.lobby-screen::before {
  content: "";
  position: absolute;
  pointer-events: none;
}

.lobby-screen::before {
  inset: 0 0 auto;
  height: 8px;
  background: var(--ink);
}

.lobby-masthead {
  position: relative;
  z-index: 1;
  width: min(1440px, 100%);
  height: 92px;
  display: flex;
  align-items: center;
  margin: 0 auto;
  padding: 8px 34px 0;
}

.lobby-brand,
.brand-title,
.brand-subtitle,
.lobby-heading h1,
.lobby-heading p,
.turn-copy h1,
.turn-copy p,
.board-header h2,
.board-header p,
.game-menu-panel p,
.result-dialog h2,
.result-dialog p {
  margin: 0;
  letter-spacing: 0;
}

.lobby-brand {
  font-family: Arial, "Microsoft YaHei UI", sans-serif;
  font-size: 21px;
  font-weight: 900;
}

.lobby-main {
  position: relative;
  z-index: 1;
  width: min(760px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 80px;
}

.lobby-heading {
  text-align: center;
}

.lobby-heading h1 {
  display: inline-block;
  padding: 0 0 12px;
  border-bottom: 5px solid var(--yellow);
  font-family: "Arial Black", Arial, sans-serif;
  font-size: 64px;
  font-weight: 900;
  line-height: 1;
}

.lobby-heading p {
  margin-top: 20px;
  color: var(--muted);
  font-size: 15px;
}

.lobby-entry {
  width: min(500px, 100%);
  margin: 58px auto 0;
  padding: 30px 0 22px;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}

.lobby-create {
  width: 100%;
  min-height: 52px;
  font-size: 15px;
}

.lobby-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 22px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.lobby-divider::before,
.lobby-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--rule);
}

.room-join {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 8px;
}

.quick-join-button {
  width: 100%;
  margin-top: 10px;
  border-color: var(--soft-rule);
  color: var(--muted);
  font-size: 12px;
}

.room-code-input {
  width: 100%;
  min-width: 0;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--rule);
  border-radius: 5px;
  background: var(--paper);
  color: var(--ink);
  font: 800 15px Arial, sans-serif;
  letter-spacing: 0;
  text-transform: uppercase;
}

.room-code-input:focus {
  border-color: var(--ink);
  outline-offset: 1px;
}

.room-code-input::placeholder {
  color: #8b9490;
  font-family: "Microsoft YaHei UI", "PingFang SC", sans-serif;
  font-size: 13px;
  font-weight: 500;
}

.lobby-connection {
  min-height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: 20px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.connection-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 4px rgba(105, 115, 111, 0.12);
}

.connection-dot.is-live {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(38, 116, 92, 0.14);
}

.connection-dot.is-waiting {
  background: var(--yellow);
  box-shadow: 0 0 0 4px rgba(242, 180, 58, 0.18);
}

.app-shell {
  width: min(1480px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 28px 40px;
}

.topbar {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  border-bottom: 1px solid rgba(24, 35, 33, 0.16);
}

.game-brand-group,
.inline-connection,
.game-actions,
.turn-copy,
.player-identity,
.view-control,
.starter-control,
.result-actions {
  display: flex;
  align-items: center;
}

.game-brand-group {
  min-width: 0;
  gap: 22px;
}

.game-brand {
  flex: 0 0 auto;
}

.brand-title {
  font-family: Arial, sans-serif;
  font-size: 17px;
  font-weight: 900;
}

.brand-subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-family: Arial, sans-serif;
  font-size: 10px;
  font-weight: 800;
}

.inline-connection {
  min-width: 0;
  gap: 8px;
  padding-left: 22px;
  border-left: 1px solid var(--rule);
}

.room-status {
  max-width: 290px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  width: 30px;
  height: 30px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  font-family: Arial, sans-serif;
  font-size: 16px;
}

.copy-room-button {
  border-color: transparent;
  background: transparent;
}

.game-actions {
  position: relative;
  justify-content: flex-end;
  gap: 10px;
}

.view-control,
.starter-control {
  padding: 3px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.78);
}

.segment {
  min-height: 32px;
  padding: 0 12px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.segment-active {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.game-menu {
  position: relative;
}

.game-menu summary {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--rule);
  border-radius: 5px;
  background: var(--paper);
  color: var(--ink);
  font: 900 23px/1 Arial, sans-serif;
  cursor: pointer;
  list-style: none;
}

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

.game-menu-panel {
  position: absolute;
  z-index: 12;
  top: calc(100% + 9px);
  right: 0;
  width: 224px;
  padding: 16px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: var(--paper);
  box-shadow: 6px 6px 0 var(--ink);
}

.game-menu-panel p {
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.menu-room-actions {
  display: grid;
  gap: 3px;
}

.menu-command {
  width: 100%;
  min-height: 34px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.menu-command:hover {
  border-color: var(--rule);
  background: var(--canvas);
}

.menu-command-danger {
  color: var(--coral);
}

.menu-divider {
  height: 1px;
  margin: 12px 0;
  background: var(--soft-rule);
}

.game-menu-panel .starter-control {
  width: 100%;
}

.game-menu-panel .segment {
  flex: 1;
}

.menu-round-button {
  width: 100%;
  margin-top: 12px;
}

.turn-band {
  min-height: 104px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 3px;
  border-bottom: 1px solid rgba(24, 35, 33, 0.16);
}

.turn-copy {
  gap: 14px;
}

.turn-avatar,
.player-token,
.result-stamp {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  font-family: Arial, sans-serif;
  font-weight: 900;
}

.turn-avatar {
  width: 46px;
  height: 46px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 3px 3px 0 var(--ink);
  font-size: 18px;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
}

.turn-copy h1 {
  margin-top: 2px;
  font-size: 27px;
  line-height: 1.2;
}

.turn-copy p:last-child {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.last-call {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.last-call strong {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border: 2px solid var(--coral);
  border-radius: 50%;
  background: var(--paper);
  color: var(--coral);
  font-family: Arial, sans-serif;
  font-size: 21px;
  font-weight: 900;
  transform: rotate(-3deg);
}

.next-round-button {
  min-width: 92px;
  min-height: 44px;
  padding-inline: 14px;
  white-space: nowrap;
}

.arena {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 1160px;
  margin: 0 auto;
  padding-top: 26px;
}

.board-sheet {
  position: relative;
  width: min(100%, 1080px);
  padding: 26px 30px;
  border: 1px solid var(--rule);
  border-top: 5px solid transparent;
  border-radius: 6px;
  background: var(--paper);
  box-shadow: var(--shadow);
  transition: border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.board-sheet.is-active {
  border-top-color: var(--yellow);
  box-shadow: 0 18px 55px rgba(24, 35, 33, 0.14);
  transform: translateY(-2px);
}

.board-sheet.is-winner {
  border-top-color: var(--green);
}

.board-header {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.player-identity {
  gap: 10px;
}

.player-token {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--paper);
  font-size: 13px;
}

.player-token-a {
  background: var(--blue);
}

.player-token-b {
  background: var(--coral);
}

.board-header h2 {
  font-size: 17px;
  line-height: 1.2;
}

.board-header p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.line-score {
  text-align: right;
}

.progress-stack {
  display: flex;
  align-items: flex-end;
  gap: 13px;
}

.opponent-progress {
  padding-bottom: 2px;
  color: #9aa5a0;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.line-score span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.line-score strong {
  font-family: Arial, sans-serif;
  font-size: 18px;
}

.grid-wrap {
  position: relative;
  isolation: isolate;
}

.number-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border-top: 2px solid var(--ink);
  border-left: 2px solid var(--ink);
}

.number-cell {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, sans-serif;
  font-size: 42px;
  font-weight: 900;
  line-height: 1;
  cursor: default;
  transition: background-color 150ms ease, color 150ms ease;
}

.number-cell.can-pick {
  cursor: pointer;
}

.number-cell.can-pick:hover {
  z-index: 2;
  background: var(--yellow-soft);
  box-shadow: inset 0 0 0 3px var(--yellow);
}

.number-cell.is-called {
  background: var(--coral-soft);
  color: var(--coral);
}

.number-cell.is-called::after {
  content: "";
  position: absolute;
  width: 64%;
  height: 64%;
  border: 3px solid currentColor;
  border-radius: 50%;
  transform: rotate(-7deg);
}

.number-cell.in-line {
  background: #fff0ed;
  color: #b7332c;
}

.number-cell.fresh-line {
  animation: line-pop 620ms ease both;
}

.line-overlay {
  position: absolute;
  z-index: 4;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.completed-line-halo,
.completed-line {
  fill: none;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.completed-line-halo {
  stroke: rgba(255, 255, 255, 0.82);
  stroke-width: 9;
}

.completed-line {
  stroke: var(--line-red);
  stroke-width: 4;
  filter: drop-shadow(0 1px 1px rgba(115, 22, 18, 0.25));
}

.completed-line.is-fresh {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: draw-line 620ms ease-out forwards;
}

.bingo-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 12px;
}

.bingo-letter {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  height: 46px;
  color: var(--muted);
  font-family: Arial, sans-serif;
  font-size: 29px;
  font-weight: 900;
}

.bingo-letter.is-earned {
  color: var(--green);
}

.bingo-letter.is-earned::after {
  content: "";
  position: absolute;
  width: 38px;
  height: 38px;
  border: 3px solid var(--green);
  border-radius: 50%;
  transform: rotate(-8deg);
  animation: stamp-in 320ms ease both;
}

.toast {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: 28px;
  max-width: calc(100vw - 32px);
  padding: 11px 16px;
  border-radius: 4px;
  background: var(--ink);
  color: var(--paper);
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

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

.room-code-dialog {
  width: min(430px, calc(100vw - 32px));
  padding: 30px;
  border: 1px solid var(--ink);
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink);
  text-align: center;
  box-shadow: 8px 8px 0 var(--ink);
}

.room-code-dialog::backdrop {
  background: rgba(24, 35, 33, 0.48);
  backdrop-filter: blur(3px);
}

.room-code-dialog h2 {
  margin: 8px 0 0;
  font-size: 23px;
}

.room-code-dialog-copy {
  margin: 9px auto 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.room-code-display {
  margin: 22px 0 20px;
  padding: 15px 12px;
  border: 2px solid var(--ink);
  border-radius: 5px;
  background: var(--yellow-soft);
  font: 900 30px/1 Arial, sans-serif;
  letter-spacing: 0.12em;
}

.room-code-feedback {
  min-height: 18px;
  margin: -8px 0 12px;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

.room-code-dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1.1fr 1.35fr;
  gap: 8px;
}

.invite-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 30px;
  border: 1px solid var(--ink);
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink);
  text-align: center;
  box-shadow: 8px 8px 0 var(--ink);
}

.invite-dialog::backdrop {
  background: rgba(24, 35, 33, 0.48);
  backdrop-filter: blur(3px);
}

.invite-dialog h2 {
  margin: 8px 0 0;
  font-size: 22px;
}

.invite-dialog > p:not(.eyebrow) {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.invite-dialog > p strong {
  color: var(--ink);
  font: 900 16px Arial, sans-serif;
  letter-spacing: 0.1em;
}

.invite-dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 8px;
  margin-top: 24px;
}

.round-request-dialog {
  width: min(430px, calc(100vw - 32px));
  padding: 30px;
  border: 1px solid var(--ink);
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink);
  text-align: center;
  box-shadow: 8px 8px 0 var(--ink);
}

.round-request-dialog::backdrop {
  background: rgba(24, 35, 33, 0.48);
  backdrop-filter: blur(3px);
}

.round-request-dialog h2 {
  margin: 8px 0 0;
  font-size: 23px;
}

.round-request-dialog > p:not(.eyebrow) {
  margin: 9px auto 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.round-request-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 22px;
}

.result-dialog {
  width: min(430px, calc(100vw - 32px));
  padding: 34px;
  border: 1px solid var(--ink);
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink);
  text-align: center;
  box-shadow: 8px 8px 0 var(--ink);
}

.result-dialog::backdrop {
  background: rgba(24, 35, 33, 0.48);
  backdrop-filter: blur(3px);
}

.result-stamp {
  width: 68px;
  height: 68px;
  margin: 0 auto 18px;
  border: 3px solid var(--green);
  border-radius: 50%;
  color: var(--green);
  font-size: 28px;
  transform: rotate(-6deg);
}

.result-dialog h2 {
  margin-top: 8px;
  font-size: 27px;
}

.result-dialog p:not(.eyebrow) {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.result-actions {
  justify-content: center;
  gap: 9px;
  margin-top: 24px;
}

@keyframes draw-line {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes stamp-in {
  from {
    opacity: 0;
    transform: scale(1.35) rotate(-15deg);
  }
  to {
    opacity: 1;
    transform: scale(1) rotate(-8deg);
  }
}

@keyframes line-pop {
  0%,
  100% {
    transform: scale(1);
  }
  45% {
    transform: scale(0.93);
    background: #ffd9d3;
  }
}

@media (max-width: 760px) {
  .lobby-masthead {
    height: 76px;
    padding-inline: 20px;
  }

  .lobby-main {
    padding-top: 36px;
  }

  .lobby-heading h1 {
    font-size: 48px;
  }

  .app-shell {
    padding-inline: 14px;
    padding-bottom: 28px;
  }

  .topbar {
    min-height: 72px;
    gap: 12px;
  }

  .game-brand-group {
    gap: 12px;
  }

  .inline-connection {
    padding-left: 12px;
  }

  .room-status {
    max-width: 180px;
  }

  .turn-band {
    min-height: 96px;
  }

  .arena {
    padding-top: 12px;
  }

  .board-sheet {
    padding: 18px 16px;
  }

  .number-cell {
    font-size: 34px;
  }
}

@media (max-width: 540px) {
  .lobby-brand {
    font-size: 18px;
  }

  .lobby-main {
    width: min(100% - 28px, 500px);
    padding-top: 28px;
  }

  .lobby-heading h1 {
    padding-bottom: 9px;
    border-bottom-width: 4px;
    font-size: 39px;
  }

  .lobby-heading p {
    max-width: 280px;
    margin: 16px auto 0;
    font-size: 13px;
    line-height: 1.7;
  }

  .lobby-entry {
    margin-top: 42px;
    padding-top: 24px;
  }

  .room-join {
    grid-template-columns: 1fr;
  }

  .game-brand-group {
    min-width: 0;
  }

  .brand-subtitle {
    display: none;
  }

  .inline-connection {
    max-width: 165px;
  }

  .room-status {
    max-width: 112px;
  }

  .view-control .segment {
    width: 42px;
    padding-inline: 5px;
    overflow: hidden;
    font-size: 0;
  }

  .view-control .segment::after {
    font-size: 11px;
  }

  .view-control #viewSelf::after {
    content: "自己";
  }

  .view-control #viewOpponent::after {
    content: "对手";
  }

  .game-menu-panel {
    right: -4px;
  }

  .turn-copy {
    gap: 10px;
  }

  .turn-avatar {
    width: 42px;
    height: 42px;
    font-size: 16px;
  }

  .turn-copy h1 {
    font-size: 21px;
  }

  .turn-copy p:last-child {
    max-width: 176px;
    font-size: 11px;
  }

  .last-call span {
    display: none;
  }

  .last-call strong {
    width: 44px;
    height: 44px;
    font-size: 19px;
  }

  .next-round-button {
    min-width: 76px;
    min-height: 40px;
    padding-inline: 10px;
    font-size: 12px;
  }

  .board-header {
    margin-bottom: 12px;
  }

  .board-sheet {
    padding: 15px 12px;
  }

  .number-cell {
    font-size: 27px;
  }

  .number-cell.is-called::after {
    border-width: 2px;
  }

  .bingo-letter {
    height: 40px;
    font-size: 24px;
  }

  .bingo-letter.is-earned::after {
    width: 34px;
    height: 34px;
    border-width: 2px;
  }

  .room-code-dialog {
    padding: 25px 18px;
  }

  .room-code-display {
    font-size: 27px;
  }

  .room-code-dialog-actions {
    grid-template-columns: 1fr;
  }

  .progress-stack {
    display: block;
  }

  .opponent-progress {
    display: block;
    margin-top: 3px;
    padding-bottom: 0;
    font-size: 9px;
  }

  .invite-dialog {
    padding: 25px 18px;
  }

  .round-request-dialog {
    padding: 25px 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}

/* Architectural lobby direction: one quiet sculptural gesture around the entry. */
:root {
  --canvas: #e9e9e3;
  --paper: #fbfbf7;
  --ink: #102b26;
  --muted: #6b7670;
  --rule: rgba(16, 43, 38, 0.2);
  --soft-rule: rgba(16, 43, 38, 0.1);
  --yellow: #e9b82f;
  --yellow-soft: #fff4cb;
  --coral: #d76455;
  --coral-soft: #f8e5df;
  --green: #276c5b;
  --green-soft: #dcece4;
  --blue: #4f7480;
  --lobby-sand: #d5c9b5;
  --lobby-glass: rgba(255, 255, 255, 0.54);
  --shadow: 0 24px 70px rgba(16, 43, 38, 0.11);
}

.lobby-screen {
  background: var(--canvas);
}

.lobby-screen::before {
  height: 4px;
  background: var(--ink);
}

.lobby-screen::after {
  content: "";
  position: absolute;
  inset: 18px 22px 20px;
  border: 1px solid rgba(16, 43, 38, 0.1);
  border-radius: 38% 62% 56% 44% / 12% 18% 82% 88%;
  pointer-events: none;
}

.lobby-masthead {
  z-index: 3;
  width: min(1320px, calc(100% - 48px));
  height: 96px;
  padding: 8px 0 0;
}

.lobby-masthead::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 1px;
  background: rgba(16, 43, 38, 0.15);
}

.lobby-brand-lockup {
  display: flex;
  align-items: center;
  gap: 11px;
}

.lobby-brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  object-fit: contain;
}

.lobby-brand {
  font-family: Arial, "Microsoft YaHei UI", sans-serif;
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
}

.lobby-brand-note {
  margin: 5px 0 0;
  color: var(--muted);
  font: 700 9px/1 Arial, sans-serif;
  letter-spacing: 0;
}

.lobby-main {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(390px, 0.86fr) minmax(470px, 1.14fr);
  align-items: center;
  width: min(1320px, calc(100% - 48px));
  min-height: calc(100dvh - 96px);
  padding: 22px 0 58px;
}

.lobby-stage {
  position: relative;
  z-index: 2;
  width: min(560px, 100%);
  padding: 18px 0 0 8px;
}

.lobby-heading {
  text-align: left;
}

.lobby-kicker {
  margin: 0 0 18px;
  color: var(--green);
  font: 800 11px/1.2 Arial, "Microsoft YaHei UI", sans-serif;
  letter-spacing: 0;
}

.lobby-heading h1 {
  position: relative;
  display: inline-block;
  padding: 0 0 20px;
  border: 0;
  color: var(--ink);
  font-family: "Arial Black", Arial, sans-serif;
  font-size: 74px;
  font-weight: 900;
  line-height: 0.9;
}

.lobby-heading h1::after {
  content: "";
  position: absolute;
  right: 4px;
  bottom: 0;
  width: 104px;
  height: 6px;
  border-radius: 0 100% 100% 0;
  background: var(--yellow);
  transform: skewX(-24deg);
}

.lobby-heading p:last-child {
  max-width: 360px;
  margin-top: 22px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.8;
}

.lobby-entry {
  position: relative;
  width: min(520px, 100%);
  margin: 42px 0 0;
  padding: 26px 0 18px;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--rule);
}

.lobby-entry::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 0;
  width: 54px;
  height: 3px;
  background: var(--yellow);
}

.lobby-create {
  min-height: 54px;
  border-color: var(--yellow);
  background: var(--yellow);
  color: var(--ink);
  box-shadow: 8px 8px 0 rgba(16, 43, 38, 0.1);
}

.lobby-create:hover {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
  transform: translate(-2px, -2px);
  box-shadow: 10px 10px 0 rgba(16, 43, 38, 0.12);
}

.lobby-divider {
  margin: 22px 0;
}

.room-code-input {
  border-color: var(--rule);
  background: var(--lobby-glass);
  backdrop-filter: blur(10px);
}

.room-code-input:focus {
  border-color: var(--ink);
  background: var(--paper);
}

.room-join .button {
  border-color: var(--ink);
  background: transparent;
}

.room-join .button:hover {
  background: var(--ink);
  color: var(--paper);
}

.quick-join-button {
  border-color: var(--soft-rule);
  background: transparent;
}

.lobby-visual {
  position: relative;
  width: min(100%, 700px);
  height: min(560px, calc(100dvh - 150px));
  min-height: 460px;
  justify-self: end;
  isolation: isolate;
}

.lobby-visual::before {
  content: "";
  position: absolute;
  inset: 7% 4% 8% 11%;
  border: 1px solid rgba(16, 43, 38, 0.12);
  border-radius: 64% 36% 53% 47% / 40% 60% 40% 60%;
  background: rgba(255, 255, 255, 0.18);
  transform: rotate(-12deg);
}

.lobby-flow {
  position: absolute;
  pointer-events: none;
  transform-origin: 50% 50%;
}

.lobby-flow-outer {
  inset: 10% 1% 12% 8%;
  border: 1px solid rgba(16, 43, 38, 0.2);
  border-radius: 61% 39% 52% 48% / 42% 58% 42% 58%;
  background: rgba(213, 201, 181, 0.24);
  box-shadow: inset 16px 22px 0 rgba(255, 255, 255, 0.16), 22px 24px 0 rgba(16, 43, 38, 0.04);
  transform: rotate(-17deg);
  animation: lobby-drift 18s ease-in-out infinite alternate;
}

.lobby-flow-middle {
  inset: 19% 11% 20% 19%;
  border: 18px solid rgba(39, 108, 91, 0.12);
  border-radius: 43% 57% 58% 42% / 55% 45% 55% 45%;
  box-shadow: inset 0 0 0 1px rgba(39, 108, 91, 0.25), 0 22px 30px rgba(16, 43, 38, 0.06);
  transform: rotate(16deg);
  animation: lobby-drift-reverse 21s ease-in-out infinite alternate;
}

.lobby-flow-inner {
  inset: 29% 22% 29% 30%;
  border: 1px solid rgba(233, 184, 47, 0.82);
  border-radius: 52% 48% 40% 60% / 45% 55% 45% 55%;
  background: rgba(255, 255, 255, 0.2);
  transform: rotate(-10deg);
  animation: lobby-drift 14s ease-in-out infinite alternate-reverse;
}

.lobby-visual-core {
  position: absolute;
  top: 50%;
  left: 53%;
  display: grid;
  width: 226px;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid rgba(16, 43, 38, 0.25);
  border-radius: 49% 51% 43% 57% / 56% 44% 56% 44%;
  background: rgba(251, 251, 247, 0.76);
  box-shadow: 18px 24px 0 rgba(16, 43, 38, 0.06), 0 20px 48px rgba(16, 43, 38, 0.12);
  transform: translate(-50%, -50%) rotate(7deg);
}

.lobby-visual-core::before {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(233, 184, 47, 0.72);
  border-radius: 55% 45% 52% 48% / 45% 55% 45% 55%;
}

.lobby-visual-core img {
  position: relative;
  z-index: 1;
  width: 128px;
  height: 128px;
  object-fit: contain;
  transform: rotate(-7deg);
}

.lobby-connection {
  margin-top: 22px;
}

@keyframes lobby-drift {
  from {
    transform: rotate(-17deg) translate3d(-8px, 4px, 0) scale(0.98);
  }
  to {
    transform: rotate(-12deg) translate3d(8px, -4px, 0) scale(1.02);
  }
}

@keyframes lobby-drift-reverse {
  from {
    transform: rotate(16deg) translate3d(7px, -5px, 0) scale(1.02);
  }
  to {
    transform: rotate(11deg) translate3d(-7px, 5px, 0) scale(0.98);
  }
}

@media (max-width: 900px) {
  .lobby-main {
    grid-template-columns: minmax(320px, 0.9fr) minmax(320px, 1.1fr);
    width: min(100% - 40px, 760px);
  }

  .lobby-heading h1 {
    font-size: 64px;
  }

  .lobby-visual {
    min-height: 390px;
  }

  .lobby-visual-core {
    width: 184px;
  }

  .lobby-visual-core img {
    width: 104px;
    height: 104px;
  }
}

@media (max-width: 680px) {
  .lobby-screen::after {
    inset: 12px;
    border-radius: 30% 70% 56% 44% / 8% 15% 85% 92%;
  }

  .lobby-masthead {
    width: min(100% - 32px, 540px);
    height: 80px;
  }

  .lobby-main {
    display: block;
    width: min(100% - 32px, 540px);
    min-height: calc(100dvh - 80px);
    padding: 34px 0 52px;
  }

  .lobby-stage {
    width: 100%;
    padding: 0;
  }

  .lobby-kicker {
    margin-bottom: 15px;
  }

  .lobby-heading h1 {
    font-size: 58px;
  }

  .lobby-heading p:last-child {
    max-width: 280px;
    margin-top: 18px;
    font-size: 13px;
    line-height: 1.7;
  }

  .lobby-entry {
    margin-top: 34px;
  }

  .lobby-visual {
    position: absolute;
    top: 30px;
    right: -150px;
    width: 430px;
    height: 360px;
    min-height: 0;
    opacity: 0.42;
    pointer-events: none;
  }

  .lobby-visual-core {
    width: 164px;
  }

  .lobby-visual-core img {
    width: 92px;
    height: 92px;
  }
}

@media (max-width: 480px) {
  .lobby-brand-mark {
    width: 32px;
    height: 32px;
  }

  .lobby-brand {
    font-size: 18px;
  }

  .lobby-heading h1 {
    font-size: 48px;
  }

  .lobby-heading h1::after {
    width: 76px;
    height: 5px;
  }

  .lobby-entry {
    padding-top: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lobby-flow-outer,
  .lobby-flow-middle,
  .lobby-flow-inner {
    animation: none;
  }
}
