:root {
    --primary-color: #275e95;
    --accent-color: #04AA6D;
    --bg-color: #f0f4f8;
    --text-color: #333;
}

/* --- GENEL AYARLAR --- */
* {
    -webkit-tap-highlight-color: transparent;
    outline: none;
    box-sizing: border-box;
}

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
    padding: 10px;
    font-family: Helvetica, "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
    background-color: var(--bg-color);
    overflow-x: hidden; /* Sadece yatay kaydırmayı engelle */
    touch-action: manipulation;
    
    /* Mobil tarayıcı hissi için seçim engelleme */
    -webkit-user-select: none;
    user-select: none;
}

/* Input ve Textarea yazılabilir olsun */
input, textarea {
    -webkit-user-select: text !important;
    user-select: text !important;
}

/* --- REKLAM ALANI (WEB İÇİN YENİ) --- */
.web-ad-banner {
    width: 100%;
    max-width: 320px;
    height: 50px;
    background-color: #e9ecef;
    border: 1px dashed #adb5bd;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 20px;
    color: #888;
    font-size: 12px;
    font-weight: bold;
}

/* --- GİRİŞ EKRANI --- */
#setup-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

#game-logo {
    width: 60%;
    max-width: 250px;
    height: auto;
    margin-bottom: 10px;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

.game-subtitle {
    font-size: 18px;
    color: #666;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#input-group {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 10px;
}

input[type="text"] {
    padding: 12px;
    border: 2px solid var(--primary-color);
    border-radius: 10px;
    font-size: 16px;
    text-align: center;
    outline: none;
    transition: border-color 0.3s;
}

input[type="text"]:focus { border-color: var(--accent-color); }

button {
    cursor: pointer;
    font-family: inherit;
    border: none;
    outline: none;
    transition: transform 0.1s;
}

button:active { transform: scale(0.98); }

#start-game {
    background-color: var(--accent-color);
    color: white;
    padding: 15px;
    border-radius: 10px;
    font-size: 18px;
    font-weight: bold;
    margin-top: 5px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.button-row {
    display: flex;
    gap: 10px;
    width: 100%;
    justify-content: center;
    margin-top: 5px;
}

#lang-open-btn, #settings-open-btn {
    flex: 1;
    background-color: white;
    color: #555;
    border: 2px solid #ddd;
    padding: 12px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: bold;
}

#rules-button {
    background-color: transparent;
    color: #f75c7b;
    border: 2px solid #f75c7b;
    padding: 10px 30px;
    border-radius: 20px;
    margin-top: 20px;
    font-size: 16px;
    font-weight: bold;
}

/* --- MODAL --- */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s;
}

.modal-content {
    background-color: #fff;
    margin: 15vh auto;
    padding: 25px;
    border-radius: 20px;
    width: 85%;
    max-width: 350px;
    text-align: center;
    position: relative;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    max-height: 90vh; /* Taşmayı önle */
    overflow-y: auto;
}

/* --- AYARLAR UI --- */
.close-modal-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    background-color: #ff4d4d;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    line-height: 1;
    z-index: 10;
}

.sound-btn {
    width: 100%;
    padding: 15px;
    border-radius: 12px;
    font-size: 18px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    cursor: pointer;
    margin-bottom: 10px;
    border: 2px solid transparent;
}

.sound-btn.sound-on { background-color: #e6f9f0; color: #04AA6D; border-color: #04AA6D; }
.sound-btn.sound-off { background-color: #ffe6e6; color: #d9534f; border-color: #d9534f; opacity: 0.8; }
.sound-icon { font-size: 24px; }

.lang-grid { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }
.lang-option {
    background-color: #f8f9fa;
    border: 2px solid #e9ecef;
    padding: 15px;
    border-radius: 12px;
    font-size: 18px;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 15px;
    color: #333;
    font-weight: 500;
}

.setting-item { margin-bottom: 20px; text-align: left; }
.setting-item label { display: block; font-weight: bold; margin-bottom: 8px; color: var(--primary-color); }

#turn-limit-select, #duration-select {
    width: 100%;
    padding: 15px 20px;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    background-color: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    cursor: pointer;
    margin-top: 5px;
    -webkit-appearance: none;
    appearance: none;
    /* Web uyumlu SVG ok */
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23275e95' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 20px;
}

#custom-cat-input {
    width: 100%;
    height: 60px;
    padding: 10px;
    border-radius: 8px;
    border: 2px solid #ccc;
    font-family: inherit;
    resize: none;
}

