/* SolToss — alive, degen, pump.fun energy */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:      #080808;
  --s1:      #0f0f0f;
  --s2:      #141414;
  --s3:      #1a1a1a;
  --border:  #252525;
  --green:   #14F195;
  --green2:  #0dbd74;
  --purple:  #9945FF;
  --yellow:  #FFD700;
  --red:     #FF3B3B;
  --text:    #ffffff;
  --muted:   #666666;
  --muted2:  #999999;
  --win-bg:  rgba(20,241,149,0.06);
  --lose-bg: rgba(255,59,59,0.06);
  --glow:    0 0 30px rgba(20,241,149,0.15);
}

html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Space Grotesk', system-ui, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ══ NAV ══ */
#nav {
  position: sticky; top: 0; z-index: 200;
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  height: 56px;
  background: rgba(8,8,8,0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px);
}

.logo {
  font-family: 'Space Mono', monospace;
  font-size: 20px; font-weight: 700;
  letter-spacing: 1px;
  flex-shrink: 0;
  color: var(--text);
}
.logo span { color: var(--green); }

/* Ticker */
.nav-ticker {
  flex: 1; overflow: hidden;
  mask-image: linear-gradient(to right, transparent, black 10%, black 90%, transparent);
}
.ticker-inner {
  display: flex; gap: 32px; align-items: center;
  width: max-content;
  animation: ticker 30s linear infinite;
}
@keyframes ticker {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
.ticker-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted2);
  white-space: nowrap; font-family: 'Space Mono', monospace;
}
.ticker-item .tw { color: var(--green); font-weight: 700; }
.ticker-item .tl { color: var(--red); }

.nav-right {
  display: flex; align-items: center; gap: 12px;
  flex-shrink: 0;
}

.online-badge {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted2);
}
.online-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: blink 2s ease-in-out infinite;
}
@keyframes blink {
  0%,100% { opacity: 1; } 50% { opacity: 0.4; }
}

#wallet-info { display: flex; align-items: center; gap: 8px; }
.wallet-addr {
  font-family: 'Space Mono', monospace;
  font-size: 12px; color: var(--muted2);
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 10px;
}

.btn-connect {
  background: var(--green); color: #000;
  border: none; border-radius: 8px;
  padding: 8px 18px;
  font-size: 13px; font-weight: 700;
  cursor: pointer; font-family: inherit;
  transition: opacity 0.15s, transform 0.1s;
}
.btn-connect:hover { opacity: 0.85; }
.btn-connect:active { transform: scale(0.97); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted); border-radius: 6px;
  padding: 8px 12px; font-size: 13px;
  min-width: 44px; min-height: 44px;
  cursor: pointer; font-family: inherit;
  transition: border-color 0.15s, color 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.btn-ghost:hover { border-color: var(--muted); color: var(--text); }

/* ══ APP LAYOUT ══ */
body { display: flex; flex-direction: column; }
#app { position: relative; flex: 1; }

/* ══ LOBBY ══ */
#lobby {
  display: grid;
  grid-template-columns: 480px 1fr;
  min-height: calc(100vh - 56px);
}

/* ── Left ── */
.lobby-left {
  padding: 32px 28px;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 24px;
  overflow-y: auto;
}

/* Hero coin */
.hero-coin-wrap {
  position: relative;
  width: 140px; height: 140px;
  margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
  perspective: 1000px;
}
.hero-ring {
  position: absolute; border-radius: 50%;
  border: 1px solid rgba(20,241,149,0.2);
  animation: ringExpand 3s ease-out infinite;
}
.hero-ring.r1 { width: 100%; height: 100%; animation-delay: 0s; }
.hero-ring.r2 { width: 130%; height: 130%; animation-delay: 0.8s; }
.hero-ring.r3 { width: 160%; height: 160%; animation-delay: 1.6s; }
@keyframes ringExpand {
  0%   { opacity: 0.6; transform: scale(0.85); }
  100% { opacity: 0; transform: scale(1.1); }
}

.hero-coin {
  width: 110px; height: 110px;
  transform-style: preserve-3d;
  position: relative;
  cursor: pointer;
  filter: drop-shadow(0 0 30px rgba(20,241,149,0.25));
}
.hero-coin.flipping { animation: heroFlip 1s cubic-bezier(0.25, 0.46, 0.45, 0.94); }
@keyframes heroFlip {
  0%   { transform: rotateY(0deg); }
  100% { transform: rotateY(720deg); }
}
.hero-coin-face {
  position: absolute; inset: 0;
  border-radius: 50%;
  backface-visibility: hidden;
  background-size: cover; background-position: center;
  box-shadow: 0 4px 18px rgba(0,0,0,0.6), inset 0 0 12px rgba(0,0,0,0.35);
}
.hero-coin-face.front { background-image: url('/heads.jpg'); }
.hero-coin-face.back  { background-image: url('/tails.jpg'); transform: rotateY(180deg); }

