:root {
  --cell: 44px;
  --bg: #f4f1e9;
  --panel: #fffdf8;
  --accent: #315f45;
  --accent-dark: #234734;
  --border: #c9c1b2;
  --tile: #ead7a6;
  --tile-border: #947844;
  --cell-bg: #dce7d9;
  --cell-border: #a9b7a4;
  --text: #26231f;
  --muted: #6e675d;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input,
select { font: inherit; }

button {
  min-height: 34px;
  padding: .35rem .55rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: white;
  cursor: pointer;
}

button.primary {
  color: white;
  background: var(--accent);
  border-color: var(--accent);
}

button.primary:active { background: var(--accent-dark); }
button:disabled { opacity: .42; cursor: default; }
.name-required:disabled { color: #9b3931; opacity: .72; }

.brand {
  flex: 0 0 auto;
  color: var(--accent);
  font-weight: 800;
  letter-spacing: .02em;
}

[hidden] { display: none !important; }

.lobby,
.resume-panel {
  display: flex;
  align-items: center;
  gap: .3rem;
  width: 100%;
  min-height: 40px;
  margin: 0;
  padding: .22rem .3rem;
  overflow-x: auto;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.lobby input {
  min-width: 0;
  height: 34px;
  padding: .3rem .42rem;
  border: 1px solid var(--border);
  border-radius: 7px;
}

.name-input { width: 110px; }
#lobby-message { white-space: nowrap; font-size: .78rem; color: #8d2f2f; }
.resume-content { flex: 1 1 360px; min-width: 0; }
.resume-content h2 { margin: 0 0 .45rem; font-size: 1rem; }
.resume-games { display: grid; gap: .4rem; }
.resume-game {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding-top: .4rem;
  border-top: 1px solid var(--border);
}
.resume-game:first-child { padding-top: 0; border-top: 0; }
.resume-description { flex: 1 1 auto; min-width: 150px; font-size: .84rem; }
.resume-message { min-height: 1.2rem; margin: .4rem 0 0; color: #8d2f2f; font-size: .82rem; }

#game:not([hidden]) {
  width: 100%;
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: .16rem;
  padding: .16rem;
  overflow: hidden;
}

.game-header {
  min-width: 0;
  display: grid;
  gap: .18rem;
  min-height: 36px;
  padding: .22rem .32rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 7px;
}

.game-title-row,
.header-details {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: .42rem;
  white-space: nowrap;
}

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

#room-label {
  min-width: 0;
  margin-left: auto;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
}

#connection {
  flex: 0 0 auto;
  font-size: .78rem;
}

.header-details {
  overflow: hidden;
  font-size: .78rem;
}

.header-details .brand,
.header-details .share-room,
#header-bag-summary {
  flex: 0 0 auto;
}

#game-limit-label,
#tile-deal-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.players {
  min-width: 0;
  display: flex;
  gap: .25rem;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}
.players::-webkit-scrollbar { display: none; }
.player {
  flex: 0 0 auto;
  padding: .2rem .4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  font-size: .78rem;
}

.player.take-anyway-voted {
  color: #4c3900;
  background: #f4d66f;
  border-color: #b88b13;
}

.player.player-flash-go {
  animation: player-flash-go 2s step-end;
}

.player.player-flash-take-anyway {
  animation: player-flash-take-anyway 2s step-end;
}

.player.can-kick {
  cursor: pointer;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: pan-x;
}

.player.can-kick.kick-hold {
  outline: 2px solid #9b3931;
  outline-offset: -1px;
}

@keyframes player-flash-go {
  0%, 20%, 40%, 60%, 100% {
    color: var(--text);
    background: var(--panel);
    border-color: var(--border);
  }
  10%, 30%, 50% {
    color: #174b2c;
    background: #b9e0c3;
    border-color: #287344;
  }
}

@keyframes player-flash-take-anyway {
  0%, 20%, 40%, 60%, 100% {
    color: var(--text);
    background: var(--panel);
    border-color: var(--border);
  }
  10%, 30%, 50% {
    color: #4c3900;
    background: #f4d66f;
    border-color: #b88b13;
  }
}

@media (prefers-reduced-motion: reduce) {
  .player.player-flash-go {
    animation: none;
    color: #174b2c;
    background: #b9e0c3;
    border-color: #287344;
  }

  .player.player-flash-take-anyway {
    animation: none;
    color: #4c3900;
    background: #f4d66f;
    border-color: #b88b13;
  }
}

