/* ── Sahte Fırça — gece atölyesi teması ───────────────── */
:root {
    --bg: #16131f;
    --bg-2: #1f1b2c;
    --card: #262136;
    --card-2: #2f2943;
    --line: #3b3452;
    --ink: #f3efe6;
    --muted: #a49cb8;
    --accent: #ffcc33;
    --accent-ink: #231a00;
    --imp: #ff4d6d;
    --crew: #3ddc97;
    --pen: #7aa2ff;
    --radius: 16px;
    --shadow: 0 14px 40px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }

body {
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(900px 500px at 15% -10%, rgba(255, 204, 51, 0.10), transparent 60%),
        radial-gradient(700px 500px at 110% 10%, rgba(255, 77, 109, 0.10), transparent 60%),
        var(--bg);
    background-attachment: fixed;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.back-link {
    position: fixed; top: 14px; left: 14px; z-index: 60;
    color: var(--muted); text-decoration: none;
    background: rgba(38, 33, 54, 0.9); border: 1px solid var(--line);
    padding: 9px 15px; border-radius: 999px; font-size: 0.9rem;
}
.back-link:hover { color: var(--accent); border-color: var(--accent); }

.screen { width: 100%; padding: 70px 16px 90px; display: flex; flex-direction: column; align-items: center; }
.screen-narrow { max-width: 520px; }
#screen-lobby { max-width: 1060px; }
.screen-wide { max-width: 1280px; }

.panel {
    width: 100%;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
}
h2 { font-size: 1.3rem; margin-bottom: 12px; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 0.82rem; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: 2px; }

.logo { text-align: center; font-size: 2.6rem; font-weight: 900; letter-spacing: -1px; }
.logo-accent { color: var(--accent); font-style: italic; }
.tagline { text-align: center; color: var(--muted); margin: 6px 0 16px; line-height: 1.45; }

.example-card {
    display: grid; gap: 8px; padding: 12px 14px; margin-bottom: 6px;
    background: var(--bg-2); border: 1px dashed var(--line); border-radius: 12px;
}
.example-card div { display: flex; flex-direction: column; gap: 2px; }
.ex-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1px; color: var(--crew); }
.ex-label.ex-imp { color: var(--imp); }

.field-label {
    display: block; font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 1px; color: var(--muted); margin: 14px 0 6px;
}
input[type="text"], textarea, select {
    width: 100%; background: var(--bg-2); color: var(--ink);
    border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px;
    font-size: 1rem; font-family: inherit; outline: none;
}
input[type="text"]:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; line-height: 1.4; }
#room-input { text-transform: uppercase; letter-spacing: 4px; }

.avatar-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; }
.avatar-btn {
    font-size: 1.45rem; background: var(--bg-2); border: 2px solid var(--line);
    border-radius: 10px; padding: 7px 0; cursor: pointer;
}
.avatar-btn.selected { border-color: var(--accent); background: rgba(255, 204, 51, 0.12); }

