:root {
    /* Color Palette */
    --bg-dark: #0f172a; /* Slate 900 */
    --bg-darker: #020617; /* Slate 950 */
    --bg-panel: rgba(30, 41, 59, 0.7); /* Slate 800 with opacity */
    --bg-panel-solid: #1e293b;
    --text-primary: #f8fafc; /* Slate 50 */
    --text-secondary: #94a3b8; /* Slate 400 */
    
    --primary-color: #facc15; /* Yellow 400 (Safety Yellow) */
    --primary-hover: #eab308; /* Yellow 500 */
    --primary-dark: #ca8a04;
    
    --success-color: #22c55e; /* Green 500 */
    --success-hover: #16a34a;
    
    --danger-color: #ef4444; /* Red 500 */
    --danger-hover: #dc2626;

    --border-color: rgba(255, 255, 255, 0.1);
    
    /* Layout */
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-darker);
    background-image: 
        radial-gradient(at 0% 0%, rgba(30, 41, 59, 1) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(15, 23, 42, 1) 0px, transparent 50%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Prevent scrolling on body, manage screens internally */
}

/* Typography */
h1, h2, h3 {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

p {
    line-height: 1.6;
    color: var(--text-secondary);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Glassmorphism Panels */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-glass);
    border-radius: var(--radius-lg);
}

.glass-panel-dark {
    background: rgba(2, 6, 23, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
}

.light-glass {
    background: rgba(255, 255, 255, 0.85); /* Frosted white glass */
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-lg);
    color: #1e293b;
}

.light-glass h1, .light-glass h2, .light-glass h3 {
    color: #0f172a;
}

.light-glass p, .light-glass .subtitle, .light-glass label {
    color: #475569;
}

.light-glass input {
    background-color: rgba(255, 255, 255, 0.7) !important;
    border: 1px solid rgba(0, 0, 0, 0.15) !important;
    color: #0f172a !important;
}

.light-glass input:focus {
    background-color: #ffffff !important;
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.2);
}

.light-glass .btn-primary {
    color: #0f172a;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    outline: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--bg-darker);
}

.btn-primary:not(:disabled):hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-danger-outline {
    background-color: transparent;
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
}

.btn-danger-outline:hover {
    background-color: var(--danger-color);
    color: white;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.btn-icon:not(:disabled):hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Forms & Inputs */
.input-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 1.5rem;
    text-align: left;
}

.input-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.input-group input {
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.2s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: rgba(255, 255, 255, 0.1);
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.screen.view-active {
    opacity: 1;
    pointer-events: auto;
    z-index: 10;
}

/* Login Screen Specific */
#login-screen {
    background: url('../assets/bg.png') center/cover no-repeat;
}
#login-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(30, 41, 59, 0.4); /* Much lighter overlay */
    backdrop-filter: blur(5px);
}

.login-card {
    position: relative;
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    text-align: center;
    z-index: 2;
}

/* Game Select Screen */
#game-select-screen {
    background: var(--bg-darker);
    display: flex;
    align-items: center;
    justify-content: center;
}

#game-select-screen .login-card {
    max-width: 800px; /* Increased to allow multiple game cards side-by-side */
    width: 90%;
}

.game-cards {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.game-card-btn {
    background: #ffffff;
    border: 2px solid rgba(0, 0, 0, 0.1);
    color: #0f172a;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    text-align: left;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.game-card-btn:hover {
    background: #fafafa;
    border-color: var(--primary-color);
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}

.game-card-btn.has-thumb {
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 180px;
    width: 250px;
}

.game-btn-thumb {
    flex: 1;
    background-size: cover;
    background-position: center;
    border-bottom: 2px solid rgba(250, 204, 21, 0.35);
}

.game-card-btn:hover .game-btn-thumb {
    border-bottom-color: var(--primary-color);
}

.game-btn-title {
    padding: 0.75rem;
    text-align: center;
    font-weight: 600;
}

.logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.logo svg {
    color: var(--primary-color);
}

.subtitle {
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-content {
    width: 90%;
    max-width: 600px;
    padding: 2rem;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-body.scrollable {
    overflow-y: auto;
    margin: 1.5rem 0;
    padding-right: 1rem;
    flex: 1;
}

.modal-body p {
    margin-bottom: 1rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 1rem;
}

/* Quiz Modal Specific */
.quiz-mode {
    max-width: 500px;
}

.quiz-question {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin: 1.5rem 0;
    font-weight: 500;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.quiz-option-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.quiz-option-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-color);
}

.quiz-option-btn.correct {
    background: rgba(34, 197, 94, 0.2);
    border-color: var(--success-color);
}

.quiz-option-btn.incorrect {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--danger-color);
}


/* Game UI */
#game-ui {
    display: flex;
    flex-direction: column;
    align-items: stretch; /* override center flex */
    justify-content: flex-start;
}

