@import url("https://fonts.googleapis.com/css2?family=SF+Pro+Display:wght@400;500;600&family=SF+Pro+Text:wght@400;500&display=swap");

:root {
  color-scheme: dark;
  --bg-1: #02040b;
  --bg-2: #050b1f;
  --glass: rgba(255, 255, 255, 0.08);
  --glass-strong: rgba(11, 16, 30, 0.65);
  --text: #f4f7ff;
  --muted: rgba(255, 255, 255, 0.7);
  --accent: #8ae7ff;
  --chip: rgba(255, 255, 255, 0.16);
  --shadow: rgba(3, 6, 17, 0.55);
  --border: rgba(255, 255, 255, 0.12);
  --card-radius: 26px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top, #07112f, var(--bg-1));
  overflow-x: hidden;
}

body.mobile-optimized {
  height: 100vh;
  overflow: hidden;
}

body.mobile-optimized .app-container {
  width: 100%;
  max-width: none;
  height: 100%;
}

.hero-title {
  position: relative;
  z-index: 1;
  width: min(1200px, 100%);
  margin: 0 auto;
  text-align: center;
  padding-top: 2rem;
  font-family: "SF Pro Display", "SF Pro Text", sans-serif;
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 600;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.9);
}

.app-container {
  position: relative;
  z-index: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.liquid-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: radial-gradient(circle at top right, rgba(53, 149, 255, 0.35), transparent 35%),
    radial-gradient(circle at 20% 20%, rgba(255, 90, 142, 0.35), transparent 45%);
}

.orb {
  position: absolute;
  width: 55vw;
  height: 55vw;
  max-width: 900px;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.65;
  animation: float 24s ease-in-out infinite;
}

.orb-one {
  top: -10%;
  left: -5%;
  background: linear-gradient(135deg, #6ec6ff, #b18cff);
}

.orb-two {
  top: 30%;
  right: -15%;
  background: linear-gradient(120deg, #ff7db1, #ffc463);
  animation-delay: 4s;
}

.orb-three {
  bottom: -15%;
  left: 10%;
  background: linear-gradient(140deg, #6ef7c8, #79b6ff);
  animation-delay: 8s;
}

.grid-overlay {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 160px 160px;
  opacity: 0.2;
}

@keyframes float {
  0% {
    transform: translate3d(0, 0, 0);
  }

  50% {
    transform: translate3d(0, -40px, 0) scale(1.05);
  }

  100% {
    transform: translate3d(0, 0, 0);
  }
}

.liquid-shell {
  position: relative;
  z-index: 1;
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 2.5rem clamp(1rem, 4vw, 3rem) 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

h1,
h2,
h3 {
  font-family: "SF Pro Display", "SF Pro Text", sans-serif;
  margin: 0;
  font-weight: 600;
}

p {
  margin: 0.2rem 0 1rem;
  color: var(--muted);
}

.panel {
  border-radius: 32px;
  padding: clamp(1.5rem, 2vw, 2.5rem);
}

.glass-panel {
  background: linear-gradient(130deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03));
  border: 1px solid var(--border);
  backdrop-filter: blur(40px);
  box-shadow: 0 40px 80px var(--shadow);
  border-radius: 40px;
}

.glass-panel.subtle {
  background: rgba(6, 10, 25, 0.65);
  box-shadow: 0 20px 60px rgba(2, 4, 9, 0.4);
}

.entry-panel {
  margin-bottom: 0.5rem;
}

.hidden {
  display: none !important;
}

form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

input {
  padding: 0.9rem 1.3rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
  font-size: 1rem;
  backdrop-filter: blur(20px);
}

button {
  border: none;
  border-radius: 999px;
  padding: 0.85rem 1.8rem;
  font-size: 1rem;
  cursor: pointer;
  color: #04060e;
  font-weight: 600;
  background: linear-gradient(135deg, #fef5ff, #8ae7ff);
  box-shadow: 0 15px 30px rgba(138, 231, 255, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

button:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 20px 30px rgba(138, 231, 255, 0.4);
}

.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: none;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.header-actions {
  display: flex;
  gap: 0.6rem;
}

.lobby-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
}

.waiting-list,
.selection,
.invites {
  border-radius: 26px;
  background: rgba(8, 12, 22, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 1.6rem;
  min-height: 200px;
  backdrop-filter: blur(30px);
}

.grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.8rem;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}

.mode-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  text-align: left;
  padding: 1.5rem;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
  height: 100%;
  width: 100%;
}

.mode-card:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-4px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.mode-card h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--accent);
}

.mode-card p {
  font-size: 0.9rem;
  margin: 0;
  color: var(--muted);
}

.bot-count-selector {
  display: flex;
  gap: 0.8rem;
  margin: 1rem 0 2rem;
}

.bot-btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  box-shadow: none;
}

