* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: #0f172a;
    font-family: 'Nunito', 'Segoe UI', sans-serif;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    color: white;
    user-select: none;
}

body::before {
    content: '';
    position: fixed; inset: 0;
    background:
        radial-gradient(ellipse at 20% 80%, rgba(249,115,22,0.10) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(96,165,250,0.10) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 10%, rgba(168,85,247,0.07) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

#input-video { position: fixed; left: -9999px; }

#output-canvas {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    opacity: 0;
    z-index: 5;
}

/* ─── GAME MODAL ─────────────────────────────────────────────── */
.game-modal {
    position: fixed; inset: 0; z-index: 300;
    display: flex; align-items: center; justify-content: center;
    background: rgba(5, 8, 22, 0.90);
}
.game-modal.hidden { display: none; }

.modal-content {
    text-align: center;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.13);
    border-radius: 28px;
    padding: 2rem 2.6rem;
    max-width: 460px;
    width: 92%;
    box-shadow: 0 24px 64px rgba(0,0,0,0.55);
    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.86) translateY(22px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-title {
    font-size: 2.2rem; 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.9rem;
    color: rgba(255,255,255,0.62);
    margin-bottom: 1.1rem;
    line-height: 1.75;
}

/* Score rules */
.score-rules {
    display: flex; flex-direction: column; gap: 0.4rem;
    margin-bottom: 1.1rem; text-align: left;
}
.rule-item {
    display: flex; align-items: center; gap: 0.75rem;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px; padding: 0.45rem 0.85rem;
}
.rule-icon  { font-size: 1rem; width: 1.4rem; text-align: center; }
.rule-text  { flex: 1; color: rgba(255,255,255,0.78); font-size: 0.85rem; }
.rule-points { font-weight: 900; font-size: 0.9rem; }
.rule-item.hit    .rule-points { color: #34d399; }
.rule-item.bonus  .rule-points { color: #a78bfa; }
.rule-item.escape .rule-points { color: #fbbf24; }

/* Difficulty */
.diff-section { margin-bottom: 1.1rem; }
.diff-label {
    font-size: 0.66rem; font-weight: 900; letter-spacing: 3px;
    color: rgba(255,255,255,0.38); margin-bottom: 0.5rem;
}
.diff-row { display: flex; gap: 0.55rem; }

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

/* Action button */
.action-btn {
    display: flex; align-items: center; justify-content: center;
    gap: 0.6rem; width: 100%; padding: 0.95rem 2rem;
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    border: none; border-radius: 14px; color: white;
    font-family: 'Nunito', sans-serif;
    font-size: 1.15rem; 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.45);
}
.action-btn.disabled { opacity: 0.32; 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.85); }

.btn-icon { font-size: 1.2rem; }
.btn-hint { margin-top: 0.55rem; font-size: 0.72rem; color: rgba(255,255,255,0.28); letter-spacing: 0.5px; }
.privacy-notice {
    margin-top: 0.75rem; font-size: 0.68rem;
    color: rgba(255,255,255,0.28);
    border-left: 2px solid rgba(255,255,255,0.1);
    padding-left: 0.75rem; text-align: left;
}

/* Stats grid (end modal) */
.stats-grid { display: flex; gap: 0.75rem; margin: 1.1rem 0 1.4rem; }
.stat-box {
    flex: 1; background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 14px; padding: 0.75rem 0.4rem;
}
.stat-label { font-size: 0.6rem; letter-spacing: 1.5px; color: rgba(255,255,255,0.38); margin-bottom: 0.3rem; }
.stat-value { font-size: 2rem; font-weight: 900; color: #fff; }
.correct-color { color: #34d399 !important; }
.wrong-color   { color: #fbbf24 !important; }

/* ─── GAME UI ────────────────────────────────────────────────── */
#game-ui {
    display: flex; flex-direction: column;
    align-items: center; justify-content: space-between;
    height: 100vh; padding: 14px 20px 18px;
    position: relative; z-index: 10;
}
#game-ui.hidden { display: none; }

/* HUD */
#hud {
    display: flex; width: 100%; max-width: 640px;
    justify-content: space-between; align-items: center;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px; padding: 10px 22px;
}
.hud-panel { text-align: center; }
.hud-label { font-size: 0.58rem; font-weight: 900; letter-spacing: 2px; color: rgba(255,255,255,0.38); }
.hud-value { font-size: 1.4rem; font-weight: 900; color: #fff; }
.hud-value.urgent { color: #f87171; animation: timerPulse 0.5s infinite alternate; }
@keyframes timerPulse { to { transform: scale(1.18); } }

/* Target panel */
#target-panel {
    display: flex; flex-direction: column;
    align-items: center; gap: 8px;
}
#target-label {
    font-size: 0.62rem; font-weight: 900; letter-spacing: 3px;
    color: rgba(255,255,255,0.38);
}
#target-time {
    font-size: clamp(2.8rem, 6vw, 3.8rem);
    font-weight: 900; color: #fff;
    letter-spacing: 0.12em; font-variant-numeric: tabular-nums;
    line-height: 1;
    text-shadow: 0 0 30px rgba(251,191,36,0.4);
}
#ref-clock {
    position: absolute;
    top: 70px;
    right: 20px;
    border-radius: 50%;
    border: 2.5px solid rgba(255,255,255,0.2);
    background: #1e293b;
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
    z-index: 50;
}

/* Clock area */
#clock-area {
    flex: 1; display: flex;
    align-items: center; justify-content: center;
    width: 100%;
}
#main-clock {
    width: min(70vh, 550px);
    height: min(70vh, 550px);
    filter: drop-shadow(0 6px 24px rgba(0,0,0,0.5));
    transition: filter 0.3s;
}

