:root {
  --bg-1: #14b8b3;
  --bg-2: #0872c9;
  --bg-3: #29d59f;

  --panel: #232923;
  --panel-2: #2e342e;
  --panel-3: #1a1e1a;

  --text: #fff9ef;
  --text-dim: #d7d2c6;
  --text-dark: #1f221f;

  --line-dark: #1d1d1d;
  --line-light: #fffdf6;

  --yellow: #ffd21a;
  --yellow-deep: #f0b900;
  --white-btn: #fff8ec;
  --danger: #ef4036;
  --success: #4cc96c;
  --sky: #5fd5ff;

  --shadow-hard: 0 8px 0 rgba(0, 0, 0, 0.28);
  --shadow-soft: 0 18px 40px rgba(0, 0, 0, 0.28);

  --radius-panel: 32px;
  --radius-card: 22px;
  --radius-pill: 999px;

  --font-display: "Fredoka", system-ui, sans-serif;
  --font-body: "Nunito Sans", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  min-width: 0;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.30) 0 4%, transparent 5%),
    radial-gradient(circle at 78% 18%, rgba(255, 255, 255, 0.25) 0 3%, transparent 4%),
    radial-gradient(circle at 30% 72%, rgba(255, 255, 255, 0.18) 0 5%, transparent 6%),
    radial-gradient(circle at 75% 80%, rgba(255, 255, 255, 0.18) 0 4%, transparent 5%),
    radial-gradient(circle at 50% 50%, rgba(8, 114, 201, 0.20), transparent 42%),
    linear-gradient(135deg, var(--bg-1), var(--bg-2) 52%, var(--bg-3));
  background-attachment: fixed;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: -10%;
  pointer-events: none;
  background:
    radial-gradient(circle at 15% 30%, rgba(255, 255, 255, 0.22), transparent 16%),
    radial-gradient(circle at 85% 72%, rgba(255, 255, 255, 0.18), transparent 14%),
    radial-gradient(circle at 55% 20%, rgba(255, 255, 255, 0.15), transparent 12%);
  filter: blur(38px);
  opacity: 0.9;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.08;
  background-image:
    linear-gradient(45deg, rgba(255, 255, 255, 0.12) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.08) 25%, transparent 25%);
  background-size: 28px 28px;
  mix-blend-mode: soft-light;
}

.bg-orb {
  position: fixed;
  border-radius: 999px;
  filter: blur(60px);
  opacity: 0.34;
  pointer-events: none;
}

.orb-a {
  width: 260px;
  height: 260px;
  left: -60px;
  top: 10%;
  background: rgba(255, 255, 255, 0.25);
}

.orb-b {
  width: 300px;
  height: 300px;
  right: -90px;
  top: 12%;
  background: rgba(255, 238, 130, 0.18);
}

.orb-c {
  width: 220px;
  height: 220px;
  left: 40%;
  bottom: -60px;
  background: rgba(255, 255, 255, 0.18);
}

.hidden {
  display: none !important;
}

.screen {
  display: none;
}

.screen.active-screen,
.screen:not(.hidden) {
  display: grid;
}

h1,
h2,
h3,
h4,
h5,
h6,
.screen-title,
.section-title,
.hero-title,
.btn,
.room-code-value,
.step-index {
  font-family: var(--font-display);
  letter-spacing: 0.02em;
}

p {
  margin: 0;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: 100vw;
  height: 100dvh;
  padding: 12px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  position: relative;
  z-index: 1;
  overflow: hidden;
}

.panel,
.scoreboard,
.sidebar-panel,
.table-panel,
.hand-panel,
.lobby-panel,
.side-panel,
.lobby-room,
.slim-panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 24%),
    linear-gradient(135deg, var(--panel-2), var(--panel));
  border-radius: var(--radius-panel);
  border: 4px solid var(--line-dark);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    var(--shadow-soft);
  position: relative;
  overflow: hidden;
}

.panel::before,
.scoreboard::before,
.sidebar-panel::before,
.table-panel::before,
.hand-panel::before,
.lobby-panel::before,
.side-panel::before,
.lobby-room::before,
.slim-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.10;
  pointer-events: none;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.08) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.06) 25%, transparent 25%);
  background-size: 24px 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  min-height: 64px;
}

.slim-panel {
  border-radius: 26px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-logo {
  display: block;
  height: clamp(32px, 4.4vh, 52px);
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.18));
}

.eyebrow {
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  font-weight: 800;
}

.screen-title {
  margin: 4px 0 0;
  font-size: clamp(1.4rem, 2vw, 2rem);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.22);
}