/* Hero text */
.hero-text { text-align: center; }
.hero-text h1 {
  font-size: 30px; font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}
.hero-text p { font-size: 14px; color: var(--muted2); line-height: 1.6; }
.hero-text strong { color: var(--green); }

/* Stats row */
.stats-row {
  display: flex; gap: 8px;
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px;
}
.stat-pill {
  flex: 1; text-align: center;
}
.stat-num {
  display: block;
  font-family: 'Space Mono', monospace;
  font-size: 18px; font-weight: 700;
  color: var(--green);
}
.stat-lbl {
  font-size: 10px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-top: 2px; display: block;
}

/* Tier label — now an h2 for semantics, visually unchanged */
.tier-label {
  font-size: 12px; font-weight: 600;
  color: var(--muted); text-transform: uppercase;
  letter-spacing: 1px; margin: 0;
}

/* Tier grid */
.tier-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.tier-card {
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 14px; padding: 20px 16px;
  cursor: pointer; position: relative; overflow: hidden;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  text-align: center;
}
.tier-card::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(20,241,149,0.04), transparent);
  opacity: 0; transition: opacity 0.2s;
}
.tier-card:hover {
  border-color: var(--green);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(20,241,149,0.12);
}
.tier-card:hover::after { opacity: 1; }
.tier-card.locked { opacity: 0.6; }

.tier-amount {
  font-family: 'Space Mono', monospace;
  font-size: 24px; font-weight: 700;
  color: var(--text); line-height: 1;
}
.tier-unit { font-size: 13px; color: var(--muted); font-weight: 400; }
.tier-win-label {
  font-size: 11px; color: var(--green);
  margin: 4px 0 10px; font-weight: 600;
}
.tier-waiting-badge {
  font-size: 11px; color: var(--muted2);
  background: var(--s3); border-radius: 20px;
  padding: 3px 10px; display: inline-flex;
  align-items: center; gap: 5px;
}
.waiting-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green);
  animation: blink 1.5s ease-in-out infinite;
}

/* ── Right — Live Feed ── */
.lobby-right {
  display: flex; flex-direction: column;
  overflow: hidden;
}

.feed-header {
  display: flex; align-items: center; gap: 8px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 12px; font-weight: 700;
  color: var(--muted2);
  flex-shrink: 0;
}
.feed-title {
  font-size: 12px; font-weight: 700;
  letter-spacing: 1px; text-transform: uppercase;
  color: var(--muted2); margin: 0;
}
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: blink 1.5s ease-in-out infinite;
}
.feed-count { margin-left: auto; color: var(--muted); font-weight: 400; }

