/* Noktalar — koyu tema */
:root {
    --bg: #0f1220;
    --panel: #1a1f35;
    --panel-2: #232a4a;
    --accent: #7c5cff;
    --accent-2: #00e5a0;
    --text: #eef0ff;
    --muted: #9aa3c7;
    --danger: #ff5c7a;
    --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    min-height: 100%;
}

body {
    background:
        radial-gradient(900px 500px at 80% -10%, rgba(124, 92, 255, 0.16), transparent 60%),
        radial-gradient(700px 400px at 0% 100%, rgba(0, 229, 160, 0.08), transparent 60%),
        var(--bg);
}

/* ── Genel ─────────────────────────────────────── */
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.85rem; }

.back-link {
    position: fixed;
    top: 14px;
    left: 16px;
    z-index: 50;
    color: var(--muted);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 10px 14px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    background: rgba(26, 31, 53, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 12px;
    backdrop-filter: blur(6px);
    transition: color 0.2s, border-color 0.2s;
}
.back-link:hover { color: var(--text); border-color: var(--accent); }

.app {
    max-width: 640px;
    margin: 0 auto;
    padding: 72px 16px 40px;
}

.screen { animation: fade-in 0.3s ease; }

@keyframes fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

.logo {
    text-align: center;
    font-size: 2.2rem;
    margin: 0 0 4px;
    letter-spacing: 0.5px;
}
.tagline {
    text-align: center;
    color: var(--muted);
    margin: 0 0 20px;
}

.panel {
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

label {
    display: block;
    margin: 14px 0 6px;
    font-size: 0.9rem;
    color: var(--muted);
}
label:first-child { margin-top: 0; }

input[type="text"], select {
    width: 100%;
    padding: 12px 14px;
    min-height: 44px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
input[type="text"]:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.25);
}
#room-input { text-transform: uppercase; letter-spacing: 4px; }

/* ── Butonlar ──────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    min-height: 46px;
    padding: 12px 18px;
    margin-top: 16px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s, opacity 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn.primary {
    background: linear-gradient(135deg, var(--accent), #5b3df0);
    color: #fff;
    box-shadow: 0 6px 20px rgba(124, 92, 255, 0.35);
}
.btn.primary:not(:disabled):hover {
    box-shadow: 0 8px 26px rgba(124, 92, 255, 0.5);
    transform: translateY(-1px);
}

.btn.ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.15);
}
.btn.ghost:hover { border-color: var(--accent-2); color: var(--accent-2); }
.btn.small { width: auto; min-height: 40px; padding: 8px 14px; font-size: 0.85rem; margin-top: 0; }

/* ── Avatar seçici ─────────────────────────────── */
.avatar-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}
.avatar-btn {
    font-size: 1.5rem;
    min-height: 48px;
    background: var(--bg);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.2s, background 0.2s;
}
.avatar-btn:hover { transform: scale(1.08); border-color: rgba(124, 92, 255, 0.5); }
.avatar-btn.selected {
    border-color: var(--accent);
    background: rgba(124, 92, 255, 0.18);
}

/* ── Lobi ──────────────────────────────────────── */
.room-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}
.room-head h2 { margin: 0; font-size: 1.2rem; }
.room-code {
    color: var(--accent-2);
    font-weight: 800;
    letter-spacing: 4px;
    font-size: 1.35rem;
}
.list-title { margin: 18px 0 8px; font-size: 1rem; }

.player-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.player-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 12px;
    padding: 10px 14px;
    min-height: 46px;
    animation: fade-in 0.25s ease;
}
.player-item.me { border-color: rgba(124, 92, 255, 0.55); }
.p-avatar { font-size: 1.3rem; }
.p-name { flex: 1; font-weight: 600; }
.p-host { font-size: 1.1rem; }

.host-controls { margin-top: 12px; }
#wait-note { margin: 16px 0 0; text-align: center; }
#min-note { margin: 10px 0 0; text-align: center; }

