* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100dvh; overflow: hidden; font-family: 'Poppins', sans-serif; }
.screen { position: fixed; inset: 0; display: none; flex-direction: column; opacity: 0; transition: opacity .3s ease; }
.screen.active { display: flex; opacity: 1; }
.screen.fade-out { opacity: 0; }

/* Landing */
#landing { background: linear-gradient(135deg, #1a0a2e 0%, #2d1b69 50%, #1a0a2e 100%); justify-content: center; align-items: center; text-align: center; z-index: 10; }
#bgCanvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.landing-content { position: relative; z-index: 2; padding: 20px; }
.landing-title { font-family: 'Baloo 2', cursive; font-size: clamp(2.2rem, 8vw, 4rem); color: #fff; text-shadow: 0 0 30px rgba(233,30,99,.6), 0 0 60px rgba(255,107,53,.4); margin-bottom: 12px; animation: glow 2s ease-in-out infinite alternate; }
@keyframes glow { to { text-shadow: 0 0 40px rgba(76,175,80,.6), 0 0 80px rgba(255,214,0,.4); } }
.landing-subtitle { color: rgba(255,255,255,.8); font-size: clamp(.9rem, 3vw, 1.2rem); margin-bottom: 32px; }
.landing-hint { color: rgba(255,255,255,.5); font-size: .85rem; margin-top: 16px; }
/* Live stats on landing */
.live-stats { position: absolute; bottom: 40px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; z-index: 3; animation: fadeInSlide .6s ease-out .5s both; }
.live-stat { display: flex; flex-direction: column; align-items: center; background: rgba(255,255,255,.1); backdrop-filter: blur(10px); border: 1px solid rgba(255,255,255,.15); border-radius: 14px; padding: 10px 18px; }
.live-stat .ls-value { font-size: 1.2rem; font-weight: 700; color: #fff; line-height: 1; }
.live-stat .ls-label { font-size: .55rem; color: rgba(255,255,255,.5); margin-top: 4px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.live-stats:empty { display: none; }

.landing-footer { position: absolute; bottom: 16px; color: rgba(255,255,255,.4); font-size: .75rem; z-index: 2; }

/* Buttons */
.btn { border: none; border-radius: 50px; padding: 14px 32px; font-family: 'Poppins', sans-serif; font-weight: 600; font-size: 1rem; cursor: pointer; transition: all .2s; touch-action: manipulation; }
.btn:active { transform: scale(.95); }
.btn-primary { background: linear-gradient(135deg, #E91E63, #FF6B35); color: #fff; font-size: 1.15rem; box-shadow: 0 4px 20px rgba(233,30,99,.4); }
.pulse { animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 4px 20px rgba(233,30,99,.4); } 50% { box-shadow: 0 4px 40px rgba(233,30,99,.7); } }

/* Play Screen */
#playScreen { background: #fff; }
#mainCanvas { width: 100%; height: 100dvh; touch-action: none; cursor: crosshair; }
.canvas-watermark { position: absolute; top: 45%; left: 50%; transform: translate(-50%, -50%); color: rgba(0,0,0,.12); font-size: 1.4rem; font-family: 'Poppins', sans-serif; text-align: center; pointer-events: none; z-index: 1; line-height: 1.8; }
.canvas-watermark.hidden { display: none; }

/* Top bar */
.top-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 5; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 12px 16px; pointer-events: none; }
.top-bar > * { pointer-events: auto; }
.tap-counter { background: rgba(0,0,0,.6); color: #fff; padding: 6px 14px; border-radius: 20px; font-size: .8rem; backdrop-filter: blur(5px); }
.tap-counter:empty { display: none; }
.btn-card { background: linear-gradient(135deg, #E91E63, #9C27B0); color: #fff; padding: 10px 20px; font-size: .85rem; animation: cardGlow 2s infinite; box-shadow: 0 4px 20px rgba(156,39,176,.4); }
.btn-card.hidden { display: none; }
@keyframes cardGlow { 0%,100% { box-shadow: 0 4px 20px rgba(156,39,176,.4); } 50% { box-shadow: 0 4px 35px rgba(156,39,176,.8), 0 0 20px rgba(233,30,99,.5); } }

.challenge-text { position: fixed; top: 52px; left: 50%; transform: translateX(-50%); background: rgba(233,30,99,.85); color: #fff; padding: 6px 14px; border-radius: 12px; font-size: .75rem; z-index: 5; animation: fadeInSlide .5s ease-out; }
.challenge-text.hidden { display: none; }
@keyframes fadeInSlide { from { opacity: 0; transform: translateX(-50%) translateY(-10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ========== BOTTOM TOOLBAR ========== */
.bottom-toolbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 8; display: flex; justify-content: space-around; align-items: center; background: rgba(0,0,0,.85); backdrop-filter: blur(12px); padding: 6px 4px; padding-bottom: max(6px, env(safe-area-inset-bottom)); border-top: 1px solid rgba(255,255,255,.1); }
.toolbar-btn { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; background: none; border: none; color: rgba(255,255,255,.5); cursor: pointer; padding: 6px 2px; font-family: 'Poppins', sans-serif; transition: all .2s; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.toolbar-btn:active { transform: scale(.9); }
.toolbar-btn.active { color: #E91E63; }
.toolbar-btn .tb-icon { font-size: 1.3rem; line-height: 1; }
.toolbar-btn .tb-label { font-size: .6rem; font-weight: 600; letter-spacing: .02em; }

/* ========== TOOL PANELS (above toolbar) ========== */
.tool-panel { position: fixed; bottom: 60px; left: 0; right: 0; z-index: 7; background: rgba(0,0,0,.75); backdrop-filter: blur(12px); padding: 10px 10px; transition: transform .25s ease, opacity .25s ease; border-top: 1px solid rgba(255,255,255,.08); }
.tool-panel.hidden { transform: translateY(100%); opacity: 0; pointer-events: none; }

/* Color picker inside panel */
.color-picker { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; padding: 2px 0; }
.color-dot { width: 34px; height: 34px; border-radius: 50%; border: 2.5px solid transparent; cursor: pointer; transition: all .15s; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.color-dot.active { border-color: #fff; transform: scale(1.2); box-shadow: 0 0 10px rgba(255,255,255,.5); animation: dotBounce .3s ease-out; }
@keyframes dotBounce { 0% { transform: scale(1); } 50% { transform: scale(1.35); } 100% { transform: scale(1.2); } }
.color-dot.random { background: conic-gradient(#FF6B35, #E91E63, #4CAF50, #FFD600, #2196F3, #9C27B0, #FF6B35); }

/* Sticker list */
.sticker-list { display: flex; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding: 2px 4px; }
.sticker-list::-webkit-scrollbar { display: none; }
.sticker-item { flex-shrink: 0; width: 52px; height: 52px; border-radius: 10px; border: 2px solid rgba(255,255,255,.3); cursor: pointer; transition: all .2s; background: rgba(255,255,255,.15); display: flex; align-items: center; justify-content: center; }
.sticker-item canvas { border-radius: 8px; }
.sticker-item.active { border-color: #E91E63; transform: scale(1.15); box-shadow: 0 0 12px rgba(233,30,99,.6); background: rgba(233,30,99,.2); }
.sticker-hint { position: fixed; bottom: 130px; left: 50%; transform: translateX(-50%); background: rgba(233,30,99,.9); color: #fff; padding: 6px 16px; border-radius: 20px; font-size: .8rem; z-index: 8; white-space: nowrap; animation: fadeInSlide .3s ease-out; }
.sticker-hint.hidden { display: none; }

/* Frame list */
.frame-list { display: flex; gap: 10px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding: 4px; }
.frame-list::-webkit-scrollbar { display: none; }
.frame-item { flex-shrink: 0; width: 64px; height: 88px; border-radius: 8px; border: 2.5px solid rgba(255,255,255,.25); cursor: pointer; transition: all .2s; background: rgba(255,255,255,.1); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.frame-item canvas { border-radius: 4px; }
.frame-item .frame-name { font-size: .55rem; color: rgba(255,255,255,.7); text-align: center; line-height: 1.1; }
.frame-item.active { border-color: #E91E63; transform: scale(1.08); box-shadow: 0 0 12px rgba(233,30,99,.5); background: rgba(233,30,99,.15); }

/* Photo hint */
.photo-hint { position: fixed; top: 60px; left: 50%; transform: translateX(-50%); background: rgba(233,30,99,.9); color: #fff; padding: 6px 16px; border-radius: 20px; font-size: .8rem; z-index: 8; white-space: nowrap; }
.photo-hint.hidden { display: none; }

/* Overlay */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; z-index: 20; backdrop-filter: blur(5px); }
.overlay.hidden { display: none; }
.overlay-card { background: #fff; border-radius: 20px; padding: 32px 28px; text-align: center; max-width: 340px; width: 90%; animation: popIn .3s ease-out; max-height: 85vh; overflow-y: auto; }
@keyframes popIn { from { opacity: 0; transform: scale(.8); } to { opacity: 1; transform: scale(1); } }
.overlay-card h2 { font-family: 'Baloo 2', cursive; font-size: 1.6rem; margin-bottom: 8px; }
.overlay-card p { color: #666; margin-bottom: 20px; }
.greeting-picker { display: flex; flex-direction: column; gap: 6px; max-height: 180px; overflow-y: auto; margin-bottom: 14px; padding: 4px 0; }
.greeting-picker::-webkit-scrollbar { width: 3px; }
.greeting-picker::-webkit-scrollbar-thumb { background: #E91E63; border-radius: 3px; }
.greeting-opt { padding: 10px 14px; border: 2px solid #eee; border-radius: 12px; font-size: .85rem; font-family: 'Poppins', sans-serif; cursor: pointer; text-align: left; background: #fff; transition: all .2s; line-height: 1.3; }
.greeting-opt:active { transform: scale(.97); }
.greeting-opt.active { border-color: #E91E63; background: linear-gradient(135deg, rgba(233,30,99,.08), rgba(156,39,176,.08)); }
.overlay-card input { width: 100%; padding: 14px 18px; border: 2px solid #eee; border-radius: 12px; font-size: 1.1rem; font-family: 'Poppins', sans-serif; text-align: center; margin-bottom: 16px; outline: none; transition: border-color .2s; }
.overlay-card input:focus { border-color: #E91E63; }

/* Card Screen */
#cardScreen { background: #111; align-items: center; justify-content: center; }
#cardCanvas { max-width: 100%; max-height: 70vh; border-radius: 8px; box-shadow: 0 8px 40px rgba(0,0,0,.5); position: relative; z-index: 1; }
.confetti-overlay { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 20px; max-width: 400px; position: relative; z-index: 2; }
.btn-download { background: #4CAF50; color: #fff; }
.btn-share { background: #25D366; color: #fff; }
.btn-copy { background: #2196F3; color: #fff; }
.btn-story { background: linear-gradient(135deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888); color: #fff; }
.btn-status { background: #25D366; color: #fff; }
.btn-back { background: rgba(255,255,255,.15); color: #fff; }

.share-toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.85); color: #fff; padding: 12px 24px; border-radius: 30px; font-size: .95rem; z-index: 30; backdrop-filter: blur(10px); animation: popIn .3s ease-out; white-space: nowrap; }
.share-toast.hidden { display: none; }

@media (max-width: 400px) {
    .btn { padding: 12px 20px; font-size: .9rem; }
    .color-dot { width: 28px; height: 28px; }
    .toolbar-btn .tb-icon { font-size: 1.1rem; }
    .toolbar-btn .tb-label { font-size: .55rem; }
}