.feed-list {
  flex: 1; overflow-y: auto;
  padding: 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.feed-empty {
  text-align: center; color: var(--muted);
  font-size: 13px; padding: 40px;
}

.feed-entry {
  display: flex; align-items: center; gap: 10px;
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 14px;
  font-size: 12px;
  animation: feedSlide 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative; overflow: hidden;
}
.feed-entry.win-entry  { border-color: rgba(20,241,149,0.2); background: var(--win-bg); }
.feed-entry.lose-entry { border-color: rgba(255,59,59,0.2);  background: var(--lose-bg); }

@keyframes feedSlide {
  from { opacity: 0; transform: translateY(-12px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.feed-badge {
  font-size: 10px; font-weight: 800;
  border-radius: 5px; padding: 2px 7px;
  flex-shrink: 0; letter-spacing: 0.5px;
}
.feed-badge.w { background: rgba(20,241,149,0.15); color: var(--green); }
.feed-badge.l { background: rgba(255,59,59,0.15);  color: var(--red); }

.feed-wallets {
  flex: 1; color: var(--muted2);
  font-family: 'Space Mono', monospace;
  font-size: 11px; overflow: hidden;
  white-space: nowrap; text-overflow: ellipsis;
}
.feed-wallets .fw { color: var(--text); }

.feed-tier {
  font-family: 'Space Mono', monospace;
  font-weight: 700; color: var(--green);
  font-size: 12px; flex-shrink: 0;
}
.feed-time { color: var(--muted); font-size: 10px; flex-shrink: 0; }

/* ══ FULLSCREEN SECTIONS ══ */
.fullscreen {
  position: fixed; inset: 56px 0 0 0;
  z-index: 150; overflow-y: auto;
  background: var(--bg);
}

/* ══ WAITING ROOM ══ */
#waiting-room {
  display: flex; flex-direction: column;
}

.btn-back {
  background: transparent; border: none;
  color: var(--muted); font-family: inherit;
  font-size: 13px; cursor: pointer;
  padding: 16px 24px; text-align: left;
  transition: color 0.15s; flex-shrink: 0;
}
.btn-back:hover { color: var(--text); }

.wr-content {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 20px; padding: 24px;
}

.wr-tier-badge {
  font-family: 'Space Mono', monospace;
  font-size: 16px; font-weight: 700;
  color: var(--green);
  background: rgba(20,241,149,0.08);
  border: 1px solid rgba(20,241,149,0.3);
  border-radius: 100px; padding: 8px 28px;
}

.wr-coin-wrap {
  position: relative; width: 140px; height: 140px;
  display: flex; align-items: center; justify-content: center;
  perspective: 1000px;
}
.wr-pulse {
  position: absolute; border-radius: 50%;
  border: 1.5px solid var(--green);
  animation: pulseOut 2.4s ease-out infinite;
}
.wr-pulse.p1 { width: 100%; height: 100%; animation-delay: 0s; }
.wr-pulse.p2 { width: 100%; height: 100%; animation-delay: 0.8s; }
.wr-pulse.p3 { width: 100%; height: 100%; animation-delay: 1.6s; }
@keyframes pulseOut {
  0%   { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.8); opacity: 0; }
}
.wr-coin-box {
  position: relative; width: 96px; height: 96px; z-index: 1;
  transform-style: preserve-3d;
  animation: coinSpin 3s linear infinite;
  filter: drop-shadow(0 0 24px rgba(20,241,149,0.35));
}
.wr-coin-face {
  position: absolute; inset: 0; border-radius: 50%;
  backface-visibility: hidden;
  background-size: cover; background-position: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.6), inset 0 0 10px rgba(0,0,0,0.35);
}
.wr-coin-face.front { background-image: url('/heads.jpg'); }
.wr-coin-face.back  { background-image: url('/tails.jpg'); transform: rotateY(180deg); }
@keyframes coinSpin {
  from { transform: rotateY(0deg); }
  to   { transform: rotateY(360deg); }
}

.wr-status {
  font-size: 12px; font-weight: 700; letter-spacing: 3px;
  color: var(--muted2); text-transform: uppercase;
}

/* Countdown ring */
.wr-countdown-wrap {
  position: relative; width: 110px; height: 110px;
  display: flex; align-items: center; justify-content: center;
}
.countdown-ring { position: absolute; inset: 0; transform: rotate(-90deg); }
.ring-bg    { fill: none; stroke: var(--s3); stroke-width: 6; }
.ring-progress {
  fill: none; stroke: var(--green); stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear, stroke 0.5s;
}
.wr-countdown {
  font-family: 'Space Mono', monospace;
  font-size: 36px; font-weight: 700; color: var(--text);
  z-index: 1;
}
.wr-countdown.urgent { color: var(--red); }
.wr-countdown-lbl { font-size: 11px; color: var(--muted); margin-top: -8px; }

.wr-room-info { font-size: 13px; color: var(--muted2); }

.wr-mini-feed {
  width: 100%; max-width: 400px;
  display: flex; flex-direction: column; gap: 6px;
  max-height: 160px; overflow: hidden;
}

/* ══ RESULT SCREEN ══ */
#result-screen { display: flex; align-items: center; justify-content: center; }

.result-bg {
  position: absolute; inset: 0; pointer-events: none;
  opacity: 0; transition: opacity 0.5s;
}
.result-bg.win-bg  { background: radial-gradient(ellipse at center, rgba(20,241,149,0.08) 0%, transparent 70%); }
.result-bg.lose-bg { background: radial-gradient(ellipse at center, rgba(255,59,59,0.08) 0%, transparent 70%); }
.result-bg.active  { opacity: 1; }

.result-content {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  align-items: center; gap: 20px;
  padding: 40px 24px; text-align: center;
}

/* Result 3D coin */
.result-coin-wrap {
  perspective: 1200px;
  width: 130px; height: 130px;
}
.result-coin {
  width: 130px; height: 130px;
  transform-style: preserve-3d; position: relative;
}
/* Google-style toss: launches up, spins many times, lands on the face set by --flip-end-rotation */
.result-coin.spin { animation: resultToss 2.5s cubic-bezier(0.25, 1, 0.4, 1) forwards; }
@keyframes resultToss {
  0%   { transform: scale(1)    rotateY(0)                                 translateY(0);    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.5)); }
  20%  { transform: scale(1.3)  rotateY(720deg)                            translateY(-160px); filter: drop-shadow(0 30px 40px rgba(0,0,0,0.8)); }
  50%  { transform: scale(1.4)  rotateY(1800deg)                           translateY(-210px); filter: drop-shadow(0 40px 50px rgba(0,0,0,0.9)); }
  80%  { transform: scale(0.92) rotateY(2880deg)                           translateY(12px);   filter: drop-shadow(0 8px 15px rgba(0,0,0,0.6)); }
  90%  { transform: scale(1.05) rotateY(var(--flip-end-rotation, 2880deg)) translateY(-6px);   filter: drop-shadow(0 12px 20px rgba(0,0,0,0.7)); }
  100% { transform: scale(1)    rotateY(var(--flip-end-rotation, 2880deg)) translateY(0);    filter: drop-shadow(0 6px 12px rgba(0,0,0,0.5)); }
}
.result-face {
  position: absolute; inset: 0; border-radius: 50%;
  backface-visibility: hidden;
  background-size: cover; background-position: center;
  box-shadow: 0 0 25px rgba(0,0,0,0.6), inset 0 0 12px rgba(0,0,0,0.35);
}
.result-face.front { background-image: url('/heads.jpg'); }
.result-face.back  { background-image: url('/tails.jpg'); transform: rotateY(180deg); }