/* ── Oyun ekranı ───────────────────────────────── */
.turn-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 10px 16px;
    margin-bottom: 12px;
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: var(--radius);
    font-weight: 600;
    transition: border-color 0.25s, box-shadow 0.25s;
}
.turn-bar.my-turn {
    border-color: var(--accent-2);
    box-shadow: 0 0 18px rgba(0, 229, 160, 0.25);
    color: var(--accent-2);
}
.turn-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    flex: none;
}

.scoreboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    margin-bottom: 14px;
}
.score-card {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-left: 4px solid var(--pc, var(--accent));
    border-radius: 12px;
    padding: 8px 12px;
    transition: box-shadow 0.25s, border-color 0.25s;
}
.score-card.active {
    border-color: var(--pc);
    box-shadow: 0 0 14px color-mix(in srgb, var(--pc) 40%, transparent);
}
.sc-avatar { font-size: 1.15rem; }
.sc-name {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sc-score {
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--pc, var(--text));
}

/* ── SVG tahta ─────────────────────────────────── */
.board-wrap {
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: var(--radius);
    padding: 10px;
}
#board {
    display: block;
    width: 100%;
    height: auto;
    touch-action: manipulation;
    user-select: none;
}
#board .dot { fill: var(--text); opacity: 0.85; pointer-events: none; }
#board .edge {
    fill: transparent;
    cursor: pointer;
    transition: fill 0.15s;
}
#board.my-turn .edge:hover { fill: rgba(238, 240, 255, 0.22); }
#board:not(.my-turn) .edge { cursor: not-allowed; }
#board .drawn-line { pointer-events: none; }
#board .box { pointer-events: none; }
#board .box.just-captured { animation: box-pop 0.45s ease; transform-origin: center; transform-box: fill-box; }

@keyframes box-pop {
    0% { opacity: 0; transform: scale(0.6); }
    60% { transform: scale(1.08); }
    100% { opacity: 1; transform: scale(1); }
}

.move-note {
    min-height: 28px;
    margin-top: 10px;
    text-align: center;
    font-weight: 600;
    color: var(--accent-2);
    opacity: 0;
    transition: opacity 0.25s;
}
.move-note.visible { opacity: 1; }

/* ── Oyun sonu ─────────────────────────────────── */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(15, 18, 32, 0.82);
    backdrop-filter: blur(4px);
    animation: fade-in 0.3s ease;
}
.over-panel {
    width: 100%;
    max-width: 420px;
    text-align: center;
}
.over-panel h2 { margin: 0 0 6px; font-size: 1.5rem; }
#over-reason { margin: 0 0 12px; }

.over-scores {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 14px 0 4px;
}
.over-score-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 12px;
    padding: 10px 14px;
}
.over-score-row.winner {
    border-color: var(--accent-2);
    box-shadow: 0 0 12px rgba(0, 229, 160, 0.2);
}
.chip {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex: none;
}
.ps-name { flex: 1; text-align: left; font-weight: 600; }
.ps-score { font-weight: 800; font-size: 1.1rem; }

/* ── Toast ─────────────────────────────────────── */
.toast-wrap {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    width: min(92vw, 420px);
    pointer-events: none;
}
.toast {
    background: var(--panel-2);
    color: var(--text);
    border: 1px solid var(--danger);
    border-radius: 12px;
    padding: 12px 18px;
    font-size: 0.92rem;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s, transform 0.3s;
    max-width: 100%;
}
.toast.info { border-color: var(--accent-2); }
.toast.show { opacity: 1; transform: none; }

/* ── Mobil ─────────────────────────────────────── */
@media (max-width: 480px) {
    .app { padding: 64px 10px 30px; }
    .panel { padding: 16px; }
    .logo { font-size: 1.8rem; }
    .avatar-grid { grid-template-columns: repeat(4, 1fr); }
    .scoreboard { grid-template-columns: repeat(2, 1fr); }
}
