:root {
  --ink: #14201c;
  --ink-soft: #2a3b34;
  --paper: #e7efe8;
  --mist: #c5d6cb;
  --lime: #b8e846;
  --lime-deep: #8fbf1f;
  --coral: #ff6b4a;
  --white: #f7fbf7;
  --shadow: 0 18px 50px rgba(20, 32, 28, 0.18);
  --radius: 18px;
  --font-display: "Syne", sans-serif;
  --font-body: "IBM Plex Sans", sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --tap: 44px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  overflow-x: hidden;
  overflow-x: clip;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  padding:
    var(--safe-top)
    var(--safe-right)
    var(--safe-bottom)
    var(--safe-left);
}

img,
svg,
video {
  max-width: 100%;
  height: auto;
}

button,
input,
select,
textarea {
  font: inherit;
  max-width: 100%;
}

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

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(184, 232, 70, 0.35), transparent 55%),
    radial-gradient(900px 500px at 90% 0%, rgba(255, 107, 74, 0.18), transparent 50%),
    linear-gradient(165deg, #dfece2 0%, #c9d9cf 45%, #b7c9be 100%);
  animation: drift 18s ease-in-out infinite alternate;
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.08;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
}

@keyframes drift {
  from {
    transform: scale(1) translateY(0);
  }
  to {
    transform: scale(1.04) translateY(-12px);
  }
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem clamp(0.85rem, 3vw, 1.25rem);
  position: sticky;
  top: 0;
  z-index: 15;
  background: linear-gradient(
    to bottom,
    rgba(223, 236, 226, 0.92),
    rgba(223, 236, 226, 0.72) 70%,
    transparent
  );
  backdrop-filter: blur(8px);
}

.topbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.45rem;
  min-width: 0;
}

.account-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.35rem;
  min-width: 0;
}

.google-btn {
  min-height: 32px;
  max-width: min(100%, 12.5rem);
  overflow: hidden;
}

.account-panel {
  margin-top: 2rem;
  text-align: left;
}

.account-head {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 0.75rem;
}

.account-head img {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  object-fit: cover;
}

.account-name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
}

