:root {
  --bg: #15161b;
  --felt: #1c6539;
  --felt-dark: #0c311e;
  --panel: #202126;
  --line: rgba(255, 255, 255, 0.12);
  --text: #f6f3ec;
  --muted: #9da09f;
  --accent: #f6a623;
  --danger: #ef6255;
  --blue: #77bdfb;
  --gold: #ef9c1d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% 42%, rgba(44, 66, 51, 0.26), transparent 38%),
    #15161b;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.home-screen,
.room-screen {
  background:
    radial-gradient(circle at 50% 0%, rgba(36, 83, 64, 0.28), transparent 38%),
    #15161b;
}

.home-shell,
.room-shell {
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 32px;
}

.home-shell {
  display: grid;
  align-content: center;
  gap: 24px;
}

.home-brand {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.18em;
}

.home-panel {
  width: min(620px, 100%);
}

.home-panel h1 {
  margin-bottom: 14px;
  font-size: clamp(42px, 7vw, 84px);
  line-height: 0.96;
}

.game-tile {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  min-height: 88px;
  margin-top: 34px;
  padding: 14px 20px;
  border: 1px solid rgba(246, 166, 35, 0.48);
  border-radius: 16px;
  background: linear-gradient(110deg, #25262e, #1b1c21);
  color: var(--text);
  text-align: left;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.32);
}

.game-tile:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.game-tile:disabled {
  opacity: 0.65;
  cursor: wait;
}

.game-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: linear-gradient(145deg, #e35c34, #2f2b61);
  color: #fff2d2;
  font-size: 25px;
}

.game-tile strong,
.game-tile small {
  display: block;
}

.game-tile strong {
  font-size: 20px;
}

.game-tile small {
  margin-top: 4px;
  color: var(--muted);
}

.game-arrow {
  color: var(--accent);
  font-size: 30px;
}

.home-error {
  min-height: 24px;
  margin-top: 12px;
  color: #ffc1b8;
}

.room-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 46px;
}

.back-link,
.secondary-link {
  color: var(--muted);
  text-decoration: none;
}

.back-link:hover,
.secondary-link:hover {
  color: var(--text);
}

.room-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 42px;
  align-items: start;
}

.room-content h1 {
  max-width: 760px;
  margin-bottom: 14px;
  font-size: clamp(42px, 6vw, 78px);
  line-height: 0.98;
}

.room-card {
  margin-top: 30px;
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  background: rgba(29, 30, 36, 0.86);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.22);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.section-heading h2,
.room-card h2 {
  margin-bottom: 0;
}

.host-badge {
  border: 1px solid rgba(246, 166, 35, 0.45);
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.room-settings {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 20px;
}

.room-submit {
  grid-column: 1 / -1;
}

.room-qr-card {
  position: sticky;
  top: 24px;
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 22px 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  background: rgba(29, 30, 36, 0.9);
  text-align: center;
}

.room-qr-card img {
  width: 210px;
  height: 210px;
  border-radius: 10px;
  background: #fff;
  padding: 8px;
}

.room-qr-card strong {
  margin-top: 8px;
}

.room-qr-card span {
  max-width: 230px;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
}

.waiting-state {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 14px rgba(246, 166, 35, 0.9);
}

.name-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 20px;
}

.room-qr-mini {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  background: #fff;
  padding: 3px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

.lead,
.hint {
  color: var(--muted);
}

.primary {
  min-height: 46px;
  border-radius: 8px;
  padding: 0 20px;
  background: var(--accent);
  color: #1b1608;
  font-weight: 850;
}

.tv-layout {
  min-height: 100vh;
  padding: 24px 32px 20px;
}

.setup-panel {
  width: min(920px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 32px;
  align-content: center;
  min-height: calc(100vh - 64px);
}

.setup-panel h1,
.table-header h1 {
  margin-bottom: 10px;
  font-size: clamp(44px, 7vw, 92px);
  line-height: 0.95;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

select option {
  color: #101a18;
}

.settings-grid .primary {
  align-self: end;
  min-height: 48px;
}

.table-screen {
  display: grid;
  grid-template-rows: auto auto minmax(420px, 1fr) auto;
  gap: 14px;
  min-height: calc(100vh - 64px);
}

.table-header,
.waiting-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}

.table-header h1 {
  font-size: clamp(30px, 4vw, 58px);
}

.waiting-panel {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 10px 14px;
  background: rgba(28, 29, 35, 0.72);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
}

.tv-screen .waiting-panel > div {
  display: none;
}

.tv-screen .waiting-panel {
  justify-content: flex-end;
}

.tv-screen {
  overflow: hidden;
}

.tv-screen .tv-layout {
  height: 100vh;
  min-height: 0;
  padding: 12px 20px;
  overflow: hidden;
}

.tv-screen .table-screen {
  height: 100%;
  min-height: 0;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 6px;
}

.tv-screen .table-header {
  min-height: 42px;
}

.tv-screen .table-header #start-hand {
  display: none !important;
}

.tv-screen .waiting-panel {
  min-height: 0;
  border: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.waiting-panel h2 {
  margin-bottom: 8px;
}

#join-link {
  margin-bottom: 4px;
  color: var(--blue);
  word-break: break-all;
}

#qr {
  width: min(10vw, 72px);
  aspect-ratio: 1;
  border-radius: 10px;
  background: #fff;
  padding: 6px;
}

