* {
    margin: 0; padding: 0;
    box-sizing: border-box;
    font-family: 'Nunito', sans-serif;
}

body {
    background: #0f172a;
    height: 100vh;
    overflow: hidden;
    position: relative;
    user-select: none;
    color: white;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 80%, rgba(239,68,68,0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(59,130,246,0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 20%, rgba(168,85,247,0.08) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.input_video  { display: none; }

.output_canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 10;
    pointer-events: none;
}

/* ==========================================
   BALON KATMANI
   ========================================== */
#balloon-layer {
    position: fixed;
    inset: 0;
    z-index: 20;
    pointer-events: none;
    overflow: hidden;
}

/* ==========================================
   BALON
   ========================================== */
.balloon-wrap {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
    will-change: left, top;
}

.balloon-body {
    width: 90px;
    height: 108px;
    border-radius: 50% 50% 48% 48% / 55% 55% 45% 45%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: inset -8px -12px 20px rgba(0,0,0,0.18), inset 6px 8px 16px rgba(255,255,255,0.25);
    animation: bsway 2.8s ease-in-out infinite;
    flex-shrink: 0;
}

/* Parlama efekti */
.balloon-body::before {
    content: '';
    position: absolute;
    width: 28%;
    height: 22%;
    top: 14%;
    left: 18%;
    background: rgba(255,255,255,0.35);
    border-radius: 50%;
    filter: blur(3px);
}

/* Küçük üçgen (bağlantı) */
.balloon-body::after {
    content: '';
    position: absolute;
    bottom: -7px;
    left: 50%;
    transform: translateX(-50%);
    width: 0; height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 10px solid currentColor;
}

.balloon-string {
    width: 2px;
    height: 40px;
    background: rgba(255,255,255,0.35);
    border-radius: 1px;
}

.balloon-icon {
    font-size: 2.2rem;
    line-height: 1;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.2));
    pointer-events: none;
    position: relative;
    z-index: 1;
}

@keyframes bsway {
    0%,100% { transform: rotate(-4deg); }
    50%      { transform: rotate(4deg); }
}