.ghost {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: 600 0.75rem/1 var(--font-body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  cursor: pointer;
  padding: 0.55rem 0.45rem;
  min-height: var(--tap);
  white-space: nowrap;
}

.ghost .icon {
  font-size: 1rem;
  letter-spacing: 0;
}

.view {
  display: none;
  min-height: calc(100vh - 4rem);
  min-height: calc(100dvh - 4rem);
  padding: 0 clamp(0.85rem, 3vw, 1.25rem) clamp(1.5rem, 4vw, 2.5rem);
}

.view.active {
  display: block;
  animation: rise 0.45s ease both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.hero {
  max-width: 42rem;
  margin: clamp(2rem, 10vh, 12vh) auto 0;
  text-align: left;
}

.hero .btn.primary {
  background: var(--ink);
  color: var(--white);
}

.brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(3.4rem, 10vw, 5.8rem);
  line-height: 0.9;
  letter-spacing: -0.04em;
  margin: 0 0 1rem;
  color: var(--ink);
  animation: brand-in 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.brand.sm {
  font-size: 1.4rem;
  letter-spacing: -0.03em;
  margin-bottom: 0.35rem;
  color: var(--ink);
  background: none;
  -webkit-background-clip: unset;
  background-clip: unset;
}

@keyframes brand-in {
  from {
    opacity: 0;
    letter-spacing: 0.08em;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    letter-spacing: -0.04em;
    transform: none;
  }
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 0.75rem;
}

h1 {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  max-width: 16ch;
}

.lede {
  color: var(--ink-soft);
  font-size: 1.05rem;
  line-height: 1.5;
  max-width: 36ch;
  margin: 0 0 1.75rem;
}

.lede.tight {
  margin-bottom: 0.5rem;
}

.meta,
.hint {
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.25rem 0;
}

.cta-row .btn {
  flex: 1 1 12rem;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 0.9rem 1.35rem;
  min-height: var(--tap);
  font: 600 0.95rem/1 var(--font-body);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  -webkit-user-select: none;
  user-select: none;
}

@media (hover: hover) and (pointer: fine) {
  .btn:hover {
    transform: translateY(-1px);
  }
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  background: var(--ink);
  color: var(--white);
  box-shadow: var(--shadow);
}

.btn.primary:hover {
  background: #0f1815;
}

.btn.secondary {
  background: var(--lime);
  color: var(--ink);
}

.btn.secondary:hover {
  background: var(--lime-deep);
  color: var(--white);
}

.btn.ghost-btn {
  background: rgba(255, 255, 255, 0.45);
  color: var(--ink);
  border: 1px solid rgba(20, 32, 28, 0.12);
}

.btn.sm {
  padding: 0.55rem 0.9rem;
  font-size: 0.85rem;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.panel {
  width: min(100%, 28rem);
  margin: clamp(1.25rem, 5vh, 6vh) auto 0;
  padding: clamp(1.15rem, 3vw, 1.75rem);
  background: rgba(247, 251, 247, 0.78);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(20, 32, 28, 0.08);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel.center {
  text-align: center;
}

.lobby-layout {
  display: grid;
  gap: 1rem;
  max-width: 56rem;
  margin: 0 auto;
}

@media (min-width: 860px) {
  .lobby-layout {
    grid-template-columns: 1.2fr 0.9fr;
    align-items: start;
    margin-top: 4vh;
  }

  .lobby-layout .panel {
    margin-top: 0;
    width: 100%;
  }
}

.field {
  display: grid;
  gap: 0.35rem;
  margin: 0.9rem 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.field.inline {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.field input,
.field select,
#chat-form input {
  border: 1px solid rgba(20, 32, 28, 0.15);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  font: 500 1rem/1.2 var(--font-body);
  font-size: 16px; /* verhindert Auto-Zoom auf iOS */
  background: var(--white);
  color: var(--ink);
  width: 100%;
}

.field.inline input {
  width: 5.5rem;
}

.field select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2314201c' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  padding-right: 2.2rem;
}

.subhead {
  margin-top: 1.25rem;
  font-size: 1.05rem;
}

.custom-list {
  margin-top: 0.75rem;
  max-height: 12rem;
  overflow: auto;
}

.custom-list .tag {
  white-space: nowrap;
}

.code {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  border: 0;
  background: var(--lime);
  color: var(--ink);
  border-radius: 12px;
  padding: 0.2rem 0.55rem;
  cursor: pointer;
  vertical-align: baseline;
}

.player-list,
.scores {
  list-style: none;
  margin: 1rem 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.player-list li,
.scores li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.8rem;
  border-radius: 12px;
  background: rgba(20, 32, 28, 0.04);
  font-weight: 500;
}

.player-list .tag,
.scores .tag {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

.game-view {
  min-height: 0 !important;
  height: calc(100dvh - 3.5rem - var(--safe-top) - var(--safe-bottom));
  padding: 0 clamp(0.5rem, 1.5vw, 1rem) 0.35rem !important;
  overflow: hidden;
}

body:has(.game-view.active) {
  overflow: hidden;
}

.game-shell {
  display: grid;
  grid-template-columns: minmax(14rem, 17rem) minmax(0, 1fr);
  gap: 0.65rem;
  height: 100%;
  max-width: none;
  margin: 0;
  min-height: 0;
  align-items: start;
}

.game-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  align-self: stretch;
  overflow: hidden;
}

.roster {
  width: auto;
  height: auto;
  max-height: 100%;
  min-height: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  padding: 0;
  border-radius: 18px;
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.72), rgba(247, 251, 247, 0.55)),
    rgba(231, 239, 232, 0.85);
  border: 1px solid rgba(20, 32, 28, 0.08);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  overflow: hidden;
}

.roster > summary {
  list-style: none;
}

.roster > summary::-webkit-details-marker {
  display: none;
}

.roster-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  cursor: pointer;
  min-height: var(--tap);
  user-select: none;
  -webkit-user-select: none;
  flex: 0 0 auto;
}

.roster-summary-right {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.roster-summary-text .brand.sm {
  margin-bottom: 0.1rem;
}

.roster-summary-text .round-label {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-weight: 600;
}

.roster-toggle {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(20, 32, 28, 0.06);
  flex: 0 0 auto;
}

.roster-toggle::after {
  content: " ▾";
}

.roster[open] .roster-toggle::after {
  content: " ▴";
}

.roster-body {
  padding: 0 0.85rem 0.75rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 0 1 auto;
  overflow: hidden;
}

.roster-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}

.btn.danger {
  color: #8a2a1a;
  border-color: rgba(138, 42, 26, 0.25);
  background: rgba(255, 107, 74, 0.14);
}

.btn.danger:hover {
  background: rgba(255, 107, 74, 0.28);
  color: #5c160c;
}

.roster-title {
  margin: 0 0 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.roster .scores {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: rank;
  overflow: auto;
  min-height: 0;
  flex: 0 1 auto;
  max-height: min(50vh, 22rem);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.play-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 999px;
  flex: 0 0 auto;
  display: inline-block;
  background: rgba(20, 32, 28, 0.2);
}

.play-dot.done {
  background: var(--lime-deep);
  box-shadow: 0 0 0 2px rgba(143, 191, 31, 0.35);
}

.play-dot.wait {
  background: rgba(20, 32, 28, 0.22);
  animation: pulse-wait 1.4s ease-in-out infinite;
}

.play-dot.mod {
  background: var(--ink);
}

@keyframes pulse-wait {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 1;
  }
}

.play-status.play-done {
  color: var(--lime-deep);
  font-weight: 600;
}

.play-status.play-wait {
  color: var(--ink-soft);
}

.play-status.play-mod {
  color: var(--ink);
  font-weight: 600;
}

.roster .scores li.play-done {
  background: linear-gradient(120deg, rgba(184, 232, 70, 0.22), rgba(255, 255, 255, 0.55));
}

.roster .scores li.play-wait:not(.is-mod) {
  opacity: 0.92;
}

.roster .scores li {
  counter-increment: rank;
  display: grid;
  grid-template-columns: 2rem 1fr auto;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  padding: 0.55rem 0.55rem 0.55rem 0.35rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.roster .scores li::before {
  content: counter(rank);
  width: 1.7rem;
  height: 1.7rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--ink);
  font-size: 0.78rem;
  background: rgba(20, 32, 28, 0.06);
}

.roster .scores li:nth-child(1)::before {
  background: #e8c76a;
  color: #3a2a00;
}

.roster .scores li:nth-child(2)::before {
  background: #cfd6d1;
}

.roster .scores li:nth-child(3)::before {
  background: #d8b49a;
}

.roster .scores li.is-you {
  border-color: rgba(143, 191, 31, 0.65);
  box-shadow: inset 0 0 0 1px rgba(184, 232, 70, 0.35);
}

.roster .scores li.is-mod {
  background: linear-gradient(120deg, rgba(184, 232, 70, 0.28), rgba(255, 255, 255, 0.55));
}

.roster .scores li.is-host-row .avatar {
  box-shadow: 0 0 0 2px rgba(201, 162, 39, 0.55);
}

.player-main {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem;
  align-items: center;
  min-width: 0;
}

.avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.78rem;
  color: var(--white);
  background: var(--ink-soft);
}

