:root {
  --bg: #0f1312;
  --panel: #f8f6f0;
  --panel-2: #ebe6da;
  --ink: #191b1e;
  --muted: #6f6d66;
  --line: rgba(25, 27, 30, 0.12);
  --felt: #146a52;
  --felt-dark: #0a3b31;
  --gold: #d8ad50;
  --red: #b9383d;
  --black: #181a1d;
  --blue: #2e67b1;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  --soft-shadow: 0 14px 42px rgba(0, 0, 0, 0.2);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 8%, rgba(216, 173, 80, 0.16), transparent 28rem),
    radial-gradient(circle at 86% 20%, rgba(46, 103, 177, 0.13), transparent 26rem),
    linear-gradient(135deg, #0f1312 0%, #242825 48%, #151718 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.app-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), transparent 82%);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 370px);
  gap: 20px;
  min-height: 100vh;
  padding: clamp(14px, 2vw, 24px);
  position: relative;
  width: 100%;
  max-width: 100vw;
}

.table-zone {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.045)),
    rgba(255, 255, 255, 0.035);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-height: calc(100vh - clamp(28px, 4vw, 48px));
  width: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px clamp(18px, 2.4vw, 28px);
  color: white;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.6rem, 2.7vw, 2.65rem);
  line-height: 1;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary-button,
.secondary-button,
.icon-button {
  min-height: 40px;
  border-radius: 8px;
  font-weight: 800;
  transition: transform 160ms ease, background 160ms ease, opacity 160ms ease, border-color 160ms ease;
  touch-action: manipulation;
}

.primary-button {
  padding: 0 16px;
  background: var(--gold);
  color: #211907;
  box-shadow: 0 10px 26px rgba(216, 173, 80, 0.2);
}

.secondary-button {
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.12);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.icon-button {
  width: 38px;
  background: rgba(255, 255, 255, 0.12);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 1.1rem;
}

.primary-button:hover,
.secondary-button:hover,
.icon-button:hover,
.card.playable:hover {
  transform: translateY(-2px);
}

.table-wrap {
  position: relative;
  flex: 1;
  min-height: 530px;
  padding: clamp(78px, 8vh, 96px) clamp(112px, 11vw, 144px) clamp(108px, 11vh, 128px);
}

.felt {
  position: relative;
  z-index: 1;
  height: 100%;
  min-height: 360px;
  border-radius: 50%;
  padding: 18px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.18), rgba(0, 0, 0, 0.18)),
    var(--felt-dark);
  box-shadow:
    inset 0 0 0 8px rgba(255, 255, 255, 0.08),
    inset 0 0 70px rgba(0, 0, 0, 0.38),
    0 22px 54px rgba(0, 0, 0, 0.26);
}

.felt-inner {
  display: grid;
  place-items: center;
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background:
    repeating-linear-gradient(35deg, rgba(255, 255, 255, 0.022) 0 2px, transparent 2px 10px),
    var(--felt);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.center-status {
  position: absolute;
  bottom: 22%;
  width: min(520px, calc(100% - 56px));
  padding: 10px 14px;
  border-radius: 8px;
  color: white;
  background: rgba(9, 20, 18, 0.58);
  text-align: center;
  font-weight: 700;
  line-height: 1.3;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
}

.trick-area {
  position: relative;
  width: min(420px, 64vw);
  height: min(280px, 42vw);
}

.trick-card {
  position: absolute;
}

.trick-card.north {
  top: 0;
  left: 50%;
  transform: translateX(-50%) rotate(180deg);
}

.trick-card.east {
  top: 50%;
  right: 0;
  transform: translateY(-50%) rotate(90deg);
}

.trick-card.south {
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}

.trick-card.west {
  top: 50%;
  left: 0;
  transform: translateY(-50%) rotate(-90deg);
}

.seat {
  position: absolute;
  z-index: 3;
  min-width: 150px;
  padding: 10px 12px;
  border-radius: 8px;
  color: white;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(14px);
  box-shadow: var(--soft-shadow);
}

.seat.active {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(215, 172, 77, 0.18);
}

.seat-north {
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
}

.seat-south {
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
}

.seat-west {
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
}

.seat-east {
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
}

.seat-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 800;
}

.seat-stat {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 5px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.78rem;
}

.dealer-chip,
.turn-chip {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 0.64rem;
  font-weight: 800;
  background: var(--gold);
  color: #211907;
}

.turn-chip {
  margin-left: 4px;
}

