:root {
  --app-vh: 1vh;
  --bg-top: #092e29;
  --bg-bottom: #124c42;
  --felt: #0f3f35;
  --panel: #0a2b24;
  --card: #f8f6ef;
  --card-border: #d6cebd;
  --text: #ecf4f2;
  --muted: #bad2cd;
  --danger: #c8452e;
  --shadow: rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Trebuchet MS", "Avenir Next", "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  color: var(--text);
}

body {
  padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
}

.home-link {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  z-index: 80;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  color: var(--text);
  background: rgba(5, 32, 27, 0.82);
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(14px);
}

body.admob-banner-visible {
  padding-bottom: calc(max(10px, env(safe-area-inset-bottom)) + 52px);
}

body.admob-banner-visible .app {
  transform: scaleY(0.92);
  transform-origin: top center;
  margin-bottom: calc(-8vh + 8px);
}

body.start-menu-open {
  overflow: hidden;
}

body.intro-video-open {
  overflow: hidden;
}

.app {
  max-width: 860px;
  margin: 0 auto;
  position: relative;
  background: radial-gradient(circle at top, #16594d, var(--felt));
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  box-shadow: 0 14px 32px var(--shadow);
  padding: 12px;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.15rem, 3.8vw, 1.7rem);
  letter-spacing: 0.03em;
}

.mode-select {
  margin-left: auto;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(6, 18, 15, 0.42);
  color: var(--text);
  min-height: 38px;
  padding: 6px 10px;
  font-weight: 700;
}

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

.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  background: rgba(7, 21, 18, 0.45);
  color: var(--text);
  cursor: pointer;
  padding: 0;
}

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

.top-icon-btn {
  width: 40px;
  height: 40px;
}

.online-panel {
  margin-top: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.2);
  padding: 8px;
  display: grid;
  gap: 8px;
}

.online-join {
  display: grid;
  gap: 8px;
}

.auth-panel {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.14);
  display: grid;
  gap: 8px;
}

.online-panel input {
  width: 100%;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(6, 18, 15, 0.45);
  color: var(--text);
  padding: 8px 10px;
  font-size: 0.95rem;
}

.online-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.online-row.single,
.online-row.single {
  grid-template-columns: 1fr;
}

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

.online-row.buttons.single {
  grid-template-columns: 1fr;
}

.online-row.buttons .btn {
  min-height: 42px;
  font-size: 0.9rem;
}

