/* Modified by Circles, 2026. Original: github.com/nebez/floppybird (Apache 2.0).
   Reskin v3: Wallet × TON perps demo. Zero blur (perf), Wallet-style trading panel. */

/* ========== Fonts ========== */
@font-face {
  font-family: "Inter";
  src: url("../assets/fonts/InterDisplay-Medium.woff2") format("woff2");
  font-style: normal; font-weight: 400; font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../assets/fonts/InterDisplay-Bold.woff2") format("woff2");
  font-style: normal; font-weight: 700; font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../assets/fonts/InterDisplay-BoldItalic.woff2") format("woff2");
  font-style: italic; font-weight: 700; font-display: swap;
}

/* ========== Tokens ========== */
:root {
  --bg: #0A0E15;
  --bg-elev: #121826;
  --bg-card: #1A2032;
  --text: #ffffff;
  --text-2: rgba(255,255,255,0.64);
  --text-3: rgba(255,255,255,0.40);

  --green: #2AFF9C;
  --pink:  #FF2A8A;
  --gold:  #FFDC60;
  --ton:   #0098EA;
  --wallet-purple: #8E72E5;
  --wallet-purple-2: #6E58B5;

  --stroke: rgba(255,255,255,0.10);
  --stroke-2: rgba(255,255,255,0.20);

  --font: "Inter", system-ui, -apple-system, sans-serif;
  --font-num: -apple-system, "SF Pro Rounded", "SF Compact Rounded", "Inter", system-ui, sans-serif;
}

/* ========== Keyframes ========== */
/* GPU-composited transform animation. Animating `left` would force layout
   on every frame for every pipe — that's the real "1fps" culprit. */
@keyframes animPipe { 0% { transform: translate3d(900px,0,0); } 100% { transform: translate3d(-100px,0,0); } }

@keyframes shake {
  0%,100% { transform: translate(0,0); }
  10% { transform: translate(-7px,3px); }
  25% { transform: translate(6px,-4px); }
  40% { transform: translate(-5px,2px); }
  55% { transform: translate(4px,3px); }
  70% { transform: translate(-3px,-2px); }
  85% { transform: translate(2px,1px); }
}

@keyframes liqFlash {
  0%   { opacity: 0; }
  20%  { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes pricePulse {
  0%,100% { opacity: 0.85; }
  50%     { opacity: 1; }
}

/* ========== Base ========== */
*, *:before, *:after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none; user-select: none;
}
html, body {
  height: 100%;
  height: 100dvh;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  touch-action: manipulation;          /* kill iOS 300ms tap delay */
  overscroll-behavior: none;
}

#gamecontainer {
  position: fixed; inset: 0;
  width: 100%; height: 100%; height: 100dvh;
  overflow: hidden;
}
#gamescreen { position: absolute; inset: 0; }

/* ========== Sky (top 67% — play area) ========== */
#sky {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 67%;
  background:
    radial-gradient(60% 50% at 30% 30%, rgba(0,152,234,.18), transparent 70%),
    radial-gradient(60% 50% at 70% 75%, rgba(142,114,229,.14), transparent 70%),
    var(--bg);
}

/* Decorative price-line in sky to fill the empty top */
#sky:before {
  content: '$1.296';
  position: absolute;
  right: 14px; top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 11px;
  color: rgba(255,255,255,0.32);
  background: rgba(0,152,234,0.18);
  border-radius: 4px;
  padding: 2px 6px;
  letter-spacing: 0.02em;
  pointer-events: none;
}
#sky:after {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 1px;
  background: repeating-linear-gradient(90deg,
    rgba(255,255,255,0.18) 0 6px,
    transparent 6px 12px);
  pointer-events: none;
}

#flyarea {
  position: absolute;
  top: 0; bottom: 0; left: 0; right: 0;
  z-index: 2;
}

/* ========== Top score (Yandex-style, top-left) ========== */
#bigscore {
  position: absolute;
  top: 14px; left: 18px;
  z-index: 100;
  font-family: var(--font);
  font-style: italic;
  font-weight: 700;
  font-size: 44px;
  letter-spacing: 0.024em;
  line-height: 1;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.65);
  pointer-events: none;
}

/* ========== Player: TON coin ========== */
#player {
  position: absolute;
  left: 60px; top: 0;
  width: 34px; height: 34px;
  background: url('../assets/wallet/ton-coin.svg') center/40px 40px no-repeat;
  z-index: 5;
  will-change: transform;
}