/* Hand: near (yaklaşma ipucu) ve grabbed (tutuldu) */
#hour-hand.near     { stroke: #fdba74; stroke-width: 9;  filter: drop-shadow(0 0 6px rgba(249,115,22,0.6)); }
#minute-hand.near   { stroke: #bfdbfe; stroke-width: 6;  filter: drop-shadow(0 0 5px rgba(96,165,250,0.6)); }
#hour-hand.grabbed  { stroke: #fb923c; stroke-width: 9;  filter: drop-shadow(0 0 12px #f97316); }
#minute-hand.grabbed{ stroke: #93c5fd; stroke-width: 6;  filter: drop-shadow(0 0 10px #60a5fa); }
#minute-hand.disabled-hand { opacity: 0.18; }

/* Clock animations */
@keyframes clockCelebrate {
    0%   { filter: drop-shadow(0 6px 24px rgba(0,0,0,0.5)); transform: scale(1); }
    35%  { filter: drop-shadow(0 0 36px #22c55e); transform: scale(1.08); }
    70%  { filter: drop-shadow(0 0 20px #86efac); transform: scale(1.04); }
    100% { filter: drop-shadow(0 6px 24px rgba(0,0,0,0.5)); transform: scale(1); }
}
@keyframes clockShake {
    0%,100% { transform: translateX(0); }
    20% { transform: translateX(-10px); }
    40% { transform: translateX(10px); }
    60% { transform: translateX(-8px); }
    80% { transform: translateX(8px); }
}
#main-clock.celebrate { animation: clockCelebrate 1s ease forwards; }
#main-clock.shake     { animation: clockShake 0.5s ease; }

/* Hand legend */
#hand-legend {
    display: flex; gap: 18px; align-items: center;
    font-size: 0.75rem; font-weight: 700;
    color: rgba(255,255,255,0.45);
}
.hl-item { display: flex; align-items: center; gap: 6px; }
.hl-dot { width: 14px; height: 5px; border-radius: 3px; }
.hour-dot { background: #f97316; }
.min-dot  { background: #60a5fa; }

/* ─── HAND DOT ───────────────────────────────────────────────── */
#hand-dot {
    position: fixed;
    width: 22px; height: 22px; border-radius: 50%;
    background: rgba(96,165,250,0.8);
    border: 2.5px solid rgba(255,255,255,0.9);
    pointer-events: none;
    transform: translate(-50%, -50%);
    display: none; z-index: 900;
    box-shadow: 0 0 12px rgba(96,165,250,0.5);
    transition: background 0.1s, transform 0.1s;
}
#hand-dot.pinching {
    background: rgba(249,115,22,0.9);
    transform: translate(-50%, -50%) scale(0.72);
}

/* ─── FEEDBACK FLASH ─────────────────────────────────────────── */
#feedback-flash {
    position: fixed; inset: 0;
    pointer-events: none; z-index: 500; opacity: 0;
}
#feedback-flash.correct { background: rgba(34,197,94,0.22);  animation: flashAnim 0.6s ease forwards; }
#feedback-flash.wrong   { background: rgba(239,68,68,0.20);  animation: flashAnim 0.6s ease forwards; }
@keyframes flashAnim { 0% { opacity: 1; } 100% { opacity: 0; } }