.online-status {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.version-note {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.voice-panel,
.chat-panel {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.14);
  display: grid;
  gap: 8px;
}

.voice-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.voice-row .btn {
  min-height: 40px;
}

.chat-messages {
  min-height: 120px;
  max-height: 180px;
  overflow-y: auto;
  padding: 7px;
  border-radius: 8px;
  background: rgba(6, 18, 15, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.88rem;
  line-height: 1.35;
}

.chat-msg {
  margin: 0 0 5px;
  color: var(--text);
  word-break: break-word;
}

.chat-msg:last-child {
  margin-bottom: 0;
}

.chat-msg .chat-author {
  color: #f6d58e;
  font-weight: 700;
  margin-right: 4px;
}

.chat-msg.system .chat-author {
  color: #9cc9ff;
}

.chat-msg.premium-entry .chat-author,
.chat-msg.premium-entry {
  color: #ffe4a0;
}

.chat-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.chat-row input {
  min-height: 40px;
}

.chat-row .btn {
  min-height: 40px;
  padding: 8px 12px;
}

.report-form {
  display: grid;
  gap: 8px;
}

.panel-field {
  width: 100%;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(6, 18, 15, 0.45);
  color: var(--text);
  padding: 8px 10px;
  font-size: 0.95rem;
  font-family: inherit;
}

textarea.panel-field {
  resize: vertical;
  min-height: 92px;
}

.details-chat-panel {
  margin-top: 8px;
}

.scoreboard {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  position: sticky;
  top: 8px;
  z-index: 25;
  padding: 8px;
  border-radius: 12px;
  background: rgba(5, 16, 13, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(3px);
}

.score-box {
  background: rgba(6, 18, 15, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.score-box span {
  color: var(--muted);
  font-size: 0.82rem;
  max-width: 78%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score-box strong {
  font-size: 1.35rem;
}

.tento-summary {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.meta-row {
  margin-top: 9px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.94rem;
}

#turnTimer {
  color: #f6d58e;
  font-weight: 800;
}

.sound-icon-btn .sound-off-slash {
  opacity: 0;
  transition: opacity 0.14s ease;
}

.sound-icon-btn.is-muted .sound-off-slash {
  opacity: 1;
}

.sound-icon-btn.is-muted {
  color: #ffb9b9;
}

.table-area {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.deal-animation {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 34;
  opacity: 0;
  visibility: hidden;
}

.deal-animation.active {
  opacity: 1;
  visibility: visible;
}

.deal-deck-stack {
  position: absolute;
  left: 50%;
  top: 52%;
  width: clamp(54px, 16vw, 76px);
  aspect-ratio: 5 / 7;
  transform: translate(-50%, -50%);
}

.deal-deck-card,
.deal-fly-card {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  border: 2px solid #8d6f2f;
  background: linear-gradient(160deg, #f5d57a 0%, #bc8830 100%);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.26);
}

.deal-deck-card::before,
.deal-deck-card::after,
.deal-fly-card::before,
.deal-fly-card::after {
  content: "";
  position: absolute;
  border-radius: 8px;
  border: 1px solid rgba(81, 52, 8, 0.35);
}

.deal-deck-card::before,
.deal-fly-card::before {
  inset: 7px;
}

.deal-deck-card::after,
.deal-fly-card::after {
  inset: 13px;
  border-style: dashed;
}

.deal-deck-card.layer-a {
  transform: rotate(-9deg) translate(-6px, 2px);
}

.deal-deck-card.layer-b {
  transform: rotate(7deg) translate(5px, -1px);
}

.deal-deck-card.layer-c {
  transform: rotate(0deg);
}

.deal-fly-card {
  left: 50%;
  top: 52%;
  width: clamp(52px, 15vw, 72px);
  aspect-ratio: 5 / 7;
  transform: translate(-50%, -50%) scale(0.72);
  opacity: 0;
}

.deal-animation.phase-shuffle .deal-deck-stack {
  animation: shuffleDeck 0.52s ease-in-out;
}

.deal-animation.phase-cut .deal-deck-stack {
  animation: cutDeck 0.38s ease-in-out;
}

.deal-fly-card.dynamic {
  animation-duration: 0.52s;
  animation-fill-mode: both;
  animation-timing-function: ease-out;
}

.deal-fly-card.dynamic.to-top {
  animation-name: dealToTop;
}

.deal-fly-card.dynamic.to-left {
  animation-name: dealToLeft;
}

.deal-fly-card.dynamic.to-right {
  animation-name: dealToRight;
}

.deal-fly-card.dynamic.to-bottom {
  animation-name: dealToBottom;
}

@keyframes shuffleDeck {
  0% {
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
  }
  22% {
    transform: translate(-49.4%, -50.6%) rotate(-8deg) scale(1.03);
  }
  44% {
    transform: translate(-50.6%, -49.4%) rotate(9deg) scale(1.02);
  }
  68% {
    transform: translate(-49.7%, -50.3%) rotate(-5deg) scale(1.01);
  }
  100% {
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
  }
}

@keyframes cutDeck {
  0% {
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
  }
  35% {
    transform: translate(-46.4%, -50%) rotate(2deg) scale(1.01);
  }
  68% {
    transform: translate(-53.2%, -50%) rotate(-2deg) scale(1.01);
  }
  100% {
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
  }
}

@keyframes dealToTop {
  0% {
    transform: translate(-50%, -50%) scale(0.72) rotate(0deg);
    opacity: 0.2;
  }
  100% {
    transform: translate(-50%, -230%) scale(0.96) rotate(-8deg);
    opacity: 0;
  }
}

@keyframes dealToLeft {
  0% {
    transform: translate(-50%, -50%) scale(0.72) rotate(0deg);
    opacity: 0.2;
  }
  100% {
    transform: translate(-285%, -50%) scale(0.95) rotate(-12deg);
    opacity: 0;
  }
}

@keyframes dealToRight {
  0% {
    transform: translate(-50%, -50%) scale(0.72) rotate(0deg);
    opacity: 0.2;
  }
  100% {
    transform: translate(185%, -50%) scale(0.95) rotate(12deg);
    opacity: 0;
  }
}

@keyframes dealToBottom {
  0% {
    transform: translate(-50%, -50%) scale(0.72) rotate(0deg);
    opacity: 0.2;
  }
  100% {
    transform: translate(-50%, 130%) scale(0.96) rotate(8deg);
    opacity: 0;
  }
}

.seat {
  text-align: center;
}

.seat-label {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  margin-bottom: 4px;
}

.seat-label.premium-label {
  color: #ffe4a0;
  text-shadow: 0 0 8px rgba(255, 212, 121, 0.42);
}

.middle-lane {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
}

.side-seat {
  width: 76px;
}

.cards-row {
  display: flex;
  gap: 7px;
  justify-content: center;
  flex-wrap: wrap;
  min-height: 80px;
}

.cards-row.vertical {
  flex-direction: column;
  align-items: center;
  min-height: 160px;
}

.card {
  position: relative;
  overflow: hidden;
  width: clamp(58px, 18vw, 82px);
  aspect-ratio: 5 / 6.2;
  border-radius: 12px;
  border: 2px solid var(--card-border);
  background: linear-gradient(180deg, #ffffff 0%, var(--card) 100%);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.24);
  user-select: none;
}

.cards-row.vertical .card {
  width: clamp(52px, 13vw, 66px);
}

.card.played-card {
  width: clamp(62px, 19vw, 90px);
}

.card.empty {
  opacity: 0.65;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.76);
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.1);
  font-size: 1.25rem;
}

.card-face {
  position: absolute;
  inset: 0;
  color: #1d1d1d;
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: center;
  background: linear-gradient(162deg, #fdfcf9 0%, #f4efe5 52%, #efe7d8 100%);
}

.card-face.red {
  color: #b12323;
}

.card-corner {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-self: start;
  margin-left: 5px;
  font-weight: 800;
  line-height: 0.95;
}

.card-corner strong {
  font-size: clamp(0.78rem, 2.9vw, 1rem);
}

.card-corner em {
  font-style: normal;
  font-size: clamp(0.63rem, 2.3vw, 0.82rem);
}

.card-corner.bottom {
  justify-self: end;
  margin-left: 0;
  margin-right: 5px;
  transform: rotate(180deg);
}

.card-center {
  justify-self: center;
  align-self: center;
  font-size: clamp(1.15rem, 5.8vw, 1.8rem);
  font-weight: 700;
  opacity: 0.92;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}

.manilha-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  background: linear-gradient(180deg, #f7dc85, #d39a2a);
  color: #432e08;
  display: grid;
  place-items: center;
  font-size: 0.62rem;
  font-weight: 800;
  border: 1px solid rgba(67, 46, 8, 0.35);
}

.card.back {
  border-color: #8d6f2f;
  background: linear-gradient(160deg, #f5d57a 0%, #bc8830 100%);
}

.card.back::before,
.card.back::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 8px;
  border: 1px solid rgba(81, 52, 8, 0.35);
}

.card.back::after {
  inset: 13px;
  border-style: dashed;
}

.back-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(59, 38, 7, 0.88);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.player-card {
  border: 2px solid #ffffff3d;
  transition: transform 0.16s ease;
  cursor: pointer;
  padding: 0;
}

.player-card:active {
  transform: translateY(-2px) scale(0.98);
}

.player-card:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.player-card:disabled .card-face {
  filter: grayscale(0.26);
}

.mesa-grid {
  min-height: 200px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-rows: auto 1fr auto;
  gap: 8px;
  align-items: center;
}

.played-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.played-wrap.top {
  grid-column: 2;
  grid-row: 1;
}

.played-wrap.left {
  grid-column: 1;
  grid-row: 2;
}

.center-info {
  grid-column: 2;
  grid-row: 2;
  min-width: min(248px, 53vw);
  text-align: center;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.16);
}

.played-wrap.right {
  grid-column: 3;
  grid-row: 2;
}

.played-wrap.bottom {
  grid-column: 2;
  grid-row: 3;
}

.played-seat-label {
  min-height: 14px;
  line-height: 1;
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  display: none;
}

.app.duo-mode .played-seat-label {
  display: block;
}

.status {
  margin: 0;
  font-size: clamp(0.9rem, 2.7vw, 1rem);
}

.trick-history {
  margin-top: 8px;
  min-height: 20px;
  color: var(--muted);
  font-size: 0.84rem;
}

.controls {
  margin-top: 10px;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.btn {
  border: none;
  border-radius: 11px;
  min-height: 46px;
  padding: 10px 12px;
  font-size: 1rem;
  font-weight: 700;
  color: white;
  cursor: pointer;
  touch-action: manipulation;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(180deg, #f4ba3f, #d89318);
  color: #1f1a12;
}

.btn-secondary {
  background: linear-gradient(180deg, #66a6d8, #2f74ab);
}

.btn-danger {
  background: linear-gradient(180deg, #d95d49, #a52b1a);
}

.icon-only-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 6px 8px;
}

.icon-only-btn.has-caption {
  flex-direction: column;
  gap: 2px;
  min-height: 56px;
}

.icon-only-btn.has-caption.caption-top {
  flex-direction: column-reverse;
}

.icon-only-btn .btn-svg-wrap {
  width: 30px;
  min-width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  position: relative;
}

.icon-only-btn svg {
  width: 24px;
  height: 24px;
}

.icon-caption {
  font-size: 0.62rem;
  line-height: 1;
  letter-spacing: 0.03em;
  font-weight: 800;
}

#coveredBtn.is-active {
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.25);
}

.raise-level {
  position: absolute;
  right: -1px;
  bottom: -1px;
  display: flex;
  gap: 2px;
}

.raise-level span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
}

.raise-level[data-level="1"] span:nth-child(-n + 1),
.raise-level[data-level="2"] span:nth-child(-n + 2),
.raise-level[data-level="3"] span:nth-child(-n + 3),
.raise-level[data-level="4"] span:nth-child(-n + 4) {
  background: #fff4c6;
}

#newMatchBtn {
  grid-column: 1 / -1;
}

.rules {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.2);
  color: var(--muted);
  font-size: 0.9rem;
}

.rules summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--text);
}

.rules ul {
  margin: 8px 0 0;
  padding-left: 16px;
}

.hidden {
  display: none !important;
}

#remoteVoiceAudio {
  display: none;
}

.intro-video-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: #000;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.intro-video-player {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  object-fit: contain;
  object-position: center;
  transform: scaleX(1.17);
  background: #000;
}

.intro-video-skip-btn {
  position: absolute;
  top: calc(10px + min(env(safe-area-inset-top), 24px));
  right: calc(10px + min(env(safe-area-inset-right), 24px));
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.52);
  color: #fff;
  min-height: 34px;
  padding: 6px 14px;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
}