.player-meta {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  min-width: 0;
}

.player-name-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  min-width: 0;
}

.player-name-row .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 650;
  font-size: 0.92rem;
}

.player-sub {
  font-size: 0.7rem;
  color: var(--ink-soft);
}

.player-points {
  text-align: right;
  font-size: 0.72rem;
  line-height: 1.2;
  color: var(--ink-soft);
}

.player-points strong {
  display: block;
  color: var(--ink);
  font-size: 1.05rem;
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}

.role-icon {
  display: inline-block;
  width: 0.95rem;
  height: 0.95rem;
  flex: 0 0 auto;
  background: var(--ink);
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
}

.role-icon.crown {
  background: #c9a227;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M3 7l4 5 5-8 5 8 4-5v12H3V7z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M3 7l4 5 5-8 5 8 4-5v12H3V7z'/%3E%3C/svg%3E");
}

.role-icon.gavel {
  background: var(--ink);
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M2 21h8v-2H2v2zm15.54-12.54l-2.12-2.12 1.41-1.41 2.12 2.12-1.41 1.41zM11.5 13.5L5 20H3v-2l6.5-6.5 2 2zm7.79-8.91l-1.41-1.41a1.5 1.5 0 0 0-2.12 0l-1.06 1.06 3.53 3.53 1.06-1.06a1.5 1.5 0 0 0 0-2.12z'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M2 21h8v-2H2v2zm15.54-12.54l-2.12-2.12 1.41-1.41 2.12 2.12-1.41 1.41zM11.5 13.5L5 20H3v-2l6.5-6.5 2 2zm7.79-8.91l-1.41-1.41a1.5 1.5 0 0 0-2.12 0l-1.06 1.06 3.53 3.53 1.06-1.06a1.5 1.5 0 0 0 0-2.12z'/%3E%3C/svg%3E");
}

.roster-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.7rem 0 0;
  font-size: 0.7rem;
  color: var(--ink-soft);
}

.roster-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.timer {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.1rem, 2.5vw, 1.45rem);
  min-width: 3.25rem;
  min-height: 2.4rem;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 0.3rem 0.7rem;
  border-radius: 14px;
  background: var(--ink);
  color: var(--lime);
  box-shadow: var(--shadow);
  font-variant-numeric: tabular-nums;
}