.result-banner {
  font-size: 52px; font-weight: 900; line-height: 1;
  letter-spacing: -1px;
}
.result-banner.win  { color: var(--green); text-shadow: 0 0 40px rgba(20,241,149,0.4); }
.result-banner.lose { color: var(--red);   text-shadow: 0 0 40px rgba(255,59,59,0.4); }

.result-amount {
  font-family: 'Space Mono', monospace;
  font-size: 22px; font-weight: 700;
  color: var(--muted2);
}
.result-vs { font-size: 13px; color: var(--muted); font-family: 'Space Mono', monospace; }
.result-tx { font-size: 12px; color: var(--green); text-decoration: none; }
.result-tx:hover { text-decoration: underline; }

.result-btns { display: flex; gap: 12px; align-items: center; margin-top: 8px; }
.btn-play-again {
  background: var(--green); color: #000;
  border: none; border-radius: 12px;
  padding: 14px 36px;
  font-size: 16px; font-weight: 800;
  cursor: pointer; font-family: inherit;
  transition: opacity 0.15s, transform 0.1s;
}
.btn-play-again:hover { opacity: 0.85; }
.btn-play-again:active { transform: scale(0.97); }

.btn-ghost-sm {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 12px; padding: 14px 24px;
  font-size: 14px; cursor: pointer; font-family: inherit;
  transition: border-color 0.15s, color 0.15s;
}
.btn-ghost-sm:hover { border-color: var(--muted2); color: var(--text); }

/* ══ TOASTS ══ */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 999; display: flex; flex-direction: column-reverse; gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 18px;
  font-size: 13px; color: var(--text);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  max-width: 320px;
  animation: toastIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: all;
}
.toast.win-toast  { border-color: rgba(20,241,149,0.4); }
.toast.lose-toast { border-color: rgba(255,59,59,0.4); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px) scale(0.9); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateX(20px) scale(0.9); }
}

/* Confetti (win) */
.confetti-piece {
  position: fixed; width: 8px; height: 8px;
  border-radius: 2px; pointer-events: none; z-index: 500;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  0%   { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* ══ RESPONSIVE ══ */
@media (max-width: 900px) {
  #lobby {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .lobby-left { border-right: none; border-bottom: 1px solid var(--border); }
  .lobby-right { min-height: 50vh; }
  /* Keep ticker visible on mobile — shrink font and speed it up slightly */
  .nav-ticker { flex: 1; min-width: 0; }
  .ticker-inner { gap: 20px; animation-duration: 20s; }
  .ticker-item { font-size: 11px; gap: 4px; }
}

@media (max-width: 540px) {
  #nav { padding: 0 12px; gap: 8px; }
  .logo { font-size: 16px; flex-shrink: 0; }
  .online-badge { display: none; }
  .btn-connect { padding: 7px 12px; font-size: 12px; flex-shrink: 0; }
  .hero-text h1 { font-size: 24px; }
  .lobby-left { padding: 20px 16px; gap: 18px; }
  .tier-grid { gap: 8px; }
  .tier-amount { font-size: 20px; }
  .result-banner { font-size: 40px; }
  /* Bump small text up to 12px minimum for mobile readability */
  .ticker-item { font-size: 12px; }
  .feed-badge { font-size: 12px; }
  .feed-wallets { font-size: 12px; }
  .feed-time { font-size: 12px; }
  .tier-waiting-badge { font-size: 12px; }
  .stat-lbl { font-size: 12px; }
  .tier-label { font-size: 12px; }
  /* Larger touch targets on mobile */
  .btn-ghost { min-width: 48px; min-height: 48px; }
  .btn-connect { padding: 10px 18px; min-height: 44px; }
  .tier-card { padding: 18px 14px; }
}