.start-menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  justify-items: center;
  align-items: start;
  align-content: start;
  height: 100dvh;
  min-height: calc(var(--app-vh) * 100);
  overflow-y: auto;
  padding: 16px;
  padding-top: calc(16px + min(env(safe-area-inset-top), 24px));
  padding-bottom: calc(16px + min(env(safe-area-inset-bottom), 24px));
  overscroll-behavior: contain;
  background:
    radial-gradient(circle at 20% 10%, rgba(225, 176, 74, 0.25), transparent 40%),
    radial-gradient(circle at 100% 90%, rgba(26, 89, 76, 0.55), transparent 55%),
    linear-gradient(165deg, #072923 0%, #114338 70%, #1c5a49 100%);
}

.start-menu-panel {
  width: min(560px, 100%);
  max-height: calc(var(--app-vh) * 100 - 32px);
  overflow-y: auto;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(4, 17, 14, 0.74);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
  padding: 18px;
}

.start-menu-logo {
  display: block;
  width: min(100%, 260px);
  margin: 0 auto 12px;
  height: auto;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.35);
  background: rgba(0, 0, 0, 0.2);
}

.start-menu-kicker {
  margin: 0;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  color: #f6d58e;
  text-transform: uppercase;
  font-weight: 800;
}

.start-menu-panel h2 {
  margin: 6px 0 0;
  font-size: clamp(1.3rem, 5vw, 1.9rem);
}