.bot-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

.bot-btn.active {
  background: var(--accent);
  color: #02040b;
  border-color: var(--accent);
  font-weight: 700;
}

.primary-action {
  width: 100%;
  padding: 1rem;
  font-size: 1.1rem;
}

.setup-content {
  display: flex;
  flex-direction: column;
  max-width: 400px;
  margin: 0 auto;
}

.player-chip {
  padding: 0.55rem 1.2rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
  transition: border 0.2s ease, transform 0.2s ease;
}

.player-chip.active {
  border-color: rgba(255, 255, 255, 0.7);
  transform: translateY(-2px);
}

.player-chip.locked {
  opacity: 0.4;
  cursor: not-allowed;
}

.invite-card {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 18px;
  padding: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.invite-actions {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin-top: 1rem;
}

.invite-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.invite-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
}

.status-pill {
  font-size: 0.78rem;
  padding: 0.15rem 0.65rem;
  border-radius: 999px;
  text-transform: uppercase;
}

.status-pending {
  background: rgba(255, 198, 92, 0.18);
  color: #ffce6b;
}

.status-accepted {
  background: rgba(108, 237, 190, 0.2);
  color: #6dedbe;
}

.status-declined {
  background: rgba(255, 104, 135, 0.2);
  color: #ff6787;
}

.table-board {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.table-middle {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(240px, 1.2fr) minmax(140px, 1fr);
  gap: 1.5rem;
  align-items: stretch;
}

.opponent-belt,
.opponent-column {
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 36px;
  padding: 0.85rem;
  overflow: hidden;
}

.opponent-belt .opponent-card {
  max-width: 360px;
}

.opponent-column.side {
  min-height: 320px;
}

.opponent-card {
  width: 100%;
  text-align: center;
  padding: 1.1rem;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.01));
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.opponent-card.current {
  border-color: rgba(255, 255, 255, 0.45);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.35);
}

.opponent-card.empty {
  opacity: 0.4;
  font-style: italic;
}

.opponent-name {
  font-weight: 600;
}

.stack-visual {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
}

.stack-card {
  width: 26px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(145deg, #0b1019, #090c13);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.45);
}

.stack-placeholder {
  width: 60px;
  height: 90px;
  border-radius: 18px;
  border: 1px dashed rgba(255, 255, 255, 0.08);
}

.opponent-extra {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.12);
}

.center-arena {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
  border-radius: 40px;
  padding: 1.7rem;
}


.discard-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.discard-area.solo {
  align-items: center;
  justify-content: center;
  min-height: 260px;
}

.player-hand {
  padding: 1.2rem 1.5rem 1.6rem;
  border-radius: 38px;
  overflow: visible;
  position: relative;
}

.hand-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.3rem;
}

/* Hiding unnecessary header bar in Round only */
#round .section-header {
  display: none !important;
}

.hand-scroll {
  /* Allow vertical scroll for grid */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.9rem 0.5rem;
  position: relative;
  z-index: 1;
  max-height: 45vh;
  /* reasonable limit */
}

.hand-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.8rem;
  width: 100%;
  justify-items: center;
}


.card {
  position: relative;
  border-radius: var(--card-radius);
  padding: 0;
  width: 100%;
  /* Fill grid cell */
  min-height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #050505;
  font-weight: 600;
  border: none;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35), 0 25px 45px rgba(0, 0, 0, 0.45);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}

