/* --- TEMA DEĞİŞKENLERİ --- */
:root {
    --transition-speed: 0.4s;
}

/* GECE (DARK) TEMA */
[data-theme="dark"] {
    --bg-primary: #050505;
    --bg-header-start: #1a1a2e;
    --bg-header-end: #050505;
    --bg-card: #111;
    --bg-btn: #0a0a0a;
    --bg-btn-hover: #111;
    --bg-info: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-muted: #888888;
    --text-footer: #444444;
    --accent-blue: #3498db;
    --accent-yellow: #f1c40f;
    --border-card: #222;
    --border-info: #f1c40f;
    --border-section: #333;
    --shadow-header: rgba(52, 152, 219, 0.3);
    --shadow-card: rgba(52, 152, 219, 0.4);
    --shadow-info: rgba(241, 196, 15, 0.15);
    --strong-color: #fff;
    --bg-header-glass: rgba(5, 5, 5, 0.85);
}

/* GÜNDÜZ (LIGHT) TEMA */
[data-theme="light"] {
    --bg-primary: #f0f2f5;
    --bg-header-start: #e8edf5;
    --bg-header-end: #f0f2f5;
    --bg-card: #ffffff;
    --bg-btn: #e8ecf1;
    --bg-btn-hover: #dce1e8;
    --bg-info: #ffffff;
    --text-primary: #1a1a2e;
    --text-secondary: #333344;
    --text-muted: #555566;
    --text-footer: #888899;
    --accent-blue: #2980b9;
    --accent-yellow: #d4a017;
    --border-card: #d0d5dd;
    --border-info: #d4a017;
    --border-section: #c0c5cc;
    --shadow-header: rgba(41, 128, 185, 0.15);
    --shadow-card: rgba(41, 128, 185, 0.2);
    --shadow-info: rgba(212, 160, 23, 0.1);
    --strong-color: #1a1a2e;
    --bg-header-glass: rgba(240, 242, 245, 0.85);
}

/* Square Cursor Implementation */
*, *::before, *::after {
    box-sizing: border-box;
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12"><rect width="10" height="10" x="1" y="1" fill="rgba(255,255,255,0.9)" stroke="black" stroke-width="1.5"/></svg>') 6 6, auto !important;
}

* {
    transition: background-color var(--transition-speed), color var(--transition-speed), border-color var(--transition-speed), box-shadow var(--transition-speed);
}

/* Theme Icon Visibility Logic */
[data-theme="dark"] .moon-icon { display: block; }
[data-theme="dark"] .sun-icon { display: none; }
[data-theme="light"] .moon-icon { display: none; }
[data-theme="light"] .sun-icon { display: block; }

/* --- ORTAK SAYFA AYARLARI --- */
body {
    margin: 0;
    overflow: hidden;
    font-family: 'Segoe UI', Arial;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    color: white;
}

canvas {
    display: block;
}

/* --- ANA SAYFA BUTONU --- */
#home-link-fixed {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 20000;
    text-decoration: none;
    background: linear-gradient(135deg, rgba(233, 69, 96, 0.95), rgba(184, 56, 75, 0.95));
    color: white;
    padding: 10px 20px;
    border-radius: 50px;
    font-weight: 800;
    font-size: 15px;
    letter-spacing: 0.5px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 5px 15px rgba(233, 69, 96, 0.5), inset 0 2px 4px rgba(255,255,255,0.4);
    pointer-events: auto;
    touch-action: manipulation;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-shadow: 0 2px 4px rgba(0,0,0,0.4);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

#home-link-fixed:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 8px 25px rgba(233, 69, 96, 0.7), inset 0 2px 8px rgba(255,255,255,0.6);
    border-color: #fff;
    color: #ffeb3b;
}

#home-link-fixed:active {
    transform: translateY(1px) scale(0.95);
}

/* --- DOKUNMATİK OYUN KONTROLLERİ --- */
#joy-alan {
    position: absolute;
    bottom: max(30px, env(safe-area-inset-bottom) + 10px);
    left: max(30px, env(safe-area-inset-left) + 10px);
    width: 140px;
    height: 140px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.3), inset 0 0 20px rgba(255, 255, 255, 0.1);
    z-index: 100;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