.section-title {
  margin: 2px 0 0;
  font-size: clamp(1.05rem, 1.35vw, 1.4rem);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.18);
}

.hero-title {
  font-size: clamp(1.55rem, 3vw, 2.5rem);
  line-height: 1.02;
  margin: 8px 0 10px;
  max-width: 11ch;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.18);
}

.compact-hero .hero-title {
  max-width: 14ch;
}

.hero-text {
  color: var(--text-dim);
  max-width: 52ch;
  font-size: 0.96rem;
  line-height: 1.45;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.badge,
.player-chip,
.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: 3px solid var(--line-dark);
  color: #202020;
  font-weight: 800;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
  background: linear-gradient(180deg, #fffef8, #f3e8d0);
  font-size: 0.84rem;
}

.badge-yellow {
  background: linear-gradient(180deg, #ffe66a, #ffd21a);
}

.badge-light {
  background: linear-gradient(180deg, #fffefb, #fff8ec);
}

.badge-green {
  background: linear-gradient(180deg, #7df0ab, #4cc96c);
}

.btn {
  position: relative;
  min-height: 50px;
  padding: 10px 18px;
  border: 4px solid var(--line-dark);
  border-radius: 20px;
  color: #202020;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-hard);
  transition: transform 120ms ease, filter 120ms ease, box-shadow 120ms ease;
}

.btn:hover {
  transform: translateY(-2px) scale(1.01);
  filter: brightness(1.03);
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.28);
}

.btn::before {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 14px;
  border: 3px solid rgba(255, 255, 255, 0.95);
  pointer-events: none;
}

.btn-primary {
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.28), transparent 18%),
    radial-gradient(circle at 70% 70%, rgba(255, 255, 255, 0.14), transparent 24%),
    linear-gradient(180deg, #ffe14e, var(--yellow) 60%, var(--yellow-deep));
}

.btn-secondary {
  background: linear-gradient(180deg, #fffefb, var(--white-btn));
  color: #1f2320;
}

input {
  width: 100%;
  min-height: 48px;
  padding: 10px 16px;
  border-radius: 16px;
  border: 4px solid var(--line-dark);
  background: rgba(255, 249, 239, 0.96);
  color: #1c201c;
  font-family: var(--font-body);
  font-size: 0.96rem;
  font-weight: 800;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.65);
}

input::placeholder {
  color: #6c6b65;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text);
}

#lobbyScreen {
  height: 100%;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 12px;
  min-height: 0;
}

.lobby-layout {
  display: grid;
  grid-template-columns: 1.35fr 0.85fr;
  gap: 12px;
  min-height: 0;
}

.lobby-panel,
.side-panel,
.lobby-room,
.sidebar-panel,
.table-panel,
.hand-panel {
  padding: 18px;
}

.hero-lockup {
  margin-bottom: 18px;
}

.form-stack {
  display: grid;
  gap: 10px;
}

.cta-grid,
.join-grid,
.action-stack {
  display: grid;
  gap: 10px;
}

.join-panel {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 2px solid rgba(255, 255, 255, 0.1);
}

.side-panel-header,
.panel-head,
.table-head,
.lobby-room-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.steps-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.step-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border-radius: 20px;
  border: 3px solid rgba(0, 0, 0, 0.28);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
}

.step-card h4 {
  margin: 0 0 4px;
  font-size: 0.96rem;
}

.step-card p {
  color: var(--text-dim);
  line-height: 1.35;
  font-size: 0.9rem;
}

.step-index {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffe66a, #ffd21a);
  color: #1f221f;
  border: 3px solid var(--line-dark);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
  font-weight: 700;
}

.lobby-room {
  min-height: 0;
}

.room-code-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 3px solid rgba(0, 0, 0, 0.28);
  padding: 8px 12px;
  border-radius: 18px;
}

.room-code-label {
  color: var(--text-dim);
  font-weight: 800;
}

.room-code-value {
  font-size: 1.15rem;
  letter-spacing: 0.12em;
  color: var(--yellow);
}

.lobby-room-body {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 12px;
  margin-top: 14px;
  min-height: 0;
}

.players-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  max-height: 100%;
  overflow: hidden;
}

.player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 18px;
  border: 3px solid rgba(0, 0, 0, 0.28);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
}

.player-row-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.player-avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #7ad9ff, #53b9e6);
  color: #17232a;
  border: 3px solid var(--line-dark);
  font-weight: 800;
}

.player-name {
  font-weight: 800;
  font-size: 0.96rem;
}

