/* ── Design tokens ── */
:root {
  --bg-deep: #0e0e10;
  --bg-base: #141416;
  --bg-mid: #1c1c20;
  --bg-surface: #242428;
  --bg-elevated: #2e2e34;
  --bg-hover: #36363d;

  --orange: #e8620a;
  --orange-light: #ff7a1a;
  --orange-dim: #b84d08;
  --orange-glow: rgba(232, 98, 10, 0.28);
  --orange-subtle: rgba(232, 98, 10, 0.12);

  --text-primary: #ececee;
  --text-secondary: #a0a0aa;
  --text-muted: #6b6b76;

  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-orange: 0 4px 14px var(--orange-glow);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;

  --card-w: 56px;
  --card-h: 82px;
  --card-overlap: -13px;
  --card-font: 1rem;
  --shell-w: 100%;
  --game-w: 100%;

  --bg-image: url('/content/back.png');
  --logo-w: 260px;
  --logo-max-h: 168px;
  --desk-max-w: 300px;
  --desk-aspect: 1.9116;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  font-family: var(--font);
  background: #1a1a1c;
  color: var(--text-primary);
}

#app {
  width: 100vw;
  height: var(--app-h, 100dvh);
  min-height: -webkit-fill-available;
  position: fixed;
  inset: 0;
  overflow: hidden;
  background-color: #1a1a1c;
  background-image: var(--bg-image);
  background-size: contain;
  background-position: center center;
  background-repeat: no-repeat;
}

.screen {
  display: none;
  width: 100%;
  height: 100%;
  flex-direction: column;
  overflow: hidden;
  background: transparent;
  position: relative;
}

.screen.active {
  display: flex;
}

.hidden {
  display: none !important;
}

/* ── Welcome / logo ── */
.lobby-header {
  flex-shrink: 0;
  padding: calc(env(safe-area-inset-top) + 0.75rem) 1rem 0.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
}

.logo-image {
  width: var(--logo-w);
  max-width: min(var(--logo-w), 88vw);
  height: auto;
  max-height: var(--logo-max-h);
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.45));
}

#welcome-screen {
  align-items: center;
  justify-content: flex-start;
  padding-bottom: 1rem;
  gap: 0.85rem;
}

#welcome-screen .balance-display,
#welcome-screen .nickname-block,
#welcome-screen .welcome-actions {
  background: rgba(20, 20, 22, 0.78);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  backdrop-filter: blur(8px);
}

#welcome-screen .balance-display {
  padding: 0.65rem 1.25rem;
  margin: 0;
}

#welcome-screen .nickname-block {
  padding: 0.85rem 1rem;
  max-width: 320px;
  width: calc(100% - 2rem);
}

#welcome-screen .welcome-actions {
  padding: 0.85rem 1rem 1rem;
  max-width: 320px;
  width: calc(100% - 2rem);
}

.hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.4;
}

.screen-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: calc(env(safe-area-inset-top) + 0.6rem) 1rem 0.75rem;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: rgba(20, 20, 22, 0.88);
  backdrop-filter: blur(10px);
}