.felt {
  position: relative;
  min-height: 420px;
  width: min(1280px, 100%);
  margin: 0 auto;
  border: 16px solid #3b3024;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 50% 48%, rgba(48, 131, 71, 0.48), transparent 52%),
    linear-gradient(135deg, var(--felt), var(--felt-dark));
  box-shadow:
    inset 0 0 0 5px rgba(111, 79, 43, 0.8),
    inset 0 0 0 10px rgba(0, 0, 0, 0.25),
    0 22px 54px rgba(0, 0, 0, 0.52);
}

.felt::before {
  content: "";
  position: absolute;
  inset: 18px;
  border: 2px solid rgba(76, 169, 82, 0.3);
  border-radius: 50%;
  pointer-events: none;
}

.felt::after {
  display: none;
  content: "♠";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: rgba(10, 42, 24, 0.54);
  font-size: clamp(38px, 5vw, 72px);
  font-weight: 900;
  pointer-events: none;
}

.community {
  position: absolute;
  left: 50%;
  top: 43%;
  transform: translate(-50%, -50%);
  display: flex;
  gap: 8px;
  z-index: 3;
}

.pot {
  position: absolute;
  left: 50%;
  top: 62%;
  transform: translateX(-50%);
  border-radius: 999px;
  padding: 7px 16px;
  background: rgba(9, 28, 17, 0.66);
  border: 1px solid rgba(247, 173, 42, 0.38);
  color: var(--accent);
  font-weight: 850;
  z-index: 3;
}

.street-pot {
  position: absolute;
  left: 50%;
  top: 54%;
  transform: translateX(-50%);
  border: 1px solid rgba(90, 210, 205, 0.42);
  border-radius: 999px;
  padding: 5px 12px;
  background: rgba(5, 35, 29, 0.72);
  color: #8de4d7;
  font-size: 12px;
  font-weight: 850;
  z-index: 3;
}

.street-pot.pot-settled {
  animation: pot-settled 700ms ease-out;
}