.player-meta {
  color: var(--text-dim);
  font-size: 0.84rem;
}

.side-note {
  color: var(--text-dim);
  line-height: 1.4;
  font-size: 0.9rem;
}

#gameScreen {
  height: 100%;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 12px;
}

.info-card {
  margin: 12px 0;
  padding: 14px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  border: 3px solid rgba(0, 0, 0, 0.28);
}

.info-label {
  display: block;
  color: var(--text-dim);
  margin-bottom: 8px;
  font-weight: 800;
}

.papayoo-badge {
  min-height: 58px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: #1f221f;
  border: 4px solid var(--line-dark);
  background: linear-gradient(180deg, #ffe66a, #ffd21a);
  box-shadow: var(--shadow-hard);
}

.table-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.table-head {
  margin-bottom: 12px;
}

.game-table {
  position: relative;
  min-height: 0;
  height: 100%;
  border-radius: 38px;
  border: 5px solid rgba(20, 28, 20, 0.72);
  background:
    radial-gradient(circle at 50% 46%, rgba(255, 255, 255, 0.18), transparent 24%),
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.08), transparent 40%),
    linear-gradient(180deg, #31c38a, #1ca76c 46%, #148458);
  box-shadow:
    inset 0 0 0 8px rgba(255, 255, 255, 0.14),
    inset 0 -18px 36px rgba(0, 0, 0, 0.16),
    var(--shadow-soft);
  overflow: hidden;
}

.game-table::before {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: 28px;
  border: 3px dashed rgba(255, 255, 255, 0.22);
  pointer-events: none;
}

.player-seats {
  position: absolute;
  inset: 0;
}

.player-seat {
  position: absolute;
  min-width: 132px;
  max-width: 200px;
  padding: 10px 12px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(49, 56, 49, 0.96), rgba(35, 41, 35, 0.96));
  border: 4px solid var(--line-dark);
  box-shadow: var(--shadow-hard);
  text-align: center;
  z-index: 5;
  overflow: visible;
}

.player-seat .seat-name,
.player-seat .seat-meta {
  position: relative;
  z-index: 1;
}

.player-seat.has-played .seat-name,
.player-seat.has-played .seat-meta {
  opacity: 0.18;
}

.seat-played-card {
  position: absolute;
  left: 50%;
  top: 50%;
  width: clamp(66px, 6.7vw, 96px);
  transform: translate(-50%, -50%);
  z-index: 10;
  pointer-events: none;
  filter: drop-shadow(0 10px 10px rgba(0, 0, 0, 0.26));
}

.trick-center {
  display: none;
}

.trick-card {
  position: absolute;
  width: clamp(66px, 6.7vw, 96px);
  transition: transform 180ms ease, left 180ms ease, top 180ms ease;
  filter: drop-shadow(0 10px 10px rgba(0, 0, 0, 0.26));
}


.hand-panel {
  margin-top: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: visible;
}

.hand-cards {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  align-items: flex-end;
  margin-top: 14px;
  padding-top: 14px;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: visible;
}

.card {
  width: clamp(62px, 5.6vw, 84px);
  border-radius: 18px;
  overflow: hidden;
  box-shadow:
    0 10px 18px rgba(0, 0, 0, 0.24),
    0 0 0 3px rgba(22, 22, 22, 0.22);
  transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease, filter 120ms ease;
  cursor: pointer;
  flex: 0 0 auto;
}

.card.playable:hover {
  transform: translateY(-12px) rotate(-1deg) scale(1.02) !important;
  box-shadow:
    0 16px 28px rgba(0, 0, 0, 0.28),
    0 0 0 4px rgba(255, 210, 26, 0.5) !important;
  z-index: 3;
}

.card.selected {
  transform: translateY(-24px) rotate(-2deg) scale(1.05) !important;
  box-shadow:
    0 24px 40px rgba(0, 0, 0, 0.38),
    0 0 0 6px rgba(95, 213, 255, 0.82) !important;
  z-index: 10 !important;
}


.card.not-playable {
  opacity: 0.58;
  filter: grayscale(0.08);
  cursor: default;
}

.game-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
}

.sidebar-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  min-height: 0;
}

.scoreboard {
  margin-top: 12px;
  padding: 14px;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

#scoreboardList {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.35) rgba(0, 0, 0, 0.15);
}

#scoreboardList::-webkit-scrollbar {
  width: 8px;
}

#scoreboardList::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.14);
  border-radius: 999px;
}

#scoreboardList::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.28);
  border-radius: 999px;
}

#scoreboardList::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.4);
}