.game-message-row {
  min-width: 0;
  min-height: 1.5rem;
  display: flex;
  align-items: center;
  gap: .25rem;
}

.message {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 1.1rem;
  padding: 0 .2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .78rem;
  line-height: 1.1rem;
}

.clear-loose-button {
  flex: 0 0 auto;
  min-height: 1.5rem;
  padding: .12rem .5rem;
  white-space: nowrap;
  font-size: .78rem;
  line-height: 1rem;
}

.waiting-panel {
  align-self: center;
  justify-self: center;
  width: min(520px, calc(100% - 1rem));
  display: grid;
  justify-items: center;
  gap: .8rem;
  padding: clamp(1rem, 4vw, 2rem);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 4px 16px rgba(38, 35, 31, .08);
  text-align: center;
}

.waiting-panel p { margin: 0; }
.waiting-panel button { min-width: 160px; }
.waiting-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .45rem; }

.board-shell {
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y pinch-zoom;
  -webkit-overflow-scrolling: touch;
  background: transparent;
  border: 0;
}

.board {
  display: grid;
  gap: 2px;
  width: max-content;
  height: max-content;
  min-width: max-content;
  min-height: max-content;
  margin: 0;
  padding: 0;
}

.cell {
  width: var(--cell);
  height: var(--cell);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  background: var(--cell-bg);
  border: 1px solid var(--cell-border);
}

