:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #607170;
  --paper: #fffaf0;
  --leaf: #2d7a51;
  --teal: #246a73;
  --gold: #ffd166;
  --danger: #d94b5f;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: #f7f1e4;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
a {
  font: inherit;
}

button,
.primary-link,
.secondary-link {
  border: 0;
  border-radius: 8px;
  padding: 0.72rem 1rem;
  cursor: pointer;
  text-decoration: none;
  font-weight: 800;
}

button,
.primary-link {
  color: #fff;
  background: var(--teal);
}

.secondary-link {
  color: #1e3f45;
  background: #d7ead7;
}

.lobby-shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 88px 0 40px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
  font-weight: 900;
  color: var(--gold);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.lobby-shell {
  display: grid;
  grid-template-columns: 390px 1fr;
  gap: 1rem;
}

.lobby-panel {
  display: grid;
  align-content: start;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid #d8d1c2;
  border-radius: 8px;
  background: var(--paper);
}

.lobby-panel h1,
.lobby-panel h2 {
  margin: 0;
}

.lobby-form,
.lobby-form label {
  display: grid;
  gap: 0.55rem;
}

input {
  min-width: 0;
  border: 1px solid #b9c7bc;
  border-radius: 8px;
  padding: 0.7rem;
  background: #fff;
}

.lobby-status {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  overflow: hidden;
  border-radius: 8px;
  background: #c8d6c1;
}

.lobby-status div {
  display: grid;
  gap: 0.25rem;
  padding: 1rem;
  background: #fff;
}

.lobby-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.max-players,
.ai-difficulty {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.max-players input,
.ai-difficulty select {
  width: 72px;
}

.player-list {
  display: grid;
  gap: 0.5rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.player-list li {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem;
  border-radius: 8px;
  background: #eef4df;
}

.swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
}

.lobby-message {
  min-height: 1.5rem;
  margin: 0;
  font-weight: 800;
}

.game-shell {
  position: fixed;
  inset: 0;
  width: 100dvw;
  height: 100dvh;
  overflow: hidden;
  background: #07131c;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100dvw;
  height: 100dvh;
}

#gameCanvas canvas {
  display: block;
  width: 100dvw !important;
  height: 100dvh !important;
}

.hud,
.scoreboard,
.settings-toggle {
  position: fixed;
  z-index: 40;
}

.hud,
.scoreboard {
  display: flex;
  gap: 0.5rem;
  pointer-events: none;
}

.hud {
  top: 72px;
  left: 16px;
  flex-wrap: wrap;
}

.hud div,
.scoreboard,
.overlay-panel {
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 250, 240, 0.88);
  backdrop-filter: blur(12px);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.18);
}

.hud div {
  min-width: 104px;
  display: grid;
  gap: 0.2rem;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
}

.hud div.warning strong {
  color: #a55f00;
}

.hud div.critical strong {
  color: var(--danger);
}

.hud span {
  font-size: 0.7rem;
  text-transform: uppercase;
  font-weight: 900;
  color: var(--muted);
}

.scoreboard {
  top: 72px;
  right: 16px;
  min-width: 180px;
  display: grid;
  gap: 0.35rem;
  padding: 0.8rem;
  border-radius: 8px;
}

.scoreboard h2 {
  margin: 0;
  font-size: 0.82rem;
  text-transform: uppercase;
}

.scoreboard ol {
  display: grid;
  gap: 0.3rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-weight: 800;
}

.scoreboard li {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 0.35rem;
}

.scoreboard li.finished {
  color: #2d7a51;
}

.scoreboard li.eliminated {
  color: var(--muted);
  opacity: 0.7;
}

.scoreboard .finish-icon {
  min-width: 1.25rem;
  text-align: center;
}

.settings-toggle {
  top: 72px;
  right: 214px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 50%;
  color: var(--ink);
  background: rgba(255, 250, 240, 0.9);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(12px);
}

.settings-panel {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  justify-items: end;
  align-items: start;
  padding: 72px 16px 16px;
  background: rgba(7, 19, 28, 0.22);
}

.settings-panel.hidden {
  display: none;
}

.settings-card {
  width: min(360px, calc(100vw - 32px));
  display: grid;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.94);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(14px);
}