#joy-top {
    position: absolute;
    top: 40px;
    left: 40px;
    width: 60px;
    height: 60px;
    background: radial-gradient(circle, rgba(255,255,255,0.95) 0%, rgba(200,200,200,0.8) 100%);
    border-radius: 50%;
    box-shadow: 0 8px 20px rgba(0,0,0,0.6), inset 0 -4px 6px rgba(0,0,0,0.3);
}

#ates-btn {
    position: absolute;
    bottom: max(30px, env(safe-area-inset-bottom) + 10px);
    right: max(30px, env(safe-area-inset-right) + 10px);
    width: 120px;
    height: 120px;
    background: radial-gradient(circle, rgba(233, 69, 96, 0.95) 0%, rgba(184, 56, 75, 0.85) 100%);
    border: 3px solid rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    color: white;
    font-weight: 900;
    font-size: 20px;
    letter-spacing: 2px;
    z-index: 100;
    -webkit-tap-highlight-color: transparent;
    pointer-events: auto;
    touch-action: manipulation;
    box-shadow: 0 0 30px rgba(233, 69, 96, 0.6), inset 0 -5px 10px rgba(0,0,0,0.4);
    text-shadow: 0 2px 4px rgba(0,0,0,0.6);
    transition: transform 0.1s cubic-bezier(0.4, 0, 0.2, 1);
}

#ates-btn:active {
    transform: scale(0.85);
    box-shadow: 0 0 15px rgba(233, 69, 96, 0.4), inset 0 5px 15px rgba(0,0,0,0.6);
}

/* --- ORTAK MENÜ YAPI KURALLARI (RENK YAZILMADI) --- */
#menu {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 25px;
    border-radius: 20px;
    text-align: center;
    width: 90%;
    max-width: 420px;
    box-sizing: border-box;
    z-index: 10000;
    
    background: rgba(15, 20, 25, 0.95);
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5), inset 0 0 20px rgba(255,255,255,0.05);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    transition: transform 0.3s ease;
}

/* Yükseklik tabanlı ölçekleme: Ekran küçükse menüyü küçült (kaydırma yerine) */
@media (max-height: 750px) {
    #menu { transform: translate(-50%, -50%) scale(0.85); padding: 20px; }
}
@media (max-height: 600px) {
    #menu { transform: translate(-50%, -50%) scale(0.70); padding: 15px; }
}
@media (max-height: 450px) {
    #menu { transform: translate(-50%, -50%) scale(0.55); }
}
@media (max-height: 350px) {
    #menu { transform: translate(-50%, -50%) scale(0.40); }
}

#menu h2 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 28px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

#menu p {
    margin: 10px 0 5px 0;
    font-size: 14px;
    font-weight: 600;
    color: #e0e0e0;
}

.grid {
    display: grid;
    gap: 8px;
    margin: 10px 0;
}

.renk-btn {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: 2px solid white;
    cursor: pointer;
    margin: 0 auto;
}

.secili {
    transform: scale(1.1);
}

#basla-btn {
    padding: 15px;
    width: 100%;
    border: none;
    border-radius: 10px;
    font-weight: bold;
    font-size: 20px;
    margin-top: 15px;
    cursor: pointer;
    color: white;
}

#basla-btn:active {
    transform: translateY(3px);
    box-shadow: none !important;
}

/* --- RESPONSIVE KURALLAR --- */
/* Her ekranda ve cihazda kontrolleri göster */
@media (hover: hover) and (pointer: fine) {
    #joy-alan, #ates-btn, #joy-base, #action-btn { display: block !important; }
}

@media (max-width: 1024px) {
    #joy-alan, #ates-btn, #joy-base, #action-btn { display: block !important; }
}