.screen-header h2 {
  flex: 1;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.header-balance {
  font-weight: 600;
  color: var(--orange-light);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.header-nick {
  font-size: 0.75rem;
  color: var(--text-secondary);
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Balance & inputs ── */
.balance-display {
  text-align: center;
  margin: 0.5rem 0;
}

.balance-label {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 500;
}

.balance-amount {
  font-size: 2rem;
  font-weight: 700;
  color: var(--orange-light);
  font-variant-numeric: tabular-nums;
}

.nickname-block {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nickname-label {
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
}

.nickname-input {
  width: 100%;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: var(--font);
  text-align: center;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.nickname-input:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-subtle);
}

.nickname-input::placeholder {
  color: var(--text-muted);
}

/* ── Welcome actions ── */
.welcome-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.65rem;
  width: 100%;
  max-width: 320px;
}

/* ── Rooms ── */
#rooms-screen,
#create-screen {
  background: transparent;
}

.rooms-toolbar {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  flex-shrink: 0;
}

.rooms-toolbar .btn-primary {
  flex: 1;
}

.rooms-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.room-card {
  background: rgba(36, 36, 40, 0.9);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(6px);
  transition: border-color 0.2s;
}

.room-card:active {
  border-color: var(--border-strong);
}

.room-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.room-card-id {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.2em;
  color: var(--text-primary);
}

.room-card-header > span:last-child,
.room-card-bet {
  color: var(--orange-light);
  font-weight: 600;
  font-size: 0.95rem;
}

.room-card-meta {
  font-size: 0.78rem;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.room-card-meta span,
.room-tag {
  background: var(--bg-elevated);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 0.76rem;
}

.room-card-occupancy {
  margin-top: -0.15rem;
}

.room-card-occupancy span {
  background: transparent;
  padding: 0;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.room-card-players {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.room-card .btn {
  align-self: flex-end;
  margin-top: 0.25rem;
}

.rooms-empty {
  padding: 2rem;
}

/* ── Create form ── */
.create-form {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.create-form fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  background: rgba(36, 36, 40, 0.88);
  backdrop-filter: blur(6px);
}

.create-form legend {
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 500;
}

.option-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.5rem;
}

.option-row label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.option-row label:has(input:checked) {
  border-color: var(--orange);
  color: var(--orange-light);
  background: var(--orange-subtle);
}

.option-row input[type="radio"] {
  accent-color: var(--orange);
  width: 14px;
  height: 14px;
}

/* ── Waiting room (стол) ── */
#waiting-screen {
  align-items: stretch;
  overflow: hidden;
}

#waiting-screen .screen-header {
  flex-shrink: 0;
}

.waiting-body {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.room-settings-info {
  flex-shrink: 0;
  width: calc(100% - 1rem);
  max-width: var(--game-w, 100%);
  margin: 0.5rem auto 0;
  padding: 0.75rem 1rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.65;
  background: rgba(36, 36, 40, 0.88);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  backdrop-filter: blur(6px);
}

.room-settings-info b {
  color: var(--orange-light);
  font-weight: 600;
}

.waiting-table {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.waiting-table .opponents-row {
  flex-shrink: 0;
  min-height: auto;
  padding: 0.35rem 0.5rem 0.15rem;
}

.waiting-center {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.75rem;
}

.waiting-self-seat {
  display: flex;
  justify-content: center;
  flex-shrink: 0;
  padding: 0.15rem 0.5rem 0.35rem;
}

.waiting-footer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  padding: 0.65rem 1rem calc(env(safe-area-inset-bottom) + 0.5rem);
  background: rgba(20, 20, 22, 0.92);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.waiting-footer #btn-ready {
  width: 100%;
  max-width: 360px;
  margin: 0;
}

.waiting-footer #waiting-status {
  margin: 0;
  padding: 0;
}

.seat-slot {
  min-width: 88px;
  position: relative;
}

.opponent-slot.seat-slot:not(.seat-empty) {
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border);
}

.seat-slot.seat-self {
  min-width: 120px;
}

.seat-slot.ready {
  border-color: rgba(232, 98, 10, 0.45);
  box-shadow: 0 0 0 1px rgba(232, 98, 10, 0.2);
}

.seat-slot.ready::after {
  content: '✓';
  position: absolute;
  top: 0.35rem;
  right: 0.4rem;
  color: var(--orange);
  font-weight: 700;
  font-size: 0.75rem;
}

.seat-slot.seat-empty {
  opacity: 0.55;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.65rem;
  background: transparent;
}

.seat-empty-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

.seat-self .seat-nick {
  font-weight: 600;
  color: var(--orange-light);
  font-size: 0.75rem;
}

.table-hint {
  font-size: 0.8rem;
  color: var(--text-primary);
  text-align: center;
  padding: 0.75rem 1rem;
  pointer-events: none;
  line-height: 1.45;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.75);
  max-width: 72%;
  position: relative;
  z-index: 1;
}

.player-name-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  flex: 1;
  min-width: 0;
}

.player-name-block .opponent-name,
.player-name-block .player-nick {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

/* ── Animated mic indicator ── */
.mic-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  height: 28px;
  justify-content: flex-end;
  color: var(--text-muted);
  opacity: 0.35;
  transition: opacity 0.2s, color 0.2s;
}

.mic-indicator.idle .mic-bars i {
  animation: none;
  transform: scaleY(0.25);
}

.mic-indicator.speaking {
  opacity: 1;
  color: var(--orange-light);
}

.mic-indicator.speaking .mic-svg {
  filter: drop-shadow(0 0 6px var(--orange-glow));
  animation: micPulse 0.55s ease-in-out infinite alternate;
}

.mic-svg {
  width: 16px;
  height: 16px;
  display: block;
}

.mic-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 10px;
}

.mic-bars i {
  display: block;
  width: 3px;
  height: 10px;
  background: currentColor;
  border-radius: 2px;
  transform: scaleY(0.25);
  transform-origin: bottom;
}

.mic-indicator.speaking .mic-bars i:nth-child(1) {
  animation: micBar 0.45s ease-in-out infinite alternate;
}

.mic-indicator.speaking .mic-bars i:nth-child(2) {
  animation: micBar 0.38s ease-in-out 0.08s infinite alternate;
}

.mic-indicator.speaking .mic-bars i:nth-child(3) {
  animation: micBar 0.52s ease-in-out 0.04s infinite alternate;
}

@keyframes micBar {
  0% { transform: scaleY(0.3); }
  100% { transform: scaleY(1); }
}

@keyframes micPulse {
  0% { transform: scale(1); }
  100% { transform: scale(1.12); }
}

#btn-ready.is-ready {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}

.seat-slot.disconnected {
  opacity: 0.45;
}