/* ---- Renk temaları ---- */
.balloon-wrap.type-shoot-red    .balloon-body { background: linear-gradient(145deg,#f87171,#dc2626); color: #dc2626; }
.balloon-wrap.type-shoot-yellow .balloon-body { background: linear-gradient(145deg,#fde047,#eab308); color: #eab308; }
.balloon-wrap.type-shoot-green  .balloon-body { background: linear-gradient(145deg,#4ade80,#16a34a); color: #16a34a; }
.balloon-wrap.type-stop-blue    .balloon-body { background: linear-gradient(145deg,#60a5fa,#2563eb); color: #2563eb; }
.balloon-wrap.type-stop-black   .balloon-body { background: linear-gradient(145deg,#64748b,#1e293b); color: #1e293b; }
.balloon-wrap.type-bonus-star   .balloon-body { background: linear-gradient(145deg,#f9a8d4,#db2777); color: #db2777; }

/* VUR balonu halkası */
.balloon-wrap.type-shoot-red    .balloon-body,
.balloon-wrap.type-shoot-yellow .balloon-body,
.balloon-wrap.type-shoot-green  .balloon-body {
    box-shadow:
        inset -8px -12px 20px rgba(0,0,0,0.18),
        inset 6px 8px 16px rgba(255,255,255,0.25),
        0 0 0 2px rgba(255,100,100,0.5);
}

/* ---- Pop animasyonu ---- */
.balloon-wrap.popped {
    animation: bpop 0.28s ease-out forwards;
    pointer-events: none;
}
@keyframes bpop {
    0%   { transform: scale(1);    opacity: 1; }
    40%  { transform: scale(1.35); opacity: 0.8; }
    100% { transform: scale(0.1);  opacity: 0; }
}

/* ---- Yanlış vuruş (mavi uyarı) ---- */
.balloon-wrap.wrong-pop {
    animation: bwrongpop 0.32s ease-out forwards;
}
@keyframes bwrongpop {
    0%   { transform: scale(1); filter: brightness(1); }
    30%  { transform: scale(1.2); filter: brightness(2.5) hue-rotate(0deg); }
    100% { transform: scale(0.1); opacity: 0; }
}

/* ---- Geçilen DUR balonu (yeşil tik) ---- */
.pass-tick {
    position: fixed;
    font-size: 1.6rem;
    font-weight: 900;
    pointer-events: none;
    z-index: 60;
    animation: tickUp 0.8s ease-out forwards;
}
@keyframes tickUp {
    0%   { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-50px) scale(0.8); }
}

/* ==========================================
   KURAL GÖSTERGESİ
   ========================================== */
#rule-badge {
    position: fixed;
    top: 88px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
    display: none;
    align-items: center;
    gap: 0.8rem;
    background: rgba(0,0,0,0.48);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 16px;
    padding: 0.55rem 1.4rem;
    white-space: nowrap;
}

#rule-badge.visible { display: flex; }

.rb-item { font-size: 0.9rem; font-weight: 900; letter-spacing: 1px; }
.rb-item.shoot b { color: #f87171; }
.rb-item.stop  b { color: #60a5fa; }
.rb-sep { color: rgba(255,255,255,0.3); font-size: 1.2rem; }

/* ==========================================
   BAŞLANGIÇ MODALİ — Açıklama
   ========================================== */
.legend-grid {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1.2rem;
}

.legend-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: 900;
    letter-spacing: 1.5px;
}

.legend-balloon {
    width: 52px;
    height: 64px;
    border-radius: 50% 50% 48% 48% / 55% 55% 45% 45%;
    box-shadow: inset -5px -8px 14px rgba(0,0,0,0.18), inset 4px 6px 10px rgba(255,255,255,0.22);
}

.legend-balloon.red  { background: linear-gradient(145deg,#f87171,#dc2626); }
.legend-balloon.blue { background: linear-gradient(145deg,#60a5fa,#2563eb); }

.shoot-item { color: #fca5a5; }
.stop-item  { color: #93c5fd; }

/* ==========================================
   HUD
   ========================================== */
#game-ui {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.2rem 2rem;
    pointer-events: none;
}

.hud-panel {
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 16px;
    padding: 0.6rem 1.5rem;
    text-align: center;
    min-width: 110px;
}

.hud-label {
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 1.8px;
    color: rgba(255,255,255,0.5);
    margin-bottom: 0.2rem;
}

.hud-value {
    font-size: 2.2rem;
    font-weight: 900;
    color: #fff;
    line-height: 1;
}

.timer-value { transition: color 0.3s; }
.timer-value.urgent {
    color: #f87171;
    animation: heartbeat 0.7s ease-in-out infinite;
}
@keyframes heartbeat {
    0%,100% { transform: scale(1); }
    40%     { transform: scale(1.15); }
}

.hud-status {
    position: fixed;
    bottom: 1.5rem; left: 1.5rem;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 12px;
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 1px;
    pointer-events: none;
    z-index: 50;
}

.status-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 8px #ef4444;
    transition: all 0.3s;
}
.status-dot.active { background: #22c55e; box-shadow: 0 0 12px #22c55e; }

.hud-value.bump { animation: bump 0.25s cubic-bezier(0.175,0.885,0.32,1.275); }
@keyframes bump {
    0%  { transform: scale(1); }
    50% { transform: scale(1.4); }
    100%{ transform: scale(1); }
}

/* ==========================================
   NİŞANGAH
   ========================================== */
#crosshair {
    position: fixed;
    width: 52px; height: 52px;
    transform: translate(-50%, -50%);
    display: none;
    pointer-events: none;
    z-index: 100;
    transition: transform 0.08s;
}

.ch-ring {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.7);
}
.ch-ring.outer { width: 52px; height: 52px; }
.ch-ring.inner { width: 18px; height: 18px; border-color: rgba(255,255,255,0.5); }

.ch-line {
    position: absolute;
    background: rgba(255,255,255,0.65);
}
.ch-line.h { top: 50%; left: 50%; width: 52px; height: 1.5px; transform: translate(-50%, -50%); }
.ch-line.v { top: 50%; left: 50%; width: 1.5px; height: 52px; transform: translate(-50%, -50%); }

#crosshair.aimed .ch-ring.outer { border-color: #f87171; box-shadow: 0 0 12px rgba(248,113,113,0.6); }
#crosshair.aimed .ch-line       { background: rgba(248,113,113,0.8); }
#crosshair.aimed .ch-ring.inner { border-color: #f87171; }

#crosshair.fired {
    animation: chFire 0.18s ease-out;
}
@keyframes chFire {
    0%   { transform: translate(-50%,-50%) scale(1); }
    40%  { transform: translate(-50%,-50%) scale(0.6); }
    100% { transform: translate(-50%,-50%) scale(1); }
}

/* ==========================================
   FLOATING SCORE
   ========================================== */
.floating-score {
    position: fixed;
    font-weight: 900;
    font-size: 1.8rem;
    pointer-events: none;
    z-index: 60;
    animation: floatUp 0.9s ease-out forwards;
    text-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
@keyframes floatUp {
    0%  { opacity: 1; transform: translateY(0) scale(1); }
    60% { transform: translateY(-40px) scale(1.2); }
    100%{ opacity: 0; transform: translateY(-60px) scale(0.9); }
}

/* ==========================================
   MODAL
   ========================================== */
.game-modal {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10,8,30,0.88);
}
.game-modal.hidden { display: none; }

.modal-content {
    text-align: center;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 28px;
    padding: 2rem 2.8rem;
    max-width: 480px;
    width: 92%;
    box-shadow: 0 24px 64px rgba(0,0,0,0.5);
    animation: modalIn 0.45s cubic-bezier(0.22,1,0.36,1);
    max-height: 94vh;
    overflow-y: auto;
}
@keyframes modalIn {
    from { opacity:0; transform: scale(0.85) translateY(20px); }
    to   { opacity:1; transform: scale(1)    translateY(0); }
}

.modal-icon {
    font-size: 3rem;
    margin-bottom: 0.6rem;
    animation: iconBounce 2s ease-in-out infinite;
}
@keyframes iconBounce {
    0%,100% { transform: translateY(0); }
    50%     { transform: translateY(-8px); }
}

.modal-title {
    font-size: 2.4rem;
    font-weight: 900;
    letter-spacing: 4px;
    background: linear-gradient(135deg, #fff 30%, #fbbf24);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.modal-subtitle {
    font-size: 0.92rem;
    color: rgba(255,255,255,0.65);
    margin-bottom: 1.2rem;
    line-height: 1.7;
}

.score-rules {
    display: flex;
    flex-direction: column;
    gap: 0.42rem;
    margin-bottom: 1.2rem;
    text-align: left;
}
.rule-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
    padding: 0.48rem 0.9rem;
    border: 1px solid rgba(255,255,255,0.08);
}
.rule-icon  { font-size: 1rem; width: 1.4rem; text-align: center; }
.rule-text  { flex: 1; color: rgba(255,255,255,0.8); font-size: 0.86rem; }
.rule-points { font-weight: 900; font-size: 0.92rem; }
.rule-item.hit    .rule-points { color: #34d399; }
.rule-item.miss   .rule-points { color: #f87171; }
.rule-item.escape .rule-points { color: #fbbf24; }
.rule-item.bonus  .rule-points { color: #a78bfa; }

.diff-section { margin-bottom: 1.2rem; }
.diff-label {
    font-size: 0.68rem; font-weight: 900; letter-spacing: 3px;
    color: rgba(255,255,255,0.4); margin-bottom: 0.5rem;
}
.diff-row { display: flex; gap: 0.6rem; }

.diff-btn {
    flex: 1;
    padding: 0.7rem 0.4rem;
    border-radius: 12px;
    border: 2px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.7);
    font-family: 'Nunito', sans-serif;
    font-size: 0.82rem; font-weight: 900;
    letter-spacing: 1px; cursor: pointer;
    transition: all 0.2s; line-height: 1.35;
}
.diff-btn span { display: block; font-size: 0.62rem; font-weight: 700; opacity: 0.65; letter-spacing: 0; margin-top: 2px; }
.diff-btn:hover { background: rgba(255,255,255,0.1); }
.diff-btn.easy.selected   { background: rgba(34,197,94,0.25);  border-color: #22c55e; color: #86efac; }
.diff-btn.medium.selected { background: rgba(251,191,36,0.25); border-color: #fbbf24; color: #fde68a; }
.diff-btn.hard.selected   { background: rgba(239,68,68,0.25);  border-color: #ef4444; color: #fca5a5; }
.diff-btn.hovered { transform: scale(1.05); filter: brightness(1.3); }

.action-btn {
    display: flex; align-items: center; justify-content: center;
    gap: 0.6rem; width: 100%; padding: 1rem 2rem;
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    border: none; border-radius: 14px; color: white;
    font-size: 1.2rem; font-weight: 900; letter-spacing: 3px; cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
    box-shadow: 0 4px 20px rgba(124,58,237,0.5);
}
.action-btn.disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }
.action-btn.hovered  { transform: scale(1.05); filter: brightness(1.3); box-shadow: 0 0 30px rgba(124,58,237,0.9); }

.btn-hint {
    margin-top: 0.6rem; font-size: 0.74rem;
    color: rgba(255,255,255,0.3); letter-spacing: 1px;
}
.privacy-notice {
    margin-top: 0.8rem; font-size: 0.7rem;
    color: rgba(255,255,255,0.3);
    border-left: 2px solid rgba(255,255,255,0.1);
    padding-left: 0.8rem; text-align: left;
}

.stats-grid { display: flex; gap: 0.8rem; margin: 1.2rem 0 1.5rem; }
.stat-box {
    flex: 1; background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 14px; padding: 0.8rem 0.5rem;
}
.stat-label { font-size: 0.62rem; letter-spacing: 1.5px; color: rgba(255,255,255,0.4); margin-bottom: 0.3rem; }
.stat-value    { font-size: 2.2rem; font-weight: 900; color: #fff; }
.correct-color { color: #34d399 !important; }
.wrong-color   { color: #f87171 !important; }

@keyframes screenShake {
    0%  { transform: translate(0,0); }
    20% { transform: translate(-10px,5px); }
    40% { transform: translate(10px,-5px); }
    60% { transform: translate(-10px,-5px); }
    80% { transform: translate(10px,5px); }
    100%{ transform: translate(0,0); }
}
/* Kırmızı flaş — yanlış vuruş */
@keyframes redFlash {
    0%  { background: rgba(239,68,68,0) ; }
    20% { background: rgba(239,68,68,0.28); }
    100%{ background: rgba(239,68,68,0); }
}
.shake      { animation: screenShake 0.35s ease both; }
.red-flash  { animation: redFlash 0.45s ease both; }

@media (max-width: 768px) {
    #game-ui { padding: 0.5rem 0.4rem; }
    .hud-panel { min-width: 80px; padding: 0.4rem 0.6rem; }
    .hud-value { font-size: 1.5rem; }
    .balloon-body { width: 74px; height: 88px; }
    .balloon-icon { font-size: 1.8rem; }
}