.card::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: calc(var(--card-radius) - 6px);
  border: 2px solid rgba(255, 255, 255, 0.25);
  pointer-events: none;
}

.card .card-value {
  font-size: 0.95rem;
  padding: 0.8rem;
}

.card-value-top {
  align-self: flex-start;
}

.card-value-bottom {
  align-self: flex-end;
  transform: rotate(180deg);
}

.card .card-symbol {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.2rem;
  letter-spacing: 0.04em;
}

.card.hand-card:not(.disabled) {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

@media (hover: hover) {
  .card.hand-card:not(.disabled):hover {
    transform: translateY(-12px) scale(1.03);
    box-shadow: 0 35px 50px rgba(0, 0, 0, 0.45);
    z-index: 3;
    cursor: pointer;
  }
}

.hand-card {
  background: rgba(255, 255, 255, 0.9);
  border: none;
  position: relative;
}

.hand-card.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.display-card {
  width: 160px;
  min-height: 230px;
  margin: 0 auto;
}

.color-indicator {
  margin-top: 1.2rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

#color-chip {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.3);
}

.player-list ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.round-player {
  display: flex;
  justify-content: space-between;
  padding: 0.7rem 0.9rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid transparent;
}

.round-player.current {
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 16, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  /* Max Z for visibility */
  backdrop-filter: blur(20px);
}

.overlay-content {
  background: rgba(11, 16, 30, 0.85);
  border-radius: 28px;
  padding: 2rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.55);
  max-width: 90%;
  /* Safety for mobile */
}

.color-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(80px, 1fr));
  gap: 0.85rem;
  margin: 1.2rem 0;
}

.color-btn {
  font-weight: 600;
  color: #04060e;
}