.game-hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    height: 70px;
    z-index: 20;
}

.hud-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.hud-item .icon {
    font-size: 1.25rem;
}

.timer {
    color: var(--primary-color);
    font-family: monospace;
    font-size: 1.2rem;
    background: rgba(0,0,0,0.2);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
}

.timer.warning {
    color: var(--danger-color);
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    from { opacity: 1; }
    to { opacity: 0.7; }
}

/* Next button pulse — signals user to go to next image */
.btn-icon.pulse {
    background: var(--primary-color);
    color: var(--bg-darker);
    animation: btnPulse 0.8s ease-in-out infinite alternate;
    box-shadow: 0 0 0 0 rgba(250, 204, 21, 0.7);
}

@keyframes btnPulse {
    from { box-shadow: 0 0 0 0 rgba(250, 204, 21, 0.7); transform: scale(1); }
    to   { box-shadow: 0 0 0 10px rgba(250, 204, 21, 0); transform: scale(1.15); }
}

.hud-center-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Game Viewport */
.game-viewport {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-darker);
    padding: 1rem;
}

.image-wrapper {
    position: relative;
    display: inline-block; /* Forces shrink-wrap behavior around image */
    line-height: 0; /* Prevents descender gap below image */
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--radius-md);
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}

#game-image {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 90px); /* 100vh - HUD */
    border-radius: var(--radius-md);
    user-select: none;
}

/* Overlay layer — passes clicks through except on child hit areas */
.interaction-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Invisible clickable hit area placed directly over each hazard */
.hazard-hit-area {
    position: absolute;
    transform: translate(-50%, -50%);
    aspect-ratio: 1;
    border-radius: 50%;
    pointer-events: auto;
    cursor: crosshair;
    /* Uncomment below to debug hit areas visually: */
    /* background: rgba(255,0,0,0.3); border: 2px solid red; */
}

/* Hazard Marker */
.hazard-marker {
    position: absolute;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 700;
    animation: markerPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    pointer-events: none;
}

.marker-correct {
    background: rgba(34, 197, 94, 0.25);
    border: 3px solid var(--success-color);
    color: var(--success-color);
}

.marker-wrong {
    background: rgba(239, 68, 68, 0.25);
    border: 3px solid var(--danger-color);
    color: var(--danger-color);
}

@keyframes markerPop {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* ─── Countdown Overlay ──────────────────────────────────────────────────── */
.countdown-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    backdrop-filter: blur(6px);
}

.countdown-number {
    font-size: 10rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1;
    opacity: 0;
    transform: scale(1.5);
}

.countdown-number.animate {
    animation: countdownPop 0.85s ease-out forwards;
}

@keyframes countdownPop {
    0%   { opacity: 0;   transform: scale(1.6); }
    20%  { opacity: 1;   transform: scale(1); }
    80%  { opacity: 1;   transform: scale(1); }
    100% { opacity: 0;   transform: scale(0.6); }
}

/* ─── Image Fade Transition ──────────────────────────────────────────────── */
#game-image {
    transition: opacity 0.25s ease;
}

#game-image.fade-out {
    opacity: 0;
}

#game-image.fade-in {
    animation: fadeIn 0.4s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Click ripple (miss indicator) */
.click-ripple {
    position: absolute;
    width: 30px;
    height: 30px;
    border: 2px solid rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    pointer-events: none;
    animation: rippleOut 0.6s ease-out forwards;
}

@keyframes rippleOut {
    0%   { transform: translate(-50%, -50%) scale(0); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(2); opacity: 0; }
}

/* Hint glow — flashes on hazard area when hint is used */
.hint-glow {
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    background: radial-gradient(circle, rgba(250,204,21,0.85) 0%, rgba(250,204,21,0.3) 50%, transparent 75%);
    animation: hintGlow 1.8s ease-out forwards;
    z-index: 20;
}