.btn {
    border: 1px solid transparent; border-radius: 10px; padding: 10px 16px;
    font-size: 0.95rem; font-weight: 700; cursor: pointer; font-family: inherit;
    transition: transform .1s, filter .2s, opacity .2s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-big { width: 100%; padding: 14px; font-size: 1.05rem; margin-top: 16px; }
.btn-small { padding: 6px 10px; font-size: 0.82rem; }
.btn-danger { background: var(--imp); color: #fff; }

.entry-status { margin-top: 10px; text-align: center; color: var(--muted); }

/* ── Lobi ─────────────────────────────────────────── */
.lobby-grid { display: grid; grid-template-columns: 1fr 1.1fr; gap: 18px; width: 100%; align-items: start; }
@media (max-width: 860px) { .lobby-grid { grid-template-columns: 1fr; } }

.room-code-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.room-code-box {
    display: flex; flex-direction: column; padding: 6px 14px; border-radius: 10px;
    background: var(--bg-2); border: 1px solid var(--line); margin-right: auto;
}
.room-code-box strong { font-size: 1.6rem; letter-spacing: 6px; color: var(--accent); }

.section-title { font-size: 0.95rem; margin: 16px 0 8px; }
.player-list { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.player-item {
    display: flex; align-items: center; gap: 8px; padding: 8px 10px;
    background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px;
}
.player-item.me { border-color: var(--accent); }
.player-avatar { font-size: 1.3rem; }
.player-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.rules-box {
    margin-top: 16px; padding: 14px 16px; border-radius: 12px;
    background: var(--bg-2); border: 1px solid var(--line); line-height: 1.5;
}
.rules-box ol { margin: 6px 0 8px 18px; font-size: 0.92rem; }
.host-note { text-align: center; margin-top: 12px; }

/* Ayarlar */
.setting { margin-bottom: 12px; }
.setting .field-label { margin-top: 4px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-btn {
    background: var(--bg-2); color: var(--ink); border: 1px solid var(--line);
    border-radius: 9px; padding: 7px 11px; font-size: 0.86rem; cursor: pointer; font-family: inherit;
    text-align: left;
}
.seg-btn small { display: block; color: var(--muted); font-size: 0.72rem; margin-top: 1px; }
.seg-btn.selected { border-color: var(--accent); background: rgba(255, 204, 51, 0.14); }
.seg-btn:disabled { cursor: default; }
.seg-btn:disabled:not(.selected) { opacity: 0.5; }
.hint-preview {
    margin-top: 8px; padding: 8px 12px; border-radius: 10px; background: var(--bg-2);
    border: 1px dashed rgba(255, 77, 109, 0.5);
}
.hint-preview strong { font-family: ui-monospace, Consolas, monospace; letter-spacing: 2px; color: var(--imp); }
.custom-wrap textarea { font-size: 0.92rem; }
.settings-modal { max-height: 88vh; overflow-y: auto; text-align: left; }

/* ── Oyun ─────────────────────────────────────────── */
.game { width: 100%; display: flex; flex-direction: column; gap: 14px; }
.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 18px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line);
}
.topbar-left { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.phase-title { font-size: 1.15rem; font-weight: 800; }
.timer {
    min-width: 58px; text-align: center; font-weight: 900; font-size: 1.35rem;
    padding: 4px 12px; border-radius: 999px; background: var(--bg-2); border: 1px solid var(--line);
    font-variant-numeric: tabular-nums;
}
.timer.urgent { color: var(--imp); border-color: var(--imp); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }

.role-card {
    display: flex; align-items: center; gap: 14px; justify-content: space-between;
    padding: 14px 18px; border-radius: var(--radius);
    background: linear-gradient(90deg, rgba(61, 220, 151, 0.16), var(--card) 70%);
    border: 1px solid rgba(61, 220, 151, 0.5);
}
.role-card.impostor {
    background: linear-gradient(90deg, rgba(255, 77, 109, 0.22), var(--card) 70%);
    border-color: rgba(255, 77, 109, 0.6);
}
.role-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.role-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--crew); font-weight: 800; }
.role-card.impostor .role-label { color: var(--imp); }
.role-text { font-size: 1.55rem; line-height: 1.2; word-break: break-word; }
.role-card.impostor .role-text { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: 3px; }
.role-card.concealed .role-text { filter: blur(9px); user-select: none; }

.phase-panel .row, .row { display: flex; gap: 8px; margin-top: 10px; }
.row input { flex: 1; }

.draw-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 14px; align-items: start; }
@media (max-width: 900px) { .draw-layout { grid-template-columns: 1fr; } }