@media (max-width: 760px) {
  .hud {
    top: 12px;
    right: 12px;
    left: 12px;
  }

  .hud div {
    min-width: 0;
    flex: 1 1 96px;
  }

  .scoreboard {
    top: auto;
    right: 12px;
    bottom: 12px;
    max-width: min(220px, calc(100vw - 24px));
  }

  .settings-toggle {
    top: auto;
    right: 12px;
    bottom: 122px;
  }

  .settings-panel {
    padding: 12px;
    align-items: center;
    justify-items: center;
  }
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.settings-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.icon-button {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--ink);
  background: #e8eedc;
}

.settings-card label {
  display: grid;
  gap: 0.35rem;
  font-weight: 800;
}

.settings-card label:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
}

.settings-bindings {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.45rem 0.8rem;
  padding: 0.75rem;
  border-radius: 8px;
  background: #eef4df;
}

.settings-bindings span {
  color: var(--muted);
}

.game-overlay {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(90deg, rgba(7, 19, 28, 0.7), rgba(7, 19, 28, 0.18));
}

.game-overlay.hidden,
.countdown.hidden {
  display: none;
}

.overlay-panel {
  width: min(520px, calc(100vw - 32px));
  display: grid;
  gap: 1rem;
  padding: 1.25rem;
  border-radius: 8px;
}

.overlay-panel h1 {
  margin: 0;
  font-size: clamp(2.4rem, 8vw, 4.7rem);
  line-height: 0.9;
}

.overlay-panel p {
  margin: 0;
}

.settings-row {
  display: grid;
  gap: 0.65rem;
}