.hand {
  display: flex;
  align-items: flex-end;
  gap: clamp(3px, 0.5vw, 8px);
  min-height: 148px;
  padding: 18px clamp(18px, 2.4vw, 28px) 22px;
  overflow-x: auto;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent),
    rgba(0, 0, 0, 0.24);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.34) transparent;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}

.card {
  display: grid;
  grid-template-rows: auto 1fr auto;
  flex: 0 0 auto;
  width: 74px;
  height: 108px;
  padding: 8px;
  border-radius: 8px;
  background: #fbfaf7;
  color: var(--black);
  border: 1px solid rgba(20, 20, 20, 0.18);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.26);
  user-select: none;
  transition: transform 160ms ease, opacity 160ms ease, filter 160ms ease;
  scroll-snap-align: center;
  touch-action: manipulation;
}

.card.red {
  color: var(--red);
}

.card.back {
  place-items: center;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), transparent),
    repeating-linear-gradient(45deg, #284f8e 0 8px, #22457d 8px 16px);
  color: white;
}

.card.disabled {
  opacity: 0.45;
  filter: grayscale(0.4);
}

.card.playable {
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.28), 0 0 0 2px rgba(216, 173, 80, 0.16);
}

.card.selected {
  transform: translateY(-18px);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.38), 0 0 0 3px var(--gold);
}

.rank {
  font-size: 1.1rem;
  font-weight: 900;
  line-height: 1;
}

.suit {
  align-self: center;
  justify-self: center;
  font-size: 2rem;
}

.mini {
  justify-self: end;
  transform: rotate(180deg);
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  max-height: calc(100vh - clamp(28px, 4vw, 48px));
  overflow-y: auto;
  padding: 14px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.28)),
    var(--panel);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.52);
  scrollbar-width: thin;
  scrollbar-color: rgba(25, 27, 30, 0.3) transparent;
}

.panel-section {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.58);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-title strong {
  color: var(--ink);
  font-size: 1rem;
}

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

.meta-item {
  padding: 10px;
  border-radius: 8px;
  background: var(--panel-2);
  min-width: 0;
}

.meta-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.meta-value {
  font-weight: 900;
  overflow-wrap: anywhere;
}

.inline-bid {
  display: inline;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--inline-ink, var(--ink));
  font-weight: 900;
  box-shadow: none;
}

.inline-C,
.inline-S {
  --inline-accent: #151719;
  --inline-ink: #151719;
}

.inline-D {
  --inline-accent: #b73a3f;
  --inline-ink: #a72f34;
}

.inline-H {
  --inline-accent: #c62f58;
  --inline-ink: #b2254c;
}

.inline-NT {
  --inline-accent: #c59637;
  --inline-ink: #8d681e;
}

.action-panel h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.bidding-panel {
  position: relative;
  overflow: visible;
}

.bidding-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, #202226, var(--gold));
}

.trump-panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.54)),
    linear-gradient(135deg, rgba(216, 173, 80, 0.14), rgba(20, 106, 82, 0.12));
}

.contract-panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.54)),
    linear-gradient(135deg, rgba(46, 103, 177, 0.12), rgba(216, 173, 80, 0.14));
}

.action-panel p {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.45;
}

.button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.bid-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 10px;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: 0 6px 14px rgba(25, 27, 30, 0.08);
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
  gap: 8px;
}

.trump-grid {
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
}

.choice,
.bid-button {
  min-height: 42px;
  padding: 8px 9px;
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel-2);
  font-weight: 800;
  border: 1px solid transparent;
  touch-action: manipulation;
}

.pass-button {
  background: #2f3334;
  color: white;
  box-shadow: 0 10px 24px rgba(25, 27, 30, 0.2);
}

.bid-button,
.contract-choice {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  box-shadow: 0 8px 18px rgba(25, 27, 30, 0.08);
}

