* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0a0e1a;
    color: #fff;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

/* ===== Hub topbar ===== */
.hub-topbar {
    position: sticky; top: 0; z-index: 100;
    background: rgba(10,14,26,.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255,255,255,.06);
    padding: 10px 16px;
}
.hub-home {
    display: inline-flex; align-items: center; gap: 8px;
    color: #fff; text-decoration: none;
    font-weight: 800; font-size: .85rem; letter-spacing: 2px;
}
.hub-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 8px;
    background: linear-gradient(135deg,#7c3aed,#6d28d9);
    font-size: .6rem;
}
body:has(#game-screen.active) .hub-topbar { display: none; }

/* ===== Screens ===== */
.screen { display: none; }
.screen.active { display: block; }
.container {
    max-width: 480px; margin: 0 auto; padding: 24px 20px 40px;
    text-align: center;
}

.title {
    font-size: 3rem; font-weight: 900; letter-spacing: 4px;
    background: linear-gradient(135deg,#a78bfa,#60a5fa);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 4px;
}
.subtitle { color: rgba(255,255,255,.5); margin-bottom: 28px; font-size: .95rem; }
h2 { margin-bottom: 20px; font-weight: 800; }

.menu-logo { position: relative; height: 110px; margin: 10px 0 6px; }
.ml-card {
    position: absolute; left: 50%; top: 0; width: 70px;
    border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.ml-c1 { transform: translateX(-90%) rotate(-14deg); }
.ml-c2 { transform: translateX(-50%) translateY(-6px); z-index: 2; }
.ml-c3 { transform: translateX(-10%) rotate(14deg); }

.menu-buttons { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }

.btn-primary {
    width: 100%; padding: 16px; border: none; border-radius: 14px;
    background: linear-gradient(135deg,#7c3aed,#6d28d9);
    color: #fff; font-size: 1rem; font-weight: 800; letter-spacing: 1px;
    cursor: pointer; transition: transform .15s, box-shadow .15s;
    box-shadow: 0 6px 20px rgba(124,58,237,.35);
}
.btn-primary:active { transform: scale(.97); }
.btn-primary:disabled { opacity: .4; cursor: default; }

.btn-secondary {
    width: 100%; padding: 16px; border-radius: 14px;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.12);
    color: #fff; font-size: 1rem; font-weight: 700; letter-spacing: 1px;
    cursor: pointer; transition: background .15s;
}
.btn-secondary:active { background: rgba(255,255,255,.12); }

.btn-back {
    margin-top: 14px; padding: 12px 24px; border: none; border-radius: 12px;
    background: transparent; color: rgba(255,255,255,.5);
    font-size: .9rem; cursor: pointer;
}

.btn-danger {
    width: 100%; padding: 14px; border: none; border-radius: 14px;
    background: rgba(239,68,68,.15); border: 1px solid rgba(239,68,68,.4);
    color: #f87171; font-weight: 700; cursor: pointer;
}

.rules-box {
    text-align: left;
    background: rgba(20,24,41,.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,.07);
    border-radius: 16px; padding: 18px;
}
.rules-title { font-weight: 800; margin-bottom: 10px; color: #a78bfa; font-size: .9rem; letter-spacing: 1px; }
.rules-box ul { list-style: none; }
.rules-box li {
    padding: 5px 0 5px 20px; position: relative;
    color: rgba(255,255,255,.65); font-size: .88rem;
}
.rules-box li::before { content: '\2663'; position: absolute; left: 0; color: #7c3aed; }

.input-group { text-align: left; margin-bottom: 16px; }
.input-group label {
    display: block; font-size: .75rem; letter-spacing: 1px;
    color: rgba(255,255,255,.45); margin-bottom: 6px; text-transform: uppercase;
}
.input-group input {
    width: 100%; padding: 15px; border-radius: 13px;
    background: rgba(20,24,41,.7);
    border: 1px solid rgba(255,255,255,.1);
    color: #fff; font-size: 1rem; outline: none;
}
.input-group input:focus { border-color: #7c3aed; }
.code-input {
    text-transform: uppercase; letter-spacing: 10px !important;
    text-align: center; font-size: 1.7rem !important; font-weight: 800;
}

/* ===== Lobby ===== */
.game-topbar { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.btn-quit {
    padding: 8px 16px; border-radius: 10px; border: 1px solid rgba(239,68,68,.4);
    background: rgba(239,68,68,.12); color: #f87171;
    font-size: .8rem; font-weight: 700; cursor: pointer;
}
.room-code-display {
    background: rgba(20,24,41,.6);
    border: 1px solid rgba(255,255,255,.07);
    border-radius: 16px; padding: 18px; margin-bottom: 12px;
}
.room-label { display: block; font-size: .7rem; letter-spacing: 2px; color: rgba(255,255,255,.4); text-transform: uppercase; }
.room-code { font-size: 2.6rem; font-weight: 900; letter-spacing: 12px; color: #a78bfa; }
.btn-invite {
    width: 100%; padding: 13px; border-radius: 12px;
    background: rgba(124,58,237,.15); border: 1px solid rgba(124,58,237,.4);
    color: #a78bfa; font-weight: 700; cursor: pointer; margin-bottom: 16px;
}
.players-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.player-item {
    display: flex; align-items: center; gap: 10px;
    background: rgba(20,24,41,.6);
    border: 1px solid rgba(255,255,255,.07);
    border-radius: 12px; padding: 13px 15px; text-align: left;
}
.player-item .p-name { font-weight: 700; flex: 1; }
.p-host-tag {
    font-size: .65rem; background: rgba(124,58,237,.25); color: #a78bfa;
    padding: 3px 8px; border-radius: 6px; font-weight: 800; letter-spacing: 1px;
}
.p-empty { color: rgba(255,255,255,.25); font-style: italic; }
.dot-online, .dot-offline {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.dot-online { background: #22C55E; box-shadow: 0 0 6px #22C55E; }
.dot-offline { background: #555; }
.lobby-info { color: rgba(255,255,255,.45); font-size: .9rem; margin-bottom: 14px; }

/* ===== Game screen ===== */
#game-screen.active {
    display: block; position: fixed; inset: 0; overflow: hidden;
}
.table-bg {
    position: absolute; inset: 0;
    background: radial-gradient(ellipse at 50% 42%, #1e3a5f 0%, #172d4c 45%, #0e1e35 75%, #081324 100%);
}
.table-bg::after {
    content: ''; position: absolute; inset: 0;
    box-shadow: inset 0 0 120px rgba(0,0,0,.6);
}

.game-hud {
    position: absolute; top: 0; left: 0; right: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px;
    padding-top: calc(10px + env(safe-area-inset-top));
}
.hud-deck {
    font-size: .8rem; font-weight: 800; color: rgba(255,255,255,.85);
    background: rgba(0,0,0,.35); padding: 6px 12px; border-radius: 20px;
}
.hud-code {
    font-size: .8rem; font-weight: 800; letter-spacing: 3px; color: rgba(255,255,255,.55);
    background: rgba(0,0,0,.35); padding: 6px 12px; border-radius: 20px;
}

.seat { position: absolute; z-index: 10; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.seat-top { top: 52px; left: 50%; transform: translateX(-50%); padding-top: env(safe-area-inset-top); }
.seat-left { left: 10px; top: 38%; transform: translateY(-50%); }
.seat-right { right: 10px; top: 38%; transform: translateY(-50%); }

.seat-badge {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    background: rgba(0,0,0,.4); backdrop-filter: blur(6px);
    border: 2px solid rgba(255,255,255,.12);
    border-radius: 14px; padding: 8px 14px; min-width: 84px;
    transition: border-color .3s, box-shadow .3s;
}
.seat-badge.turn {
    border-color: #fbbf24;
    box-shadow: 0 0 18px rgba(251,191,36,.5);
    animation: turnPulse 1.6s ease-in-out infinite;
}
@keyframes turnPulse {
    0%, 100% { box-shadow: 0 0 10px rgba(251,191,36,.35); transform: scale(1); }
    50% { box-shadow: 0 0 24px rgba(251,191,36,.75); transform: scale(1.04); }
}
.seat-badge.offline { opacity: .5; }
.seat-name { font-size: .8rem; font-weight: 800; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-stats { font-size: .68rem; color: #fbbf24; font-weight: 700; }
.seat-cards { font-size: .65rem; color: rgba(255,255,255,.5); }

/* ===== Pile (center) ===== */
.pile-area {
    position: absolute; left: 50%; top: 42%;
    transform: translate(-50%, -50%);
    width: 140px; height: 130px; z-index: 5;
    transition: filter .2s;
}
.pile-back {
    position: absolute; left: 50%; top: 50%; width: 66px;
    border-radius: 5px; box-shadow: 0 3px 10px rgba(0,0,0,.5);
}
.pb-0 { transform: translate(-50%, -50%) rotate(-7deg) translateX(-4px); }
.pb-1 { transform: translate(-50%, -50%) rotate(5deg) translateX(3px); }
.pb-2 { transform: translate(-50%, -50%) rotate(-2deg) translateY(-2px); }
.pile-top {
    position: absolute; left: 50%; top: 50%; width: 72px;
    transform: translate(-50%, -50%);
    border-radius: 5px; box-shadow: 0 5px 16px rgba(0,0,0,.6);
    z-index: 3;
    animation: playIn .25s ease-out;
}
@keyframes playIn {
    from { transform: translate(-50%, -80%) scale(1.25) rotate(7deg); opacity: 0; }
    to { transform: translate(-50%, -50%) scale(1) rotate(0deg); opacity: 1; }
}
.pile-count {
    position: absolute; right: -6px; bottom: -4px; z-index: 4;
    background: rgba(0,0,0,.6); border: 1px solid rgba(255,255,255,.2);
    color: #fff; font-size: .72rem; font-weight: 800;
    padding: 3px 9px; border-radius: 12px;
}
.pile-empty {
    position: absolute; left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    width: 72px; height: 100px;
    border: 2px dashed rgba(255,255,255,.18); border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: .65rem; font-weight: 800; color: rgba(255,255,255,.3);
    letter-spacing: 2px;
}
.pile-area.flash-capture { animation: flashCap .9s ease-out; }
@keyframes flashCap {
    0% { filter: drop-shadow(0 0 24px rgba(96,165,250,.9)); }
    100% { filter: none; }
}
.pile-area.flash-pisti { animation: flashPisti 1.2s ease-out; }
@keyframes flashPisti {
    0% { filter: drop-shadow(0 0 34px rgba(251,191,36,1)) brightness(1.35); }
    35% { filter: drop-shadow(0 0 30px rgba(251,191,36,.9)) brightness(1.15); }
    100% { filter: none; }
}
/* Pisti ani altin parlama halkasi */
.pile-area.flash-pisti::before {
    content: ''; position: absolute; left: 50%; top: 50%;
    width: 20px; height: 20px; margin: -10px 0 0 -10px;
    border-radius: 50%; pointer-events: none; z-index: 6;
    background: radial-gradient(circle, rgba(251,191,36,.95) 0%, rgba(251,191,36,.4) 45%, rgba(251,191,36,0) 70%);
    animation: pistiFlashRing .9s ease-out forwards;
}
@keyframes pistiFlashRing {
    0% { transform: scale(.5); opacity: 1; }
    100% { transform: scale(11); opacity: 0; }
}
/* Yigin kazanana dogru supurulur */
.pile-area .sweep-top { animation: pSweepTop .42s ease-in forwards !important; }
.pile-area .sweep-bottom { animation: pSweepBottom .42s ease-in forwards !important; }
.pile-area .sweep-left { animation: pSweepLeft .42s ease-in forwards !important; }
.pile-area .sweep-right { animation: pSweepRight .42s ease-in forwards !important; }
@keyframes pSweepTop { to { transform: translate(-50%, -300%) scale(.4); opacity: 0; } }
@keyframes pSweepBottom { to { transform: translate(-50%, 220%) scale(.4); opacity: 0; } }
@keyframes pSweepLeft { to { transform: translate(-320%, -50%) scale(.4); opacity: 0; } }
@keyframes pSweepRight { to { transform: translate(220%, -50%) scale(.4); opacity: 0; } }

.turn-banner {
    position: absolute; left: 50%; top: 62%;
    transform: translateX(-50%); z-index: 6;
    font-size: .85rem; font-weight: 800; color: #fbbf24;
    background: rgba(0,0,0,.45); padding: 7px 16px; border-radius: 20px;
    white-space: nowrap;
}

.me-bar {
    position: absolute; left: 0; right: 0; bottom: 158px; z-index: 10;
    display: flex; justify-content: center;
}
.me-bar .seat-badge { flex-direction: row; gap: 10px; padding: 6px 16px; }

.hand {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 15;
    display: flex; justify-content: center; align-items: flex-end;
    padding: 10px 12px calc(14px + env(safe-area-inset-bottom));
    overflow-x: auto; overflow-y: hidden;
}
.hand-card {
    width: 82px; margin-left: -18px; flex-shrink: 0;
    border-radius: 6px;
    box-shadow: -3px 0 10px rgba(0,0,0,.45);
    transition: transform .15s, filter .15s;
    cursor: pointer;
}
.hand-card:first-child { margin-left: 0; }
.hand-card:active { transform: translateY(-18px) rotate(-2deg); }
.hand.my-turn .hand-card { filter: drop-shadow(0 -2px 8px rgba(251,191,36,.4)); }
.hand:not(.my-turn) .hand-card { filter: brightness(.75); cursor: default; }

/* ===== Result overlay ===== */
.result-overlay {
    position: absolute; inset: 0; z-index: 50;
    background: rgba(5,8,15,.8); backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.result-box {
    width: 100%; max-width: 380px;
    background: rgba(20,24,41,.95);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 20px; padding: 26px; text-align: center;
}
.result-title {
    font-size: 1.4rem; font-weight: 900; letter-spacing: 3px;
    background: linear-gradient(135deg,#fbbf24,#f59e0b);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 18px;
}
.result-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.result-row {
    display: flex; align-items: center; gap: 10px;
    background: rgba(255,255,255,.04);
    border-radius: 12px; padding: 12px 14px;
}
.result-row.winner { background: rgba(251,191,36,.12); border: 1px solid rgba(251,191,36,.4); }
.result-rank { font-weight: 900; color: rgba(255,255,255,.4); width: 22px; }
.result-main { flex: 1; text-align: left; }
.result-name { display: block; font-weight: 700; }
.result-detail { display: block; font-size: .7rem; color: rgba(255,255,255,.45); margin-top: 2px; }
.result-score { font-size: 1rem; color: #fbbf24; font-weight: 800; }
.result-total { font-size: .75rem; color: rgba(255,255,255,.45); }

/* ===== Toast ===== */
.toast {
    position: fixed; bottom: 30px; left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(20,24,41,.95);
    border: 1px solid rgba(255,255,255,.15);
    color: #fff; padding: 12px 22px; border-radius: 14px;
    font-size: .9rem; font-weight: 600;
    opacity: 0; transition: all .3s; z-index: 999;
    pointer-events: none; white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.gold { border-color: rgba(251,191,36,.6); color: #fbbf24; }

/* ===== Efektler: dagitim animasyonu ===== */
.hand.dealt .hand-card { animation: dealIn .32s cubic-bezier(.22,.9,.32,1.15) backwards; }
.hand.dealt .hand-card:nth-child(1) { animation-delay: 0s; }
.hand.dealt .hand-card:nth-child(2) { animation-delay: .04s; }
.hand.dealt .hand-card:nth-child(3) { animation-delay: .08s; }
.hand.dealt .hand-card:nth-child(4) { animation-delay: .12s; }
.hand.dealt .hand-card:nth-child(5) { animation-delay: .16s; }
.hand.dealt .hand-card:nth-child(6) { animation-delay: .2s; }
.hand.dealt .hand-card:nth-child(7) { animation-delay: .24s; }
.hand.dealt .hand-card:nth-child(8) { animation-delay: .28s; }
.hand.dealt .hand-card:nth-child(9) { animation-delay: .32s; }
.hand.dealt .hand-card:nth-child(10) { animation-delay: .36s; }
.hand.dealt .hand-card:nth-child(11) { animation-delay: .4s; }
.hand.dealt .hand-card:nth-child(12) { animation-delay: .44s; }
.hand.dealt .hand-card:nth-child(13) { animation-delay: .48s; }
.hand.dealt .hand-card:nth-child(14) { animation-delay: .52s; }
@keyframes dealIn {
    from { transform: translateY(46px) scale(.92); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

/* ===== Efektler: konfeti ===== */
.confetti-layer { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.confetti-piece {
    position: absolute; top: -14px; width: 8px; height: 13px;
    border-radius: 2px; opacity: 0;
    animation: confettiFall 3s linear forwards;
}
@keyframes confettiFall {
    0% { opacity: 1; transform: translate3d(0, -10px, 0) rotate(0deg); }
    100% { opacity: .9; transform: translate3d(var(--dx, 0px), 105vh, 0) rotate(720deg); }
}

@media (max-width: 400px) {
    .hand-card { width: 72px; margin-left: -16px; }
    .pile-top { width: 64px; }
    .pile-back { width: 58px; }
}

/* Kick butonu (lobi) */
.kick-btn{width:26px;height:26px;border-radius:8px;border:1px solid rgba(239,68,68,.4);background:rgba(239,68,68,.12);color:#f87171;font-size:.75rem;font-weight:800;cursor:pointer;flex-shrink:0;margin-left:auto}
.kick-btn.confirm{background:rgba(239,68,68,.5);color:#fff}