.small-hint { font-size: 12px; color: #888; margin-top: 4px; }
#lbl-tie-hint {
    display: block;
    margin-top: 10px;
    padding: 10px;
    background-color: #e6f2ff;
    color: var(--primary-color);
    font-size: 13px;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
}

#save-settings-btn {
    background-color: var(--accent-color);
    color: white;
    padding: 12px 20px;
    width: 100%;
    border-radius: 10px;
    font-size: 16px;
    font-weight: bold;
}

/* --- OYUN ARAYÜZÜ --- */
#game-ui-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    width: 100%;
    max-width: 600px;
    flex-grow: 1;
}

#top-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin-bottom: 10px;
}

#timer-container { font-size: 20px; font-weight: bold; color: #333; margin-bottom: 8px; }
#timer { font-size: 24px; color: #d9534f; min-width: 30px; display: inline-block; text-align: center; }
#category-container { width: 100%; text-align: center; }
#category-name {
    background-color: #6f42c1;
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 1.2rem;
    display: inline-block;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    max-width: 90%;
    word-wrap: break-word;
}

#game-wrapper {
    position: relative;
    width: 100%;
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

#game-container {
    position: relative;
    width: 85vmin;
    height: 85vmin;
    max-width: 500px;
    max-height: 500px;
    border-radius: 50%;
}

/* --- PASS BUTONU --- */
#pass-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30%;
    height: 30%;
    border-radius: 50%;
    background-color: white !important;
    border: 4px solid var(--accent-color);
    color: var(--accent-color) !important;
    font-weight: 900;
    font-size: 20px;
    text-align: center;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 150;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

#pass-button:active {
    background-color: var(--accent-color) !important;
    color: white !important;
}

.letter-box {
    position: absolute;
    width: 12%;
    height: 12%;
    background-color: white;
    border: 2px solid var(--accent-color);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 4vmin;
    font-weight: bold;
    color: #333;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    user-select: none;
    z-index: 50;
    transition: transform 0.1s;
}

.letter-box:active { transform: scale(0.9); }
.letter-box.blue { background-color: #007bff; color: white; border-color: #0056b3; }
.letter-box.red { background-color: #ff4d4d; color: white; border-color: #cc0000; }
.letter-box.faded { opacity: 0.5; }
.letter-box.clicked { pointer-events: none; }

/* --- UYARI & PROGRESS --- */
#timeout-warning {
    color: #d9534f;
    font-size: 13px;
    font-weight: bold;
    text-align: center;
    width: 90%;
    max-width: 400px;
    margin-bottom: 5px;
    padding: 8px;
    background-color: #fde8e8;
    border: 1px solid #f8b4b4;
    border-radius: 8px;
    animation: pulse-warning 1.5s infinite;
}

@keyframes pulse-warning {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(0.98); }
    100% { opacity: 1; transform: scale(1); }
}

#progress-container {
    width: 90%;
    max-width: 400px;
    margin: 10px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#progress-bar-wrapper {
    display: flex;
    width: 100%;
    height: 15px;
    background-color: #e9ecef;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #ccc;
    margin-bottom: 5px;
}

.progress-segment {
    flex: 1;
    background-color: transparent;
    border-right: 1px solid white;
    transition: background-color 0.3s;
}
.progress-segment:last-child { border-right: none; }
.progress-segment.filled { background-color: var(--accent-color); }
#progress-text { font-size: 14px; font-weight: bold; color: #666; }

/* --- SCOREBOARD --- */
#scoreboard {
    display: flex;
    justify-content: space-around;
    width: 100%;
    padding: 10px 0;
    background: white;
    border-radius: 15px 15px 0 0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.score-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 5px 15px;
    border-radius: 10px;
    min-width: 90px;
    transition: all 0.3s;
    opacity: 0.6;
}

.score-box span:first-child { font-size: 13px; color: #888; margin-bottom: 0px; font-weight: 500; }
#player1-score-val, #player2-score-val { font-size: 36px; font-weight: 900; line-height: 1.1; color: #333; }

.pass-indicator {
    font-size: 14px;
    margin-top: 4px;
    background-color: transparent;
    padding: 0;
    letter-spacing: 2px;
    opacity: 1;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.1));
}

