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

body {
    background: #1a1a2e url('assets/bg_classroom.jpg') center/cover no-repeat;
    height: 100vh;
    overflow: hidden;
    position: relative;
    user-select: none;
    color: white;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.18);
    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;
}

/* ==========================================
   SORT BOXES
   ========================================== */
.sort-box {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 200px;
    min-height: 240px;
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 1rem 1.5rem;
    z-index: 20;
    transition: box-shadow 0.2s, transform 0.2s;
    cursor: pointer;
}

.box-left {
    left: 40px;
    background: rgba(59, 130, 246, 0.25);
    border: 3px solid rgba(59, 130, 246, 0.6);
    box-shadow: 0 8px 32px rgba(59, 130, 246, 0.2);
}

.box-right {
    right: 40px;
    background: rgba(249, 115, 22, 0.25);
    border: 3px solid rgba(249, 115, 22, 0.6);
    box-shadow: 0 8px 32px rgba(249, 115, 22, 0.2);
}

.sort-box.hovered.box-left {
    background: rgba(59, 130, 246, 0.5);
    border-color: #3b82f6;
    box-shadow: 0 0 40px rgba(59, 130, 246, 0.7);
    transform: translateY(-50%) scale(1.05);
}

.sort-box.hovered.box-right {
    background: rgba(249, 115, 22, 0.5);
    border-color: #f97316;
    box-shadow: 0 0 40px rgba(249, 115, 22, 0.7);
    transform: translateY(-50%) scale(1.05);
}

.sort-box.correct-flash {
    animation: correctFlash 0.5s ease-out;
}

.sort-box.wrong-flash {
    animation: wrongFlash 0.5s ease-out;
}

@keyframes correctFlash {
    0%   { filter: brightness(1); }
    30%  { filter: brightness(2.5); }
    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); }
}

.box-label {
    font-size: 2.8rem;
    font-weight: 900;
    letter-spacing: 2px;
    line-height: 1;
    margin-bottom: 0.3rem;
}

.box-left  .box-label { color: #93c5fd; }
.box-right .box-label { color: #fdba74; }

.box-sublabel {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    opacity: 0.7;
    margin-bottom: 1rem;
}

.box-inner {
    width: 100%;
    flex: 1;
    min-height: 100px;
    border-radius: 14px;
    background: rgba(255,255,255,0.06);
    border: 2px dashed rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==========================================
   LETTER CARD
   ========================================== */
#letter-card {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 30;
    display: none;
    width: 180px;
    height: 180px;
    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;
    transition: box-shadow 0.15s;
    will-change: left, top;
}

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

/* Tutulunca bob durur, biraz büyür */
#letter-card.grabbed {
    animation: none;
    transform: translate(-50%, -50%) scale(1.12) rotate(-4deg);
    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);
    cursor: grabbing;
    z-index: 50;
}

#letter-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; }
}

#letter-card.flying-left {
    animation: flyLeft 0.35s cubic-bezier(0.55, 0, 1, 0.45) forwards !important;
}
#letter-card.flying-right {
    animation: flyRight 0.35s cubic-bezier(0.55, 0, 1, 0.45) forwards !important;
}
@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); } }

#letter-display {
    font-size: 7rem;
    font-weight: 900;
    line-height: 1;
}

/* Pinch göstergesi — iki nokta arasındaki çizgi */
#pinch-indicator {
    position: fixed;
    pointer-events: none;
    z-index: 60;
}

/* ==========================================
   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 animasyonu */
.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.85);
    transition: opacity 0.3s;
}
.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: 2.5rem 3.5rem;
    max-width: 500px;
    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: 3.5rem;
    margin-bottom: 0.8rem;
    animation: iconBounce 2s ease-in-out infinite;
}
@keyframes iconBounce {
    0%,100% { transform: translateY(0); }
    50%      { transform: translateY(-8px); }
}

.modal-title {
    font-size: 2.6rem;
    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.5rem;
}

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

.score-rules {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    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.55rem 1rem;
    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.9rem; }
.rule-points { font-weight: 900; font-size: 0.95rem; }
.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; }

.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.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.78rem;
    color: rgba(255,255,255,0.3);
    letter-spacing: 1px;
}

.privacy-notice {
    margin-top: 1rem;
    font-size: 0.72rem;
    color: rgba(255,255,255,0.35);
    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; }

/* ==========================================
   EL GÖSTERGESİ (crosshair yerine)
   ========================================== */
#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%);
}

/* Pinch aktif: halka küçülür, sarı parlar */
#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);
}

/* ==========================================
   KONFETI (canvas particle - sadece JS)
   ========================================== */
@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) {
    .sort-box { width: 120px; min-height: 180px; }
    .box-left { left: 10px; }
    .box-right { right: 10px; left: auto; }
    .box-label { font-size: 1.8rem; }
    #game-ui { padding: 0.5rem 0.4rem; gap: 0.3rem; }
    .hud-panel { min-width: 70px; padding: 0.4rem 0.6rem; }
    .hud-value { font-size: 1.4rem; }
    #letter-card { width: 120px; height: 160px; font-size: 5rem; }
}