.score-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 2px solid rgba(255, 255, 255, 0.08);
  font-variant-numeric: tabular-nums lining-nums;
}

.score-row:last-child {
  border-bottom: none;
}

.score-name {
  font-weight: 800;
  font-size: 0.92rem;
}

.score-pill {
  min-width: 58px;
  text-align: center;
  padding: 5px 8px;
  border-radius: 999px;
  border: 3px solid var(--line-dark);
  background: linear-gradient(180deg, #fffef8, #f3e8d0);
  color: #1f221f;
  font-weight: 800;
  font-size: 0.82rem;
}

.table-message {
  position: fixed;
  left: 50%;
  top: 8%;
  transform: translateX(-50%);
  z-index: 30;
  min-width: min(72vw, 420px);
  max-width: min(86vw, 560px);
  padding: 12px 18px;
  border-radius: 22px;
  border: 4px solid var(--line-dark);
  background:
    radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.28), transparent 22%),
    radial-gradient(circle at 72% 72%, rgba(255, 255, 255, 0.14), transparent 28%),
    linear-gradient(180deg, #ffe66a, #ffd21a 62%, #f0b900);
  color: #1f221f;
  text-align: center;
  box-shadow:
    0 16px 28px rgba(0, 0, 0, 0.22),
    0 8px 0 rgba(0, 0, 0, 0.24);
  font-family: var(--font-display);
  font-size: clamp(0.98rem, 1.5vw, 1.18rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  animation: popBanner 220ms ease;
}

.table-message::before {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 16px;
  border: 3px solid rgba(255, 255, 255, 0.92);
  pointer-events: none;
}

.table-message.info {
  background:
    radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.28), transparent 22%),
    radial-gradient(circle at 72% 72%, rgba(255, 255, 255, 0.14), transparent 28%),
    linear-gradient(180deg, #ffe66a, #ffd21a 62%, #f0b900);
  color: #1f221f;
  box-shadow:
    0 16px 28px rgba(0, 0, 0, 0.22),
    0 8px 0 rgba(0, 0, 0, 0.24);
}

.table-message.error {
  background:
    radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.20), transparent 22%),
    radial-gradient(circle at 72% 72%, rgba(255, 255, 255, 0.10), transparent 28%),
    linear-gradient(180deg, #ff8b7f, #ef4036 70%, #cf2e24);
  color: #fffdfb;
  box-shadow:
    0 16px 28px rgba(0, 0, 0, 0.24),
    0 8px 0 rgba(0, 0, 0, 0.26);
}

.table-message.info {
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.28),
    0 0 0 6px rgba(255, 210, 26, 0.16);
}

.table-message.error {
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.28),
    0 0 0 6px rgba(239, 64, 54, 0.16);
}

@keyframes popBanner {
  from {
    opacity: 0;
    transform: translateX(-50%) scale(0.92);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) scale(1);
  }
}

@media (max-width: 1180px) {

  .lobby-layout,
  .lobby-room-body,
  .game-layout {
    grid-template-columns: 1fr;
  }

  #scoreboardList {
    max-height: 220px;
  }

  .app-shell,
  #lobbyScreen,
  #gameScreen {
    overflow-y: auto;
  }

  html,
  body {
    overflow: auto;
  }
}

@media (max-width: 900px) {
  .app-shell {
    padding: 8px;
    gap: 8px;
  }

  .topbar,
  .lobby-panel,
  .side-panel,
  .lobby-room,
  .sidebar-panel,
  .table-panel,
  .hand-panel {
    padding: 14px;
  }

  .game-table {
    min-height: 420px;
  }

  .player-seat {
    min-width: 104px;
    max-width: 150px;
    padding: 8px 10px;
  }

  .card {
    width: 68px;
  }

  .topbar {
    padding: 6px 10px;
    min-height: 56px;
  }

  .brand-logo {
    height: 30px;
  }

  .table-message {
    top: 7%;
    padding: 10px 14px;
    max-width: 92vw;
  }
}

.hand-cards .card {
  position: relative;
}

.card.papayoo-card>* {
  position: relative;
  z-index: 1;
}

.card.papayoo-card.not-playable {
  opacity: 0.64;
  filter: saturate(0.92);
}

.card.papayoo-card.playable:hover {
  transform: translateY(-12px) rotate(-1deg) scale(1.02) !important;
  box-shadow:
    0 18px 30px rgba(0, 0, 0, 0.30),
    0 0 0 4px rgba(255, 210, 26, 0.55) !important;
  z-index: 4;
}