.score-box.current-player {
    opacity: 1;
    transform: scale(1.05);
    background-color: white;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.current-player.winner-blue { border-bottom: 4px solid #007bff; }
.current-player.winner-red { border-bottom: 4px solid #ff4d4d; }
.winner-blue #player1-score-val { color: #007bff; }
.winner-red #player2-score-val { color: #ff4d4d; }
.winner-tie { color: #555; }

/* --- GAME OVER --- */
.game-over {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9);
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

#replayButton, #backToHomeButton {
    padding: 12px;
    border-radius: 25px;
    color: white;
    font-size: 16px;
    font-weight: bold;
    min-width: 120px;
}

#replayButton { background-color: #6f42c1; }
#backToHomeButton { background-color: #808080; }

.modal-buttons { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }

/* --- RULES PAGE --- */
.rules-container { width: 100%; height: 100vh; max-width: 600px; padding: 20px; display: flex; flex-direction: column; align-items: center; overflow: hidden; }
.rules-header { width: 100%; text-align: center; flex-shrink: 0; margin-bottom: 10px; }
.rules-logo { width: 80px; height: auto; margin-bottom: 5px; }
#rules-page-title { color: var(--primary-color); font-size: 24px; margin: 0; text-transform: uppercase; letter-spacing: 1px; }
.rules-card {
    background: white; padding: 20px; border-radius: 20px; box-shadow: 0 10px 25px rgba(0,0,0,0.08); width: 100%; border: 2px solid #eef2f5;
    flex-grow: 0; height: auto; max-height: 60vh; overflow-y: auto; margin-top: auto; margin-bottom: auto;
}
#rules-list { list-style: none; padding: 0; margin: 0; text-align: left; }
#rules-list li { position: relative; padding-left: 30px; margin-bottom: 12px; font-size: 16px; line-height: 1.4; color: #444; }
#rules-list li::before { content: '✔'; position: absolute; left: 0; top: 0; color: var(--accent-color); font-weight: bold; font-size: 18px; background: #e6f9f0; width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.rules-footer { width: 100%; text-align: center; flex-shrink: 0; padding-top: 10px; }
#back-home-btn { width: 100%; padding: 12px; font-size: 16px; border-radius: 12px; background-color: var(--primary-color); color: white; font-weight: bold; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
.contact-info { margin-top: 15px; font-size: 12px; color: #888; }
.contact-info p { margin: 0 0 5px 0; }
.email-link { color: var(--primary-color); text-decoration: none; font-weight: bold; }

/* RTL Support */
body.rtl { direction: rtl; }
body.rtl .letter-box { transform: rotate(0deg); }
body.rtl #close-modal { right: auto; left: 20px; }
body.rtl #rules-list { text-align: right; }
body.rtl #rules-list li { padding-left: 0; padding-right: 35px; }
body.rtl #rules-list li::before { left: auto; right: 0; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulse-red { 0% { transform: scale(1); color: #d9534f; } 50% { transform: scale(1.2); color: red; text-shadow: 0 0 10px rgba(255,0,0,0.5); } 100% { transform: scale(1); color: #d9534f; } }
.timer-critical { animation: pulse-red 0.8s infinite; }
@keyframes pop-effect { 0% { transform: scale(1); } 50% { transform: scale(1.2); } 100% { transform: scale(1); } }
.letter-box.clicked { animation: pop-effect 0.2s ease-out; }

#toast-message { visibility: hidden; min-width: 250px; background-color: #333; color: #fff; text-align: center; border-radius: 50px; padding: 16px; position: fixed; z-index: 200; left: 50%; bottom: 30px; transform: translateX(-50%); font-size: 17px; box-shadow: 0 4px 10px rgba(0,0,0,0.3); opacity: 0; transition: opacity 0.5s, bottom 0.5s; }
#toast-message.show { visibility: visible; opacity: 1; bottom: 50px; }

/* Landscape Fix */
@media (max-height: 500px) and (orientation: landscape) {
    #game-ui-container { flex-direction: row; }
    #top-bar { width: 20%; justify-content: center; }
    #scoreboard { width: 20%; flex-direction: column; height: 100%; border-radius: 15px 0 0 15px;}
    #game-wrapper { width: 60%; }
    #game-container { width: 70vmin; height: 70vmin; }
    .modal-content { margin: 5vh auto; overflow-y: auto; max-height: 90vh; }
}