/* ==========================================================================
   base.css — Sıfırlama, gece/gündüz tema değişkenleri, ortak bileşenler
   ========================================================================== */

:root {
    --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-display: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
    --font-serif: Georgia, "Times New Roman", serif;

    --radius: 18px;
    --radius-sm: 12px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);

    --noise: url("data:image/svg+xml,%3Csvg width='120' height='120' viewBox='0 0 120 120' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.09'/%3E%3C/svg%3E");
}

/* ---------- Gece teması (varsayılan) ---------- */
:root,
:root[data-theme="night"] {
    --bg: #0b1220;
    --surface: rgba(20, 29, 49, 0.88);
    --surface-solid: #151e34;
    --surface-2: rgba(255, 255, 255, 0.07);
    --text: #eef2ff;
    --text-dim: #9aa6c4;
    --accent: #fbbf24;
    --accent-ink: #2b1b00;
    --good: #34d399;
    --bad: #fb7185;
    --border: rgba(255, 255, 255, 0.12);
    --shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    --veil: rgba(4, 8, 22, 0.62);
    --game-dim: rgba(2, 8, 20, 0.34);
    --btn-ghost-bg: rgba(255, 255, 255, 0.09);
    color-scheme: dark;
}

/* ---------- Gündüz teması ---------- */
:root[data-theme="day"] {
    --bg: #f4efe3;
    --surface: rgba(255, 253, 247, 0.92);
    --surface-solid: #fffdf7;
    --surface-2: rgba(70, 50, 10, 0.07);
    --text: #2a2418;
    --text-dim: #7a6f58;
    --accent: #e08e00;
    --accent-ink: #ffffff;
    --good: #15803d;
    --bad: #dc2646;
    --border: rgba(70, 50, 10, 0.16);
    --shadow: 0 12px 30px rgba(60, 40, 0, 0.22);
    --veil: rgba(255, 246, 220, 0.4);
    --game-dim: rgba(0, 0, 0, 0);
    --btn-ghost-bg: rgba(70, 50, 10, 0.09);
    color-scheme: light;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    overscroll-behavior: none;
}

button {
    font-family: inherit;
    color: inherit;
    cursor: pointer;
    border: 0;
    background: none;
    padding: 0;
    touch-action: manipulation;
}

input {
    font-family: inherit;
    -webkit-user-select: text;
    user-select: text;
}

h1, h2, h3, p { margin: 0; }

.hidden { display: none !important; }

/* ---------- Uygulama kabuğu ---------- */
#app {
    position: fixed;
    inset: 0;
    overflow: hidden;
}

.table-bg,
.table-fx,
.table-dim {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.table-bg { background: #0d4732; }
.table-bg::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--noise);
    opacity: 0.8;
}
.table-fx { overflow: hidden; }
.table-dim { background: var(--veil); transition: background 0.4s; }
#app[data-screen="game"] .table-dim { background: var(--game-dim); }
#app[data-screen="splash"] .table-dim { background: rgba(3, 8, 20, 0.55); }

/* ---------- Ekranlar ---------- */
.screen {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    padding: var(--safe-top) var(--safe-right) 0 var(--safe-left);
    color: var(--text);
}

.screen.is-active {
    display: flex;
    animation: screenIn 0.28s ease-out;
}

@keyframes screenIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