@keyframes pot-settled {
  0% { transform: translateX(-50%) scale(1); opacity: 1; }
  50% { transform: translateX(-50%) scale(1.18); opacity: 0.9; }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

.bet-flight {
  position: absolute;
  z-index: 10;
  border: 1px solid rgba(255, 210, 75, 0.92);
  border-radius: 999px;
  padding: 6px 10px;
  background: linear-gradient(180deg, #f7bf35, #d87918);
  color: #241607;
  font-size: 12px;
  font-weight: 900;
  pointer-events: none;
  transform: translate(0, 0) scale(1);
  opacity: 1;
  transition: transform 650ms cubic-bezier(0.2, 0.8, 0.3, 1), opacity 650ms ease;
}

.bet-flight.is-flying {
  opacity: 0.08;
}

.dealing-card {
  position: absolute;
  z-index: 12;
  width: 28px;
  height: 40px;
  border: 1px solid rgba(238, 153, 33, 0.8);
  border-radius: 4px;
  background:
    linear-gradient(135deg, rgba(255, 168, 27, 0.18), transparent 45%),
    repeating-linear-gradient(45deg, #3d2419 0 5px, #241c19 5px 10px);
  box-shadow: 0 8px 14px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  transform: translate(0, 0) rotate(0deg);
  transition: transform 340ms cubic-bezier(0.2, 0.8, 0.3, 1), opacity 340ms ease;
}

.dealing-card.is-flying {
  opacity: 0.18;
}

.card {
  display: grid;
  place-items: center;
  width: 64px;
  height: 86px;
  border-radius: 6px;
  background: #f4efe4;
  color: #151515;
  font-size: 26px;
  font-weight: 900;
  box-shadow: 0 10px 16px rgba(0, 0, 0, 0.3);
  z-index: 3;
}

.card.red {
  color: #c22d2d;
}

.card.back {
  background:
    linear-gradient(135deg, rgba(255, 168, 27, 0.18), transparent 45%),
    repeating-linear-gradient(45deg, #3d2419 0 5px, #241c19 5px 10px);
  border: 1px solid rgba(238, 153, 33, 0.7);
  color: transparent;
}

.seats {
  position: absolute;
  inset: 0;
  z-index: 4;
}

.seat {
  position: absolute;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  column-gap: 7px;
  width: 214px;
  min-height: 62px;
  padding: 0;
  border: 0;
  background: transparent;
  transform: translateZ(0);
}

.seat.current {
  filter: drop-shadow(0 0 8px rgba(247, 166, 35, 0.7));
}

.seat.winner {
  filter: drop-shadow(0 0 13px rgba(255, 202, 57, 0.95));
  animation: winner-pulse 0.8s ease-in-out infinite alternate;
}

.seat.winner .seat-name,
.seat.winner .seat-meta {
  border-color: rgba(255, 193, 47, 0.8);
}

@keyframes winner-pulse {
  from { transform: translateZ(0) scale(1); }
  to { transform: translateZ(0) scale(1.04); }
}

.seat.folded {
  opacity: 0.48;
}

.seat::before {
  content: "P";
  display: grid;
  grid-row: 1 / span 2;
  place-items: center;
  width: 46px;
  height: 46px;
  align-self: center;
  border: 2px solid var(--gold);
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.46), transparent 18%),
    linear-gradient(145deg, #e75b2e, #3e2148 62%, #141c4e);
  color: #fff4d9;
  font-size: 18px;
  font-weight: 900;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.seat.empty::before {
  content: "·";
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(13, 21, 17, 0.65);
  color: rgba(255, 255, 255, 0.4);
}

.seat:nth-child(3n + 2)::before {
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.46), transparent 18%),
    linear-gradient(145deg, #2d9ca4, #20325f 62%, #171b37);
}

.seat:nth-child(3n)::before {
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.46), transparent 18%),
    linear-gradient(145deg, #f4a52f, #74336e 62%, #231d48);
}

.seat.occupied::after {
  content: "";
  position: absolute;
  left: 26px;
  bottom: -8px;
  width: 13px;
  height: 17px;
  border: 1px solid #d66d21;
  border-radius: 50%;
  background: repeating-linear-gradient(0deg, #e5532d 0 3px, #f6b629 3px 5px);
  box-shadow: 0 3px 5px rgba(0, 0, 0, 0.42);
}

.seat-panel {
  min-width: 0;
  align-self: center;
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 999px;
  background: linear-gradient(110deg, rgba(37, 39, 47, 0.96), rgba(25, 26, 32, 0.9));
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.26);
}

.seat-name {
  grid-column: 2;
  padding: 8px 11px 2px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-bottom: 0;
  border-radius: 999px 999px 0 0;
  background: linear-gradient(110deg, rgba(37, 39, 47, 0.96), rgba(25, 26, 32, 0.9));
  font-weight: 850;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seat-meta {
  grid-column: 2;
  padding: 0 11px 8px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-top: 0;
  border-radius: 0 0 999px 999px;
  background: linear-gradient(110deg, rgba(37, 39, 47, 0.96), rgba(25, 26, 32, 0.9));
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.seat-cards {
  position: absolute;
  left: 42px;
  top: -25px;
  display: flex;
  gap: 3px;
  margin-top: 0;
  z-index: -1;
}

.seat-cards.revealed {
  z-index: 2;
}

.seat-cards.revealed .card {
  background: #f4efe4;
  color: #151515;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  text-indent: 0;
}

.seat-cards.revealed .card.red {
  color: #c22d2d;
}

.seat-cards[data-dealt="0"] .card,
.seat-cards[data-dealt="1"] .card + .card {
  opacity: 0;
}

.seat-cards::after {
  content: "Ставка " attr(data-bet);
  position: absolute;
  left: 0;
  top: 41px;
  min-width: 44px;
  padding: 3px 7px;
  border: 1px solid rgba(246, 166, 35, 0.46);
  border-radius: 999px;
  background: rgba(15, 29, 20, 0.88);
  color: #f2b62d;
  font-size: 10px;
  font-weight: 850;
  text-align: center;
  white-space: nowrap;
}

.seat-cards[data-blind="small"]::before,
.seat-cards[data-blind="big"]::before {
  position: absolute;
  left: 48px;
  top: 41px;
  padding: 3px 6px;
  border-radius: 999px;
  background: #e88622;
  color: #241708;
  font-size: 9px;
  font-weight: 900;
  z-index: 2;
}

.seat-cards[data-blind="small"]::before {
  content: "МБ";
}

.seat-cards[data-blind="big"]::before {
  content: "ББ";
  background: #ffbd31;
}

.seat-cards .card {
  width: 27px;
  height: 38px;
  border-radius: 4px;
  font-size: 0;
  transform: rotate(-9deg);
}

.seat-cards .card + .card {
  transform: rotate(8deg) translateY(3px);
}

.event-log {
  display: flex;
  gap: 10px;
  overflow: hidden;
  min-height: 34px;
  color: var(--muted);
  font-size: 12px;
}

.event-log span {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.06);
}

.phone-screen {
  background:
    radial-gradient(circle at 50% 10%, rgba(42, 99, 123, 0.34), transparent 38%),
    repeating-radial-gradient(circle at 10% 15%, rgba(111, 187, 214, 0.08) 0 1px, transparent 1px 18px),
    #0b1d2a;
}

.phone-shell {
  width: min(440px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.join-card,
.controller {
  display: grid;
  gap: 20px;
  min-height: calc(100vh - 44px);
  align-content: center;
}

.join-card h1,
.controller h1 {
  margin-bottom: 0;
  font-size: 36px;
  line-height: 1;
}

#join-form {
  display: grid;
  gap: 12px;
}

.controller {
  align-content: start;
}

.controller header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.stack {
  align-self: center;
  border-radius: 999px;
  padding: 9px 12px;
  background: rgba(244, 201, 93, 0.14);
  color: var(--accent);
  font-weight: 850;
}

.private-cards {
  display: flex;
  justify-content: center;
  gap: 14px;
  min-height: 142px;
}

.private-cards .card {
  width: 102px;
  height: 138px;
  font-size: 34px;
}

.status {
  min-height: 48px;
  color: var(--muted);
  text-align: center;
}

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

.action-button {
  min-width: 0;
  min-height: 50px;
  border: 1px solid rgba(91, 213, 241, 0.55) !important;
  border-radius: 7px !important;
  padding: 0 10px;
  overflow: hidden;
  background: linear-gradient(180deg, #087ea9, #056487) !important;
  color: #f2fbff !important;
  font-size: 15px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-button:disabled {
  border-color: rgba(120, 160, 174, 0.18) !important;
  background: rgba(20, 42, 53, 0.66) !important;
  color: rgba(235, 245, 247, 0.35) !important;
  cursor: not-allowed;
}

#raise-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 7px;
  margin-top: 8px;
}

#raise-row.hidden {
  display: none !important;
}

#raise-row button {
  min-height: 44px;
  border-radius: 7px;
  padding: 0 12px;
  background: #087ea9;
  color: #fff;
  font-weight: 850;
}

#raise-row #confirm-raise {
  background: linear-gradient(180deg, #f6b22c, #d77d16);
  color: #211505;
}

.phone-room-tools {
  border-top: 1px solid var(--line);
  margin: 18px 0;
  padding-top: 14px;
}

.round-controls,
.rebuy-card {
  border: 1px solid rgba(246, 166, 35, 0.35);
  border-radius: 10px;
  padding: 14px;
  background: rgba(25, 34, 34, 0.72);
}

.round-controls p,
.rebuy-card p {
  margin-bottom: 8px;
}

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

.round-control-buttons button,
.rebuy-row button {
  min-height: 44px;
  border-radius: 7px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-weight: 850;
}

.rebuy-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

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

.bot-row select,
.bot-row button {
  min-height: 44px;
}

.actions button {
  min-height: 54px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-weight: 850;
}

.actions button[data-action="fold"] {
  background: rgba(242, 109, 91, 0.18);
  color: #ffd0ca;
}

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

.mini-table {
  display: grid;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.mini-player {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.mini-player strong {
  color: var(--text);
}

@media (max-width: 760px) {
  .home-shell,
  .room-shell {
    padding: 20px 18px;
  }

  .room-topbar {
    margin-bottom: 28px;
  }

  .room-layout {
    grid-template-columns: 1fr;
    gap: 22px;
  }

  .room-qr-card {
    position: static;
    order: -1;
  }

  .room-qr-card img {
    width: 170px;
    height: 170px;
  }

  .room-settings,
  .name-form {
    grid-template-columns: 1fr;
  }

  .room-submit {
    grid-column: auto;
  }

  .tv-layout {
    padding: 18px;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .table-header,
  .waiting-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  #qr {
    width: 164px;
  }

  .felt {
    min-height: 520px;
    border-radius: 28px;
  }
}