.waiting-voice-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem 0.65rem;
  margin: 0 auto;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  max-width: var(--game-w, 340px);
  width: calc(100% - 2rem);
}

/* ── Buttons (flat + shadow) ── */
.btn {
  border: none;
  border-radius: var(--radius-md);
  padding: 0.75rem 1.2rem;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s, opacity 0.15s;
  letter-spacing: 0.02em;
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none !important;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: none !important;
}

.btn-primary {
  background: var(--orange);
  color: #fff;
  box-shadow: var(--shadow-orange);
}

.btn-primary:not(:disabled):hover {
  background: var(--orange-light);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.btn-secondary:not(:disabled):hover {
  background: var(--bg-hover);
}

.btn-danger {
  background: #8b2942;
  color: #fff;
  box-shadow: 0 4px 14px rgba(139, 41, 66, 0.35);
}

.btn-success {
  background: var(--bg-elevated);
  color: var(--orange-light);
  border: 1px solid var(--orange);
  box-shadow: var(--shadow-sm);
}

.btn-large {
  padding: 1rem 1.5rem;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}

.btn-small {
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.btn-small:not(:disabled):hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-voice {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.btn-voice.muted {
  background: #3d2028;
  color: #e07070;
  border-color: rgba(224, 112, 112, 0.3);
}

/* ── Game screen phases ── */
#game-screen.phase-waiting .action-bar,
#game-screen.phase-waiting .turn-indicator {
  display: none !important;
}

#game-screen.phase-waiting #table-hint {
  display: block;
}

#game-screen.phase-playing #table-hint {
  display: none !important;
}

#game-screen .self-seat-slot {
  display: none !important;
}

#game-screen.phase-waiting .opponent-slot.ready .opponent-avatar {
  border-color: rgba(232, 98, 10, 0.55);
  box-shadow: 0 0 8px rgba(232, 98, 10, 0.35);
}

.game-lobby-bar {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  padding: 0.65rem 1rem calc(env(safe-area-inset-bottom) + 0.5rem);
  background: rgba(20, 20, 22, 0.92);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(8px);
  flex-shrink: 0;
}

#game-screen.phase-waiting .game-lobby-bar {
  display: flex;
}

#game-screen.phase-waiting .game-lobby-bar #btn-ready {
  width: 100%;
  max-width: 360px;
}

#game-screen.phase-waiting .game-lobby-bar #waiting-status {
  margin: 0;
  padding: 0;
}

.room-settings-info--game {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 0.68rem;
  line-height: 1.35;
  padding: 0.25rem 0.35rem;
  color: var(--text-secondary);
  background: rgba(20, 20, 22, 0.72);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(6px);
}

.room-settings-info--game b {
  color: var(--orange-light);
  font-weight: 600;
}

.room-id-tag {
  color: var(--text-primary);
  font-weight: 600;
}

#game-screen .table-hint {
  position: relative;
  z-index: 2;
  margin: 0;
  padding: 0.5rem 0.75rem;
  text-align: center;
  font-size: 0.88rem;
  color: var(--text-primary);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.65);
}

/* ── Game screen ── */
#game-screen {
  background: transparent;
}

.game-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.35rem;
  padding: calc(env(safe-area-inset-top) + 0.4rem) 0.75rem 0.5rem;
  flex-shrink: 0;
  background: rgba(20, 20, 22, 0.82);
  backdrop-filter: blur(8px);
}

.game-top-bar .room-settings-info--game {
  flex: 1;
  min-width: 0;
}

.btn-leave-room {
  flex-shrink: 0;
  font-size: 0.78rem;
  padding: 0.4rem 0.65rem;
  white-space: nowrap;
}


.waiting-footer .btn-leave-room {
  width: 100%;
  max-width: 360px;
  font-size: 0.85rem;
  padding: 0.55rem 1rem;
}

.game-pot {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--orange-light);
  padding: 0.35rem 0.75rem;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.voice-bar {
  display: flex;
  gap: 0.35rem;
  background: var(--bg-surface);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.game-table {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0 0.5rem env(safe-area-inset-bottom);
}

.opponents-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.35rem;
  flex-shrink: 0;
}

.opponent-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem 0.25rem;
  background: transparent;
  border: none;
  box-shadow: none;
  min-width: 0;
}

.opponent-avatar {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  width: 56px;
  min-height: 56px;
  padding: 0.35rem 0.25rem 0.25rem;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.28);
  box-shadow: var(--shadow-sm);
}

.opponent-slot.active-turn .opponent-avatar {
  border-color: #e74c3c;
  box-shadow: 0 0 10px rgba(231, 76, 60, 0.45);
}

.opponent-slot.is-defender .opponent-avatar {
  border-color: #27ae60;
  box-shadow: 0 0 10px rgba(39, 174, 96, 0.4);
}