.color-btn.red {
  background: linear-gradient(120deg, #ff6b6b, #ff2c5b);
}

.color-btn.yellow {
  background: linear-gradient(120deg, #ffe66d, #ffc048);
}

.color-btn.green {
  background: linear-gradient(120deg, #5ef2c1, #1ddb86);
}

.color-btn.blue {
  background: linear-gradient(120deg, #69c3ff, #327bff);
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 14, 25, 0.85);
  padding: 0.95rem 1.3rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.toast.show {
  opacity: 1;
}

.color-red {
  background: linear-gradient(145deg, #ff6161, #ff2d5d);
}

.color-yellow {
  background: linear-gradient(145deg, #ffe066, #ffb347);
}

.color-green {
  background: linear-gradient(145deg, #3fe0a6, #13c779);
}

.color-blue {
  background: linear-gradient(145deg, #5bb0ff, #2874ff);
}

.color-black {
  background: linear-gradient(145deg, #f5f5f5, #bfc4d2);
}

ol {
  padding-left: 1.2rem;
}

.mobile-count-banner {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 28px;
  background: rgba(5, 8, 18, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  flex-wrap: wrap;
}

.mobile-count-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 70px;
  padding: 0.4rem 0.75rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
}

.mobile-count-chip.active {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(138, 231, 255, 0.35);
}

.mobile-count-value {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.1;
}

.mobile-count-name {
  font-size: 0.75rem;
  color: var(--muted);
}

.mobile-count-placeholder {
  width: 100%;
  text-align: center;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  color: var(--muted);
}

/* Old mobile-card-counts rule removed to allow universal top bar */

/* Global/Shared Top Bar Styling (Desktop & Mobile) */
.mobile-count-banner {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.8rem;
  padding: 0.5rem 1rem;
  margin: 0;
  background: rgba(12, 18, 32, 0.85) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
  width: 100%;
  z-index: 20;
  backdrop-filter: blur(20px);
  border-radius: 16px;
  /* Rounded for desktop */
  margin-bottom: 2rem;
  /* Desktop spacing */
}

@media (max-width: 640px) {
  .mobile-count-banner {
    border-radius: 0 0 16px 16px;
    margin-bottom: 0.5rem;
    position: relative;
  }
}

.mobile-chips-scroll {
  /* Swap position: Chips First */
  order: 1;
  display: flex;
  flex: 0 1 auto;
  gap: 0.6rem;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.2rem 0;
  -webkit-overflow-scrolling: touch;
  align-items: center;
  max-width: 45%;
}

.mobile-chips-scroll::-webkit-scrollbar {
  height: 0;
  background: transparent;
}

.mobile-status-label {
  /* Swap position: Status Middle */
  order: 2;
  flex: 1;
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0 0.5rem;
}

.mobile-exit-btn {
  order: 3;
}

.mobile-count-chip {
  flex: 0 0 auto;
  min-width: auto;
  padding: 0.35rem 0.7rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  transition: all 0.2s ease;
}

.mobile-count-chip.active {
  background: rgba(138, 231, 255, 0.1);
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(138, 231, 255, 0.15);
}

.mobile-count-value {
  font-size: 1rem;
  line-height: 1;
  font-weight: 700;
}

.mobile-count-name {
  font-size: 0.65rem;
  max-width: 60px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.8;
}

@media (max-width: 640px) {
  :root {
    --card-radius: 14px;
  }

  body.mobile-optimized {
    height: 100dvh;
    overflow: hidden;
    position: fixed;
    /* Prevent bouncy scroll on iOS */
    inset: 0;
  }

  body.mobile-optimized .liquid-bg {
    background: radial-gradient(circle at top, #0b1221, #000000);
  }

  body.mobile-optimized .app-container {
    height: 100%;
    width: 100%;
    max-width: none;
    padding: 0;
    display: flex;
    flex-direction: column;
  }

  body.mobile-optimized .hero-title {
    display: none;
    /* Hide main title to save space on mobile game */
  }

  /* Main Shell uses Flex to fill height */
  body.mobile-optimized .liquid-shell {
    padding: 0.5rem;
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0;
    margin: 0;
    overflow: hidden;
  }

  body.mobile-optimized #round {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
  }

  /* Top Bar: Opponent Counts */





  /* Hide Desktop Opponents & Header */
  .mobile-exit-btn {
    display: flex;
  }

  .section-header,
  .opponent-belt,
  .opponent-column,
  #mobile-players {
    display: none !important;
  }

  /* Center Arena: Play Area */
  .table-board {
    flex: 1;
    /* Take up all remaining space */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 0;
    /* Allow shrinking */
    gap: 0;
    width: 100%;
  }

  .table-middle {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    grid-template-columns: none;
  }

  .center-arena {
    padding: 0;
    width: 100%;
    max-width: 360px;
    height: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1rem;
    background: transparent;
    box-shadow: none;
    border: none;
  }

  .discard-area.solo {
    min-height: auto;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
  }

  /* Responsive Display Card */
  .display-card {
    width: 140px;
    /* Slightly larger for visibility */
    min-height: 200px;
    max-height: 45vh;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    z-index: 5;
  }

  .display-card .card-value {
    font-size: 1.1rem;
    padding: 0.6rem;
  }

  .display-card .card-symbol {
    font-size: 4rem;
  }

  .color-indicator {
    margin: 0;
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 99px;
    backdrop-filter: blur(10px);
  }

  /* Action Buttons */
  .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    width: 100%;
    padding: 0 1rem;
    margin-bottom: 0.5rem;
  }

  .actions button {
    padding: 1rem;
    font-size: 1rem;
    border-radius: 16px;
  }

  /* Player Hand: Pinned Bottom */
  .player-hand {
    flex: 0 0 auto;
    width: 100%;
    /* Allow it to grow up to ~35% of screen but not more to keep board visible */
    max-height: 40vh;
    background: rgba(15, 20, 35, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px 20px 0 0;
    padding: 0.8rem 0.5rem 1.2rem 0.5rem;
    z-index: 10;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
  }

  .hand-header {
    display: flex;
    justify-content: center;
    padding-bottom: 0.5rem;
    color: var(--muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  .hand-header h3 {
    font-size: 0.9rem;
    opacity: 0.8;
  }

  .hand-scroll {
    overflow-x: hidden;
    overflow-y: auto;
    /* Vertical scroll if too many cards */
    white-space: normal;
    padding: 0.2rem;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    height: auto;
    display: block;
    /* Normal block flow for wrapping */
  }

  .hand-grid {
    display: grid;
    /* Adaptive Value: 65px min to fit ~5 cards per row on typical phones */
    grid-template-columns: repeat(auto-fill, minmax(65px, 1fr));
    gap: 0.5rem;
    width: 100%;
    justify-content: center;
    padding-bottom: 1rem;
  }

  .card.hand-card {
    width: 100%;
    /* Fill grid cell */
    min-width: 0;
    aspect-ratio: 2/3;
    height: auto;
    min-height: 0;
    margin: 0;
    /* No overlap in grid */
    transition: transform 0.1s ease;
    border-radius: 10px;
    flex-shrink: 0;
  }

  /* Remove overlap reset */
  .card.hand-card:last-child {
    margin-right: 0;
  }

  .card.hand-card:not(.disabled):active {
    transform: scale(0.95);
  }

  .card.hand-card .card-value {
    font-size: 0.75rem;
    padding: 0.2rem;
  }

  .card.hand-card .card-symbol {
    font-size: 1.8rem;
  }

  .card.hand-card:focus {
    z-index: 50;
    transform: scale(1.05);
    /* Highlight slightly */
    outline: 2px solid var(--accent);
  }

  /* Overlay / Color Picker Fixes */
  .overlay-content {
    width: 90%;
    max-width: 320px;
    padding: 1.5rem;
  }

  /* Start/Lobby Styles on Mobile */
  body.mobile-optimized #lobby {
    overflow-y: auto;
    /* Allow scroll in lobby */
    padding-bottom: 2rem;
    display: block;
    height: 100%;
  }

  body.mobile-optimized #lobby .lobby-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-bottom: 2rem;
  }

  body.mobile-optimized .invites {
    order: -1;
  }

  /* Mobile Exit Button */
  .mobile-exit-btn {
    position: absolute;
    top: 0.8rem;
    right: 0.8rem;
    z-index: 50;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 60, 60, 0.2);
    border: 1px solid rgba(255, 60, 60, 0.3);
    color: #ff6b6b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    padding: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: pointer;
  }

  .mobile-exit-btn:active {
    background: rgba(255, 60, 60, 0.4);
    transform: scale(0.95);
  }

  .mobile-status-text {
    text-align: center;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.3rem;
    color: var(--muted);
    transition: color 0.3s ease;
  }

  .mobile-status-text.my-turn {
    color: var(--accent);
    font-size: 1.1rem;
    text-shadow: 0 0 10px rgba(138, 231, 255, 0.4);
  }
}


/* Scrollbar styling for hand */
.hand-scroll::-webkit-scrollbar {
  height: 4px;
}

.hand-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.hand-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

#round {
  position: relative;
}

.desktop-exit-btn {
  position: absolute;
  top: 1rem;
  left: 1.5rem;
  z-index: 50;
  padding: 0.6rem 1.4rem;
  font-size: 0.95rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  color: var(--muted);
  transition: all 0.2s ease;
}

.desktop-exit-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text);
  transform: translateY(-1px);
}

@media (max-width: 640px) {
  .desktop-exit-btn {
    display: none;
  }
}.speed-control {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem 1rem;
    border-radius: 99px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
}

.speed-control label {
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 500;
    white-space: nowrap;
}

.speed-control input[type="range"] {
    width: 100px;
    height: 4px;
    border-radius: 2px;
    appearance: none;
    background: rgba(255, 255, 255, 0.2);
    outline: none;
    padding: 0;
    border: none;
}

.speed-control input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    transition: transform 0.1s;
}

.speed-control input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

@media (min-width: 641px) {
    .mobile-count-banner {
        padding-left: 9rem;
        padding-right: 15rem;
    }
}

@media (max-width: 640px) {
    .speed-control {
        position: relative;
        top: auto;
        right: auto;
        width: 100%;
        margin-bottom: 0.5rem;
        background: rgba(0, 0, 0, 0.2);
        justify-content: center;
    }
}