.prompt-wrap {
  max-width: none;
  width: 100%;
  margin: 0 0 0.55rem;
  text-align: center;
  flex: 0 0 auto;
  overflow: visible;
}

.card {
  border-radius: 16px;
  padding: 1.25rem 1.35rem;
  min-height: 8rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.75rem;
  box-shadow: var(--shadow);
  position: relative;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.card.prompt {
  background: var(--ink);
  color: var(--white);
  text-align: left;
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 2.6vw, 1.65rem);
  font-weight: 700;
  line-height: 1.4;
  min-height: auto;
  padding: 1.15rem 1.4rem 1.3rem;
  overflow: visible;
  animation: flip-in 0.5s ease both;
}

.card.prompt p,
#prompt-text {
  margin: 0;
  padding: 0 0 0.12em;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: inherit;
}

@keyframes flip-in {
  from {
    opacity: 0;
    transform: rotateX(-8deg) translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.card.answer {
  background: var(--white);
  color: var(--ink);
  border: 1px solid rgba(20, 32, 28, 0.08);
  cursor: pointer;
  text-align: left;
  font-size: 0.98rem;
  line-height: 1.35;
  min-width: 11rem;
  max-width: 14rem;
}

@media (hover: hover) and (pointer: fine) {
  .card.answer:hover {
    transform: translateY(-4px);
    box-shadow: 0 22px 40px rgba(20, 32, 28, 0.22);
  }

  .roster .scores li:hover {
    transform: translateX(2px);
  }
}

.card.answer:active {
  transform: scale(0.98);
}

.card.answer.selected {
  outline: 3px solid var(--lime);
}

.card.answer img {
  width: 100%;
  border-radius: 10px;
  max-height: 140px;
  object-fit: cover;
  background: var(--mist);
}

.card .actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.phase-hint {
  margin: 0.4rem 0 0;
  color: var(--ink-soft);
  font-weight: 500;
  font-size: 0.9rem;
}

.table {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: flex-start;
  gap: 0.55rem;
  max-width: none;
  width: 100%;
  margin: 0;
  min-height: 0;
  flex: 1 1 auto;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0.15rem 0;
}

.table .card.answer {
  min-width: min(100%, 11rem);
  max-width: 14rem;
  min-height: 8rem;
  flex: 0 1 12.5rem;
}

.hand-dock {
  position: relative;
  bottom: auto;
  flex: 0 1 auto;
  max-height: 52%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0.55rem 0 0.35rem;
  background: linear-gradient(to top, rgba(201, 217, 207, 0.95) 40%, rgba(201, 217, 207, 0));
  z-index: 5;
  overflow: hidden;
}

.hand-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  max-width: none;
  width: 100%;
  margin: 0 0 0.35rem;
  padding: 0 0.15rem;
  flex-wrap: wrap;
  flex: 0 0 auto;
}

.hand-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.hand-actions .btn {
  flex: 0 1 auto;
}

.hand-label {
  margin: 0;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  font-weight: 600;
}

.hand {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 11.5rem), 1fr));
  gap: 0.65rem;
  overflow: auto;
  padding: 0.25rem 0.15rem 0.5rem;
  max-width: none;
  width: 100%;
  margin: 0;
  min-height: 0;
  flex: 1 1 auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.hand .card.answer {
  min-width: 0;
  max-width: none;
  width: 100%;
  min-height: 8rem;
  padding: 1.15rem 1.25rem;
  font-size: 0.98rem;
  line-height: 1.35;
}

.chat {
  position: fixed;
  right: max(0.75rem, var(--safe-right));
  bottom: max(0.75rem, var(--safe-bottom));
  width: min(22rem, calc(100vw - 1.5rem - var(--safe-left) - var(--safe-right)));
  height: min(22rem, 45dvh);
  max-height: min(22rem, 45dvh);
  display: flex;
  flex-direction: column;
  background: rgba(247, 251, 247, 0.97);
  border: 1px solid rgba(20, 32, 28, 0.1);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 20;
  animation: rise 0.25s ease both;
}

.chat[hidden] {
  display: none;
}

.chat header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid rgba(20, 32, 28, 0.08);
}

.chat-log {
  flex: 1;
  overflow: auto;
  padding: 0.75rem;
  display: grid;
  gap: 0.45rem;
  font-size: 0.9rem;
}

.chat-log .msg strong {
  display: block;
  font-size: 0.75rem;
  color: var(--ink-soft);
}

#chat-form {
  display: flex;
  gap: 0.4rem;
  padding: 0.65rem;
  border-top: 1px solid rgba(20, 32, 28, 0.08);
}