.message-reason {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.single-weave-rule { color: #9b3931; font-weight: 800; }

.cell.valid { background: #d6ead9; }
.cell.invalid { background: #f2caca; }
.cell.uncovered { background: #f3ddb0; }
.cell.drop-target {
  background: #b9ddc2;
  outline: 3px solid #315f45;
  outline-offset: -3px;
}
.cell.drop-blocked {
  background: #efb8b3;
  outline: 3px solid #9b3931;
  outline-offset: -3px;
}

.tile {
  width: calc(var(--cell) - 6px);
  height: calc(var(--cell) - 6px);
  display: grid;
  place-items: center;
  position: relative;
  border: 1px solid var(--tile-border);
  border-radius: 6px;
  background: linear-gradient(#f3e3b9, var(--tile));
  box-shadow: 0 1px 3px rgba(0,0,0,.22);
  font-weight: 800;
  font-size: calc(var(--cell) * .42);
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  touch-action: none;
  cursor: grab;
}

.tile.dragging {
  opacity: .22;
  cursor: grabbing;
}

.value {
  position: absolute;
  right: 3px;
  bottom: 1px;
  font-size: calc(var(--cell) * .15);
}

.rack-wrap {
  min-width: 0;
  width: 100%;
  max-height: 40dvh;
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  align-items: start;
  gap: .25rem;
  padding: .22rem;
  padding-bottom: max(.22rem, env(safe-area-inset-bottom));
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 7px;
}

.rack-actions {
  display: flex;
  flex-direction: column;
  gap: .25rem;
}

.rack-actions button {
  width: 68px;
  min-height: 42px;
  padding: .3rem .3rem;
  font-weight: 700;
  line-height: 1.05;
}

.rack {
  min-width: 0;
  width: 100%;
  min-height: calc(50px + .7rem);
  max-height: calc(40dvh - .45rem);
  display: grid;
  grid-template-columns: repeat(auto-fill, 50px);
  grid-auto-rows: 50px;
  justify-content: start;
  align-content: start;
  gap: .32rem;
  padding: .35rem;
  overflow-x: hidden;
  overflow-y: auto;
  background: #8a6441;
  border-radius: 7px;
  -webkit-overflow-scrolling: touch;
}

.rack .tile {
  --cell: 50px;
  width: 50px;
  height: 50px;
  touch-action: none;
  cursor: grab;
}

.rack .tile.dragging {
  cursor: grabbing;
}

.rack.drop-target {
  outline: 3px solid #315f45;
  outline-offset: -3px;
}

.drag-ghost {
  position: fixed;
  z-index: 200;
  margin: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(1.06);
  opacity: .92;
  box-shadow: 0 7px 18px rgba(0,0,0,.3);
  transition: width .1s ease, height .1s ease, font-size .1s ease;
}

.drag-ghost.board-size {
  width: calc(var(--cell) - 6px);
  height: calc(var(--cell) - 6px);
  font-size: calc(var(--cell) * .42);
}

.drag-ghost.board-size .value {
  font-size: calc(var(--cell) * .15);
}

.drag-ghost.rack-size {
  width: 50px;
  height: 50px;
  font-size: 21px;
}

.drag-ghost.rack-size .value {
  font-size: 7.5px;
}

.rack .tile.drop-before {
  box-shadow: inset 4px 0 #315f9b, 0 1px 3px rgba(0,0,0,.22);
}

.rack .tile.drop-after {
  box-shadow: inset -4px 0 #315f9b, 0 1px 3px rgba(0,0,0,.22);
}

.chat-panel {
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel);
}

.chat-panel:not([open]) {
  position: relative;
  z-index: 150;
  width: auto;
  max-width: 50%;
  box-shadow: none;
}

.chat-panel[open] {
  position: fixed;
  right: max(.5rem, env(safe-area-inset-right));
  bottom: max(.5rem, env(safe-area-inset-bottom));
  z-index: 150;
  width: min(360px, calc(100vw - 1rem));
  box-shadow: 0 7px 24px rgba(38, 35, 31, .22);
}

.chat-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .48rem .65rem;
  color: white;
  background: var(--accent);
  font-weight: 750;
  cursor: pointer;
  user-select: none;
}

.chat-panel summary::marker,
.chat-panel summary::-webkit-details-marker {
  display: none;
  content: "";
}

.chat-summary-tools {
  display: flex;
  align-items: center;
  gap: .4rem;
}

.chat-toggle-icon {
  width: 1.25rem;
  height: 1.25rem;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: 4px;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
}

.chat-toggle-icon::before { content: "+"; }
.chat-panel[open] .chat-toggle-icon::before { content: "−"; }

.chat-panel:not([open]) summary {
  min-height: 1.5rem;
  padding: .12rem .55rem;
  font-size: .78rem;
  line-height: 1rem;
}

.chat-unread {
  min-width: 1.35rem;
  padding: .08rem .35rem;
  border-radius: 999px;
  color: #3b250d;
  background: #ffd28a;
  font-size: .75rem;
  text-align: center;
}

.chat-panel.attention > summary {
  animation: chat-attention 2.2s step-end;
}

@keyframes chat-attention {
  0%, 20%, 40%, 60%, 100% { background: var(--accent); }
  10%, 30%, 50% { background: #c66b20; }
}

@media (prefers-reduced-motion: reduce) {
  .chat-panel.attention > summary {
    animation: none;
    background: #9b5620;
  }
}

.chat-messages {
  height: min(300px, 38dvh);
  padding: .45rem .55rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #f8f5ed;
  -webkit-overflow-scrolling: touch;
}

.chat-message {
  margin: 0 0 .42rem;
  overflow-wrap: anywhere;
  font-size: .85rem;
  line-height: 1.25;
}

.chat-message.system { color: var(--muted); font-style: italic; }
.chat-time { margin-left: .35rem; color: var(--muted); font-size: .7rem; white-space: nowrap; }

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .35rem;
  padding: .45rem;
  border-top: 1px solid var(--border);
}

.chat-form input {
  min-width: 0;
  padding: .4rem .5rem;
  border: 1px solid var(--border);
  border-radius: 7px;
}

@media (max-width: 640px) {
  body { position: fixed; inset: 0; }

  .lobby,
  .resume-panel { gap: .22rem; padding: .18rem .22rem; }
  .name-input { width: 90px; }
  .lobby button,
  .resume-panel button { padding: .3rem .4rem; }

  #game:not([hidden]) { gap: .12rem; padding: .12rem; }

  .game-header {
    gap: .12rem;
    padding: .16rem .24rem;
  }

  .game-title-row { font-size: .9rem; }
  .header-details {
    gap: .32rem;
    font-size: .72rem;
  }
  .header-details .brand { font-size: .88rem; }
  .header-details .share-room {
    min-width: max-content;
    min-height: 26px;
    padding: .16rem .4rem;
  }

  .rack-wrap {
    grid-template-columns: 62px minmax(0, 1fr);
    max-height: 42dvh;
    gap: .2rem;
    padding: .18rem;
    padding-bottom: max(.18rem, env(safe-area-inset-bottom));
  }

  .chat-panel {
    max-width: 50%;
  }

  .chat-panel[open] {
    right: max(.25rem, env(safe-area-inset-right));
    bottom: max(.25rem, env(safe-area-inset-bottom));
    max-width: none;
    width: calc(100vw - .5rem);
  }

  .chat-messages { height: min(260px, 35dvh); }

  .rack-actions button {
    width: 62px;
    min-height: 40px;
    font-size: .88rem;
  }

  .rack {
    min-height: calc(47px + .56rem);
    max-height: calc(42dvh - .36rem);
    grid-template-columns: repeat(auto-fill, 47px);
    grid-auto-rows: 47px;
    gap: .26rem;
    padding: .28rem;
  }

  .rack .tile {
    --cell: 47px;
    width: 47px;
    height: 47px;
  }

  .drag-ghost.rack-size {
    width: 47px;
    height: 47px;
    font-size: 19.74px;
  }
}

.winner-message{margin:.15rem 0 .9rem;font-size:clamp(1.35rem,5vw,2rem);font-weight:850;color:var(--accent);text-align:center}.final-results tr.winner{font-weight:700;background:#d9eddd}.final-results tr.winner.you{background:#cde7d2}.final-results-actions{display:flex;justify-content:flex-end;margin-top:.85rem}.final-results{position:fixed;inset:0;z-index:100;display:grid;place-items:center;padding:1rem;background:rgba(28,28,24,.68)}.final-results[hidden]{display:none}.final-results-card{width:min(680px,100%);max-height:90dvh;overflow:auto;padding:1rem;border:1px solid var(--border);border-radius:12px;background:var(--panel);box-shadow:0 12px 40px rgba(0,0,0,.28)}.final-results-card h2{margin:0 0 .75rem}.final-results table{width:100%;border-collapse:collapse}.final-results th,.final-results td{padding:.45rem .35rem;border-bottom:1px solid var(--border);text-align:right}.final-results th:first-child,.final-results td:first-child,.final-results th:last-child,.final-results td:last-child{text-align:left}.final-results tr.you{background:#e7f4e9}@media(max-width:640px){.final-results{padding:.4rem}.final-results-card{padding:.65rem}.final-results th,.final-results td{padding:.35rem .22rem;font-size:.84rem}}

.lobby-page {
  width: 100%;
  height: 100dvh;
  overflow: auto;
  padding: clamp(.8rem, 3vw, 2rem);
}

.lobby-header {
  width: min(980px, 100%);
  margin: 0 auto 1rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.lobby-header h1,
.lobby-header p,
.lobby-card h2,
.lobby-card p {
  margin: 0;
}

.lobby-header h1 { font-size: clamp(1.8rem, 6vw, 3rem); }
.lobby-header p,
.lobby-card p { color: var(--muted); }

.admin-link {
  padding: .45rem .65rem;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel);
}

.lobby-name,
.lobby-settings,
.invite-note,
.lobby-grid,
.lobby-message {
  width: min(980px, 100%);
  margin-left: auto;
  margin-right: auto;
}

.lobby-name {
  display: grid;
  gap: .3rem;
  margin-bottom: .8rem;
  font-weight: 650;
}

.lobby-settings {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: .65rem;
  margin-bottom: .8rem;
  padding: .7rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel);
}
.lobby-setting { display: grid; gap: .3rem; font-weight: 650; }
.lobby-setting select {
  min-height: 42px;
  padding: .5rem .65rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: white;
}
.lobby-settings small { flex: 1 1 220px; color: var(--muted); }

.lobby-name input,
.lobby-card input,
.admin-login input {
  width: 100%;
  min-height: 42px;
  padding: .55rem .65rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: white;
}

.name-controls {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  width: min(540px, 100%);
}
.name-controls input { flex: 1 1 220px; }
.name-controls button { flex: 0 1 auto; }

.invite-note {
  margin-bottom: .8rem;
  padding: .7rem;
  border: 1px solid #a9c6ad;
  border-radius: 8px;
  background: #e7f4e9;
}

.lobby-grid {
  display: grid;
  grid-template-columns: minmax(0, 560px);
  justify-content: center;
  gap: .8rem;
  align-items: start;
}

.lobby-card,
.card {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 4px 16px rgba(38, 35, 31, .06);
}

.start-card,
.join-card { display: grid; gap: .85rem; }
.start-card label { display: grid; gap: .3rem; }
.start-card small { color: var(--muted); font-weight: 400; }
.start-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.start-option {
  display: grid;
  align-content: start;
  gap: .75rem;
  padding: .85rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
}
.start-option h3,
.start-option p { margin: 0; }
.start-option button { align-self: end; }
.quick-play-option { grid-template-rows: auto auto 1fr auto; }
.start-option .player-hint { color: var(--accent); font-weight: 650; }
.join-card button { width: 100%; white-space: normal; }
.instructions-card h2 { margin-bottom: .65rem; }
.instructions-card ol { margin: 0; padding-left: 1.35rem; }
.instructions-card li + li { margin-top: .45rem; }
.instructions-card p { margin-top: .8rem; }

.card-heading,
.admin-section-heading,
.admin-room-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
}

.empty-list { margin: .8rem 0 0; color: var(--muted); }
.empty-list.error,
.lobby-message,
.admin-message { color: #8d2f2f; }
.lobby-message { min-height: 1.3rem; margin-top: .7rem; }

.resume-card {
  width: min(620px, calc(100% - 2rem));
  min-height: 0;
  margin: 2rem auto;
  padding: 1rem;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.resume-actions { display: flex; gap: .4rem; margin-left: auto; }
.share-room { min-height: 28px; padding: .2rem .45rem; font-size: .76rem; }

.admin-page {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: auto;
  -webkit-overflow-scrolling: touch;
}

.admin-header,
.admin-main {
  width: min(1100px, calc(100% - 2rem));
  margin-left: auto;
  margin-right: auto;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
}

.admin-header h1 { margin: .15rem 0 0; }
.admin-header .brand { text-decoration: none; }
.admin-main { padding-bottom: 2rem; }
.admin-login { width: min(440px, 100%); margin: 2rem auto; }
.admin-login h2 { margin-top: 0; }
.admin-login form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .4rem; }

.admin-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .7rem;
}

.summary-card {
  display: grid;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
}

.summary-card strong { font-size: 1.7rem; color: var(--accent); }
.summary-card span { color: var(--muted); }
.admin-section { margin-top: 1.4rem; }
.admin-section h2,
.admin-section p,
.admin-room h3 { margin: 0; }
.admin-section > p,
.admin-section-heading p { color: var(--muted); }
.admin-room-list { display: grid; gap: .7rem; margin-top: .7rem; }
.admin-room h3 { font-size: 1.05rem; }
.admin-room-heading small { color: var(--muted); }
.room-facts { margin: .7rem 0 !important; color: var(--muted); }

.status-badge {
  padding: .2rem .45rem;
  border-radius: 999px;
  background: #ece8df;
  font-size: .76rem;
  font-weight: 700;
}

.status-playing { color: #1f5534; background: #d9eddd; }
.status-finished { color: #254e7a; background: #dce9f5; }
.status-interrupted { color: #7d3f2b; background: #f3ded5; }
.admin-room table { width: 100%; border-collapse: collapse; }
.admin-room th,
.admin-room td { padding: .4rem; border-top: 1px solid var(--border); text-align: right; }
.admin-room th:first-child,
.admin-room td:first-child { text-align: left; }
.online { color: #287344; }
.offline { color: var(--muted); }

@media (max-width: 700px) {
  .lobby-grid { grid-template-columns: 1fr; }
  .start-options { grid-template-columns: 1fr; }
  .resume-card { margin: 1rem auto; }
  .resume-game { align-items: stretch; flex-direction: column; }
  .resume-actions { width: 100%; margin-left: 0; }
  .resume-actions button { flex: 1 1 auto; }
  .admin-page { position: static; inset: auto; }
  .admin-summary { grid-template-columns: 1fr; }
  .admin-login form { grid-template-columns: 1fr; }
  .admin-room { overflow-x: auto; }
  .admin-room-heading { min-width: 480px; }
  .admin-room table { min-width: 480px; }
}

.rematch-status {
  min-height: 1.3rem;
  margin: .8rem 0 0;
  color: var(--muted);
  text-align: center;
}

.final-results-actions {
  flex-wrap: wrap;
  gap: .45rem;
}

.final-player-views { margin-top: 1rem; }
.final-player-views h3 { margin: 0; }
.final-player-views > p { margin: .25rem 0 .55rem; color: var(--muted); }
.final-board-carousel {
  display: flex;
  gap: .7rem;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: .15rem;
  padding: .15rem .15rem .65rem;
  -webkit-overflow-scrolling: touch;
}
.final-player-card {
  flex: 0 0 min(92%, 560px);
  min-width: 0;
  scroll-snap-align: start;
  padding: .65rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f7fbf5;
}
.final-player-card h4 { margin: 0 0 .55rem; font-size: 1.05rem; }
.final-board-scroll { max-width: 100%; overflow: auto; color: var(--muted); }
.final-board-grid {
  --final-cell: 30px;
  display: grid;
  gap: 1px;
  width: max-content;
  padding: 1px;
  background: var(--cell-border);
}
.final-board-cell {
  width: var(--final-cell);
  height: var(--final-cell);
  display: grid;
  place-items: center;
  background: var(--cell-bg);
}
.final-view-tile {
  position: relative;
  width: calc(var(--final-cell) - 3px);
  height: calc(var(--final-cell) - 3px);
  display: grid;
  place-items: center;
  border: 1px solid #8e7650;
  border-radius: 4px;
  background: #f4dfad;
  color: var(--text);
  font-weight: 800;
}
.final-view-tile small { position: absolute; right: 2px; bottom: 0; font-size: 8px; }
.final-hand-heading { display: block; margin-top: .6rem; }
.final-hand { min-height: 32px; display: flex; flex-wrap: wrap; gap: 3px; align-items: center; color: var(--muted); }
.final-hand .final-view-tile { --final-cell: 34px; }


.invite-settings {
  margin-top: 1rem;
  display: grid;
  gap: 1rem;
}

.invite-settings[hidden],
.quick-choices[hidden] {
  display: none;
}

.invite-settings fieldset {
  border: 1px solid var(--border, #c9c9c9);
  border-radius: .7rem;
  display: grid;
  gap: .65rem;
  margin: 0;
  padding: .8rem;
}

.invite-settings legend {
  font-weight: 700;
  padding: 0 .25rem;
}

.quick-choices {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  padding-left: 1.6rem;
}

.quick-choices label {
  border: 1px solid var(--border, #c9c9c9);
  border-radius: 999px;
  cursor: pointer;
  padding: .35rem .7rem;
}

.quick-play-option {
  order: -1;
}


/* Avskalad ingång från en inbjudningslänk. */
.lobby-page.invite-mode {
  max-width: 440px;
  min-height: 100dvh;
  margin: 0 auto;
  padding-top: clamp(2rem, 10vh, 6rem);
}

.lobby-page.invite-mode .lobby-header {
  width: 100%;
  align-items: flex-start;
}

.lobby-page.invite-mode .lobby-header > div {
  width: 100%;
}

.lobby-page.invite-mode .admin-link,
.lobby-page.invite-mode .lobby-name > label,
.lobby-page.invite-mode #random-name {
  display: none;
}

.lobby-page.invite-mode #lobby-intro {
  max-width: 32rem;
  margin-top: 1.5rem;
  color: var(--ink);
  font-size: 1.1rem;
  line-height: 1.5;
}

.lobby-page.invite-mode .lobby-name,
.lobby-page.invite-mode .lobby-grid,
.lobby-page.invite-mode .lobby-message {
  width: 100%;
}

.lobby-page.invite-mode .lobby-name {
  display: block;
  margin-top: 1rem;
}

.lobby-page.invite-mode .name-controls,
.lobby-page.invite-mode .name-input {
  width: 100%;
}

.lobby-page.invite-mode .lobby-grid {
  display: block;
  margin-top: 0.75rem;
}

.lobby-page.invite-mode .join-card {
  display: grid;
  gap: 1rem;
}

.lobby-page.invite-mode #join-invite {
  width: 100%;
}

.invite-secondary {
  display: grid;
  gap: 0.35rem;
  margin-top: clamp(2.5rem, 10vh, 5rem);
  color: var(--muted);
  font-size: 0.88rem;
}

.invite-secondary details {
  padding: 0.45rem 0;
  border-top: 1px solid var(--border);
}

.invite-secondary summary {
  width: fit-content;
  cursor: pointer;
  font-weight: 600;
}

.invite-secondary p {
  margin: 0.7rem 0;
}

.invite-secondary button {
  width: auto;
  font-size: 0.9rem;
}

@media (max-width: 520px) {
  .lobby-page.invite-mode {
    padding-top: 1.25rem;
  }
}
