body {
  font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  background: #dff1ff;
  color: #181a20;
  margin: 0;
  -webkit-tap-highlight-color: transparent;
}

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 16px 96px;
}

.card {
  background: #ffffff;
  border-radius: 22px;
  padding: 16px;
  border: 1px solid #eceef2;
}

.subtext {
  color: #5d7383;
  margin-top: 0;
}

.hero-card {
  margin-bottom: 14px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  color: #737784;
}

.funding-copy {
  font-size: 0.95rem;
  line-height: 1.45;
  color: #3a3f4b;
  margin: 10px 0 14px;
  font-weight: 600;
}

.chain-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #e0efff;
  border: 1px solid #b6d6ee;
  color: #1f3b56;
  font-size: 0.82rem;
  font-weight: 800;
  margin-top: 8px;
}

.chain-badge.subtle {
  margin: 4px 0 8px;
  background: #edf6ff;
}

.wallet-debug {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #1a1d24;
  color: #e8ecf4;
  font-size: 0.78rem;
  line-height: 1.4;
}

.wallet-debug strong {
  display: block;
  margin-bottom: 6px;
  color: #9ecbff;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.wallet-debug pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}

.usdc-balance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #f7f8fb;
  border: 1px solid #e6e9f0;
}

.usdc-balance-row span {
  color: #737784;
}

.pill-actions {
  display: flex;
  gap: 10px;
}

.pill-button {
  flex: 1;
  border-radius: 999px;
  background: #171923;
  color: #fff;
  min-height: 52px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.pill-button.muted {
  background: #eceef2;
  color: #171923;
}

.pill-button.invite {
  background: #fde68a;
  color: #111827;
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.mini-card {
  background: #fff;
  border: 1px solid #eceef2;
  border-radius: 20px;
  text-align: left;
  color: #181a20;
  padding: 16px;
}

.mini-card span {
  display: block;
  color: #737784;
  margin-bottom: 8px;
}

.form-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

input {
  margin-left: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #d8dde5;
  background: #fff;
  color: #111827;
}

button {
  background: #171923;
  color: white;
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  min-height: 44px;
}

#status {
  margin: 12px 0;
  min-height: 22px;
  color: #3a3f4b;
}

.board {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
  background: #2e66d5;
  padding: 8px;
  border-radius: 18px;
  width: min(100%, 98vw);
  box-sizing: border-box;
  position: relative;
  z-index: 2;
}

.board-wrap {
  margin-top: 10px;
  position: relative;
}

.end-coin-rain {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 8px;
  bottom: 8px;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.rain-coin {
  position: absolute;
  width: calc((100% - 30px) / 7);
  max-width: 56px;
  aspect-ratio: 1 / 1;
  border-radius: 999px;
  border: 2px solid rgba(17, 24, 39, 0.15);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.2);
  animation: rain-fall 1000ms ease-in forwards;
}

.rain-coin.A {
  background: radial-gradient(circle at 30% 30%, #ffe88a, #facc15);
}

.rain-coin.B {
  background: radial-gradient(circle at 30% 30%, #ff8a8a, #ef4444);
}

.board-front {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  border-radius: 18px;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
  background: transparent;
  z-index: 3;
  pointer-events: none;
  box-shadow: inset 0 0 0 6px rgba(14, 67, 170, 0.22);
}

.board-hole {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: transparent;
  border: 2px solid rgba(20, 73, 179, 0.55);
  box-sizing: border-box;
}

.turn-cooldown {
  margin-top: 10px;
  background: #f7f8fb;
  border: 1px solid #e1e6ef;
  border-radius: 12px;
  padding: 10px;
}

.turn-cooldown-head {
  color: #4a5566;
  font-size: 0.86rem;
  margin-bottom: 8px;
}

.turn-cooldown-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #e8edf5;
  overflow: hidden;
}

.turn-cooldown-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #facc15);
  transform-origin: left center;
}

.turn-cooldown-fill.turn-a {
  background: linear-gradient(90deg, #f59e0b, #facc15);
}

.turn-cooldown-fill.turn-b {
  background: linear-gradient(90deg, #ef4444, #f97316);
}

.cell {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: #e6e9ef;
  border: 0;
  touch-action: manipulation;
}

.cell.A {
  background: #facc15;
}

.cell.B {
  background: #ef4444;
}

.cell.drop-in {
  transform-origin: center top;
  animation: coin-drop-bounce 900ms cubic-bezier(0.18, 0.72, 0.28, 1) both;
}

@keyframes coin-drop-bounce {
  0% {
    transform: translateY(-280%) scale(0.95);
  }
  62% {
    transform: translateY(0) scale(1);
  }
  76% {
    transform: translateY(-18%) scale(1);
  }
  88% {
    transform: translateY(0) scale(1);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

@keyframes rain-fall {
  0% {
    transform: translateY(-180%) scale(0.98);
  }
  80% {
    transform: translateY(100%) scale(1);
  }
  100% {
    transform: translateY(125%) scale(1);
    opacity: 0.92;
  }
}

.hidden {
  display: none;
}

.screen-section {
  background: #fff;
  border: 1px solid #eceef2;
  border-radius: 22px;
  padding: 14px;
  position: relative;
}

.winner-splash {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 16, 32, 0.28);
  border-radius: 22px;
  pointer-events: none;
}

.winner-splash.hidden {
  display: none;
}

.winner-splash img {
  width: min(84%, 320px);
  max-width: 320px;
  border-radius: 12px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.35);
  transform: scale(0.22);
  animation: winner-zoom-in 700ms cubic-bezier(0.15, 0.85, 0.2, 1) forwards;
}

.invite-panel {
  background: #fff7cc;
  border: 1px solid #f4e39a;
  border-radius: 16px;
  padding: 12px;
  margin-top: 10px;
  overflow: visible;
}

.invite-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #5f5a3b;
  margin-bottom: 8px;
}

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

.search-wrap {
  position: relative;
}

#friendUsername {
  margin-left: 0;
  font-family: "Cooper Black", "Arial Black", "Segoe UI", sans-serif;
  color: #0f172a;
  font-weight: 700;
}

.friend-results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 10;
  list-style: none;
  margin: 0;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid #b6d6ee;
  background: #fff;
  max-height: 160px;
  overflow: auto;
}