/* leverage badge — absolutely positioned via JS transform */
#lev-badge {
  position: absolute;
  top: 0; left: 0;
  z-index: 6;
  pointer-events: none;
  padding: 4px 10px;
  border-radius: 999px;
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 13px;
  color: var(--gold);
  background: rgba(255,220,96,0.16);
  border: 1px solid rgba(255,220,96,0.55);
  display: none;
  white-space: nowrap;
  will-change: transform;
}

/* ========== Pipes: candlesticks ========== */
.pipe {
  position: absolute;
  left: 0; top: 0;
  width: 52px;
  height: 100%;
  z-index: 10;
  will-change: transform;
  /* motion is driven by Web Animations API in JS — see spawnPipe() */
  contain: layout paint;
}
.pipe_upper, .pipe_lower {
  position: absolute;
  width: 52px;
}
.pipe_upper { top: 0; }
.pipe_lower { bottom: 0; }

.pipe.bull .pipe_upper, .pipe.bull .pipe_lower {
  background: linear-gradient(180deg, var(--green), #14B574);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 4px;
}
.pipe.bear .pipe_upper, .pipe.bear .pipe_lower {
  background: linear-gradient(180deg, #E0245F, var(--pink));
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 4px;
}

/* candle wicks (centre line into the gap) */
.pipe_upper:after, .pipe_lower:after {
  content: '';
  position: absolute;
  width: 2px; height: 14px;
  left: 50%;
  margin-left: -1px;
  background: rgba(255,255,255,0.45);
  border-radius: 1px;
}
.pipe_upper:after { bottom: -14px; }
.pipe_lower:after { top: -14px; }

/* ========== Splash card (clean — no blur) ========== */
#splash {
  position: absolute;
  top: 22%;
  left: 0; right: 0;
  margin: 0 auto;
  width: 280px;
  padding: 22px 20px 20px;
  border-radius: 20px;
  background: var(--bg-card);
  border: 1px solid var(--stroke-2);
  box-shadow: 0 18px 48px rgba(0,0,0,0.55);
  text-align: center;
  z-index: 50;
  opacity: 0;
}
.splash-coin {
  width: 56px; height: 56px;
  margin: 0 auto 10px;
  display: block;
}
.splash-title {
  font-style: italic;
  font-weight: 700;
  font-size: 28px;
  letter-spacing: 0.024em;
  text-transform: uppercase;
  color: #fff;
  line-height: 1;
  margin-bottom: 6px;
}
.splash-subtitle {
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 12px;
}
.splash-leverage {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 11px;
  color: var(--gold);
  background: rgba(255,220,96,0.12);
  border: 1px solid rgba(255,220,96,0.40);
}

/* ========== Scoreboard (clean — no blur) ========== */
#scoreboard {
  position: absolute;
  display: none;
  opacity: 0;
  top: 18%;
  left: 0; right: 0;
  margin: 0 auto;
  width: 300px;
  padding: 22px 22px 18px;
  z-index: 1000;
  text-align: center;
  border-radius: 20px;
  background: var(--bg-card);
  border: 1px solid var(--stroke-2);
  box-shadow: 0 24px 56px rgba(0,0,0,0.6);
}
.score-title {
  font-style: italic;
  font-weight: 700;
  font-size: 22px;
  text-transform: uppercase;
  letter-spacing: 0.024em;
  color: var(--pink);
  margin-bottom: 4px;
}
.score-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 16px;
}
.score-rows {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}
.score-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  border-radius: 14px;
  border: 1px solid var(--stroke);
}
.score-row-label {
  font-size: 11px;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.score-row-value {
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 22px;
  color: var(--text);
}
.score-row.best .score-row-value { color: var(--gold); }

#medal { display: none; }
.medal-pill {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
  background: rgba(255,220,96,0.10);
  border: 1px solid rgba(255,220,96,0.40);
  margin-bottom: 12px;
}

#replay {
  display: block;
  width: 100%;
  padding: 14px 0;
  border-radius: 14px;
  text-align: center;
  cursor: pointer;
  font-weight: 600;
  font-size: 16px;
  color: #fff;
  background: linear-gradient(180deg, var(--wallet-purple), var(--wallet-purple-2));
  border: none;
  box-shadow: 0 10px 24px rgba(142,114,229,0.40);
  user-select: none;
  -webkit-user-select: none;
  opacity: 0;
}
#replay:active { transform: scale(0.985); }
#replay img { display: none; }

/* ========== Liquidation flash ========== */
.liq-flash {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: radial-gradient(ellipse at center, rgba(255,42,138,0.45), rgba(255,42,138,0.08) 60%, transparent 100%);
  pointer-events: none;
  animation: liqFlash 600ms ease-out forwards;
}

