* {
    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% 20%, rgba(59,130,246,0.14) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(249,115,22,0.14) 0%, transparent 50%),
        radial-gradient(ellipse at 20% 80%, rgba(34,197,94,0.14)  0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(168,85,247,0.14) 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;
}

/* ==========================================
   RAKAM KUTULARI (4 köşe)
   ========================================== */
.zone-box {
    position: fixed;
    width: 150px;
    height: 150px;
    border-radius: 22px;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
    transition: box-shadow 0.2s, transform 0.2s, background 0.2s;
}

.zone-box.visible { display: flex; }

.zone-top-left     { top: 90px;   left: 30px;  }
.zone-top-right    { top: 90px;   right: 30px; }
.zone-bottom-left  { bottom: 80px; left: 30px;  }
.zone-bottom-right { bottom: 80px; right: 30px; }

/* Köşe renkleri — görsel yön ayrımı için, anlamsal değil */
#zone-tl { background: rgba(59,130,246,0.18);  border: 3px solid rgba(59,130,246,0.5);  box-shadow: 0 6px 24px rgba(59,130,246,0.12); }
#zone-tr { background: rgba(249,115,22,0.18);  border: 3px solid rgba(249,115,22,0.5);  box-shadow: 0 6px 24px rgba(249,115,22,0.12); }
#zone-bl { background: rgba(34,197,94,0.18);   border: 3px solid rgba(34,197,94,0.5);   box-shadow: 0 6px 24px rgba(34,197,94,0.12);  }
#zone-br { background: rgba(168,85,247,0.18);  border: 3px solid rgba(168,85,247,0.5);  box-shadow: 0 6px 24px rgba(168,85,247,0.12); }

#zone-tl.hovered { background: rgba(59,130,246,0.45);  border-color: #3b82f6; box-shadow: 0 0 40px rgba(59,130,246,0.7);  transform: scale(1.08); }
#zone-tr.hovered { background: rgba(249,115,22,0.45);  border-color: #f97316; box-shadow: 0 0 40px rgba(249,115,22,0.7);  transform: scale(1.08); }
#zone-bl.hovered { background: rgba(34,197,94,0.45);   border-color: #22c55e; box-shadow: 0 0 40px rgba(34,197,94,0.7);   transform: scale(1.08); }
#zone-br.hovered { background: rgba(168,85,247,0.45);  border-color: #a855f7; box-shadow: 0 0 40px rgba(168,85,247,0.7);  transform: scale(1.08); }

.zone-box.correct-flash { animation: correctFlash 0.5s ease-out; }
.zone-box.wrong-flash   { animation: wrongFlash 0.5s ease-out; }

@keyframes correctFlash {
    0%  { filter: brightness(1); }
    30% { filter: brightness(2.8); }
    100%{ filter: brightness(1); }
}
@keyframes wrongFlash {
    0%,100% { filter: brightness(1); }
    25%  { filter: brightness(0.4) sepia(1) hue-rotate(-30deg); }
    75%  { filter: brightness(0.4) sepia(1) hue-rotate(-30deg); }
}

.zone-number {
    font-size: 3.8rem;
    font-weight: 900;
    color: #fff;
    line-height: 1;
    text-shadow: 0 2px 14px rgba(0,0,0,0.35);
    animation-fill-mode: both;
}

.zone-number.pop {
    animation: numPop 0.38s cubic-bezier(0.22,1,0.36,1);
}

@keyframes numPop {
    from { transform: scale(0.3) rotate(-8deg); opacity: 0; }
    to   { transform: scale(1)   rotate(0deg);  opacity: 1; }
}

/* ==========================================
   NESNE KARTI (orta)
   ========================================== */
#number-card {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 30;
    display: none;
    width: 190px;
    height: 190px;
    border-radius: 28px;
    background: white;
    box-shadow: 0 16px 48px rgba(0,0,0,0.35), 0 0 0 4px rgba(255,255,255,0.3);
    align-items: center;
    justify-content: center;
    animation: cardBob 2s ease-in-out infinite;
    will-change: left, top;
}

@keyframes cardBob {
    0%, 100% { transform: translate(-50%, -50%) translateY(0px); }
    50%       { transform: translate(-50%, -50%) translateY(-10px); }
}

#number-card.grabbed {
    animation: none;
    transform: translate(-50%, -50%) scale(1.1) rotate(-3deg);
    box-shadow: 0 24px 60px rgba(0,0,0,0.5), 0 0 0 4px rgba(251,191,36,0.7), 0 0 30px rgba(251,191,36,0.4);
    z-index: 50;
}