.friend-results li {
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-family: "Cooper Black", "Arial Black", "Segoe UI", sans-serif;
  color: #0f172a;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.friend-results li:hover {
  background: #eff7ff;
}

.friend-results-header {
  cursor: default !important;
  color: #5f5a3b !important;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: transparent !important;
  padding-bottom: 4px !important;
}

.friend-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid #cbe4f7;
  background: #eaf6ff;
}

.friend-label {
  line-height: 1.1;
}

.queue-panel {
  background: #f7fbff;
  border: 1px solid #d2e7fb;
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 10px;
}

.match-loading {
  margin-top: 12px;
  background: #fff;
  border: 1px solid #f1df9d;
  border-radius: 16px;
  padding: 14px;
  text-align: center;
}

.match-loading p {
  margin: 6px 0 0;
  color: #6d5a33;
}

.coins-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.coin {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: inline-block;
  border: 2px solid rgba(17, 24, 39, 0.15);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.28);
  animation: coin-spin 1s linear infinite;
}

.coin.red {
  background: radial-gradient(circle at 30% 30%, #ff8a8a, #ef4444);
}

.coin.yellow {
  background: radial-gradient(circle at 30% 30%, #ffe88a, #facc15);
  animation-delay: 0.15s;
}

.match-found {
  margin-top: 10px;
  background: #fff4d6;
  border: 1px solid #f3d77b;
  border-radius: 16px;
  padding: 14px;
  text-align: center;
  animation: pop-in 220ms ease-out;
}

.match-found p {
  margin: 6px 0 0;
  color: #6d5a33;
}

.history-list {
  margin: 0;
  padding-left: 18px;
  color: #2f485a;
}

.history-list li {
  margin: 6px 0;
  font-size: 0.9rem;
  line-height: 1.25;
}

.history-item {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8fbff;
  border: 1px solid #d6e6f6;
  border-radius: 12px;
  padding: 10px;
}

.history-text {
  color: #23405a;
  font-size: 0.86rem;
  line-height: 1.35;
  word-break: break-word;
}

.copy-record-btn {
  align-self: flex-end;
  min-height: 36px;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.8rem;
  background: #e9edf3;
  color: #0f172a;
  border: 1px solid #d7dde7;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-weight: 600;
  letter-spacing: 0.01em;
}

@keyframes coin-spin {
  from {
    transform: rotateY(0deg);
  }
  to {
    transform: rotateY(360deg);
  }
}

@keyframes pop-in {
  from {
    transform: scale(0.96);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes winner-zoom-in {
  0% {
    transform: scale(0.22);
    opacity: 0.45;
  }
  78% {
    transform: scale(1.06);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.queue-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  color: #35546e;
}

.waiting-list {
  margin: 0;
  padding-left: 18px;
  color: #3b4e5f;
}

.waiting-list li {
  font-weight: 600;
}

.waiting-player {
  list-style: none;
  margin: 8px 0;
  padding: 8px;
  border: 1px solid #d6e6f6;
  border-radius: 12px;
  background: #f8fbff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.waiting-player-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.waiting-player-name {
  color: #23405a;
  font-size: 0.9rem;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.waiting-player .friend-avatar {
  width: 30px;
  height: 30px;
}

.join-waiting-btn {
  min-height: 34px;
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 0.8rem;
  background: #171923;
  color: #fff;
}

.escrow-panel {
  background: #f7f8fb;
  border: 1px solid #e6e9f0;
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 10px;
}

.approval-panel {
  background: #f7fbff;
  border: 1px solid #d2e7fb;
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 10px;
}

.approval-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #35546e;
  margin-bottom: 8px;
}

.coin-flip-wrap {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 10px;
}

.flip-coin {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: inline-block;
  border: 2px solid rgba(17, 24, 39, 0.15);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.28);
  animation: coin-spin 700ms linear 4;
}

.flip-coin.red {
  background: radial-gradient(circle at 30% 30%, #ff8a8a, #ef4444);
}

.flip-coin.yellow {
  background: radial-gradient(circle at 30% 30%, #ffe88a, #facc15);
  animation-delay: 80ms;
}

.escrow-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #636978;
  margin-bottom: 8px;
}

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

.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.profile-card {
  background: #f7f8fb;
  border: 1px solid #e6e9f0;
  border-radius: 14px;
  padding: 12px;
}

.profile-card span {
  color: #737784;
  display: block;
  margin-bottom: 6px;
}

.wallet-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

#walletProviderSelect {
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid #b6d6ee;
  padding: 10px 12px;
  font-size: 0.95rem;
  background: #f4fbff;
  font-family: "Cooper Black", "Arial Black", "Segoe UI", sans-serif;
  color: #0f172a;
  font-weight: 700;
}

#walletProviderSelect option {
  font-family: "Cooper Black", "Arial Black", "Segoe UI", sans-serif;
  font-weight: 700;
  color: #0f172a;
}

.manual-wallet-box {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

#manualWalletInput {
  margin-left: 0;
  font-family: "Cooper Black", "Arial Black", "Segoe UI", sans-serif;
  color: #0f172a;
  font-weight: 700;
}

.profile-avatar-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 999px;
  border: 2px solid #b6d6ee;
  object-fit: cover;
  background: #ecf7ff;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.95);
  border-top: 1px solid #e7eaf0;
  backdrop-filter: blur(8px);
}

.nav-item {
  min-height: 42px;
  border-radius: 999px;
  background: transparent;
  color: #9aa1af;
  border: 1px solid transparent;
  font-weight: 600;
}

.nav-item.active {
  color: #181a20;
  background: #f1f3f7;
  border-color: #e1e5ec;
}

@media (max-width: 640px) {
  .container {
    margin: 0 auto;
    padding: 12px 12px 90px;
  }

  h1 {
    font-size: 1.6rem;
    margin-bottom: 8px;
  }

  .pill-actions {
    flex-direction: column;
  }

  .escrow-actions {
    grid-template-columns: 1fr;
  }

  .invite-actions {
    grid-template-columns: 1fr;
  }

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

  .wallet-controls {
    grid-template-columns: 1fr;
  }

  label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
  }

  input {
    margin-left: 0;
    width: 100%;
    box-sizing: border-box;
  }

  button {
    width: 100%;
  }
}