.settings-row label {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.countdown {
  position: fixed;
  z-index: 60;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff7bd;
  text-shadow:
    0 7px 0 #743914,
    0 16px 38px rgba(0, 0, 0, 0.55);
  font-size: clamp(7rem, 22vw, 17rem);
  font-weight: 1000;
  pointer-events: none;
}

@media (max-width: 780px) {
  .scoreboard {
    display: none;
  }

  .settings-toggle {
    right: 16px;
  }
}

.game-shell .hud {
  top: 14px;
  left: 14px;
  max-width: min(720px, calc(100vw - 96px));
  gap: 0.45rem;
}

.game-shell .hud div,
.game-shell .scoreboard {
  border: 4px solid #4a240d;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 230, 126, 0.26), rgba(255, 230, 126, 0) 34%),
    linear-gradient(135deg, rgba(134, 75, 31, 0.96), rgba(58, 29, 13, 0.94));
  color: #fff;
  box-shadow:
    inset 0 0 0 2px rgba(255, 240, 156, 0.18),
    inset 0 -7px 0 rgba(48, 22, 7, 0.35),
    0 12px 26px rgba(0, 0, 0, 0.32);
  backdrop-filter: none;
}

.game-shell .hud div {
  min-width: 92px;
  padding: 0.45rem 0.65rem 0.55rem;
}

.game-shell .hud span,
.game-shell .scoreboard h2 {
  color: #ffe99d;
  text-shadow: 0 2px 0 rgba(45, 20, 6, 0.8);
}

.game-shell .hud strong {
  font-size: 1.05rem;
  color: #fff;
  text-shadow: 0 2px 0 #301407;
}

.game-shell .hud div.warning strong {
  color: #ffd84f;
}

.game-shell .hud div.critical strong {
  color: #ff7a45;
}

.game-shell .scoreboard {
  top: 14px;
  right: 14px;
  min-width: 210px;
  gap: 0.45rem;
  padding: 0.7rem;
}

.game-shell .scoreboard h2 {
  font-size: 1rem;
  letter-spacing: 0;
}

.game-shell .scoreboard ol {
  gap: 0.35rem;
}

.game-shell .scoreboard li {
  padding: 0.35rem 0.5rem;
  border: 2px solid rgba(255, 226, 142, 0.24);
  border-radius: 8px;
  background: rgba(45, 21, 8, 0.5);
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

.game-shell .scoreboard li:first-child {
  background: linear-gradient(#ffd84f, #f59d18);
  color: #3b1c07;
  text-shadow: none;
}

.game-shell .settings-toggle {
  top: 14px;
  right: 238px;
  border: 4px solid #4a240d;
  background: linear-gradient(#ffd84f, #f59d18);
  color: #3b1c07;
  box-shadow: 0 7px 0 rgba(55, 25, 8, 0.75), 0 12px 24px rgba(0, 0, 0, 0.32);
  backdrop-filter: none;
}

.game-shell .settings-panel {
  padding: 72px 14px 14px;
}

@media (max-width: 780px) {
  .game-shell .hud {
    top: 10px;
    left: 10px;
    max-width: calc(100vw - 20px);
  }

  .game-shell .hud div {
    min-width: calc(50% - 0.3rem);
  }

  .game-shell .scoreboard {
    display: none;
  }

  .game-shell .settings-toggle {
    top: 10px;
    right: 10px;
  }
}

.start-screen {
  position: fixed;
  inset: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  color: #fff;
  background: #07131c;
}

.start-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.start-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 38%, rgba(255, 209, 102, 0.2), rgba(7, 19, 28, 0.1) 34%, rgba(7, 19, 28, 0.74) 100%);
}

.start-menu {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 1rem;
  padding: 24px;
  text-align: center;
  text-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
}

.start-menu h1 {
  margin: 0;
  font-size: clamp(4rem, 12vw, 10rem);
  line-height: 0.82;
  color: #fff;
}

.press-start,
.quick-play {
  min-width: 240px;
  border: 4px solid rgba(255, 255, 255, 0.82);
  border-radius: 8px;
  box-shadow: 0 12px 0 #734013, 0 22px 42px rgba(0, 0, 0, 0.35);
  color: #fff;
  text-transform: uppercase;
  text-decoration: none;
  font-weight: 1000;
}

.press-start {
  padding: 1rem 1.45rem;
  background: linear-gradient(#ffd44e, #f08b18);
  font-size: clamp(1.5rem, 4vw, 2.5rem);
}

.quick-play {
  padding: 0.72rem 1.2rem;
  background: linear-gradient(#32c7d2, #1572b9);
  font-size: 1rem;
}

.lobby-shell {
  position: fixed;
  inset: 0;
  width: auto;
  margin: 0;
  padding: clamp(18px, 3vw, 36px);
  display: grid;
  grid-template-columns: minmax(230px, 330px) 1fr;
  gap: clamp(16px, 3vw, 34px);
  overflow: auto;
  background: linear-gradient(rgba(20, 56, 42, 0.18), rgba(42, 21, 8, 0.2)), url("/game/assets/backgrounds/tree-trunk-backdrop.png") center / cover no-repeat;
}

.lobby-panel {
  border: 4px solid #6f3b14;
  border-radius: 8px;
  background: linear-gradient(#a75a22, #673414);
  box-shadow: inset 0 0 0 3px rgba(255, 209, 102, 0.2), 0 20px 42px rgba(0, 0, 0, 0.35);
  color: #fff;
}

.lobby-command-panel {
  align-self: center;
}

.lobby-roster-panel {
  background: rgba(87, 46, 20, 0.88);
}

.lobby-panel h1,
.lobby-panel h2 {
  color: #fff;
  text-shadow: 0 4px 0 rgba(59, 27, 8, 0.8);
}

.lobby-form input,
.max-players input,
.ai-difficulty select {
  border: 3px solid #5e2e12;
  color: #fff;
  background: #2d170a;
  font-weight: 900;
}

.lobby-button {
  border: 3px solid rgba(255, 255, 255, 0.72);
  box-shadow: 0 7px 0 rgba(56, 28, 8, 0.72);
  text-transform: uppercase;
  font-size: 1.05rem;
}

.lobby-button.create,
.lobby-button.ready {
  background: linear-gradient(#91dc25, #39a71d);
}

.lobby-button.join {
  background: linear-gradient(#42b9ff, #166abf);
}

.lobby-button.ai,
.lobby-button.nudge {
  background: linear-gradient(#b757e8, #6a30ba);
}

.lobby-button.remove {
  background: linear-gradient(#ff9c2d, #e55514);
}

.lobby-button.start {
  color: #f3e4c8;
  background: linear-gradient(#6f685b, #3b352d);
  border-color: rgba(255, 255, 255, 0.36);
  box-shadow: 0 7px 0 rgba(35, 18, 8, 0.64);
  filter: saturate(0.45) brightness(0.82);
  font-size: 1.35rem;
}

.lobby-button.start.armed {
  color: #fff;
  background: linear-gradient(#ffd84f, #f2a018);
  border-color: rgba(255, 255, 255, 0.72);
  filter: none;
}

.lobby-button.start:not(.armed),
.lobby-button.start:disabled {
  color: #d6c6aa !important;
  background: linear-gradient(#625b50, #2e2924) !important;
  border-color: rgba(255, 255, 255, 0.28) !important;
  box-shadow: 0 7px 0 rgba(35, 18, 8, 0.64) !important;
  cursor: not-allowed;
  filter: grayscale(0.85) brightness(0.72) !important;
}

.lobby-button.start:not(.armed):hover,
.lobby-button.start:disabled:hover {
  transform: none;
  filter: grayscale(0.85) brightness(0.72) !important;
}

.lobby-status {
  border: 3px solid #5e2e12;
  background: #2d170a;
}

.lobby-status div,
.player-list li {
  color: #fff;
  background: rgba(45, 23, 10, 0.86);
}

.lobby-status span,
.settings-bindings span {
  color: #ffe5a1;
}

.lobby-slots {
  display: grid;
  grid-template-columns: repeat(6, minmax(76px, 1fr));
  gap: 0.8rem;
}

.lobby-slots div {
  position: relative;
  min-height: 136px;
  display: grid;
  place-items: end center;
  padding: 0.45rem;
  border: 4px solid #6f3b14;
  border-radius: 8px;
  background: linear-gradient(#d9a15f, #9c642f);
  box-shadow: inset 0 -8px 0 rgba(54, 28, 9, 0.22);
}

.lobby-slots span {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 42px;
  padding: 0.2rem 0.5rem;
  border-radius: 8px;
  color: #fff;
  background: #d74739;
  text-align: center;
  font-weight: 1000;
  box-shadow: 0 4px 0 rgba(58, 24, 8, 0.55);
}

.lobby-slots div:nth-child(2) span { background: #2477d1; }
.lobby-slots div:nth-child(3) span { background: #63ad28; }
.lobby-slots div:nth-child(4) span { background: #edbd19; }
.lobby-slots div:nth-child(5) span { background: #9b37cc; }
.lobby-slots div:nth-child(6) span { background: #23b9c3; }

.lobby-slots img {
  width: min(96px, 90%);
  height: 96px;
  object-fit: contain;
  filter: drop-shadow(0 7px 5px rgba(42, 18, 4, 0.4));
}

@media (max-width: 920px) {
  .lobby-shell {
    position: static;
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
  }

  .lobby-slots {
    grid-template-columns: repeat(3, 1fr);
  }
}

html,
body {
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  background: #102c2a;
}

.start-screen {
  place-items: stretch;
  isolation: isolate;
}

.start-art {
  z-index: -2;
}

.start-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, rgba(255, 242, 122, 0.26), rgba(22, 102, 79, 0.2) 38%, rgba(7, 19, 28, 0.66)),
    radial-gradient(circle at 50% 26%, rgba(255, 255, 255, 0.35), transparent 28%);
}

.start-screen::after {
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(3, 20, 28, 0.42), transparent 28%, transparent 72%, rgba(3, 20, 28, 0.42)),
    linear-gradient(0deg, rgba(5, 32, 23, 0.62), transparent 42%);
}

.start-menu {
  align-self: center;
  justify-self: center;
  gap: clamp(0.8rem, 2vw, 1.35rem);
  position: absolute;
  inset: 0;
  width: 100%;
  min-height: 100%;
  align-content: center;
  justify-content: center;
  padding: clamp(20px, 5vw, 56px);
}

.start-menu h1 {
  color: #fff6c3;
  text-shadow:
    0 5px 0 #783d17,
    0 12px 24px rgba(0, 0, 0, 0.46);
}

.press-start,
.quick-play,
.lobby-button {
  transition: transform 120ms ease, filter 120ms ease;
}

.press-start,
.quick-play {
  width: min(380px, calc(100vw - 48px));
  display: grid;
  place-items: center;
}

.press-start:hover,
.quick-play:hover,
.lobby-button:hover {
  transform: translateY(-2px);
  filter: saturate(1.08) brightness(1.04);
}

.press-start:active,
.quick-play:active,
.lobby-button:active {
  transform: translateY(4px);
}

.lobby-shell {
  height: auto;
  min-height: 100vh;
  grid-template-columns: minmax(210px, 300px) minmax(520px, 1fr);
  align-items: center;
  padding: clamp(16px, 2.4vw, 34px);
  background:
    linear-gradient(180deg, rgba(255, 230, 104, 0.18), rgba(26, 135, 123, 0.08) 36%, rgba(20, 63, 41, 0.34)),
    url("/game/assets/backgrounds/tree-parallax-bg.png") center / cover no-repeat;
}

.lobby-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 7% 15%, rgba(255, 215, 74, 0.28), transparent 18%),
    radial-gradient(circle at 92% 78%, rgba(38, 197, 211, 0.2), transparent 24%),
    linear-gradient(90deg, rgba(36, 93, 38, 0.2), transparent 24%, transparent 76%, rgba(36, 93, 38, 0.22));
}

.lobby-panel {
  position: relative;
  border-width: 5px;
  border-color: #4c250d;
  background:
    linear-gradient(180deg, rgba(255, 206, 106, 0.2), transparent 22%),
    linear-gradient(135deg, #a7622a, #633013);
  box-shadow:
    inset 0 0 0 3px rgba(255, 237, 153, 0.22),
    inset 0 -10px 0 rgba(58, 26, 8, 0.32),
    0 22px 46px rgba(0, 0, 0, 0.34);
}

.lobby-command-panel {
  gap: 1.25rem;
  padding: 1rem;
}

.lobby-command-panel h1 {
  font-size: clamp(1.9rem, 3.5vw, 3rem);
  line-height: 0.95;
}

.lobby-command-panel .eyebrow {
  margin: 0 0 0.45rem;
  color: #fff2a6;
  text-shadow: 0 3px 0 rgba(71, 32, 9, 0.7);
}

.lobby-roster-panel {
  min-height: min(720px, calc(100vh - 48px));
  padding: clamp(0.9rem, 2vw, 1.35rem);
  background:
    linear-gradient(180deg, rgba(255, 219, 127, 0.14), transparent 18%),
    linear-gradient(135deg, rgba(130, 72, 28, 0.94), rgba(73, 37, 15, 0.92));
}

.lobby-roster-panel.hidden,
.lobby-management-actions.hidden,
.lobby-button.hidden {
  display: none;
}

.lobby-heading {
  padding: 0.25rem 0.35rem;
}

.lobby-heading h2 {
  font-size: clamp(1.8rem, 4vw, 3.1rem);
}

.lobby-form {
  gap: 0.8rem;
}

.lobby-form label,
.max-players,
.ai-difficulty {
  color: #fff2a6;
  font-weight: 1000;
  text-transform: uppercase;
}

.lobby-form input,
.max-players input,
.ai-difficulty select {
  min-height: 48px;
  box-shadow: inset 0 4px 0 rgba(0, 0, 0, 0.26);
}

.lobby-actions,
.lobby-round-actions,
.lobby-management-actions {
  display: grid;
}

.lobby-actions {
  grid-template-columns: 1fr;
}

.lobby-button {
  min-height: 58px;
  border-radius: 8px;
  letter-spacing: 0;
  text-shadow: 0 3px 0 rgba(35, 16, 6, 0.42);
}

.lobby-round-actions {
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  margin-top: auto;
  padding-top: 0.85rem;
  border-top: 3px solid rgba(255, 229, 144, 0.18);
}

.lobby-management-actions {
  grid-template-columns: minmax(180px, 1.2fr) repeat(2, minmax(96px, 1fr));
  gap: 0.65rem;
  align-items: end;
  padding: 0.75rem;
  border: 3px solid rgba(255, 226, 142, 0.22);
  border-radius: 8px;
  background: rgba(44, 20, 7, 0.24);
}

.lobby-button.selected {
  box-shadow:
    inset 0 -5px 0 rgba(0, 0, 0, 0.22),
    0 0 0 4px rgba(255, 245, 169, 0.28);
}

.lobby-status {
  box-shadow: inset 0 0 0 3px rgba(255, 221, 136, 0.14);
}

.lobby-status strong {
  font-size: 1.45rem;
  color: #fff;
}

.lobby-slots,
.character-select {
  grid-template-columns: repeat(6, minmax(88px, 1fr));
  gap: clamp(0.65rem, 1.4vw, 1rem);
}

.character-select {
  display: grid;
}

.lobby-slots div {
  min-height: clamp(142px, 19vh, 194px);
  padding: 0.55rem 0.45rem 0.75rem;
  background:
    radial-gradient(circle at 50% 45%, #6c3b1a 0 30%, transparent 31%),
    linear-gradient(#d6a267, #9b6331);
}

.lobby-slots div::after {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: 9px;
  height: 11px;
  border-radius: 8px;
  background: linear-gradient(90deg, #5d981f, #8fd63b, #5f9d25);
  box-shadow: 0 4px 0 rgba(42, 19, 5, 0.26);
}

.lobby-slots img {
  width: min(112px, 96%);
  height: min(112px, 58%);
  align-self: center;
  transform: translateY(9px);
}

.character-card {
  position: relative;
  min-height: clamp(128px, 17vh, 172px);
  display: grid;
  justify-items: center;
  align-content: end;
  gap: 0.35rem;
  padding: 0.55rem;
  border: 3px solid #5a2a0d;
  border-radius: 8px;
  color: #3b1c07;
  font: inherit;
  font-weight: 1000;
  background:
    radial-gradient(circle at 50% 40%, #fff0a6 0 24%, transparent 25%),
    linear-gradient(#e5b76e, #a96d32);
  box-shadow:
    inset 0 -7px 0 rgba(58, 26, 8, 0.24),
    0 8px 0 rgba(58, 26, 8, 0.36);
}

.character-card img {
  width: min(104px, 92%);
  height: min(104px, 68%);
  object-fit: contain;
}

.character-card.selected {
  border-color: #fff2a6;
  background:
    radial-gradient(circle at 50% 40%, #fff7c2 0 28%, transparent 29%),
    linear-gradient(#ffd84f, #f59d18);
  transform: translateY(-4px);
}

.player-list {
  min-height: 48px;
}

.player-list li {
  display: grid;
  grid-template-columns: 14px 44px minmax(92px, 1fr) auto auto auto auto auto;
  align-items: center;
  gap: 0.55rem;
  border: 2px solid rgba(255, 226, 148, 0.22);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18);
}

.ai-row-difficulty,
.ai-row-remove {
  min-height: 34px;
  border: 2px solid rgba(255, 226, 148, 0.42);
  border-radius: 8px;
  font-weight: 1000;
}

.ai-row-difficulty {
  color: #fff;
  background: #2d170a;
}

.ai-row-remove {
  padding: 0.35rem 0.55rem;
  background: linear-gradient(#ff9c2d, #e55514);
}

.player-avatar {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.player-badge,
.player-state {
  padding: 0.25rem 0.45rem;
  border-radius: 8px;
  color: #3b1c07;
  font-size: 0.72rem;
  font-weight: 1000;
  text-transform: uppercase;
  background: #ffe99d;
}

.player-badge.host {
  background: #f59d18;
}

.ai-player .player-badge {
  background: #94e1ff;
}

.player-state {
  background: rgba(255, 255, 255, 0.82);
}

.lobby-message {
  color: #fff5bf;
  text-shadow: 0 2px 0 rgba(50, 22, 6, 0.7);
}

.lobby-shake .lobby-shell {
  animation: lobby-nudge-shake 0.34s linear;
}

@keyframes lobby-nudge-shake {
  0%, 100% { transform: translate(0, 0); }
  18% { transform: translate(-9px, 4px); }
  36% { transform: translate(8px, -4px); }
  54% { transform: translate(-6px, -3px); }
  72% { transform: translate(7px, 3px); }
}

@media (max-width: 980px) {
  .lobby-shell {
    position: static;
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
    align-items: start;
  }

  .lobby-roster-panel {
    min-height: 0;
  }

  .lobby-round-actions {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .lobby-management-actions {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .max-players {
    grid-column: 1 / -1;
  }

  .lobby-button.start {
    grid-column: auto;
  }
}

@media (max-width: 620px) {
  .start-menu {
    width: 100%;
    min-height: 100vh;
  }

  .lobby-shell {
    padding: 12px;
  }

  .lobby-slots,
  .character-select {
    grid-template-columns: repeat(2, 1fr);
  }

  .lobby-round-actions,
  .lobby-management-actions {
    grid-template-columns: 1fr;
  }

  .player-list li {
    grid-template-columns: 14px 40px 1fr;
  }

  .player-badge,
  .player-state {
    justify-self: start;
  }
}