.start-menu-help {
  margin: 8px 0 14px;
  color: var(--muted);
}

.start-menu-options {
  display: grid;
  gap: 10px;
}

.start-mode-btn {
  min-height: 56px;
  font-size: clamp(0.96rem, 3.8vw, 1.05rem);
}

.start-menu-purchase {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.start-purchase-btn {
  width: 100%;
  min-height: 52px;
  border-color: rgba(255, 211, 90, 0.7);
  box-shadow: 0 0 0 1px rgba(255, 211, 90, 0.18);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.52);
  display: grid;
  place-items: center;
  padding: 14px;
}

#settingsOverlay {
  z-index: 95;
}

#responseOverlay {
  z-index: 98;
}

#rematchOverlay {
  z-index: 99;
}

.dialog {
  width: min(420px, 94vw);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 10px 24px var(--shadow);
}

.dialog h2 {
  margin: 0;
  font-size: 1.1rem;
}

.dialog p {
  margin: 8px 0 14px;
  color: var(--muted);
}

.dialog-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.settings-dialog {
  width: min(600px, 96vw);
  max-height: min(86vh, 760px);
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
}

.rematch-dialog {
  width: min(430px, 94vw);
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.close-settings-btn {
  width: 36px;
  height: 36px;
}

.settings-content {
  overflow: auto;
  padding-right: 2px;
}

.settings-content .rules {
  margin-top: 8px;
}

.settings-content .purchase-rules {
  border-color: rgba(255, 211, 90, 0.55);
  box-shadow: 0 0 0 1px rgba(255, 211, 90, 0.15), 0 10px 22px rgba(0, 0, 0, 0.18);
}

.settings-content .purchase-rules > summary {
  color: #ffe08a;
  font-weight: 800;
}

.app.duel-mode #leftSeat,
.app.duel-mode #rightSeat,
.app.duel-mode .played-wrap.left,
.app.duel-mode .played-wrap.right {
  visibility: hidden;
}

.app.duo-mode .seat-label {
  display: none;
}

@media (max-width: 460px) {
  .title-row {
    gap: 8px;
  }

  .online-row {
    grid-template-columns: 1fr;
  }

  .voice-row {
    grid-template-columns: 1fr;
  }

  .chat-row {
    grid-template-columns: 1fr;
  }

  .middle-lane {
    grid-template-columns: 64px 1fr 64px;
  }

  .center-info {
    min-width: min(180px, 45vw);
  }

  .side-seat {
    width: 64px;
  }

  .app.duo-mode .middle-lane {
    grid-template-columns: 54px minmax(0, 1fr) 54px;
    gap: 6px;
  }

  .app.duo-mode .side-seat {
    width: 54px;
  }

  .app.duo-mode .cards-row.vertical {
    min-height: 128px;
  }

  .app.duo-mode .cards-row.vertical .card {
    width: clamp(38px, 11vw, 50px);
  }

  .app.duo-mode .mesa-grid {
    min-height: 160px;
    gap: 4px;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  }

  .app.duo-mode .card.played-card {
    width: clamp(50px, 15vw, 62px);
  }

  .app.duo-mode .center-info {
    min-width: 0;
    width: 100%;
    padding: 6px;
  }

  .app.duo-mode .played-seat-label {
    font-size: 0.6rem;
  }

}

@media (max-height: 760px) {
  body.admob-banner-visible {
    padding-bottom: calc(max(8px, env(safe-area-inset-bottom)) + 48px);
  }

  body.admob-banner-visible .app {
    transform: scaleY(0.88);
    margin-bottom: calc(-12vh + 8px);
  }
}

@media (min-width: 780px) {
  .app {
    padding: 14px;
  }

  .controls {
    max-width: 430px;
    margin: 12px auto 0;
  }
}
