:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --game-max: 640px;
  --green: #1ed760;
  --lime: #7cff67;
  --yellow: #ffe100;
  --blue: #51c9ff;
  --navy: #072a31;
  --ink: #031317;
  --theme-accent: #61df54;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; width: 100%; min-height: 100%; overflow: hidden; overscroll-behavior: none; background: #031116; color: #fff; font-family: "Trebuchet MS", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body.canary-game { width: 100vw; height: 100dvh; touch-action: none; user-select: none; }
body.canary-game::before { content: ""; position: fixed; inset: 0; pointer-events: none; background: radial-gradient(circle at 50% 25%, rgba(24, 153, 117, .18), transparent 34%), #020b0e; }
#flappy-canvas { position: fixed; z-index: 1; top: 0; bottom: 0; left: max(0px, calc((100vw - var(--game-max)) / 2)); width: min(100vw, var(--game-max)); height: 100dvh; display: block; background: #123f47; touch-action: none; box-shadow: 0 0 70px rgba(0,0,0,.72); }
body.collision-shake #flappy-canvas { animation: collisionShake .38s cubic-bezier(.36,.07,.19,.97); }
@keyframes collisionShake { 0%,100%{transform:translate3d(0,0,0)} 15%{transform:translate3d(-7px,3px,0)} 30%{transform:translate3d(6px,-4px,0)} 45%{transform:translate3d(-5px,-2px,0)} 60%{transform:translate3d(4px,3px,0)} 75%{transform:translate3d(-2px,-1px,0)} }
html.is-android, html.is-android body { height: 100%; min-height: 100%; }
html.is-android body.canary-game, html.is-android #flappy-canvas { height: 100svh; }

.boot-loader { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 22px; background: radial-gradient(circle at 50% 18%, rgba(28, 220, 105, .25), transparent 36%), linear-gradient(180deg, #082f38 0%, #020e12 100%); transition: opacity .25s ease, visibility .25s ease; }
.boot-loader.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.boot-card { width: min(90vw, 340px); padding: 25px 21px 21px; border: 1px solid rgba(137,255,164,.22); border-radius: 25px; background: linear-gradient(180deg, rgba(10,60,65,.95), rgba(2,20,25,.96)); box-shadow: 0 24px 70px rgba(0,0,0,.48), inset 0 1px 0 rgba(255,255,255,.08); text-align: center; }
.boot-card h1 { margin: 12px 0 5px; color: #fff; font-size: 1.55rem; letter-spacing: -.04em; font-weight: 1000; }
.boot-card p { margin: 0 0 14px; color: rgba(235,255,243,.76); font-size: .84rem; line-height: 1.38; }
.boot-card small { color: rgba(235,255,243,.74); font-weight: 900; }
.boot-mark { width: 72px; height: 72px; margin: 0 auto; position: relative; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle, rgba(255,225,0,.88), rgba(255,225,0,.12) 60%, transparent 68%); }
.boot-mark span, .boot-mark i { position: absolute; inset: 5px; border-radius: 50%; border: 3px solid transparent; border-top-color: var(--lime); border-right-color: var(--blue); animation: bootSpin 1.05s linear infinite; }
.boot-mark i { inset: 18px; border-top-color: #fff; border-right-color: var(--yellow); animation-duration: .72s; animation-direction: reverse; }
.boot-progress { height: 7px; margin: 14px 0 8px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,.14); }
.boot-progress span { display: block; width: 35%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--green), var(--yellow), var(--blue)); animation: bootLoad 1.2s ease-in-out infinite; }
@keyframes bootSpin { to { transform: rotate(360deg); } }
@keyframes bootLoad { 0% { transform: translateX(-110%); } 100% { transform: translateX(300%); } }

.top-hud { position: fixed; z-index: 20; top: calc(0px + var(--safe-top)); left: 50%; width: min(100vw, var(--game-max)); min-height: 76px; padding: 16px 18px 0; transform: translateX(-50%); display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; pointer-events: none; text-shadow: 0 2px 2px rgba(0,0,0,.55); }
.hud-item { min-width: 0; color: rgba(237,248,247,.74); font-size: .72rem; font-weight: 800; text-transform: uppercase; line-height: 1.05; }
.hud-item span { display: block; }
.hud-item strong { display: block; margin-top: 4px; color: #fff; font-size: .9rem; line-height: 1; letter-spacing: -.025em; text-transform: none; }
.hud-item small { display: block; margin-top: 5px; color: rgba(234,249,247,.62); font-size: .58rem; text-transform: none; }
.hud-item small b { color: #fff; font-size: inherit; }
.hud-bet { text-align: left; }
.hud-bet strong { color: #d9ff8a; }
.demo-hud .hud-bet strong { display: none; }
.hud-prize { justify-self: center; text-align: center; }
.hud-prize strong { margin-top: 2px; color: #5dceff; font-family: "Arial Black", "Trebuchet MS", sans-serif; font-size: clamp(1.75rem, 7.2vw, 2.55rem); letter-spacing: -.075em; text-shadow: 0 4px 0 #0d516b, 0 6px 10px rgba(0,0,0,.46); white-space: nowrap; }
.hud-target { justify-self: end; text-align: right; }
.hud-target strong { color: var(--yellow); font-size: 1.28rem; font-family: "Arial Black", "Trebuchet MS", sans-serif; text-shadow:0 3px 0 rgba(91,70,0,.62),0 6px 12px rgba(0,0,0,.36); }

.exit-btn { position: fixed; z-index: 23; top: calc(63px + var(--safe-top)); right: max(16px, calc((100vw - var(--game-max)) / 2 + 16px)); min-width: 50px; height: 32px; padding: 0 12px; border: 1px solid rgba(255,255,255,.28); border-radius: 10px; background: rgba(8,35,37,.58); color: #f4fffa; font-weight: 800; font-size: .82rem; box-shadow: 0 6px 16px rgba(0,0,0,.2); cursor: pointer; }
.exit-btn:active { transform: scale(.97); }

.round-panel { position: fixed; z-index: 20; top: calc(76px + var(--safe-top)); left: 50%; width: min(220px, 42vw); padding: 0; transform: translateX(-50%); pointer-events: none; }
.result-line { display: none; }
.progress-track { height: 14px; padding: 3px; overflow: hidden; border: 1px solid rgba(255,255,255,.14); border-radius: 99px; background: rgba(1,19,22,.54); box-shadow: inset 0 2px 4px rgba(0,0,0,.28); }
.progress-track span { display: block; width: 0%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #28c9f1 0%, #55ddff 55%, #a7f3ff 100%); box-shadow: 0 0 12px rgba(44,203,242,.42); transition: width .18s ease; }
.round-panel small { display: none; }

.sound-btn { position: fixed; z-index: 24; right: max(18px, calc((100vw - var(--game-max)) / 2 + 18px)); bottom: calc(17px + var(--safe-bottom)); width: 55px; height: 55px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.28); border-radius: 17px; background: rgba(4,38,26,.8); color: #fff; box-shadow: 0 10px 22px rgba(0,0,0,.35); cursor: pointer; }
.sound-btn svg { width: 29px; height: 29px; fill: currentColor; }
.sound-btn.muted { color: rgba(255,255,255,.42); }
.sound-btn:active { transform: scale(.96); }

.cashout-btn { position: fixed; z-index: 32; left: 50%; bottom: calc(84px + var(--safe-bottom)); width: min(82vw, 330px); height: 52px; transform: translateX(-50%); border: 1px solid rgba(255,255,255,.48); border-radius: 16px; background: linear-gradient(180deg, #fff35c, #45e66f); color: #082316; font-size: 1rem; font-weight: 1000; box-shadow: 0 14px 32px rgba(28,215,96,.34); cursor: pointer; }
.cashout-btn.hidden { display: none; }
.cashout-btn:active { transform: translateX(-50%) scale(.985); }
body[data-mode="demo"] .cashout-btn { border-color:#ffe7a6; background:linear-gradient(180deg,#ffb229 0%,#ff7a00 55%,#f45100 100%); color:#2b1000; box-shadow:0 12px 34px rgba(255,106,0,.58),0 0 18px rgba(255,172,37,.42); animation:demoRescuePulse .9s ease-in-out infinite; }
@keyframes demoRescuePulse { 0%,100% { transform:translateX(-50%) scale(1); } 50% { transform:translateX(-50%) scale(1.075); } }

.gesture-hint { position: fixed; z-index: 34; top: 50%; left: 50%; width: min(90vw, 580px); transform: translate(-50%, -50%); display: grid; justify-items: center; gap: 6px; pointer-events: none; text-align: center; }
.gesture-hint.hidden { display: none; }
.gesture-hint strong { color: #71f294; font-family: "Arial Black", "Trebuchet MS", sans-serif; font-size: clamp(1.75rem, 7.8vw, 2.75rem); letter-spacing: -.06em; line-height: 1; text-shadow: 0 4px 0 rgba(0,88,55,.72), 0 7px 16px rgba(0,0,0,.52); animation: hintPulse 1.15s ease-in-out infinite; }
.gesture-hint small { color: rgba(255,255,255,.82); font-size: .73rem; font-weight: 800; text-shadow: 0 2px 8px rgba(0,0,0,.6); }
@keyframes hintPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.035); } }

.rewind-overlay { position: fixed; z-index: 22; top: 0; bottom: 0; left: 50%; width: min(100vw, var(--game-max)); transform: translateX(-50%); display: grid; place-items: center; overflow: hidden; pointer-events: all; background: rgba(2,17,20,.56); }
.rewind-overlay.hidden { display: none; }
.rewind-overlay::before { content: ""; position: absolute; inset: -8px 0 0; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(137,228,255,.085) 0 2px, transparent 2px 6px), linear-gradient(90deg, rgba(41,145,255,.10), transparent 34%, rgba(255,57,86,.08)); animation: rewindScan .22s linear infinite; }
.rewind-overlay::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle at center, transparent 10%, rgba(0,9,14,.22) 72%, rgba(0,5,9,.58) 100%); }
.rewind-feedback { position: relative; z-index: 1; display: grid; justify-items: center; gap: 11px; padding: 20px; text-align: center; filter: drop-shadow(0 8px 18px rgba(0,0,0,.52)); }
.rewind-icon { width: 78px; height: 78px; display: grid; place-items: center; border: 1px solid rgba(180,236,255,.72); border-radius: 14px; background: linear-gradient(145deg, #5daeff, #3890ef 58%, #286ed4); box-shadow: 0 0 16px rgba(72,174,255,.9), 0 0 36px rgba(44,137,255,.48), inset 0 1px 0 rgba(255,255,255,.5); animation: rewindPulse .52s ease-in-out infinite; }
.rewind-icon svg { width: 57px; height: 57px; fill: #fff; filter: drop-shadow(0 2px 2px rgba(0,50,130,.38)); }
.rewind-feedback strong { color: #a6eaff; font-size: clamp(1rem, 4.4vw, 1.35rem); font-weight: 1000; letter-spacing: .13em; text-shadow: 0 0 10px rgba(104,218,255,.92), 0 3px 0 rgba(0,61,91,.72); }
.rewind-feedback small { color: rgba(225,249,255,.82); font-size: .72rem; font-weight: 900; letter-spacing: .02em; text-shadow: 0 2px 8px rgba(0,0,0,.72); }
@keyframes rewindScan { to { transform: translateY(6px); } }
@keyframes rewindPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(.92); } }

.overlay, .bet-modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: calc(18px + var(--safe-top)) 14px calc(18px + var(--safe-bottom)); background: rgba(0,20,19,.64); transition: opacity .22s ease, visibility .22s ease; }
.overlay.hidden, .bet-modal.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.panel, .bet-card { width: min(90vw, 360px); padding: 23px 19px 19px; border: 1px solid rgba(116,244,144,.27); border-radius: 24px; background: linear-gradient(180deg, rgba(13,76,62,.98), rgba(3,32,30,.98)); box-shadow: 0 24px 68px rgba(0,0,0,.48), inset 0 1px 0 rgba(255,255,255,.08); text-align: center; }
.panel-badge { display: inline-flex; min-height: 29px; align-items: center; justify-content: center; padding: 0 13px; border: 1px solid rgba(255,225,0,.28); border-radius: 99px; background: rgba(255,225,0,.13); color: var(--yellow); font-size: .69rem; font-weight: 1000; letter-spacing: .08em; text-transform: uppercase; }
.panel h1, .bet-card h2 { margin: 13px 0 7px; color: #fff; font-size: 1.58rem; font-weight: 1000; letter-spacing: -.05em; }
.panel p, .bet-card p { margin: 0 0 17px; color: rgba(236,255,242,.78); font-size: .88rem; font-weight: 700; line-height: 1.42; }
.panel button, .bet-btn { width: 100%; height: 50px; border: 0; border-radius: 15px; background: linear-gradient(180deg, #fff251, #32dd69); color: #092619; font-size: .96rem; font-weight: 1000; box-shadow: 0 12px 28px rgba(24,210,91,.27); cursor: pointer; }
.panel button:disabled { opacity: .6; cursor: wait; }
body[data-mode="demo"] .overlay.demo-result .panel-badge { display: none; }
body[data-mode="demo"] .overlay.demo-result .panel h1 { margin: 0 0 12px; font-size: 1.12rem; letter-spacing: -.025em; }
body[data-mode="demo"] .overlay.demo-result .panel p { margin: 0 0 21px; color: #fff251; font-size: clamp(2.35rem, 11vw, 3.25rem); font-weight: 1000; line-height: 1; letter-spacing: -.065em; text-shadow: 0 4px 0 rgba(0,75,42,.55), 0 10px 24px rgba(255,226,48,.2); }
body[data-mode="demo"] .overlay.demo-result .panel button { text-transform: uppercase; }
.bet-btn.secondary { border: 1px solid rgba(255,255,255,.15); background: rgba(255,255,255,.08); color: #fff; box-shadow: none; }
.bet-actions { display: grid; grid-template-columns: .9fr 1.1fr; gap: 9px; margin-top: 14px; }
.bet-stepper { display: grid; grid-template-columns: 48px 1fr 48px; gap: 8px; align-items: center; margin: 12px 0 8px; }
.bet-stepper > * { min-width:0; }
.bet-step-btn { height: 48px; border: 1px solid rgba(255,255,255,.17); border-radius: 14px; background: rgba(255,255,255,.08); color: #fff; font-size: 1.3rem; font-weight: 1000; }
#bet-input { width:100%; min-width:0; height:48px; border:1px solid rgba(255,255,255,.18); border-radius:14px; outline:0; background:rgba(0,0,0,.2); color:var(--yellow); text-align:center; font-size:1.32rem; font-weight:1000; }
.bet-card small { display: block; color: rgba(235,255,242,.66); font-size: .7rem; font-weight: 800; }
#bet-preview { display:flex; align-items:center; justify-content:center; gap:8px; flex-wrap:wrap; margin-top:10px; }
#bet-preview span { color:rgba(235,255,242,.72); }
#bet-preview strong { padding:6px 10px; border:1px solid rgba(255,225,0,.3); border-radius:999px; background:rgba(255,225,0,.12); color:var(--yellow); font-size:.88rem; }
.bet-suggest-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 11px 0; }
.bet-suggest-btn { height: 37px; border: 1px solid rgba(255,255,255,.15); border-radius: 12px; background: rgba(255,255,255,.08); color: #effff4; font-weight: 900; }
.bet-suggest-btn,.bet-btn { min-width:0; }

.gain-feed { position: fixed; inset: 0; z-index: 31; pointer-events: none; overflow: hidden; }
.gain-pop { position: absolute; color: #d8ff78; font-family: "Arial Black", "Trebuchet MS", sans-serif; font-size: 1.05rem; font-weight: 1000; white-space: nowrap; text-shadow: 0 3px 0 rgba(0,82,49,.72), 0 6px 14px rgba(0,0,0,.42); animation: gainRise .72s ease-out forwards; }
@keyframes gainRise { from { opacity: 0; transform: translate(-50%, 4px) scale(.88); } 16% { opacity: 1; } to { opacity: 0; transform: translate(-50%, -54px) scale(1.06); } }

@media (max-width: 430px) {
  .top-hud { padding-inline: 17px; }
  .hud-item { font-size: .66rem; }
  .hud-item strong { font-size: .82rem; }
  .hud-prize strong { font-size: clamp(1.72rem, 9vw, 2.25rem); }
  .hud-target strong { font-size: 1.08rem; }
  .round-panel { top: calc(72px + var(--safe-top)); width: 220px; max-width: 44vw; }
  .progress-track { height: 13px; }
  .exit-btn { top: calc(61px + var(--safe-top)); right: 16px; }
  .gesture-hint { top: 51%; }
}

@media (max-width: 360px) {
  .top-hud { padding-inline: 12px; }
  .hud-prize strong { font-size: 1.65rem; }
  .round-panel { width: 142px; }
  .panel, .bet-card { padding: 20px 16px 16px; border-radius: 21px; }
  .panel h1, .bet-card h2 { font-size: 1.4rem; }
  .sound-btn { width: 49px; height: 49px; border-radius: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  .boot-mark span, .boot-mark i, .boot-progress span, .gesture-hint strong, .rewind-overlay::before, .rewind-icon, body[data-mode="demo"] .cashout-btn, body.collision-shake #flappy-canvas { animation: none; }
}