/* ---------- Butonlar ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 12px 22px;
    border-radius: 16px;
    font-weight: 800;
    font-size: 16px;
    letter-spacing: 0.02em;
    color: #fff;
    background: linear-gradient(180deg, #4b5563, #374151);
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35), 0 10px 18px rgba(0, 0, 0, 0.25);
    transition: transform 0.08s, box-shadow 0.08s, opacity 0.2s, filter 0.2s;
    position: relative;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}

.btn:active:not(:disabled) {
    transform: translateY(3px);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35), 0 4px 8px rgba(0, 0, 0, 0.25);
}

.btn:disabled {
    opacity: 0.5;
    filter: grayscale(0.6);
    cursor: not-allowed;
}

.btn-wide { width: 100%; }
.btn-play {
    min-height: 62px;
    font-size: 24px;
    letter-spacing: 0.12em;
    background: linear-gradient(180deg, #34d27b, #15935a);
    box-shadow: 0 5px 0 #0c6b3f, 0 14px 26px rgba(21, 147, 90, 0.45);
}
.btn-play:active:not(:disabled) { box-shadow: 0 2px 0 #0c6b3f, 0 6px 12px rgba(21, 147, 90, 0.4); }
.btn-gold {
    background: linear-gradient(180deg, #ffd24d, #f08c00);
    color: #3a2300;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
    box-shadow: 0 4px 0 #a45c00, 0 10px 20px rgba(240, 140, 0, 0.35);
}
.btn-blue {
    background: linear-gradient(180deg, #4aa3ff, #2563eb);
    box-shadow: 0 4px 0 #1b3fa0, 0 10px 20px rgba(37, 99, 235, 0.35);
}
.btn-red {
    background: linear-gradient(180deg, #ff6b7f, #d6264a);
    box-shadow: 0 4px 0 #8f1431, 0 10px 20px rgba(214, 38, 74, 0.35);
}
.btn-ghost {
    background: var(--btn-ghost-bg);
    color: var(--text);
    text-shadow: none;
    box-shadow: inset 0 0 0 1px var(--border);
}
.btn-ghost:active:not(:disabled) { box-shadow: inset 0 0 0 1px var(--border); transform: scale(0.97); }
.btn-small { min-height: 38px; padding: 8px 14px; font-size: 14px; border-radius: 12px; }

.icon-btn {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    background: var(--surface);
    box-shadow: inset 0 0 0 1px var(--border), 0 4px 10px rgba(0, 0, 0, 0.18);
    position: relative;
    transition: transform 0.1s;
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn.small { width: 38px; height: 38px; font-size: 18px; border-radius: 12px; }
.back-btn { font-size: 30px; line-height: 1; padding-bottom: 4px; }

.count-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 11px;
    font-style: normal;
    font-weight: 800;
    line-height: 18px;
    text-align: center;
}
.count-badge:empty { display: none; }

/* ---------- Çipler / segment kontrol ---------- */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    padding: 6px 12px;
    border-radius: 14px;
    background: var(--surface);
    box-shadow: inset 0 0 0 1px var(--border);
    font-weight: 700;
    font-size: 15px;
}

.seg {
    display: flex;
    gap: 6px;
    padding: 4px;
    border-radius: 14px;
    background: var(--surface-2);
    box-shadow: inset 0 0 0 1px var(--border);
}

