@font-face {
  font-family: 'Bungee';
  src: url('../assets/fonts/Bungee-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: block;
}

@font-face {
  font-family: 'Poppins';
  src: url('../assets/fonts/Poppins-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: block;
}

@font-face {
  font-family: 'Poppins';
  src: url('../assets/fonts/Poppins-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: block;
}

@font-face {
  font-family: 'Poppins';
  src: url('../assets/fonts/Poppins-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: block;
}

@font-face {
  font-family: 'Poppins';
  src: url('../assets/fonts/Poppins-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: block;
}

:root {
  --overlay-world-top: #071a0f;
  --overlay-world-mid: #030e07;
  --overlay-world-bottom: #010805;
  --overlay-surface: rgba(4, 18, 10, 0.97);
  --overlay-surface-strong: rgba(2, 11, 6, 0.98);
  --overlay-line: rgba(0, 200, 110, 0.18);
  --overlay-shadow: rgba(0, 0, 0, 0.65);
  --overlay-ink: #b8f0cc;
  --overlay-ink-inverse: #efffd3;
  --overlay-accent: #d8ff72;
  --overlay-accent-soft: #5adb8e;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #01110c;
  font-family: 'Poppins', Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  position: relative;
}

img {
  display: block;
}

button {
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

.hidden {
  display: none !important;
}

.screen-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px 18px;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 50% -6%, rgba(0, 180, 80, 0.08), transparent 34%),
    radial-gradient(circle at 50% 108%, rgba(0, 140, 60, 0.10), transparent 42%),
    linear-gradient(180deg, var(--overlay-world-top) 0%, var(--overlay-world-mid) 43%, var(--overlay-world-bottom) 100%);
  background-repeat: no-repeat;
}

.screen-overlay::before {
  content: '';
  position: absolute;
  inset: 14px;
  border-radius: 34px;
  background:
    radial-gradient(circle at top center, rgba(0, 200, 100, 0.05), transparent 30%),
    linear-gradient(180deg, rgba(0, 80, 30, 0.04) 0%, rgba(0, 0, 0, 0.08) 100%);
  box-shadow:
    inset 0 0 0 1px rgba(0, 200, 100, 0.08),
    inset 0 0 0 7px rgba(0, 30, 12, 0.14),
    inset 0 16px 36px rgba(0, 100, 40, 0.04),
    inset 0 -28px 42px rgba(0, 0, 0, 0.22);
  pointer-events: none;
}

.boot-screen {
  z-index: 80;
}

.overlay-card {
  position: relative;
  z-index: 1;
  width: min(300px, 60vw);
  max-height: 60vh;
  overflow-y: auto;
  background:
    linear-gradient(180deg, rgba(8, 30, 16, 0.97) 0%, var(--overlay-surface) 100%);
  border-radius: 24px;
  padding: 28px 28px 32px;
  box-shadow:
    0 28px 60px var(--overlay-shadow),
    inset 0 1px 0 rgba(0, 200, 100, 0.10);
  border: 1px solid rgba(0, 180, 80, 0.18);
  color: var(--overlay-ink);
  text-align: center;
}

.overlay-card--brand,
.overlay-card--ready {
  background:
    linear-gradient(180deg, rgba(5, 22, 12, 0.98) 0%, var(--overlay-surface-strong) 55%, rgba(2, 9, 5, 0.99) 100%);
  color: var(--overlay-ink-inverse);
  border-color: var(--overlay-line);
  box-shadow:
    0 30px 70px rgba(0, 0, 0, 0.65),
    inset 0 1px 0 rgba(0, 220, 110, 0.10);
}

.overlay-card h1,
.overlay-card h2 {
  font-family: 'Bungee', sans-serif;
  letter-spacing: 0.04em;
  line-height: 1;
}

.overlay-card h1 {
  font-size: clamp(24px, 6vw, 38px);
  color: var(--overlay-accent);
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
}

.overlay-card h2 {
  font-size: 26px;
  margin-bottom: 12px;
}

.overlay-card p {
  font-size: 15px;
  color: inherit;
  opacity: 0.92;
}

.overlay-suits {
  font-size: 24px;
  color: #b8ff8a;
  letter-spacing: 10px;
  margin-bottom: 10px;
  opacity: 0.84;
}

.overlay-caption {
  margin-top: 14px;
  font-size: 12px;
  letter-spacing: 0.04em;
  opacity: 0.85;
}

.overlay-spinner {
  width: 42px;
  height: 42px;
  margin: 18px auto 0;
  border-radius: 50%;
  border: 4px solid rgba(56, 123, 82, 0.18);
  border-top-color: #3da96d;
  animation: spin 1s linear infinite;
}

.ready-label {
  font-family: 'Bungee', sans-serif;
  font-size: 18px;
  letter-spacing: 0.1em;
  color: #bef875;
}

.ready-count {
  font-family: 'Bungee', sans-serif;
  font-size: clamp(36px, 10vw, 64px);
  line-height: 1;
  color: #f0ffd0;
  text-shadow: 0 8px 18px rgba(2, 16, 12, 0.38);
  margin: 8px 0 4px;
}

.loading-track {
  width: 100%;
  height: 10px;
  margin-top: 18px;
  background: #112811;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid #2d6b2d;
}

.loading-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4ade80, #86efac);
  border-radius: 999px;
  transition: width 0.15s ease;
}

.game-screen {
  position: fixed;
  inset: 0;
  background: #01110c;
  display: none;
}

.game-screen.active {
  display: block;
}

.shell-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #01110c;
}

.shell-fit {
  position: relative;
  width: 471px;
  height: 844px;
  flex: 0 0 auto;
}

.phone {
  width: 471px;
  height: 844px;
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: top left;
  overflow: hidden;
}

.game-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: url('../assets/ui/GameBG.png') center/cover no-repeat;
}

.opp-zone {
  position: absolute;
  z-index: 2;
  top: 0;
  left: 0;
  right: 0;
  height: 152px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 8px 8px;
  gap: 4px;
}

.opp-module {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
  max-width: 78px;
  transition: opacity 0.2s ease;
}

.opp-module.disconnected {
  opacity: 0.45;
}

.opp-name-wrap {
  position: relative;
  width: 68px;
  height: 24px;
  display: grid;
  place-items: center;
}

.opp-name-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.opp-name-text {
  position: relative;
  width: 86%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: center;
  font-family: 'Bungee', sans-serif;
  font-size: 9px;
  line-height: 1;
  color: #9fd52c;
  text-shadow: 0 2px 0 rgba(2, 23, 16, 0.46);
}

.opp-avatar-wrap {
  position: relative;
  width: 62px;
  height: 62px;
}

.opp-timer-svg {
  position: absolute;
  inset: -5px;
  width: calc(100% + 10px);
  height: calc(100% + 10px);
  transform: rotate(-90deg);
  pointer-events: none;
  z-index: 2;
}

.arc-track {
  stroke: rgba(255,255,255,0.12);
}

.arc-fill {
  stroke: #4ade80;
  transition: stroke-dashoffset 0.25s linear;
}

.opp-avatar-shell {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid #9fd52c;
  background: radial-gradient(circle at 40% 34%, rgba(239,255,239,0.98) 0%, rgba(209,243,210,0.95) 54%, rgba(179,217,170,0.78) 100%);
  box-shadow: 0 8px 18px rgba(0,0,0,0.32), inset 0 0 0 1.5px rgba(0,0,0,0.08);
  display: grid;
  place-items: center;
}

.opp-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.opp-active-ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2.5px solid transparent;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  pointer-events: none;
  z-index: 3;
}