.opponent-card-count {
  position: absolute;
  top: 2px;
  right: 3px;
  font-size: 0.58rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.opponent-avatar .mic-indicator {
  position: absolute;
  top: 2px;
  left: 3px;
  width: 14px;
  height: 14px;
  font-size: 0.55rem;
}

.opponent-slot .player-name-block {
  width: auto;
}

.opponent-name {
  font-size: 0.72rem;
  color: var(--text-secondary);
  max-width: 96px;
  font-weight: 500;
  text-align: center;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

.opponent-hand.fan-hand,
.fan-hand {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  position: relative;
  min-height: calc(var(--card-h) * 0.48);
  width: auto;
  max-width: 100%;
  padding: 0;
  overflow: visible;
}

.opponent-hand.fan-hand {
  min-height: calc(var(--card-h) * 0.42);
  align-items: flex-start;
}

.fan-hand .card {
  transform-origin: bottom center;
  margin-left: var(--card-overlap);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.fan-hand .card:first-child {
  margin-left: 0;
}

.fan-hand--top .card {
  transform-origin: top center;
}

.zone-center {
  flex: 1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.35rem;
  min-height: 36vh;
  padding: 0.35rem 0.25rem;
  width: 100%;
  position: relative;
}

.table-drop-zone {
  position: relative;
  justify-self: center;
  width: 100%;
  max-width: var(--desk-max-w);
  aspect-ratio: var(--desk-aspect) / 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
  transition: filter 0.2s;
}

.table-desk-bg {
  position: absolute;
  inset: -4% -2%;
  background: url('/content/desk.png') center center / contain no-repeat;
  pointer-events: none;
  z-index: 0;
  filter: drop-shadow(0 10px 28px rgba(0, 0, 0, 0.35));
  transition: filter 0.2s, transform 0.2s;
}

.table-drop-zone.drag-over .table-desk-bg {
  filter: drop-shadow(0 10px 28px rgba(0, 0, 0, 0.35))
    brightness(1.06)
    drop-shadow(0 0 18px rgba(232, 98, 10, 0.35));
}

.battlefield,
.table-hint {
  position: relative;
  z-index: 1;
}

.table-drop-zone--waiting {
  width: 100%;
  max-width: var(--desk-max-w);
  max-height: 100%;
}

.zone-player {
  flex-shrink: 0;
  padding-bottom: 0.35rem;
}

.game-bottom-dock {
  flex-shrink: 0;
  position: relative;
}

.hand {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  min-height: calc(var(--card-h) * 0.58);
}

.player-hand {
  min-height: calc(var(--card-h) * 0.62);
  padding: 0.2rem 0.15rem 0.1rem;
}

/* ── Cards ── */
.card {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 7px;
  background: #f4f4f6;
  border: 1px solid #d8d8dc;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--card-font);
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
  touch-action: none;
  box-shadow: var(--shadow-md);
  transition: box-shadow 0.15s;
}

.player-hand .card {
  margin-left: var(--card-overlap);
}

.player-hand .card:first-child {
  margin-left: 0;
}

.card.selected {
  box-shadow: 0 10px 24px var(--orange-glow), 0 0 0 2px var(--orange);
  z-index: 20;
}

.card-holding {
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.55), 0 0 0 2px var(--orange) !important;
  z-index: 30 !important;
}

.drag-ghost {
  position: fixed;
  z-index: 600;
  pointer-events: none;
  opacity: 0.96;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.55), 0 0 0 2px var(--orange-light);
  transition: none;
}

.card.red { color: #c0392b; }
.card.black { color: #1a1a1e; }

.card-rank { line-height: 1; }
.card-suit { font-size: 1.05rem; line-height: 1; }

.card-back {
  background: linear-gradient(145deg, #2e2e36, #1e1e24);
  border: 1px solid var(--border-strong);
}

.card.trump-indicator {
  box-shadow: 0 0 0 2px var(--orange), var(--shadow-md);
}

/* ── Deck ── */
.deck-area {
  flex-shrink: 0;
  align-self: center;
}

.deck-stack {
  position: relative;
  width: var(--card-h);
  height: calc(var(--card-h) + var(--card-w) * 0.55);
}

.deck-pile {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 2;
  width: var(--card-w);
  height: var(--card-h);
  margin-left: calc(var(--card-w) / -2);
  border-radius: 7px;
  background: linear-gradient(145deg, #2e2e36, #222228);
  border: 1px solid var(--border-strong);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  box-shadow: var(--shadow-md);
}

.deck-label {
  position: absolute;
  top: -1rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 500;
}

.deck-count {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.trump-slot {
  position: absolute;
  z-index: 1;
  top: calc(var(--card-h) - var(--card-w) * 0.38);
  left: 50%;
  transform: translateX(-50%) rotate(90deg);
  transform-origin: center center;
}

.trump-slot:empty {
  display: none;
}

.trump-slot .card {
  box-shadow: 0 0 0 2px var(--orange), var(--shadow-md);
}

.discard-pile {
  position: absolute;
  right: max(0.25rem, env(safe-area-inset-right));
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 7px;
  background: var(--bg-surface);
  border: 1px dashed var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  flex-shrink: 0;
  margin: 0;
}

/* ── Battlefield ── */
.battlefield {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
  align-items: center;
  width: 62%;
  max-width: 100%;
  min-height: 50%;
  padding: 0.2rem;
}

.battlefield--transferable {
  flex-direction: column;
  justify-content: stretch;
  align-items: stretch;
  width: 72%;
  min-height: 62%;
  height: 100%;
  padding: 0.15rem 0.45rem;
  gap: 0;
}

.table-half {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  min-height: 0;
}

.table-half--center {
  flex: 0 0 auto;
  justify-content: center;
  padding: 0.15rem 0;
}

.table-half--opponent {
  flex: 1;
  justify-content: flex-end;
  padding-top: 12%;
  padding-bottom: 0.15rem;
}

.table-half--self {
  flex: 1;
  justify-content: flex-start;
  padding-top: 0.2rem;
  padding-bottom: 16%;
}

.attack-grid {
  display: grid;
  grid-template-columns: repeat(2, var(--card-w));
  grid-auto-rows: calc(var(--card-h) + 14px);
  gap: 0.35rem 0.45rem;
  justify-content: center;
  align-content: start;
  width: calc(var(--card-w) * 2 + 0.45rem);
  max-width: 100%;
  margin: 0 auto;
}

.attack-grid-cell {
  position: relative;
  width: var(--card-w);
  height: calc(var(--card-h) + 14px);
  overflow: visible;
  contain: layout style;
}

.attack-grid-cell .battle-pair--grid {
  position: absolute;
  inset: 0;
  width: var(--card-w);
  height: calc(var(--card-h) + 14px);
}

.attack-grid-cell .battle-pair--grid .card.attack,
.attack-grid-cell .battle-pair--grid .card.table-card {
  position: absolute;
  bottom: 0;
  left: 0;
  z-index: 1;
  width: var(--card-w);
  height: var(--card-h);
  transition: none;
  animation: none;
}

.attack-grid-cell .battle-pair--grid .card.defense {
  position: absolute;
  bottom: 4px;
  left: 10px;
  z-index: 2;
  width: var(--card-w);
  height: var(--card-h);
  transform: rotate(18deg);
  transition: none;
  animation: none;
}

.attack-grid > .transfer-slot.attack-grid-slot {
  position: relative;
  left: auto;
  right: auto;
  bottom: auto;
  top: auto;
  width: var(--card-w);
  height: calc(var(--card-h) + 14px);
  margin: 0;
  box-sizing: border-box;
  border-radius: 7px;
  border: 2px dashed rgba(232, 98, 10, 0.65);
  background: rgba(232, 98, 10, 0.1);
  cursor: pointer;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.defended-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
  margin-top: 0.25rem;
}

.attack-grid.shift-in {
  animation: attackGridShiftIn 0.42s cubic-bezier(0.34, 1.2, 0.64, 1);
}

@keyframes attackGridShiftIn {
  0% {
    opacity: 0.75;
    transform: translateY(var(--shift-y, 24px));
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.battle-pair {
  position: relative;
  width: calc(var(--card-w) + 6px);
  height: calc(var(--card-h) + 14px);
  flex-shrink: 0;
}

.battle-pair .card.attack {
  position: absolute;
  bottom: 0;
  left: 0;
  z-index: 1;
  transition: transform 0.35s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.battle-pair .card.defense {
  position: absolute;
  bottom: 4px;
  left: 10px;
  z-index: 2;
  transform: rotate(18deg);
  transition: transform 0.4s cubic-bezier(0.34, 1.3, 0.64, 1), opacity 0.3s;
}

.battle-pair .card.defense.animate-in {
  animation: cardDefendLand 0.45s cubic-bezier(0.34, 1.4, 0.64, 1) forwards;
}

.battle-pair .card.attack.animate-in-side {
  animation: cardThrowLand 0.4s cubic-bezier(0.34, 1.2, 0.64, 1) forwards;
}

.battle-pair .card.attack.animate-in-deck {
  animation: cardFromDeck 0.5s cubic-bezier(0.34, 1.2, 0.64, 1) forwards;
}

@keyframes cardDefendLand {
  0% {
    opacity: 0;
    transform: translate(-30px, -60px) rotate(-30deg) scale(0.7);
  }
  100% {
    opacity: 1;
    transform: rotate(18deg);
  }
}

@keyframes cardThrowLand {
  0% {
    opacity: 0;
    transform: translateX(40px) translateY(-20px) scale(0.8);
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

@keyframes cardFromDeck {
  0% {
    opacity: 0;
    transform: translate(-80px, -40px) scale(0.6);
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

.battle-pair.target-highlight .card.attack {
  box-shadow: 0 0 0 2px var(--orange), 0 4px 16px var(--orange-glow);
}

.battle-pair.has-transfer-slot {
  width: calc(var(--card-w) * 2 + 12px);
}

.transfer-slot:not(.attack-grid-slot) {
  position: absolute;
  bottom: 0;
  left: calc(var(--card-w) + 6px);
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 7px;
  border: 2px dashed rgba(232, 98, 10, 0.65);
  background: rgba(232, 98, 10, 0.1);
  cursor: pointer;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s, transform 0.15s;
  box-sizing: border-box;
}

.transfer-slot-label {
  font-size: 0.58rem;
  font-weight: 700;
  color: var(--orange);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.1;
  text-align: center;
  pointer-events: none;
  opacity: 0.85;
}

.transfer-slot.active {
  border-style: solid;
  border-color: var(--orange);
  background: rgba(232, 98, 10, 0.22);
  box-shadow: 0 0 0 2px rgba(232, 98, 10, 0.3), 0 4px 14px var(--orange-glow);
}

.transfer-slot.active .transfer-slot-label {
  opacity: 1;
}

.transfer-slot.drag-over {
  border-color: var(--orange);
  background: rgba(232, 98, 10, 0.32);
  transform: scale(1.03);
}

/* ── Anim layer ── */
.anim-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 500;
}

.flying-card {
  position: fixed;
  z-index: 501;
  pointer-events: none;
  transition: left 0.42s cubic-bezier(0.25, 0.8, 0.3, 1),
              top 0.42s cubic-bezier(0.25, 0.8, 0.3, 1),
              transform 0.42s cubic-bezier(0.25, 0.8, 0.3, 1);
}

.flying-card.defend-fly {
  transition-duration: 0.45s;
}

/* ── Turn & actions ── */
.turn-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  text-align: center;
  font-size: 0.84rem;
  padding: 0.4rem 0.75rem;
  min-height: 1.5rem;
  flex-shrink: 0;
  color: var(--text-secondary);
  font-weight: 500;
}

.turn-label {
  color: var(--text-muted);
}

.turn-value {
  font-weight: 600;
}

.turn-indicator.yours .turn-value {
  color: var(--orange-light);
}

.turn-indicator.opponent .turn-value {
  color: var(--text-primary);
}

.action-bar {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom) + var(--card-h) + 28px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.45rem;
  z-index: 50;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 95%;
}

.action-bar .btn {
  padding: 0.55rem 1rem;
  font-size: 0.88rem;
}

/* ── Overlay & toast ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 8, 10, 0.82);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.overlay-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 2rem 1.5rem;
  text-align: center;
  max-width: 320px;
  width: 90%;
  box-shadow: var(--shadow-md);
}

.overlay-content h2 {
  margin-bottom: 0.75rem;
  font-size: 1.35rem;
  font-weight: 700;
}

.result-payout {
  margin-bottom: 1.25rem;
  color: var(--orange-light);
  font-size: 1.1rem;
  font-weight: 600;
}

.toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom) + 1rem);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 0.7rem 1.2rem;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  z-index: 300;
  max-width: 90%;
  text-align: center;
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-md);
}

@media (max-width: 480px) {
  :root {
    --card-w: 62px;
    --card-h: 90px;
    --card-overlap: -13px;
    --card-font: 1rem;
    --opp-card-w: 28px;
    --opp-card-h: 40px;
    --logo-w: min(200px, 72vw);
    --logo-max-h: 20vmin;
    --desk-max-w: 100vw;
    --desk-aspect: 1.9116;
  }

  #app {
    background-size: auto 100%;
    background-position: center center;
  }

  #game-screen .game-table {
    position: relative;
    flex: 1;
    min-height: 0;
    padding: 0;
    overflow: visible;
  }

  #game-screen .opponents-row {
    position: absolute;
    top: calc(env(safe-area-inset-top) + 2.35rem);
    left: 0;
    right: 0;
    z-index: 6;
    justify-content: space-evenly;
    flex-wrap: nowrap;
    width: 100%;
    padding: 0.15rem 0.25rem 0.05rem;
    gap: 0.15rem;
  }

  #game-screen .zone-center {
    position: absolute;
    top: calc(env(safe-area-inset-top) + 6.5rem);
    bottom: calc(env(safe-area-inset-bottom) + var(--card-h) + 1.25rem);
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 0;
    margin: 0;
    padding: 0;
    width: 100%;
    overflow: visible;
    container-type: size;
  }

  #game-screen .game-bottom-dock {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 20;
    flex-shrink: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .room-settings-info--game {
    font-size: 0.55rem;
    padding: 0.18rem 0.28rem;
    max-width: 38vw;
  }

  #game-screen .game-top-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 30;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.35rem;
    background: transparent;
    backdrop-filter: none;
    padding: calc(env(safe-area-inset-top) + 0.15rem) 0.45rem 0.25rem;
    pointer-events: none;
  }

  #game-screen .game-top-bar > * {
    pointer-events: auto;
  }

  #game-screen .voice-bar {
    padding: 0.15rem;
    gap: 0.2rem;
    background: rgba(20, 20, 22, 0.72);
    backdrop-filter: blur(6px);
  }

  #game-screen .game-top-bar .btn-leave-room {
    font-size: 0.68rem;
    padding: 0.32rem 0.45rem;
    background: rgba(20, 20, 22, 0.72);
    backdrop-filter: blur(6px);
  }

  #game-screen .opponent-slot {
    flex: 1;
    max-width: 33%;
    padding: 0;
    gap: 0.12rem;
  }

  #game-screen .opponent-avatar {
    width: 56px;
    min-height: 56px;
    padding: 0.35rem 0.22rem 0.22rem;
  }

  #game-screen .opponent-name {
    font-size: 0.62rem;
    max-width: 56px;
  }

  #game-screen .opponent-hand.fan-hand .card {
    width: var(--opp-card-w);
    height: var(--opp-card-h);
  }

  #game-screen .opponent-hand.fan-hand {
    min-height: calc(var(--opp-card-h) + 2px);
  }

  #game-screen .deck-area {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 4;
  }

  #game-screen .deck-stack {
    width: calc(var(--card-w) + var(--card-h) * 0.5);
    height: var(--card-h);
  }

  #game-screen .deck-pile {
    left: 0;
    margin-left: 0;
    z-index: 2;
  }

  #game-screen .trump-slot {
    top: 50%;
    left: var(--card-w);
    z-index: 1;
    transform: translate(-50%, -50%) rotate(90deg);
    transform-origin: center center;
  }

  #game-screen .deck-label {
    display: none;
  }

  #game-screen .deck-count {
    position: absolute;
    top: -1.35rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.65);
  }

  #game-screen .deck-pile .deck-count {
    position: absolute;
    top: -1.35rem;
    left: 50%;
    transform: translateX(-50%);
  }

  #game-screen .discard-pile {
    position: absolute;
    right: max(0.2rem, env(safe-area-inset-right));
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    width: var(--card-w);
    height: var(--card-h);
    font-size: 0.82rem;
    opacity: 1;
    margin: 0;
  }

  #game-screen .table-drop-zone {
    position: relative;
    width: 100%;
    max-height: 100%;
    aspect-ratio: 692 / 1323;
    height: auto;
    flex-shrink: 0;
    overflow: hidden;
    min-height: 160px;
  }

  @supports (width: 1cqw) {
    #game-screen .table-drop-zone {
      width: min(100cqw, calc(100cqh * 692 / 1323), calc(100vw - var(--card-w) * 2 - 1.5rem));
      max-height: 100cqh;
    }
  }

  @supports not (width: 1cqw) {
    #game-screen .table-drop-zone {
      width: calc(100% - var(--card-w) * 2 - 1rem);
      max-width: 100%;
    }
  }

  #game-screen .table-desk-bg {
    position: absolute;
    left: 50%;
    top: 50%;
    width: calc(100% * 1323 / 692);
    aspect-ratio: 1323 / 692;
    height: auto;
    transform: translate(-50%, -50%) rotate(90deg);
    transform-origin: center center;
    background: url('/content/desk.png') center center / 100% 100% no-repeat;
    pointer-events: none;
    z-index: 0;
    filter: none;
    border-radius: 0;
  }

  #game-screen .table-drop-zone.drag-over .table-desk-bg {
    filter: brightness(1.06) drop-shadow(0 0 18px rgba(232, 98, 10, 0.35));
  }

  #game-screen .battlefield {
    padding: 0 2.8rem;
  }

  #game-screen .battlefield--transferable {
    width: 78%;
    min-height: 58%;
    padding: 0.1rem 0.35rem;
  }

  #game-screen .table-half--opponent {
    padding-top: 14%;
  }

  #game-screen .table-half--self {
    padding-bottom: 18%;
  }

  #game-screen .attack-grid {
    grid-template-columns: repeat(2, var(--card-w));
    grid-auto-rows: calc(var(--card-h) + 14px);
    gap: 0.28rem 0.35rem;
  }

  #game-screen .zone-player {
    position: relative;
    z-index: 12;
    margin-bottom: 0;
    padding-bottom: 0.15rem;
  }

  #game-screen .player-hand {
    min-height: calc(var(--card-h) + 6px);
    padding: 0.15rem 0.1rem 0;
  }

  #game-screen .turn-indicator {
    display: none !important;
  }

  #game-screen .action-bar {
    position: fixed;
    bottom: calc(env(safe-area-inset-bottom) + var(--card-h) + 42px);
    left: 50%;
    transform: translateX(-50%);
    flex-shrink: 0;
    gap: 0.35rem;
    max-width: 95%;
    margin: 0;
    z-index: 50;
  }

  #game-screen .action-bar .btn {
    min-width: auto;
    height: auto;
    padding: 0.42rem 0.7rem;
    font-size: 0.78rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
  }

  .table-drop-zone {
    width: 100%;
    max-width: 100vw;
  }

  .btn-voice {
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
  }

  .turn-indicator {
    font-size: 0.7rem;
    padding: 0.15rem 0.35rem;
    min-height: 1.1rem;
  }

  .waiting-footer {
    padding: 0.4rem 0.65rem calc(env(safe-area-inset-bottom) + 0.3rem);
    gap: 0.28rem;
  }

  .waiting-footer #btn-ready {
    padding: 0.6rem 0.85rem;
    font-size: 0.88rem;
  }

  .waiting-footer .btn-leave-room {
    padding: 0.48rem 0.75rem;
    font-size: 0.78rem;
  }

  .room-settings-info {
    padding: 0.4rem 0.6rem;
    font-size: 0.72rem;
    margin-top: 0.3rem;
  }

  .screen-header {
    padding: calc(env(safe-area-inset-top) + 0.3rem) 0.55rem 0.4rem;
  }

  .screen-header h2 {
    font-size: 0.85rem;
  }

  .waiting-voice-bar {
    padding: 0.35rem 0.65rem 0.45rem;
    gap: 0.35rem;
  }

  .logo-image {
    max-width: min(200px, 72vw);
  }

  .battlefield {
    width: 72%;
  }

  #welcome-screen .balance-display,
  #welcome-screen .nickname-block,
  #welcome-screen .welcome-actions {
    padding: 0.55rem 0.75rem;
  }

  .lobby-header {
    padding-top: calc(env(safe-area-inset-top) + 0.45rem);
  }
}

@media (max-width: 360px) {
  :root {
    --card-w: 54px;
    --card-h: 78px;
    --card-overlap: -11px;
    --opp-card-w: 26px;
    --opp-card-h: 38px;
    --logo-w: min(180px, 76vw);
    --logo-max-h: 18vmin;
    --desk-aspect: 1.9116;
  }

  #game-screen .game-top-bar .btn-leave-room {
    font-size: 0.62rem;
    padding: 0.28rem 0.38rem;
  }
}

@media (min-width: 769px) {
  :root {
    --shell-w: 400px;
    --game-w: 720px;
    --card-w: 80px;
    --card-h: 114px;
    --card-overlap: -16px;
    --card-font: 1.2rem;
    --logo-w: 300px;
    --logo-max-h: 190px;
    --desk-max-w: 500px;
    --desk-aspect: 1.9116;
  }

  #app {
    background-size: 100% auto;
    background-position: center top;
    background-repeat: no-repeat;
  }

  .table-desk-bg {
    inset: -5% -3%;
  }

  #welcome-screen,
  #rooms-screen,
  #create-screen,
  #waiting-screen,
  #game-screen {
    align-items: center;
  }

  .lobby-header,
  .balance-display,
  .nickname-block,
  .welcome-actions {
    max-width: var(--shell-w);
    width: 100%;
  }

  .welcome-actions {
    align-items: center;
  }

  .welcome-actions .btn {
    width: 100%;
    max-width: 300px;
  }

  .screen-header,
  .rooms-toolbar,
  .rooms-list,
  .create-form,
  .room-settings-info,
  .waiting-voice-bar {
    width: 100%;
    max-width: var(--shell-w);
    margin-left: auto;
    margin-right: auto;
  }

  .rooms-toolbar .btn-primary {
    flex: 0 1 auto;
    min-width: 180px;
  }

  .waiting-body {
    max-width: var(--game-w);
    margin: 0 auto;
  }

  #waiting-screen .screen-header,
  #waiting-screen .room-settings-info,
  #waiting-screen .waiting-voice-bar {
    max-width: var(--game-w);
  }

  .waiting-table {
    max-width: none;
  }

  .waiting-footer #btn-ready {
    width: auto;
    min-width: 240px;
  }

  .create-form .btn-large {
    width: auto;
    min-width: 220px;
    align-self: center;
  }

  .game-top-bar,
  .game-table {
    width: 100%;
    max-width: var(--game-w);
    margin-left: auto;
    margin-right: auto;
  }

  .table-drop-zone {
    max-width: var(--desk-max-w);
  }

  .zone-center {
    min-height: 320px;
  }

  .logo-image {
    max-width: var(--logo-w);
  }

  .balance-amount {
    font-size: 2.4rem;
  }

  .btn-large {
    font-size: 1.02rem;
    padding: 0.85rem 1.75rem;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  :root {
    --card-w: 52px;
    --card-h: 76px;
    --card-overlap: -9px;
  }

  #game-screen .player-hand { min-height: calc(var(--card-h) + 10px); }
  #game-screen .action-bar {
    bottom: calc(env(safe-area-inset-bottom) + var(--card-h) + 36px);
  }
}