@media (max-width: 768px) {
    #ui { font-size: 14px; top: 15px; left: 15px; }
    #home-link-fixed { font-size: 11px; padding: 8px 12px; top: 15px; right: 15px; }
    #joy-alan { width: 150px; height: 150px; bottom: 20px; left: 20px; }
    #joy-top { width: 70px; height: 70px; top: 40px; left: 40px; }
    #ates-btn { width: 120px; height: 120px; bottom: 30px; right: 20px; font-size: 18px; border-width: 3px;}
    
    #menu { width: 95%; max-height: 90vh; overflow-y: auto; padding: 15px; }
    .renk-btn { width: 50px; height: 50px; }
    .lvl-btn { width: 65px; height: 65px; font-size: 20px; margin: 5px; }
    .silah-btn { font-size: 14px; padding: 12px; margin: 5px; width: calc(50% - 15px); }
    #basla-btn { font-size: 22px; padding: 18px; }
}
/* --- HEADER --- */
header {
    position: sticky; top: 0; z-index: 1000; padding: 10px 0; background: var(--bg-header-glass);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); width: 100%;
    border-bottom: 2px solid var(--accent-blue); box-shadow: 0 5px 20px var(--shadow-header);
}
.header-content { width: 95%; max-width: 1200px; margin: 0 auto; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.header-logo { width: 60px; height: 60px; margin-bottom: 5px; border-radius: 50%; filter: drop-shadow(0 0 10px var(--accent-blue)); transition: transform 0.3s; }
.header-logo:hover { transform: scale(1.1) rotate(5deg); }
header h1 { font-size: 1.5rem; margin: 0; background: linear-gradient(90deg, var(--accent-blue), var(--accent-yellow)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; letter-spacing: 2px; text-transform: uppercase; }
header p { margin: 0; font-size: 0.8rem; color: var(--text-secondary); font-weight: 500; }

/* --- DİL DROPDOWN --- */
.lang-dropdown { position: relative; display: inline-block; }
.lang-flag { width: 22px; height: 15px; object-fit: cover; border-radius: 3px; }
.lang-btn { background: var(--bg-card); border: 2px solid var(--border-card); padding: 8px 12px; border-radius: 20px; cursor: pointer; display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--text-primary); transition: all 0.3s; }
.lang-menu { position: absolute; top: calc(100% + 5px); left: 0; background: var(--bg-card); border: 1px solid var(--border-card); border-radius: 12px; display: none; flex-direction: column; min-width: 130px; z-index: 2000; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.lang-menu.show { display: flex; }
.lang-menu button { background: transparent; border: none; padding: 10px 15px; text-align: left; cursor: pointer; font-size: 0.85rem; color: var(--text-primary); display: flex; align-items: center; gap: 8px; }
.lang-menu button:hover { background: var(--accent-blue); color: white; }

/* --- TEMA TOGGLE --- */
.theme-toggle { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--accent-blue); background: var(--bg-card); cursor: pointer; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }
.theme-toggle svg { position: absolute; transition: transform 0.4s, opacity 0.3s; width: 22px; height: 22px; }
[data-theme="dark"] .sun-icon { opacity: 0; transform: translateY(20px); }
[data-theme="dark"] .moon-icon { opacity: 1; transform: translateY(0); }
[data-theme="light"] .sun-icon { opacity: 1; transform: translateY(0); }
[data-theme="light"] .moon-icon { opacity: 0; transform: translateY(-20px); }

/* --- KULLANICI BUTONU & MODAL --- */
.user-btn { background: linear-gradient(135deg, var(--accent-blue), #2980b9); color: white; border: none; padding: 8px 15px; border-radius: 20px; font-weight: bold; cursor: pointer; display: flex; align-items: center; gap: 5px; height: 40px; }
.user-btn.logged { background: linear-gradient(135deg, #2ecc71, #27ae60); }
.modal-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.7); backdrop-filter: blur(5px); z-index: 9999; display: none; opacity: 0; transition: opacity 0.3s; }
.user-modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.9); width: 90%; max-width: 380px; background: var(--bg-card); border-radius: 20px; padding: 30px; box-shadow: 0 20px 60px rgba(0,0,0,0.6); z-index: 10000; border: 2px solid var(--border-section); display: none; opacity: 0; transition: all 0.3s; }
.modal-overlay.show, .user-modal.show { display: block; opacity: 1; }
.user-modal.show { transform: translate(-50%, -50%) scale(1); }

@media (max-width: 1024px) {
    header h1, header p { display: none; }
    .header-content { grid-template-columns: 1fr auto 1fr; }
    .header-center { order: 1; justify-self: start; }
    .header-left { order: 2; justify-self: center; }
    .header-right { order: 3; justify-self: end; }
}