#number-card.spawning {
    animation: cardSpawn 0.4s cubic-bezier(0.22,1,0.36,1) forwards, cardBob 2s ease-in-out 0.4s infinite;
}
@keyframes cardSpawn {
    from { transform: translate(-50%,-50%) scale(0.3); opacity: 0; }
    to   { transform: translate(-50%,-50%) scale(1);   opacity: 1; }
}

#number-card.flying-up    { animation: flyUp    0.35s cubic-bezier(0.55,0,1,0.45) forwards !important; }
#number-card.flying-down  { animation: flyDown  0.35s cubic-bezier(0.55,0,1,0.45) forwards !important; }
#number-card.flying-left  { animation: flyLeft  0.35s cubic-bezier(0.55,0,1,0.45) forwards !important; }
#number-card.flying-right { animation: flyRight 0.35s cubic-bezier(0.55,0,1,0.45) forwards !important; }

@keyframes flyUp    { to { top: -20vh  !important; opacity:0; transform:translate(-50%,-50%) scale(0.5) rotate(-10deg); } }
@keyframes flyDown  { to { top: 120vh  !important; opacity:0; transform:translate(-50%,-50%) scale(0.5) rotate(10deg);  } }
@keyframes flyLeft  { to { left:-20vw  !important; opacity:0; transform:translate(-50%,-50%) scale(0.5) rotate(-15deg); } }
@keyframes flyRight { to { left:120vw  !important; opacity:0; transform:translate(-50%,-50%) scale(0.5) rotate(15deg);  } }

#objects-display {
    width: 158px;
    height: 158px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#objects-display svg {
    width: 100%;
    height: 100%;
}

/* ==========================================
   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.7rem;
    font-weight: 800;
    letter-spacing: 2px;
    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); }
}

/* ==========================================
   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 3rem;
    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);
}
@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: 3px;
    background: linear-gradient(135deg, #fff 30%, #fbbf24);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.4rem;
}

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

.score-rules {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    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.5rem 0.9rem;
    border: 1px solid rgba(255,255,255,0.08);
}
.rule-icon  { font-size: 1rem; }
.rule-text  { flex: 1; color: rgba(255,255,255,0.8); font-size: 0.88rem; }
.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.time   .rule-points { color: #60a5fa; }

.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.85rem;
    font-weight: 900;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1.3;
}
.diff-btn span { display: block; font-size: 0.65rem; font-weight: 700; opacity: 0.6; letter-spacing: 0; }
.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.75rem;
    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.68rem; letter-spacing: 2px; 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; }

/* ==========================================
   CROSSHAIR
   ========================================== */
#crosshair {
    position: fixed;
    width: 48px; height: 48px;
    border: 2.5px solid rgba(255,255,255,0.6);
    border-radius: 50%;
    transform: translate(-50%,-50%);
    display: none;
    pointer-events: none;
    z-index: 100;
    transition: width 0.12s, height 0.12s, border-color 0.12s, background 0.12s;
}
#crosshair .dot {
    position: absolute; top: 50%; left: 50%;
    width: 8px; height: 8px;
    background: #fbbf24; border-radius: 50%;
    transform: translate(-50%,-50%);
    box-shadow: 0 0 10px #fbbf24;
    transition: all 0.12s;
}
#crosshair .ring {
    position: absolute; top: 50%; left: 50%;
    width: 20px; height: 20px;
    border: 1.5px solid rgba(251,191,36,0.4); border-radius: 50%;
    transform: translate(-50%,-50%);
}
#crosshair.pinching {
    width: 28px; height: 28px;
    border-color: #fbbf24;
    background: rgba(251,191,36,0.15);
    box-shadow: 0 0 20px rgba(251,191,36,0.6);
}
#crosshair.pinching .dot {
    background: #f59e0b;
    box-shadow: 0 0 16px #f59e0b;
    transform: translate(-50%,-50%) scale(1.5);
}

@keyframes screenShake {
    0%  { transform: translate(0,0); }
    20% { transform: translate(-8px,4px); }
    40% { transform: translate(8px,-4px); }
    60% { transform: translate(-8px,-4px); }
    80% { transform: translate(8px,4px); }
    100%{ transform: translate(0,0); }
}
.shake { animation: screenShake 0.35s ease both; }

@media (max-width: 768px) {
    .zone-box { width: 115px; height: 115px; }
    .zone-number { font-size: 2.8rem; }
    .zone-top-left  { top: 80px; left: 8px; }
    .zone-top-right { top: 80px; right: 8px; }
    .zone-bottom-left  { bottom: 60px; left: 8px; }
    .zone-bottom-right { bottom: 60px; right: 8px; }
    #game-ui { padding: 0.5rem 0.4rem; }
    .hud-panel { min-width: 70px; padding: 0.4rem 0.6rem; }
    .hud-value { font-size: 1.4rem; }
}