.stage { padding: 14px; }
.stage-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; min-height: 32px; }
.stage-title { font-weight: 800; }
.toolbar { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.color-row { display: flex; flex-wrap: wrap; gap: 6px; }
.color-btn {
    width: 28px; height: 28px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.25);
    cursor: pointer;
}
.color-btn.selected { outline: 3px solid var(--accent); outline-offset: 2px; }
.tool-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.size-row { display: flex; gap: 4px; margin-right: 6px; }
.size-btn, .tool-btn {
    background: var(--bg-2); color: var(--ink); border: 1px solid var(--line);
    border-radius: 9px; height: 34px; min-width: 34px; padding: 0 9px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; font-family: inherit; font-size: 0.85rem;
}
.size-btn .dot { display: block; border-radius: 50%; background: var(--ink); }
.size-btn.selected, .tool-btn.active { border-color: var(--accent); background: rgba(255, 204, 51, 0.14); }
.tool-btn:disabled { opacity: 0.4; cursor: default; }

.canvas-frame {
    position: relative; width: 100%; aspect-ratio: 4 / 3; border-radius: 12px; overflow: hidden;
    background: #fff; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}
.canvas-frame canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
.canvas-frame.readonly canvas { cursor: default; }
.stage-overlay {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    text-align: center; padding: 20px; background: rgba(22, 19, 31, 0.55); color: #fff;
    font-weight: 700; font-size: 1.05rem; pointer-events: none;
}
.stage-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
#done-btn.is-done { background: var(--crew); color: #062417; }
.toolbar.disabled { opacity: 0.4; pointer-events: none; }

.gallery-wrap { min-width: 0; }
.gallery-wrap .section-title { margin-top: 0; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.g-card {
    background: var(--card); border: 2px solid var(--line); border-radius: 12px; padding: 6px;
    cursor: pointer; position: relative; transition: border-color .2s, transform .15s;
}
.g-card:hover { border-color: var(--muted); }
.g-card.staged { border-color: var(--pen); }
.g-card.turn { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 204, 51, 0.25); }
.g-card.me .g-name::after { content: " (sen)"; color: var(--muted); font-weight: 400; }
.g-card .canvas-frame { border-radius: 8px; }
.g-card canvas { cursor: pointer; }
.g-meta { display: flex; align-items: center; gap: 6px; padding: 6px 2px 2px; font-size: 0.86rem; min-width: 0; }
.g-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.g-status { font-size: 0.75rem; color: var(--muted); white-space: nowrap; }
.g-status.ok { color: var(--crew); }
.g-vote { width: 100%; margin-top: 6px; }
.g-card.my-vote { border-color: var(--imp); }
.g-card.imp-reveal { border-color: var(--imp); }
.g-card.imp-reveal::before {
    content: "SAHTEKÂR"; position: absolute; top: 12px; left: 12px; z-index: 2;
    background: var(--imp); color: #fff; font-size: 0.68rem; font-weight: 900; letter-spacing: 1px;
    padding: 3px 7px; border-radius: 6px;
}
.g-cover {
    position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 4px; background: var(--card-2); font-size: 1.8rem;
}
.g-cover span { font-size: 0.75rem; color: var(--muted); }
.vote-pips { display: flex; gap: 2px; flex-wrap: wrap; }
.vote-pip { font-size: 0.9rem; }

/* Oylama / sonuç fazında galeri büyür, sahne gizlenir */
.game.phase-vote .stage, .game.phase-guess .stage, .game.phase-over .stage, .game.phase-write .draw-layout { display: none; }
.game.phase-vote .draw-layout, .game.phase-guess .draw-layout, .game.phase-over .draw-layout { grid-template-columns: 1fr; }
.game.phase-vote .gallery, .game.phase-guess .gallery, .game.phase-over .gallery { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

/* ── Sonuç ───────────────────────────────────────── */
.overlay {
    position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center;
    padding: 16px; background: rgba(10, 8, 16, 0.72); backdrop-filter: blur(4px);
}
.overlay-panel { max-width: 520px; text-align: center; max-height: 92vh; overflow-y: auto; }
.result-emoji { font-size: 3rem; }
.result-prompt {
    display: flex; flex-direction: column; gap: 2px; margin: 14px 0; padding: 12px;
    background: var(--bg-2); border-radius: 12px; border: 1px solid var(--line);
}
.result-prompt strong { font-size: 1.4rem; color: var(--accent); }
.result-impostors { display: grid; gap: 6px; }
.imp-row {
    display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 10px;
    background: rgba(255, 77, 109, 0.12); border: 1px solid rgba(255, 77, 109, 0.4); text-align: left;
}
.imp-row .mono { color: var(--imp); }
.score-list { list-style: none; display: grid; gap: 4px; text-align: left; }
.score-list li {
    display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 9px; background: var(--bg-2);
}
.score-list li .sc-name { flex: 1; }
.score-list li .sc-plus { color: var(--crew); font-weight: 800; min-width: 34px; text-align: right; }
.score-list li .sc-total { font-weight: 900; min-width: 34px; text-align: right; }
.overlay-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; justify-content: center; }
.overlay-actions .btn-big { margin-top: 0; }
.results-reopen { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 70; box-shadow: var(--shadow); }

/* ── Sohbet ──────────────────────────────────────── */
.chat {
    position: fixed; right: 14px; bottom: 14px; z-index: 75; width: 300px; max-width: calc(100vw - 28px);
    background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
    overflow: hidden;
}
.chat-toggle {
    width: 100%; background: var(--card-2); color: var(--ink); border: 0; padding: 10px 14px;
    text-align: left; font-weight: 700; cursor: pointer; font-family: inherit; font-size: 0.92rem;
}
.chat-badge { background: var(--imp); color: #fff; border-radius: 999px; padding: 1px 7px; font-size: 0.75rem; margin-left: 6px; }
.chat.collapsed .chat-body { display: none; }
.chat-log { list-style: none; height: 230px; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; font-size: 0.88rem; }
.chat-log li { line-height: 1.35; word-break: break-word; }
.chat-log .who { font-weight: 700; color: var(--accent); }
.chat-log .sys { color: var(--muted); font-style: italic; }
.chat-form { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--line); }
.chat-form input { padding: 8px 10px; font-size: 0.9rem; }

/* ── Toast ───────────────────────────────────────── */
.toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
    background: var(--card-2); color: var(--ink); border: 1px solid var(--line); padding: 10px 16px;
    border-radius: 10px; box-shadow: var(--shadow); font-size: 0.92rem; transition: opacity .3s, transform .3s;
}
.toast-error { border-color: var(--imp); }
.toast-success { border-color: var(--crew); }
.toast-out { opacity: 0; transform: translateY(-8px); }