#chat-form input {
  flex: 1;
  width: auto;
  border-radius: 999px;
  min-width: 0;
}

dialog {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: min(28rem, calc(100vw - 2rem - var(--safe-left) - var(--safe-right)));
  margin: auto;
  max-height: calc(100dvh - 2rem - var(--safe-top) - var(--safe-bottom));
}

dialog::backdrop {
  background: rgba(20, 32, 28, 0.45);
}

.dialog {
  margin: 0;
  max-height: inherit;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.dialog ol {
  padding-left: 1.2rem;
  color: var(--ink-soft);
  line-height: 1.5;
}

.error {
  color: var(--coral);
  font-weight: 600;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(1.25rem, calc(var(--safe-bottom) + 0.75rem));
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 2rem - var(--safe-left) - var(--safe-right));
  background: var(--ink);
  color: var(--white);
  padding: 0.75rem 1.1rem;
  border-radius: 999px;
  font-weight: 500;
  z-index: 40;
  animation: rise 0.25s ease both;
  text-align: center;
}

.winner-flash {
  outline: 3px solid var(--coral);
}

@media (min-width: 861px) {
  .roster-summary {
    pointer-events: none;
    border-bottom: 1px solid rgba(20, 32, 28, 0.08);
  }

  .roster-toggle {
    display: none;
  }

  .roster:not([open]) .roster-body {
    display: block;
  }
}

/* —— Mobile / Tablet —— */
@media (max-width: 860px) {
  .game-top {
    flex-direction: column;
  }

  .game-status {
    order: 0;
    width: 100%;
    margin-left: 0;
    display: flex;
    justify-content: flex-end;
    position: sticky;
    top: 0.35rem;
    z-index: 6;
  }

  .roster {
    width: 100%;
    order: 1;
  }

  .roster:not([open]) .roster-body {
    display: none;
  }

  .roster .scores {
    max-height: min(40vh, 16rem);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .hand {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .table .card.answer {
    min-width: min(100%, 10.5rem);
    max-width: 12.5rem;
    flex: 1 1 10rem;
  }

  .card {
    min-height: 7rem;
    padding: 1rem 1.05rem;
  }

  .chat {
    inset: auto 0 0 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: min(78dvh, 34rem);
    border-radius: 18px 18px 0 0;
    padding-bottom: var(--safe-bottom);
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .brand {
    font-size: clamp(2.6rem, 14vw, 4rem);
  }

  h1 {
    font-size: clamp(1.35rem, 6.5vw, 1.8rem);
    max-width: none;
  }

  .lede {
    max-width: none;
    font-size: 1rem;
  }

  .cta-row .btn {
    flex: 1 1 100%;
  }

  .roster .scores li {
    grid-template-columns: 1.7rem 1fr auto;
    gap: 0.4rem;
    padding: 0.45rem 0.4rem;
  }

  .avatar {
    width: 1.75rem;
    height: 1.75rem;
    font-size: 0.7rem;
  }

  .player-name-row .name {
    font-size: 0.85rem;
  }

  .player-sub {
    font-size: 0.65rem;
  }

  .player-points strong {
    font-size: 0.95rem;
  }

  .roster-legend {
    display: none;
  }

  .hand-actions {
    width: 100%;
  }

  .hand-actions .btn {
    flex: 1 1 calc(50% - 0.3rem);
    padding-left: 0.55rem;
    padding-right: 0.55rem;
    font-size: 0.8rem;
  }

  .hand-label {
    width: 100%;
  }

  .hand {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card.answer {
    font-size: 0.9rem;
    min-height: 6.5rem;
  }

  .card.answer img {
    max-height: 100px;
  }

  .phase-hint {
    font-size: 0.92rem;
  }

  .field.inline {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }

  .field.inline input {
    width: 100%;
  }

  .lobby-layout .panel {
    width: 100%;
  }
}

@media (max-width: 380px) {
  .hand {
    grid-template-columns: 1fr;
  }

  .ghost {
    letter-spacing: 0.04em;
    font-size: 0.7rem;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .hero {
    margin-top: 1rem;
  }

  .brand {
    font-size: clamp(2.2rem, 8vw, 3.2rem);
  }

  .roster .scores {
    max-height: 28vh;
  }

  .chat {
    max-height: 85dvh;
  }

  .hand-dock {
    position: static;
    background: none;
  }
}

@supports not (height: 100dvh) {
  html,
  body {
    min-height: 100vh;
  }

  .view {
    min-height: calc(100vh - 4rem);
  }

  .chat {
    max-height: min(28rem, 70vh);
  }
}