.bid-button {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background:
    linear-gradient(90deg, var(--bid-accent, var(--gold)) 0 5px, transparent 5px),
    linear-gradient(180deg, #fffdf8, #ece6da);
  color: var(--bid-ink, var(--ink));
  border-color: rgba(25, 27, 30, 0.12);
}

.bid-level {
  position: relative;
  z-index: 1;
  font-size: 1rem;
  line-height: 1;
  color: var(--bid-accent, currentColor);
}

.bid-suit {
  position: relative;
  z-index: 1;
  min-width: 1.25em;
  font-size: 1.12rem;
  line-height: 1;
  color: var(--bid-accent, currentColor);
}

.trump-C {
  --bid-accent: #2a2d30;
  --bid-ink: #202326;
  color: var(--bid-ink);
  border-color: rgba(18, 19, 21, 0.22);
}

.trump-D {
  --bid-accent: #b73a3f;
  --bid-ink: #a72f34;
  color: var(--bid-ink);
  border-color: rgba(185, 56, 61, 0.28);
}

.trump-H {
  --bid-accent: #c62f58;
  --bid-ink: #b2254c;
  color: var(--bid-ink);
  border-color: rgba(190, 44, 76, 0.3);
}

.trump-S {
  --bid-accent: #151719;
  --bid-ink: #151719;
  color: var(--bid-ink);
  border-color: rgba(18, 19, 21, 0.22);
}

.trump-NT {
  --bid-accent: #c59637;
  --bid-ink: #8d681e;
  color: var(--bid-ink);
  border-color: rgba(216, 173, 80, 0.5);
}

.contract-zero {
  color: #17352d;
  border-color: rgba(20, 106, 82, 0.28);
  background: linear-gradient(145deg, #d8f1e7, #a6dbc9) !important;
}

.contract-low {
  color: #23385c;
  border-color: rgba(46, 103, 177, 0.22);
  background: linear-gradient(145deg, #dceafe, #aecaec) !important;
}

.contract-mid {
  color: #2c230d;
  border-color: rgba(216, 173, 80, 0.34);
  background: linear-gradient(145deg, #f3e5b4, #dfbd64) !important;
}

.contract-high {
  color: #fff7f4;
  border-color: rgba(185, 56, 61, 0.34);
  background: linear-gradient(145deg, #d65e5e, #963238) !important;
}

.choice:hover,
.bid-button:hover {
  border-color: var(--gold);
  filter: brightness(1.04) saturate(1.06);
}

.bid-button:focus-visible,
.contract-choice:focus-visible,
.pass-button:focus-visible {
  outline: 3px solid rgba(216, 173, 80, 0.72);
  outline-offset: 2px;
}

.scoreboard {
  display: grid;
  gap: 8px;
}

.score-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 8px;
  background: var(--panel-2);
  min-width: 0;
}

.score-name {
  font-weight: 900;
}

.score-detail {
  color: var(--muted);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.score-value {
  font-weight: 900;
  font-size: 1.25rem;
}

.log {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 210px;
  overflow-y: auto;
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.35;
}

.rules-dialog {
  width: min(720px, calc(100vw - 28px));
  border: 0;
  padding: 0;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
  border-radius: 14px;
  overflow: hidden;
}

.room-dialog {
  width: min(520px, calc(100vw - 28px));
  border: 0;
  padding: 0;
  border-radius: 14px;
  overflow: hidden;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.room-dialog::backdrop {
  background: rgba(0, 0, 0, 0.64);
}

.room-body {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.room-status {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 700;
  line-height: 1.35;
}

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

.room-input {
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  font-weight: 800;
}

.code-input {
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.dark-button {
  background: #303335;
  color: white;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.room-share {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border-radius: 12px;
  background: white;
  border: 1px solid var(--line);
}

.room-code-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.room-code {
  margin-top: 3px;
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.room-qr {
  width: 112px;
  height: 112px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
}

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

.room-seat {
  padding: 10px;
  border-radius: 10px;
  background: var(--panel-2);
}

.room-seat strong {
  display: block;
}

.room-seat span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.rules-dialog::backdrop {
  background: rgba(0, 0, 0, 0.64);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px;
  background: #202421;
  color: white;
}

.rules-dialog ul {
  margin: 0;
  padding: 18px 22px 22px 38px;
  line-height: 1.55;
}

.rules-dialog li + li {
  margin-top: 8px;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .side-panel {
    max-height: none;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .action-panel {
    grid-column: 1 / -1;
    order: -1;
  }
}

@media (max-width: 1100px) {
  body {
    background:
      radial-gradient(circle at 50% -8%, rgba(216, 173, 80, 0.16), transparent 18rem),
      linear-gradient(180deg, #101413 0%, #1c211f 56%, #111414 100%);
  }

  .app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100svh;
    padding: 0;
    gap: 0;
    inline-size: 100vw;
    max-inline-size: 100vw;
    overflow-x: hidden;
  }

  .table-zone,
  .side-panel {
    border-radius: 0;
    box-shadow: none;
    inline-size: 100vw;
    max-inline-size: 100vw;
  }

  .table-zone {
    min-height: auto;
    border-left: 0;
    border-right: 0;
  }

  .topbar {
    position: relative;
    display: block;
    padding: 12px 12px 10px;
    min-height: 68px;
    width: 100%;
    min-width: 0;
  }

  .topbar > div:first-child {
    min-width: 0;
    padding-right: 104px;
  }

  .eyebrow {
    margin-bottom: 3px;
    font-size: 0.66rem;
  }

  h1 {
    font-size: 1.32rem;
    line-height: 1.05;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .top-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    gap: 6px;
    flex-wrap: nowrap;
  }

  .top-actions .secondary-button {
    display: none;
  }

  .top-actions .primary-button {
    width: 44px;
    padding: 0;
    font-size: 0;
  }

  .top-actions .primary-button::before {
    content: "+";
    font-size: 1.45rem;
    line-height: 1;
  }

  .primary-button,
  .secondary-button,
  .icon-button {
    min-height: 44px;
  }

  .primary-button {
    padding: 0 12px;
  }

  .icon-button {
    width: 44px;
  }

  .table-wrap {
    min-height: clamp(390px, 58svh, 510px);
    padding: 68px 8px 96px;
    inline-size: 100vw;
    max-inline-size: 100vw;
    overflow: hidden;
  }

  .felt {
    width: 100%;
    max-width: 100%;
    min-height: clamp(245px, 39svh, 330px);
    border-radius: 24px;
    padding: 12px;
  }

  .felt-inner {
    border-radius: 20px;
  }

  .trick-area {
    width: min(310px, 80vw);
    height: min(220px, 51vw);
  }

  .center-status {
    bottom: 16px;
    width: calc(100% - 28px);
    padding: 9px 10px;
    font-size: 0.85rem;
  }

  .seat {
    min-width: 112px;
    max-width: calc(50vw - 14px);
    padding: 8px 9px;
    font-size: 0.85rem;
    border-radius: 10px;
  }

  .seat-stat {
    grid-template-columns: auto auto;
    gap: 5px;
    margin-top: 3px;
    font-size: 0.68rem;
  }

  .seat-stat span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .seat-north {
    top: 9px;
  }

  .seat-south {
    bottom: 8px;
  }

  .seat-west,
  .seat-east {
    top: auto;
    bottom: 60px;
    transform: none;
  }

  .seat-west {
    left: 8px;
  }

  .seat-east {
    right: 8px;
    left: auto;
  }

  .hand {
    min-height: 120px;
    gap: 6px;
    padding: 12px 12px 16px;
    width: 100%;
    max-width: 100vw;
    overflow-x: auto;
    overflow-y: visible;
  }

  .card {
    width: clamp(54px, 15vw, 64px);
    height: clamp(82px, 22vw, 94px);
    padding: 7px;
  }

  .suit {
    font-size: 1.58rem;
  }

  .rank {
    font-size: 1rem;
  }

  .side-panel {
    display: flex;
    padding: 10px 10px calc(10px + var(--safe-bottom));
    gap: 10px;
    background: var(--panel);
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .panel-section {
    padding: 12px;
    border-radius: 12px;
  }

  .action-panel {
    position: sticky;
    bottom: 0;
    z-index: 10;
    order: -1;
    margin: 0 -10px;
    padding: 13px 12px calc(13px + var(--safe-bottom));
    border-left: 0;
    border-right: 0;
    border-radius: 16px 16px 0 0;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(248, 246, 240, 0.98)),
      var(--panel);
    box-shadow: 0 -12px 34px rgba(0, 0, 0, 0.18);
    max-height: min(52svh, 430px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .action-panel h3 {
    font-size: 1rem;
  }

  .action-panel p {
    font-size: 0.88rem;
    margin-bottom: 10px;
  }

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

  .choice-grid {
    grid-template-columns: repeat(auto-fit, minmax(58px, 1fr));
    max-height: min(35svh, 240px);
    overflow-y: auto;
    padding-right: 2px;
  }

  .choice,
  .bid-button {
    min-height: 46px;
    padding: 8px 6px;
    font-size: 0.92rem;
  }

  .button-row .primary-button {
    width: 100%;
  }

  .score-row {
    padding: 9px;
  }

  .log {
    max-height: 150px;
  }
}

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

  h1 {
    font-size: 1.12rem;
  }

  .primary-button {
    padding: 0 10px;
  }

  .seat {
    min-width: 104px;
    font-size: 0.78rem;
  }

  .seat-stat {
    font-size: 0.64rem;
  }

  .choice-grid {
    grid-template-columns: repeat(auto-fit, minmax(52px, 1fr));
  }
}

@media (min-width: 1280px) {
  .card {
    width: 78px;
    height: 114px;
  }

  .table-wrap {
    min-height: 610px;
  }
}

@media (hover: none) {
  .primary-button:hover,
  .secondary-button:hover,
  .icon-button:hover,
  .card.playable:hover {
    transform: none;
  }
}