/* ── Araçlar v2 ──────────────────────────────────── */
.tool { flex-direction: column; height: 46px; min-width: 50px; gap: 1px; font-size: 1.05rem; line-height: 1; }
.tool span { font-size: 0.64rem; color: var(--muted); }
.tool.active span { color: var(--accent); }
.color-line { display: flex; gap: 8px; align-items: center; }
.color-row { gap: 4px; }
.color-btn { width: 22px; height: 22px; border-width: 1px; }
.color-custom {
    position: relative; width: 40px; height: 40px; flex: none; border-radius: 10px; cursor: pointer;
    border: 2px solid var(--line);
    background: conic-gradient(#f33, #fd3, #3d6, #3cf, #36f, #c3f, #f33);
    display: flex; align-items: center; justify-content: center;
}
.color-current { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.4); }
.color-custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
#stage-canvas[data-tool="fill"] { cursor: cell; }
#stage-canvas[data-tool="picker"] { cursor: copy; }
.inter-note {
    margin-top: 14px; padding: 9px 12px; border-radius: 10px; font-weight: 700;
    background: rgba(255, 204, 51, 0.12); border: 1px solid rgba(255, 204, 51, 0.4); color: var(--accent);
}
.role-card.spectator {
    background: linear-gradient(90deg, rgba(122, 162, 255, 0.18), var(--card) 70%);
    border-color: rgba(122, 162, 255, 0.5);
}
.role-card.spectator .role-label { color: var(--pen); }
.role-card.spectator .role-text { font-size: 1.15rem; }