@keyframes hintGlow {
    0%   { opacity: 0;   transform: translate(-50%, -50%) scale(0.4); box-shadow: 0 0 0 0 rgba(250,204,21,0.9); }
    20%  { opacity: 1;   transform: translate(-50%, -50%) scale(1.2); box-shadow: 0 0 30px 15px rgba(250,204,21,0.6); }
    60%  { opacity: 0.8; transform: translate(-50%, -50%) scale(1);   box-shadow: 0 0 20px 10px rgba(250,204,21,0.4); }
    100% { opacity: 0;   transform: translate(-50%, -50%) scale(1.4); box-shadow: 0 0 0 0 rgba(250,204,21,0); }
}

/* Hint button */
.btn-hint {
    background: rgba(250, 204, 21, 0.15);
    color: var(--primary-color);
    border: 1px solid rgba(250, 204, 21, 0.4);
    font-size: 0.85rem;
    padding: 0.4rem 0.9rem;
    white-space: nowrap;
}

.btn-hint:not(:disabled):hover {
    background: rgba(250, 204, 21, 0.3);
}

.btn-hint.hint-exhausted,
.btn-hint:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    z-index: 1000;
}

.toast {
    background: var(--bg-panel-solid);
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    border-left: 4px solid var(--primary-color);
    animation: slideIn 0.3s ease forwards;
    opacity: 0;
    transform: translateX(100%);
}

.toast.success { border-left-color: var(--success-color); }
.toast.error { border-left-color: var(--danger-color); }

@keyframes slideIn {
    to { opacity: 1; transform: translateX(0); }
}

/* End Screen */
.end-card {
    text-align: center;
    padding: 3rem;
    min-width: 560px;
}

.final-score-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 1.5rem 0;
}

.final-score-label {
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.final-score-number {
    font-size: 5rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1;
    animation: scorePop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes scorePop {
    0%   { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1);   opacity: 1; }
}

.final-score-grade {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

.grade-s { color: #facc15; }
.grade-a { color: #22c55e; }
.grade-b { color: #60a5fa; }
.grade-c { color: #f87171; }

.stats {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin: 1.5rem 0;
    flex-wrap: wrap;
}

.stat-box {
    background: rgba(0,0,0,0.2);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    min-width: 110px;
}

.stat-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.stat-value {
    display: block;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-top: 0.25rem;
}

/* Live score in HUD */
.hud-score-live {
    color: var(--primary-color);
    font-weight: 700;
    font-size: 1.1rem;
    font-family: monospace;
}

/* Floating score popup */
.score-popup {
    position: fixed;
    top: 80px;
    right: 2rem;
    font-size: 1.3rem;
    font-weight: 700;
    pointer-events: none;
    z-index: 500;
    animation: scoreFloat 1s ease-out forwards;
}

.score-popup.positive { color: var(--success-color); }
.score-popup.negative { color: var(--danger-color); }

@keyframes scoreFloat {
    0%   { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-40px); }
}

/* ─── Mobile Responsiveness ─── */
@media (max-width: 768px) {
    .game-hud {
        flex-wrap: wrap;
        height: auto;
        min-height: 70px;
        padding: max(45px, env(safe-area-inset-top)) 0.5rem 0.5rem 0.5rem; /* Garanti 45px çentik boşluğu */
        gap: 0.5rem;
        justify-content: center;
    }
    .hud-item {
        font-size: 0.85rem;
    }
    .timer {
        font-size: 0.95rem;
        padding: 0.3rem 0.6rem;
    }
    .hud-center-controls {
        width: 100%;
        justify-content: center;
        order: 5; /* Menüyü yukarıdan alıp alt satıra yerleştiriyoruz */
        padding-top: 0.5rem;
        border-top: 1px solid rgba(255,255,255,0.1);
        border-bottom: none;
    }
    .btn-hint, .btn-primary, .btn-danger-outline {
        font-size: 0.8rem;
        padding: 0.4rem 0.6rem;
    }
    #game-image {
        max-height: calc(100vh - 160px);
    }
    .end-card {
        min-width: 90%;
        padding: 1.5rem;
    }
    .final-score-number {
        font-size: 3.5rem;
    }
    .stat-box {
        min-width: 45%;
        padding: 0.75rem;
    }
    .login-card {
        padding: 1.5rem;
        width: 90%;
    }
    .game-card-btn.has-thumb {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .hud-item.user-info {
        display: none; /* Çok dar ekranlarda isim gizlensin */
    }
}