.seg button {
    flex: 1;
    min-height: 38px;
    padding: 6px 10px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-dim);
    white-space: nowrap;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.15;
    transition: background 0.15s, color 0.15s, transform 0.1s;
}
.seg button small { font-size: 10px; font-weight: 700; opacity: 0.8; }
.seg button.is-on {
    background: var(--accent);
    color: var(--accent-ink);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.seg button:active { transform: scale(0.95); }
.seg button:disabled { opacity: 0.4; }

/* ---------- Logo ---------- */
.logo {
    font-family: var(--font-serif);
    font-weight: 900;
    font-size: clamp(44px, 14vw, 66px);
    line-height: 1;
    text-align: center;
    letter-spacing: 0.04em;
    background: linear-gradient(180deg, #fff3b0 0%, #fbbf24 45%, #b45309 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.55));
}
.logo small {
    display: block;
    margin-top: 4px;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    background: none;
    -webkit-text-fill-color: var(--text-dim);
    filter: none;
}
.logo-big { font-size: clamp(60px, 22vw, 96px); }

/* ---------- Avatar / rütbe / XP ---------- */
.avatar {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 25%, #6ea8ff, #2a4fa8);
    font-size: 1.5em;
    line-height: 1;
}

.rank-badge {
    --rank-size: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--rank-size);
    height: calc(var(--rank-size) * 1.12);
    flex: 0 0 auto;
    clip-path: polygon(50% 0, 100% 14%, 100% 62%, 50% 100%, 0 62%, 0 14%);
    background: linear-gradient(160deg, var(--rank-c1), var(--rank-c2));
    color: #1d1100;
    font-weight: 900;
    font-size: calc(var(--rank-size) * 0.42);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
}
.rank-badge b { transform: translateY(-1px); }

.xpbar {
    position: relative;
    display: block;
    height: 14px;
    min-width: 96px;
    border-radius: 7px;
    background: rgba(0, 0, 0, 0.35);
    box-shadow: inset 0 0 0 1px var(--border);
    overflow: hidden;
}
.xpbar i {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0;
    border-radius: 7px;
    background: linear-gradient(90deg, #22d3ee, #3b82f6 60%, #a855f7);
    transition: width 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.xpbar small {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

/* ---------- Bilgi kutusu ---------- */
.notice {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: rgba(220, 38, 70, 0.16);
    box-shadow: inset 0 0 0 1px rgba(220, 38, 70, 0.4);
    color: var(--text);
    font-size: 14px;
    text-align: center;
}

/* ---------- Modal ---------- */
.modal-root {
    position: absolute;
    inset: 0;
    z-index: 100;
    pointer-events: none;
}

.modal {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(var(--safe-top) + 16px) 16px calc(var(--safe-bottom) + 16px);
    background: rgba(2, 6, 18, 0.66);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    pointer-events: auto;
    animation: fadeIn 0.2s ease-out;
}

.modal-card {
    width: 100%;
    max-width: 440px;
    max-height: 100%;
    overflow-y: auto;
    padding: 20px;
    border-radius: 24px;
    background: var(--surface-solid);
    color: var(--text);
    box-shadow: var(--shadow), inset 0 0 0 1px var(--border);
    animation: popIn 0.28s cubic-bezier(0.2, 1.2, 0.4, 1);
    scrollbar-width: none;
}
.modal-card::-webkit-scrollbar { display: none; }
.modal-card h2 { font-size: 22px; text-align: center; margin-bottom: 4px; }
.modal-card .lead { text-align: center; color: var(--text-dim); font-size: 14px; margin-bottom: 14px; }
.modal-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.modal-actions.row { flex-direction: row; }
.modal-actions.row .btn { flex: 1; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn {
    from { opacity: 0; transform: scale(0.85) translateY(14px); }
    to { opacity: 1; transform: none; }
}

/* ---------- Toast ---------- */
.toast-root {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(var(--safe-top) + 12px);
    z-index: 300;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}
.toast {
    max-width: 88%;
    padding: 10px 18px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.94);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(255, 255, 255, 0.14);
    animation: toastIn 0.25s ease-out;
}
.toast.good { background: rgba(21, 128, 61, 0.96); }
.toast.bad { background: rgba(190, 18, 60, 0.96); }
.toast.out { opacity: 0; transform: translateY(-10px); transition: 0.3s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px) scale(0.9); } to { opacity: 1; transform: none; } }

/* ---------- Efekt katmanları ---------- */
.fx-layer,
.fx-canvas {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 150;
}
.float-text {
    position: absolute;
    font-family: var(--font-display);
    font-weight: 900;
    font-size: 30px;
    color: #fde047;
    text-shadow: 0 3px 0 #92400e, 0 6px 14px rgba(0, 0, 0, 0.55);
    white-space: nowrap;
}
.float-text.big { font-size: 52px; letter-spacing: 0.06em; }
.float-text.cool { color: #7dd3fc; text-shadow: 0 3px 0 #0c4a6e, 0 6px 14px rgba(0, 0, 0, 0.55); }
.float-text.bad { color: #fda4af; text-shadow: 0 3px 0 #7f1d1d, 0 6px 14px rgba(0, 0, 0, 0.55); }

/* ---------- Reklam alanları ---------- */
.ad-slot {
    display: none;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: var(--ad-h, 50px);
    padding-bottom: 0;
    background: rgba(0, 0, 0, 0.2);
    overflow: hidden;
}
.ad-slot.is-on { display: flex; }
.ad-slot[data-ad-slot^="banner"] { margin-top: auto; padding-bottom: 0; }
.ad-slot.is-on:last-child { margin-bottom: var(--safe-bottom); }
.ad-slot.inline { margin: 12px auto; max-width: 336px; border-radius: var(--radius-sm); }

.ad-mock {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: repeating-linear-gradient(135deg, var(--surface-2) 0 10px, transparent 10px 20px);
    border: 1px dashed var(--border);
    color: var(--text-dim);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.2em;
}
.ad-mock small { font-weight: 600; letter-spacing: 0.04em; opacity: 0.75; }

.ad-overlay {
    position: absolute;
    inset: 0;
    z-index: 400;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.92);
}
.ad-overlay.is-open { display: flex; }
.ad-mock-card {
    width: 100%;
    max-width: 340px;
    padding: 22px;
    border-radius: 22px;
    text-align: center;
    background: linear-gradient(160deg, #1e293b, #0f172a);
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.ad-mock-card p { color: #94a3b8; font-size: 13px; }
.ad-mock-tag { font-size: 11px; letter-spacing: 0.16em; color: #fbbf24; font-weight: 800; }
.ad-mock-bar { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.ad-mock-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #fbbf24, #f97316); }

/* ---------- Açılış ekranı ---------- */
.splash-center {
    margin: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    color: #fff;
}
.splash-loader { width: 160px; height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.15); overflow: hidden; }
.splash-loader i { display: block; width: 40%; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #fbbf24, #f97316); animation: loader 1.1s ease-in-out infinite; }
#splash-text { font-size: 13px; opacity: 0.75; letter-spacing: 0.1em; }
@keyframes loader { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }

@media (prefers-reduced-motion: reduce) {
    .screen.is-active, .modal, .modal-card { animation: none; }
}

#screen-game .ad-mock {
    border-color: rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 0.7);
    background: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0 10px, transparent 10px 20px);
}
