/* ============================================
   144artıbir Online - Giriş & Lobi
   ============================================ */
:root {
    --bg: #eef0fb;
    --bg-grad: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --surface: #ffffff;
    --surface-2: #f5f6fc;
    --text: #1d1f33;
    --muted: #6b6f85;
    --border: #dfe2f0;
    --primary: #5a67d8;
    --primary-text: #ffffff;
    --danger: #d64545;
    --ok: #2f9e5b;
    --yellow: #f9d423;
    --red: #eb3349;
    --blue: #4facfe;
    --green: #43e97b;
    --shadow: 0 6px 20px rgba(30, 30, 80, .12);
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #12131f; --surface: #1c1e2e; --surface-2: #24273a; --text: #e6e7f0; --muted: #9a9db3;
        --border: #2f3247; --primary: #7f8cff; --shadow: 0 6px 20px rgba(0, 0, 0, .4);
        --bg-grad: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    }
}
:root[data-theme="dark"] {
    --bg: #12131f; --surface: #1c1e2e; --surface-2: #24273a; --text: #e6e7f0; --muted: #9a9db3;
    --border: #2f3247; --primary: #7f8cff; --shadow: 0 6px 20px rgba(0, 0, 0, .4);
    --bg-grad: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-grad);
    background-attachment: fixed;
    color: var(--text);
    min-height: 100vh;
}
[hidden] { display: none !important; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }

/* ---------- Üst bar ---------- */
.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    padding: 12px 20px; background: var(--surface); box-shadow: var(--shadow);
}
.brand { font-size: 1.4rem; font-weight: 800; letter-spacing: .5px; }
.tag { font-size: .7rem; vertical-align: middle; background: var(--primary); color: var(--primary-text); padding: 2px 8px; border-radius: 99px; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-chip { padding: 6px 12px; background: var(--surface-2); border-radius: 99px; }

/* ---------- Butonlar & form ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border: 1px solid transparent; border-radius: 8px; padding: 8px 14px; font-size: .95rem; font-weight: 600;
    cursor: pointer; text-decoration: none; background: var(--surface-2); color: var(--text); transition: transform .1s, filter .15s;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 4px 10px; font-size: .8rem; }

label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 12px; }
input[type=text], input[type=password], select {
    display: block; width: 100%; margin-top: 6px; padding: 10px 12px; font-size: 1rem;
    border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text);
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.form-error { color: var(--danger); min-height: 1.2em; margin-bottom: 8px; font-size: .9rem; }

.card { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); padding: 16px; }
.card h3 { font-size: 1rem; margin-bottom: 10px; }

/* ---------- Giriş ---------- */
.auth-wrap { display: flex; justify-content: center; padding: 48px 16px; }
.auth-card { width: 100%; max-width: 400px; padding: 28px; }
.auth-card h1 { font-size: 2rem; margin-bottom: 6px; }
.auth-card > p { margin-bottom: 18px; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.tab { flex: 1; border: 0; padding: 8px; border-radius: 8px; background: transparent; color: var(--muted); font-weight: 700; cursor: pointer; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.1); }
.auth-card .small { margin-top: 14px; }

/* ---------- Lobi ---------- */
.lobby { display: grid; grid-template-columns: 1fr 340px; gap: 20px; padding: 20px; max-width: 1400px; margin: 0 auto; }
.lobby-side { display: flex; flex-direction: column; gap: 16px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; color: #fff; }
.section-head h2 { font-size: 1.5rem; text-shadow: 0 1px 3px rgba(0,0,0,.25); }

.banner {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    background: var(--surface); border-left: 5px solid var(--yellow); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; box-shadow: var(--shadow);
}

.tables-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.table-card { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.table-card.mine { outline: 3px solid var(--yellow); }
.table-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.table-title { font-weight: 800; font-size: 1.1rem; word-break: break-word; }
.table-meta { font-size: .8rem; color: var(--muted); }
.status { font-size: .75rem; font-weight: 700; padding: 3px 10px; border-radius: 99px; white-space: nowrap; }
.status.waiting { background: #e3f6ea; color: #1e7a45; }
.status.playing { background: #fdebd2; color: #a35a00; }
.status.finished { background: #e7e8f3; color: #4b4f6b; }

/* Masa çizimi: ortada tahta, 4 yanda koltuk */
.table-visual {
    display: grid; grid-template-columns: 1fr 1.3fr 1fr; grid-template-rows: auto auto auto; gap: 6px; align-items: center; justify-items: center;
}
.tv-board {
    grid-column: 2; grid-row: 2; width: 100%; aspect-ratio: 1; border-radius: 8px;
    background: repeating-linear-gradient(0deg, #2b2b2b 0 2px, #cfcfcf 2px 12px), #cfcfcf;
    display: flex; align-items: center; justify-content: center; font-weight: 900; color: #222; font-size: 1.1rem;
    border: 4px solid #000; position: relative;
}
.tv-board span { background: rgba(255,255,255,.9); padding: 2px 6px; border-radius: 4px; }
.seat { width: 100%; min-height: 44px; border-radius: 8px; padding: 6px; font-size: .8rem; text-align: center; font-weight: 700; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 2px dashed var(--border); background: var(--surface-2); word-break: break-word; }
.seat.taken { border-style: solid; color: #1d1f33; }
.seat-1 { grid-column: 2; grid-row: 3; }
.seat-2 { grid-column: 3; grid-row: 2; }
.seat-3 { grid-column: 2; grid-row: 1; }
.seat-4 { grid-column: 1; grid-row: 2; }
.seat.c1.taken { background: var(--yellow); border-color: #c9a800; }
.seat.c2.taken { background: var(--red); border-color: #b4202f; color: #fff; }
.seat.c3.taken { background: var(--blue); border-color: #2479c7; }
.seat.c4.taken { background: var(--green); border-color: #22a85a; }
.seat .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.seat.c1 .dot { background: var(--yellow); } .seat.c2 .dot { background: var(--red); }
.seat.c3 .dot { background: var(--blue); } .seat.c4 .dot { background: var(--green); }
.table-actions { display: flex; gap: 8px; }
.table-actions .btn { flex: 1; }

.empty-state { background: var(--surface); border-radius: 14px; padding: 40px; text-align: center; box-shadow: var(--shadow); }
.empty-icon { font-size: 3rem; margin-bottom: 8px; }

.online-list { list-style: none; max-height: 200px; overflow-y: auto; }
.online-list li { display: flex; justify-content: space-between; padding: 6px 4px; border-bottom: 1px solid var(--border); font-size: .9rem; }
.online-list li:last-child { border-bottom: 0; }
.online-list .where { color: var(--muted); font-size: .8rem; }
.online-list .me { font-weight: 800; }

.chat-log { height: 200px; overflow-y: auto; background: var(--surface-2); border-radius: 8px; padding: 8px; font-size: .88rem; margin-bottom: 8px; }
.chat-log .msg { margin-bottom: 4px; word-wrap: break-word; }
.chat-log .msg b { color: var(--primary); }
.chat-log .msg.sys { color: var(--muted); font-style: italic; }
.chat-form { display: flex; gap: 6px; }
.chat-form input { margin-top: 0; }

.lb-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.lb-table th, .lb-table td { padding: 5px 4px; text-align: left; border-bottom: 1px solid var(--border); }
.lb-table th { color: var(--muted); font-weight: 600; }
.my-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.my-stats div { background: var(--surface-2); border-radius: 8px; padding: 8px; text-align: center; }
.my-stats strong { display: block; font-size: 1.3rem; }
.my-stats span { font-size: .75rem; color: var(--muted); }

/* ---------- Modal & toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 100; }
.modal-card { width: 100%; max-width: 420px; padding: 24px; }
.modal-card h2 { margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toast {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200;
    background: #222; color: #fff; padding: 10px 18px; border-radius: 8px; box-shadow: var(--shadow); max-width: calc(100% - 32px);
}
.toast.error { background: var(--danger); }

@media (max-width: 900px) {
    .lobby { grid-template-columns: 1fr; padding: 16px; }
}