.opp-module.active .opp-active-ring {
  border-color: #4ade80;
  box-shadow: 0 0 12px rgba(74, 222, 128, 0.6);
}

.opp-count-wrap {
  position: absolute;
  bottom: -5px;
  left: -7px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.opp-count-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.opp-count {
  position: relative;
  font-family: 'Poppins', sans-serif;
  font-weight: 800;
  font-size: 12px;
  line-height: 1;
  color: #ddff9f;
  text-shadow: 0 2px 0 rgba(9, 88, 50, 0.9), 0 5px 10px rgba(0, 0, 0, 0.28);
}

.table-zone {
  position: absolute;
  z-index: 2;
  top: 152px;
  left: 0;
  right: 0;
  height: 432px;
}

.market-col {
  position: absolute;
  left: 16%;
  top: 58%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.market-stack {
  position: relative;
  width: 76px;
  height: 117px;
}

.mcard {
  position: absolute;
  width: 76px;
  height: 117px;
  border-radius: 7px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
  object-fit: cover;
  transition: opacity 0.2s ease;
}

.mc2 { transform: translate(-3px, -5px) rotate(-4deg); }
.mc1 { transform: translate(0, -2px) rotate(1.5deg); }
.mc0 { transform: none; }

.mcount-wrap {
  position: absolute;
  top: -10px;
  left: -10px;
  width: 44px;
  height: 44px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mcount-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.mcount-text {
  position: relative;
  font-family: 'Bungee', sans-serif;
  font-size: 14px;
  line-height: 1;
  color: #f4ffca;
  text-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

.market-anchor {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 76px;
  height: 117px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

 .discard-col {
  position: absolute;
  left: 50%;
  top: 58%;
  transform: translate(-50%, -50%);
  width: 125px;
  height: 193px;
}

.discard-stack {
  position: relative;
  width: 125px;
  height: 193px;
}

.discard-card {
  position: absolute;
  width: 125px;
  height: 193px;
  border-radius: 11px;
  object-fit: cover;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}

.discard-anchor {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 125px;
  height: 193px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.timer-col {
  position: absolute;
  left: 83%;
  top: 58%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.timer-box {
  position: relative;
  width: 88px;
  height: 68px;
}

.timer-bg {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.timer-val {
  position: absolute;
  top: 50%;
  left: 42%;
  transform: translate(-50%, -55%);
  font-family: 'Bungee', sans-serif;
  font-size: 26px;
  color: #ddff9f;
  text-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.timer-flash .timer-val {
  color: #ff8d76;
}

.hand-zone {
  position: absolute;
  z-index: 3;
  bottom: 0;
  left: 0;
  right: 0;
  height: 260px;
  display: flex;
  flex-direction: column;
}

.hand-header {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hand-count-wrap {
  position: relative;
  width: 110px;
  height: 30px;
}

.hand-count-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.hand-count-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #f4ffca;
}

.hand-main {
  flex: 1;
  position: relative;
  overflow: visible;
}

.hand-cards {
  position: absolute;
  inset: 0;
}

.hand-anchor {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 80px;
  height: 123px;
  transform: translateX(-50%);
  pointer-events: none;
}

.hand-card {
  position: absolute;
  width: 80px;
  height: 123px;
  cursor: pointer;
  transform-origin: center bottom;
  transition: transform 0.2s cubic-bezier(.34,1.56,.64,1), opacity 0.2s ease, box-shadow 0.2s ease;
}

.hand-card img {
  width: 100%;
  height: 100%;
  border-radius: 7px;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.hand-card.selected img {
  box-shadow: 0 0 0 3px #4ade80, 0 6px 18px rgba(74,222,128,0.4);
}

.hand-card.selected {
  transform: translateY(-22px) !important;
}

.hand-card.muted {
  opacity: 0.55;
}

.hand-card.playable img {
  box-shadow: 0 0 0 2px rgba(74,222,128,0.6), 0 4px 12px rgba(0,0,0,0.5);
}

.hand-card.hidden {
  opacity: 0;
  pointer-events: none;
}

.hand-tray {
  height: 62px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 10px;
}

.tray-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.tray-arrow {
  position: relative;
  z-index: 1;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s ease;
}

.tray-arrow img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.tray-arrow:disabled {
  opacity: 0.3;
  pointer-events: none;
}

.tray-preview {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex: 1;
  overflow: hidden;
}

.tray-card {
  width: 26px;
  height: 40px;
  border-radius: 4px;
  object-fit: cover;
  box-shadow: 0 2px 5px rgba(0,0,0,0.4);
  flex-shrink: 0;
  transition: opacity 0.2s ease, outline 0.2s ease;
  cursor: pointer;
}

.tray-card.in-view {
  outline: 1.5px solid #4ade80;
}

.turn-banner {
  position: absolute;
  z-index: 20;
  top: 165px;
  left: 0;
  right: 0;
  height: 0;
  pointer-events: none;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.banner-box {
  max-width: 85%;
  padding: 12px 28px;
  border-radius: 14px;
  background: rgba(10,22,10,0.88);
  color: #ecf0f1;
  font-family: 'Bungee', sans-serif;
  font-size: 22px;
  white-space: nowrap;
  text-align: center;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}

.banner-box.visible {
  opacity: 1;
  transform: translateY(0);
}

.banner-box.effect {
  font-size: 26px;
  color: #f8f3e8;
  background: rgba(8,20,8,0.93);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.opp-module.active .opp-avatar-shell {
  animation: pop 0.35s ease;
}

@media (prefers-reduced-motion: reduce) {
  .loading-fill,
  .overlay-spinner,
  .arc-fill,
  .opp-active-ring,
  .tray-arrow,
  .hand-card,
  .tray-card,
  .banner-box,
  .opp-module.active .opp-avatar-shell {
    animation: none !important;
    transition: none !important;
  }
}

/* ── Leaderboard modal ─────────────────────────────────────────────── */

.overlay-card--leaderboard {
  width: min(340px, 82vw);
  max-height: min(78vh, 640px);
  overflow: hidden;
  padding: 28px 20px 32px;
}

.overlay-card--leaderboard h2 {
  margin-bottom: 4px;
}

.end-subtitle {
  font-size: 13px;
  color: var(--overlay-accent-soft);
  margin-bottom: 16px;
  opacity: 0.9;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  padding: 2px;
  margin-bottom: 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 200, 110, 0.3) transparent;
}

.leaderboard-list::-webkit-scrollbar { width: 4px; }
.leaderboard-list::-webkit-scrollbar-track { background: transparent; }
.leaderboard-list::-webkit-scrollbar-thumb {
  background: rgba(0, 200, 110, 0.3);
  border-radius: 999px;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(0, 180, 80, 0.06);
  border: 1px solid var(--overlay-line);
  text-align: left;
}

.lb-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
  border: 1px solid rgba(0, 200, 110, 0.2);
}

.lb-row--winner .lb-avatar {
  border-color: rgba(74, 222, 128, 0.5);
}

.lb-row--winner {
  background: rgba(74, 222, 128, 0.10);
  border-color: rgba(74, 222, 128, 0.28);
}

.lb-row--draw {
  background: rgba(250, 204, 21, 0.12);
  border-color: rgba(250, 204, 21, 0.34);
}

.lb-row--loser {
  background: rgba(255, 141, 118, 0.08);
  border-color: rgba(255, 141, 118, 0.22);
}

.lb-name {
  flex: 1;
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 13px;
  color: var(--overlay-ink-inverse);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-row--winner .lb-name { color: #4ade80; }
.lb-row--draw .lb-name { color: #facc15; }
.lb-row--loser .lb-name { color: #ffb4a4; }

.lb-count {
  font-family: 'Poppins', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--overlay-ink);
  opacity: 0.85;
  white-space: nowrap;
  flex-shrink: 0;
}

.lb-row--winner .lb-count {
  color: #86efac;
  opacity: 1;
}

.lb-row--draw .lb-count {
  color: #fde047;
  opacity: 1;
}

.lb-row--loser .lb-count {
  color: #ffb4a4;
  opacity: 1;
}

.lb-badge {
  flex-shrink: 0;
  font-family: 'Bungee', sans-serif;
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--overlay-surface);
  background: var(--overlay-accent);
  padding: 3px 7px;
  border-radius: 6px;
  line-height: 1.2;
}

.lb-badge--winner {
  color: #052313;
  background: #4ade80;
}

.lb-badge--draw {
  color: #3b2f05;
  background: #facc15;
}

.lb-badge--loser {
  color: #2f0f08;
  background: #ff9b87;
}