/* ========== Trading floor (#land — bottom 33%) ========== */
/* Mimics Wallet perps screen: header (TON · price · change · leverage),
   chart, big PnL, action pills */
#land {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 33%;
  background: linear-gradient(180deg, #11161F, #0A0E15);
  border-top: 1px solid rgba(142,114,229,0.30);
  z-index: 3;
  overflow: hidden;
  padding: 12px 14px env(safe-area-inset-bottom, 12px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Top header row: TON + price + change + leverage */
.tf-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.tf-coin {
  width: 32px; height: 32px;
  background: url('../assets/wallet/ton-coin.svg') center/contain no-repeat;
  flex-shrink: 0;
}
.tf-asset {
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0;
}
.tf-asset-name {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  line-height: 1.1;
}
.tf-asset-tag {
  display: inline-flex; gap: 6px;
}
.tf-tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(255,255,255,0.08);
  color: var(--text-2);
}
.tf-price-block {
  margin-left: auto;
  text-align: right;
  display: flex; flex-direction: column; gap: 2px;
}
.tf-price {
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 18px;
  color: #fff;
  line-height: 1;
  letter-spacing: -0.01em;
}
.tf-change {
  font-family: var(--font-num);
  font-weight: 600;
  font-size: 11px;
  color: var(--green);
  display: inline-flex; align-items: center; gap: 4px;
  justify-content: flex-end;
}
.tf-lev {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 11px;
  color: var(--gold);
  background: rgba(255,220,96,0.14);
  border: 1px solid rgba(255,220,96,0.40);
  letter-spacing: 0.02em;
}

/* Position history feed — newest at top, slides down as more come in */
.tf-positions {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
  overflow: hidden;
  align-content: flex-start;
}
.ph-row {
  display: grid;
  grid-template-columns: 80px 36px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 7px 11px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,0.025);
  transition: opacity 240ms ease, transform 240ms ease;
  animation: phSlideIn 240ms ease both;
}
@keyframes phSlideIn {
  0%   { opacity: 0; transform: translateY(-12px) scale(0.96); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.ph-bull .ph-dir { color: var(--green); }
.ph-bear .ph-dir { color: var(--pink); }
.ph-row .ph-lev {
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 11px;
  color: var(--gold);
  text-align: center;
}
.ph-row .ph-entry {
  font-family: var(--font-num);
  font-weight: 600;
  color: var(--text-2);
  text-align: right;
  font-size: 11px;
}
.ph-status {
  font-family: var(--font-num);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* Open (current/active position) — Wallet purple highlight */
.ph-row.ph-open {
  background: linear-gradient(180deg, rgba(142,114,229,0.22), rgba(142,114,229,0.10));
  border-color: rgba(142,114,229,0.55);
}
.ph-status.ph-open {
  color: var(--wallet-purple);
  background: rgba(142,114,229,0.18);
}
.ph-status.ph-open:before {
  content: '●';
  margin-right: 4px;
  animation: pricePulse 1500ms ease-in-out infinite;
}

/* Closed (passed) — green */
.ph-row.ph-closed { opacity: 0.62; }
.ph-status.ph-closed {
  color: var(--green);
  background: rgba(42,255,156,0.12);
}

/* Liquidated (hit) — pink */
.ph-row.ph-liquidated {
  background: rgba(255,42,138,0.12);
  border-color: rgba(255,42,138,0.40);
}
.ph-status.ph-liq {
  color: var(--pink);
  background: rgba(255,42,138,0.16);
}

/* Watermark — bottom-right tiny */
.tf-watermark {
  position: absolute;
  right: 12px; bottom: 6px;
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 9px;
  color: var(--text-3);
  letter-spacing: 0.06em;
  pointer-events: none;
}
.tf-watermark .wallet-mark {
  width: 12px; height: 12px;
  background: url('../assets/wallet/wallet-icon.png') center/contain no-repeat;
  border-radius: 3px;
}
.tf-watermark strong { color: rgba(255,255,255,0.55); font-weight: 600; }

/* ========== TMA debug overlay ========== */
#tma-debug {
  font-family: var(--font) !important;
  background: rgba(0,0,0,0.7) !important;
  border: 1px solid var(--stroke-2) !important;
}

/* ========== Bounding boxes (debug only) ========== */
.boundingbox {
  position: absolute; display: none;
  top: 0; left: 0; width: 0; height: 0;
  border: 1px solid red;
}

/* ========== Footer ========== */
#footer { display: none; }
