/* ============================================================
   TacticWar — JKT48 Card Game  |  Complete UI Redesign
   Font: Inter (Google Fonts)
   Colors: #FF1493 (pink/primary), #00CED1 (teal/accent)
   ============================================================ */

/* ---- Reset & Base ---- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --pink:       #FF1493;
    --pink-light: #FF69B4;
    --pink-dim:   rgba(255,20,147,0.15);
    --teal:       #00CED1;
    --teal-dim:   rgba(0,206,209,0.15);
    --bg:         #080c1e;
    --surface:    #111628;
    --surface2:   #1a2040;
    --border:     rgba(255,20,147,0.25);
    --border2:    rgba(0,206,209,0.2);
    --text:       #f0f0f5;
    --text-sub:   #8a90b0;
    --success:    #00e676;
    --danger:     #ff5252;
    --radius-sm:  8px;
    --radius:     14px;
    --radius-lg:  22px;
    --shadow-pink: 0 8px 32px rgba(255,20,147,0.25);
    --shadow-teal: 0 8px 32px rgba(0,206,209,0.2);
    --transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
}

/* ---- Light Mode ---- */
body.light-mode {
    --bg:       #f0f2fa;
    --surface:  #ffffff;
    --surface2: #e8eaf6;
    --border:   rgba(255,20,147,0.3);
    --border2:  rgba(0,206,209,0.25);
    --text:     #1a1d2e;
    --text-sub: #5a6080;
    --shadow-pink: 0 8px 32px rgba(255,20,147,0.18);
    --shadow-teal: 0 8px 32px rgba(0,206,209,0.15);
}

html, body { height: 100%; overflow: hidden; }

body {
    font-family: 'Inter', 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

/* ---- Custom Scrollbar ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--pink); }

/* ---- App Container ---- */
#app { width: 100%; height: 100vh; position: relative; }

/* ============================================================
   SCREEN MANAGEMENT
   ============================================================ */
.screen {
    display: none;
    width: 100%;
    height: 100%;
    position: fixed;
    inset: 0;
    z-index: 1;
}
.screen.active { display: flex; }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.toast {
    background: var(--surface2);
    border-left: 4px solid var(--pink);
    color: var(--text);
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    max-width: 320px;
    animation: toastIn 0.3s ease-out;
    pointer-events: all;
}
.toast.toast-error { border-left-color: var(--danger); }
.toast.toast-success { border-left-color: var(--success); }
.toast.toast-out { animation: toastOut 0.3s ease-in forwards; }
@keyframes toastIn  { from { opacity:0; transform: translateX(40px); } to { opacity:1; transform: translateX(0); } }
@keyframes toastOut { from { opacity:1; transform: translateX(0); } to { opacity:0; transform: translateX(40px); } }

/* ============================================================
   SHARED BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 22px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    user-select: none;
    letter-spacing: 0.3px;
}
.btn:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; }

.btn-primary {
    background: linear-gradient(135deg, var(--pink), var(--pink-light));
    color: #fff;
    box-shadow: 0 4px 16px rgba(255,20,147,0.3);
}
.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(255,20,147,0.5);
    filter: brightness(1.1);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-danger {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: #fff;
    box-shadow: 0 4px 16px rgba(231,76,60,0.3);
}
.btn-danger:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(231,76,60,0.5);
}

.btn-outline {
    background: transparent;
    color: var(--teal);
    border: 1.5px solid var(--teal);
}
.btn-outline:hover:not(:disabled) {
    background: var(--teal-dim);
    transform: translateY(-1px);
}

.btn-sm  { padding: 7px 14px; font-size: 12px; border-radius: 6px; }
.btn-full { width: 100%; }
.btn-arrow { font-size: 16px; transition: transform 0.2s; }
.btn-primary:hover .btn-arrow { transform: translateX(4px); }

.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; filter: none !important; }

/* ============================================================
   SHARED INPUT
   ============================================================ */
input[type="text"], input[type="password"] {
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--surface2);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 11px 14px;
    transition: var(--transition);
    outline: none;
}
input[type="text"]::placeholder, input[type="password"]::placeholder { color: var(--text-sub); }
input[type="text"]:focus, input[type="password"]:focus {
    border-color: var(--pink);
    box-shadow: 0 0 0 3px rgba(255,20,147,0.15);
    background: var(--surface);
}

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
#loginScreen {
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

/* Animated background orbs */
.login-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}
.bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.35;
    animation: orbFloat 10s ease-in-out infinite;
}
.orb-1 { width: 500px; height: 500px; background: var(--pink); top: -150px; left: -150px; animation-delay: 0s; }
.orb-2 { width: 400px; height: 400px; background: var(--teal); bottom: -100px; right: -100px; animation-delay: -4s; }
.orb-3 { width: 300px; height: 300px; background: #6c3bff; top: 50%; left: 50%; transform: translate(-50%,-50%); animation-delay: -7s; }

@keyframes orbFloat {
    0%,100% { transform: translate(0,0) scale(1); }
    33%      { transform: translate(30px,-20px) scale(1.05); }
    66%      { transform: translate(-20px,30px) scale(0.97); }
}

/* Login Card */
.login-card {
    position: relative;
    z-index: 2;
    background: rgba(17,22,40,0.85);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-lg);
    padding: 48px 44px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 32px 80px rgba(0,0,0,0.6), var(--shadow-pink);
    animation: cardUp 0.7s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes cardUp {
    from { opacity:0; transform: translateY(40px) scale(0.96); }
    to   { opacity:1; transform: translateY(0) scale(1); }
}

.login-logo { text-align: center; margin-bottom: 36px; }
.logo-icon { font-size: 56px; line-height: 1; margin-bottom: 12px; filter: drop-shadow(0 0 20px rgba(255,20,147,0.5)); }
.logo-title { font-size: 36px; font-weight: 900; background: linear-gradient(135deg, var(--pink), var(--teal)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; letter-spacing: -0.5px; }
.logo-subtitle { margin-top: 6px; color: var(--text-sub); font-size: 14px; font-weight: 500; }

.login-form { display: flex; flex-direction: column; gap: 14px; }

.input-group {
    position: relative;
    display: flex;
    align-items: center;
}
.input-icon {
    position: absolute;
    left: 14px;
    font-size: 16px;
    pointer-events: none;
    z-index: 1;
}
.input-group input {
    width: 100%;
    padding-left: 44px;
    height: 52px;
    font-size: 15px;
    border-radius: var(--radius-sm);
}

.btn-end-turn { padding: 11px 20px; font-size: 13px; }

.login-hint {
    margin-top: 20px;
    text-align: center;
    font-size: 12px;
    color: var(--text-sub);
}

/* ============================================================
   LOBBY SCREEN
   ============================================================ */
#lobbyScreen { background: var(--bg); }

.lobby-layout {
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* --- Sidebar --- */
.lobby-sidebar {
    width: 280px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px 20px;
    overflow-y: auto;
    gap: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
}
.brand-icon { font-size: 24px; }
.brand-name { font-size: 20px; font-weight: 900; flex: 1; background: linear-gradient(135deg, var(--pink), var(--teal)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

/* Theme toggle button */
.btn-theme-toggle {
    background: var(--surface2);
    border: 1.5px solid var(--border);
    border-radius: 50%;
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    color: var(--text-sub);
    flex-shrink: 0;
    transition: var(--transition);
    padding: 0;
}
.btn-theme-toggle:hover { border-color: var(--pink); color: var(--pink); transform: rotate(20deg); }

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface2);
    border-radius: var(--radius);
    padding: 14px 16px;
    border: 1px solid var(--border);
}
.user-avatar {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--pink), var(--pink-light));
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; font-weight: 800; color: #fff;
    flex-shrink: 0;
    box-shadow: 0 4px 16px rgba(255,20,147,0.3);
}
.user-details { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.user-label { font-size: 11px; color: var(--text-sub); text-transform: uppercase; letter-spacing: 0.5px; }
.user-name { font-size: 15px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-divider { height: 1px; background: var(--border); margin: 20px 0; }

.sidebar-section { flex: 0 0 auto; }
.sidebar-section-title { font-size: 12px; font-weight: 700; color: var(--text-sub); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 14px; }

/* Online count */
.sidebar-online { display: flex; align-items: center; gap: 7px; padding: 2px 0; }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: #00e676; box-shadow: 0 0 6px #00e676; animation: pulseDot 1.8s infinite; margin-left: auto; }
@keyframes pulseDot { 0%,100% { opacity:1; transform:scale(1); } 50% { opacity:.5; transform:scale(1.3); } }
.online-count-num { font-size: 15px; font-weight: 800; color: #00e676; }
.online-count-label { font-size: 12px; color: var(--text-sub); }

/* Leaderboard in sidebar */
.leaderboard { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; padding-right: 2px; }
.leaderboard::-webkit-scrollbar { width: 4px; }
.leaderboard::-webkit-scrollbar-track { background: transparent; }
.leaderboard::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.leaderboard::-webkit-scrollbar-thumb:hover { background: var(--teal); }
.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: var(--surface2);
    transition: var(--transition);
    cursor: default;
}
.leaderboard-item:hover { background: rgba(0,206,209,0.1); transform: translateX(4px); }
.rank { font-size: 13px; font-weight: 800; color: var(--pink); width: 22px; flex-shrink: 0; text-align: center; }
.leaderboard-item:nth-child(1) .rank { color: #ffd700; }
.leaderboard-item:nth-child(2) .rank { color: #c0c0c0; }
.leaderboard-item:nth-child(3) .rank { color: #cd7f32; }
.lb-username { flex: 1; font-size: 12px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-wins    { font-size: 11px; font-weight: 700; color: #00e676; white-space: nowrap; }
.lb-losses  { font-size: 11px; font-weight: 700; color: #ff5252; white-space: nowrap; }
.lb-winpct  { font-size: 10px; color: var(--teal); background: rgba(0,206,209,0.1); border-radius: 4px; padding: 1px 5px; white-space: nowrap; min-width: 34px; text-align: right; }

/* Lobby Chat */
.sidebar-lobby-chat { display: flex; flex-direction: column; }
.lobby-chat-messages {
    height: 180px;
    overflow-y: auto;
    background: var(--surface2);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
}
.lobby-chat-messages::-webkit-scrollbar { width: 4px; }
.lobby-chat-messages::-webkit-scrollbar-track { background: transparent; }
.lobby-chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.lobby-chat-messages::-webkit-scrollbar-thumb:hover { background: var(--teal); }
.lobby-chat-msg { font-size: 12px; line-height: 1.5; color: var(--text); word-break: break-word; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px; }
.lobby-chat-msg .msg-user { font-weight: 700; color: var(--teal); flex-shrink: 0; }
.lobby-chat-msg .msg-text { flex: 1; }
.lobby-chat-msg .msg-time { font-size: 10px; color: var(--text-sub); margin-left: auto; white-space: nowrap; flex-shrink: 0; }
.lobby-chat-input-row { display: flex; gap: 6px; }
.lobby-chat-input-row input {
    flex: 1;
    background: var(--surface2);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    color: var(--text);
    font-size: 12px;
    outline: none;
}
.lobby-chat-input-row input:focus { border-color: var(--teal); }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* Spectator notice in chat tab */
.spectator-notice { padding: 10px; text-align: center; font-size: 12px; color: var(--text-sub); background: rgba(255,165,0,0.08); border-radius: var(--radius-sm); margin-top: 6px; }

/* --- Lobby Main Content --- */
.lobby-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 28px 32px;
    overflow-y: auto;
    gap: 24px;
}

/* Lobby footer */
.lobby-footer {
    margin-top: auto;
    padding-top: 12px;
    text-align: center;
    font-size: 12px;
    color: var(--text-sub);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.footer-heart { color: var(--pink); font-size: 14px; vertical-align: middle; }

.lobby-main-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}
.lobby-main-title { font-size: 24px; font-weight: 800; color: var(--text); }
.lobby-main-sub { font-size: 13px; color: var(--text-sub); margin-top: 3px; }

/* Create Room Card */
.create-room-card {
    display: flex;
    align-items: center;
    gap: 18px;
    background: linear-gradient(135deg, rgba(255,20,147,0.08), rgba(0,206,209,0.06));
    border: 1.5px dashed var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    transition: var(--transition);
}
.create-room-card:focus-within { border-color: var(--pink); border-style: solid; box-shadow: var(--shadow-pink); }
.create-room-icon {
    width: 50px; height: 50px; flex-shrink: 0;
    background: linear-gradient(135deg, var(--pink), var(--pink-light));
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; color: #fff; font-weight: 300;
    box-shadow: 0 4px 16px rgba(255,20,147,0.3);
}
.create-room-content { flex: 1; }
.create-room-content h3 { font-size: 15px; font-weight: 700; margin-bottom: 10px; color: var(--text); }
.create-room-form { display: flex; flex-direction: column; gap: 8px; }
.create-room-inputs { display: flex; gap: 10px; }
.create-room-inputs input[type="text"],
.create-room-inputs input[type="password"] { flex: 1; min-width: 0; }
.create-room-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* Password toggle row */
.password-toggle-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}
.toggle-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-sub);
    cursor: pointer;
    user-select: none;
}
/* Toggle switch */
.toggle-switch { position: relative; display: inline-flex; cursor: pointer; }
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
    width: 40px; height: 22px;
    background: var(--surface2);
    border: 1.5px solid var(--border);
    border-radius: 11px;
    transition: var(--transition);
    position: relative;
}
.toggle-thumb {
    position: absolute;
    top: 2px; left: 2px;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--text-sub);
    transition: var(--transition);
}
.toggle-switch input:checked ~ .toggle-track { background: var(--teal-dim); border-color: var(--teal); }
.toggle-switch input:checked ~ .toggle-track .toggle-thumb { transform: translateX(18px); background: var(--teal); }

/* Password input that appears when toggle is on */
.room-password-wrap { display: flex; flex: 1; min-width: 0; }
.room-password-wrap.room-password-hidden { display: none; }
.room-password-wrap input[type="password"] { flex: 1; width: 100%; }

/* ============================================================
   PASSWORD MODAL
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(6px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 32px 28px;
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    animation: slideUp 0.2s ease;
}
.modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--teal);
}
.modal-header h3 { font-size: 18px; font-weight: 700; color: var(--text); }
.modal-desc { font-size: 13px; color: var(--text-sub); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* Rooms Grid */
.rooms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.room-item {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: relative;
    overflow: hidden;
}
.room-item::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--pink-dim), var(--teal-dim));
    opacity: 0;
    transition: opacity 0.25s;
    pointer-events: none;
}
.room-item:hover { border-color: var(--pink); transform: translateY(-4px); box-shadow: var(--shadow-pink); }
.room-item:hover::after { opacity: 1; }

.room-info { position: relative; z-index: 1; }
.room-info h3 { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.room-info p  { font-size: 12px; color: var(--text-sub); }

.room-header { display: flex; justify-content: space-between; align-items: center; position: relative; z-index: 1; }
.room-name   { font-size: 16px; font-weight: 700; color: var(--text); margin: 0; }
.room-host   { font-size: 12px; color: var(--text-sub); margin: 0; position: relative; z-index: 1; }
.room-footer { display: flex; justify-content: space-between; align-items: center; position: relative; z-index: 1; }

.room-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.status-waiting  { background: rgba(0,230,118,0.15); color: #00e676; border: 1px solid rgba(0,230,118,0.3); }
.status-playing  { background: rgba(255,20,147,0.15); color: var(--pink-light); border: 1px solid var(--border); }
.status-finished { background: rgba(120,120,120,0.15); color: #888; border: 1px solid rgba(120,120,120,0.3); }

.room-actions-badges {
    display: flex;
    align-items: center;
    gap: 6px;
}

.room-lock-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--teal);
    background: rgba(0,206,209,0.1);
    border: 1px solid rgba(0,206,209,0.3);
    border-radius: 20px;
    padding: 3px 10px;
}
.room-finished-badge {
    font-size: 11px;
    color: #888;
}

.room-header-badges {
    display: flex;
    align-items: center;
    gap: 6px;
}

.room-bo-badge {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--pink);
    background: rgba(255,20,147,0.12);
    border: 1px solid rgba(255,20,147,0.3);
    border-radius: 20px;
    padding: 3px 10px;
}

.bo-select {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    outline: none;
}
.bo-select:focus {
    border-color: var(--pink);
}

/* ============================================================
   GAME SCREEN
   ============================================================ */
#gameScreen {
    background: url('/assets/frame/bg-image.png') center center / cover no-repeat;
    position: relative;
}
#gameScreen::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(8, 12, 30, 0.72);
    pointer-events: none;
    z-index: 0;
}
#gameScreen > * { position: relative; z-index: 1; }

.game-layout {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* --- Top Bar --- */
.game-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 56px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 16px;
}
.topbar-brand { font-size: 16px; font-weight: 800; color: var(--text); white-space: nowrap; }
.topbar-center { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.turn-badge {
    background: linear-gradient(135deg, var(--pink-dim), var(--teal-dim));
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 16px;
    font-size: 13px;
    font-weight: 700;
    color: var(--teal);
    transition: var(--transition);
}
.turn-badge.my-turn { border-color: var(--teal); color: var(--teal); box-shadow: 0 0 12px rgba(0,206,209,0.4); }
.turn-count { font-size: 11px; color: var(--text-sub); font-weight: 500; }
.topbar-actions { display: flex; gap: 8px; }

/* --- Game Body --- */
.game-body {
    flex: 1;
    display: flex;
    overflow: hidden;
    gap: 0;
}

/* --- Battlefield --- */
.battlefield {
    flex: 1;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    padding: 20px 24px;
    gap: 24px;
    overflow: hidden;
    border-right: 1px solid var(--border);
}

/* Left column: two player panels stacked */
.players-column {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-self: stretch;
    gap: 16px;
    flex-shrink: 0;
    width: 190px;
}

/* Center column: opponent card → VS → player card → recall btn */
.field-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

/* Right column: deck pile */
.deck-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-shrink: 0;
    width: 110px;
}
.deck-pile {
    position: relative;
    width: 90px;
    height: 126px;
    cursor: pointer;
    transition: transform 0.2s;
}
.deck-pile:hover { transform: translateY(-4px) scale(1.04); }
.deck-pile:hover .deck-card-img { box-shadow: 0 8px 28px rgba(255,20,147,0.5); }
.deck-card-img {
    position: absolute;
    width: 90px;
    height: 126px;
    object-fit: cover;
    border-radius: 10px;
    border: 2px solid var(--border);
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    top: 0; left: 0;
}
.deck-card-2 { top: -4px; left: -4px; z-index: -1; opacity: 0.7; }
.deck-card-3 { top: -8px; left: -8px; z-index: -2; opacity: 0.4; }
.deck-count-badge {
    position: absolute;
    bottom: -8px; right: -8px;
    background: var(--pink);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    border-radius: 50%;
    width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--bg);
    z-index: 10;
}
.deck-label {
    font-size: 11px;
    color: var(--text-sub);
    font-weight: 600;
    text-align: center;
}
.deck-pile.disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

/* Pick card modal */
.pick-card-modal-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    width: 90vw;
    max-width: 720px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    z-index: 1;
}
.pick-card-options {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 20px;
}
.pick-card-option {
    position: relative;
    width: 150px;
    cursor: pointer;
    border-radius: 12px;
    overflow: hidden;
    border: 2.5px solid var(--border);
    transition: all 0.2s;
    background: var(--surface2);
    flex-shrink: 0;
}
.pick-card-option:hover {
    border-color: var(--pink);
    transform: translateY(-6px);
    box-shadow: 0 12px 32px rgba(255,20,147,0.35);
}
.pick-card-option .frame-wrap {
    position: relative;
    width: 150px;
    height: 210px;
}
.pick-card-option .member-photo {
    position: absolute;
    inset: 0;
    width: 100%; height: 100%;
    object-fit: cover;
}
.pick-card-option .member-frame {
    position: absolute;
    inset: 0;
    width: 100%; height: 100%;
    object-fit: fill;
    pointer-events: none;
    z-index: 2;
}
.pick-card-option .card-info {
    padding: 8px 8px 10px;
    text-align: center;
}
.pick-card-option .card-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pick-card-option .card-stats {
    display: flex;
    justify-content: center;
    gap: 10px;
    font-size: 10px;
    color: var(--text-sub);
    margin-top: 4px;
}
.pick-card-option .stat-atk { color: var(--pink); }
.pick-card-option .stat-def { color: var(--teal); }
.must-draw-banner {
    background: linear-gradient(135deg, var(--pink-dim), var(--teal-dim));
    border: 1.5px solid var(--pink);
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
    animation: pulse 1.5s ease-in-out infinite;
}

.player-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 14px;
}

.player-avatar {
    width: 52px; height: 52px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; font-weight: 800; color: #fff;
    flex-shrink: 0;
}
.opponent-color { background: linear-gradient(135deg, #e74c3c, #c0392b); box-shadow: 0 4px 16px rgba(231,76,60,0.4); }
.self-color      { background: linear-gradient(135deg, var(--teal), #00a8b0); box-shadow: 0 4px 16px rgba(0,206,209,0.4); }

.player-details { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.player-name-text { font-size: 13px; font-weight: 700; color: var(--text); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.health-bar-wrap { display: flex; align-items: center; gap: 8px; }
.health-bar {
    flex: 1;
    height: 10px;
    background: rgba(0,0,0,0.4);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.08);
}
.health-fill {
    height: 100%;
    width: 100%;
    border-radius: 6px;
    transition: width 0.5s cubic-bezier(0.4,0,0.2,1);
}
.player-health   { background: linear-gradient(90deg, #00e676, var(--teal)); }
.opponent-health { background: linear-gradient(90deg, #ff9800, #e74c3c); }
.health-num { font-size: 11px; font-weight: 700; color: var(--text-sub); white-space: nowrap; }

.field-card {
    width: 150px;
    height: 200px;
    background: var(--surface2);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    padding: 0;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.field-card.empty { padding: 14px; }
.field-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--pink-dim), transparent);
    opacity: 0;
    transition: opacity 0.25s;
}
.field-card:not(.empty):hover::before { opacity: 1; }
.field-card:not(.empty) { border-color: var(--pink); box-shadow: var(--shadow-pink); cursor: default; }
.field-card.empty { border-style: dashed; opacity: 0.5; }
.field-card.empty span { font-size: 12px; color: var(--text-sub); }
.field-card-placeholder { font-size: 32px; opacity: 0.4; }

/* Field card with member photo */
.field-card-inner {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}
.field-member-wrap {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 0;
}
.field-member-photo {
    position: absolute;
    inset: 0;
    width: 100%; height: 100%;
    object-fit: cover;
}
.field-member-frame {
    position: absolute;
    inset: 0;
    width: 100%; height: 100%;
    object-fit: fill;
    pointer-events: none;
    z-index: 2;
}
.field-card-stats-overlay {
    position: absolute;
    bottom: 6px; left: 0; right: 0;
    display: flex;
    justify-content: center;
    gap: 8px;
    z-index: 3;
}
.fstat-atk, .fstat-def {
    font-size: 10px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 5px;
    background: rgba(0,0,0,0.75);
}
.fstat-atk { color: var(--pink); }
.fstat-def { color: var(--teal); }
.field-card-label {
    width: 100%;
    padding: 5px 4px 2px;
    font-size: 10px;
    font-weight: 700;
    color: var(--text);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.field-card.drag-over {
    border-color: var(--teal) !important;
    border-style: solid !important;
    opacity: 1 !important;
    box-shadow: 0 0 24px rgba(0,206,209,0.5);
    transform: scale(1.04);
}

.drop-zone { cursor: copy; }

/* ============================================================
   SVG ICON UTILITY
   ============================================================ */
.icon {
    display: inline-block;
    vertical-align: -0.125em;
    flex-shrink: 0;
    width: 1em;
    height: 1em;
}
.icon-sm  { width: 14px; height: 14px; }
.icon-md  { width: 18px; height: 18px; }
.icon-lg  { width: 24px; height: 24px; }
.icon-xl  { width: 32px; height: 32px; }
.icon-2xl { width: 40px; height: 40px; }
.icon-3xl { width: 64px; height: 64px; }

/* Recall / Swap Card button */
.btn-recall {
    width: 150px;
    margin-top: 8px;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 700;
    background: linear-gradient(135deg, rgba(0,206,209,0.15), rgba(0,206,209,0.08));
    color: var(--teal);
    border: 1.5px solid var(--teal);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    letter-spacing: 0.3px;
}
.btn-recall:hover {
    background: var(--teal-dim);
    box-shadow: 0 4px 16px rgba(0,206,209,0.3);
    transform: translateY(-2px);
}
.btn-recall:active { transform: translateY(0); }

/* Card content inside field */
.field-card .card-name   { font-size: 13px; font-weight: 700; color: var(--pink); position: relative; z-index: 1; }
.field-card .card-member { font-size: 11px; color: var(--teal); position: relative; z-index: 1; }
.field-card .card-stats  { display: flex; gap: 8px; justify-content: center; position: relative; z-index: 1; }
.field-card .stat {
    background: var(--surface);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid var(--border);
}

/* VS Divider */
.vs-divider {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 4px 0;
    width: 100%;
    flex-shrink: 0;
}
.vs-line { flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--border), transparent); }
.vs-badge {
    background: linear-gradient(135deg, var(--pink), var(--teal));
    color: #fff;
    font-size: 12px;
    font-weight: 900;
    padding: 5px 14px;
    border-radius: 20px;
    letter-spacing: 1px;
    box-shadow: 0 4px 16px rgba(255,20,147,0.3);
}

/* --- Side Panel (Log + Chat) --- */
.side-panel {
    width: 300px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    overflow: hidden;
}

.tab-bar {
    display: flex;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-sub);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 14px 8px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: var(--transition);
    letter-spacing: 0.2px;
    position: relative;
}
.tab-btn:hover  { color: var(--text); background: rgba(255,255,255,0.03); }
.tab-btn.active { color: var(--pink); border-bottom-color: var(--pink); }

/* Chat unread badge */
.tab-chat-badge {
    position: absolute;
    top: 6px; right: 8px;
    background: var(--pink);
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    border-radius: 10px;
    min-width: 16px;
    height: 16px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 4px;
    animation: badgePop 0.25s cubic-bezier(0.34,1.56,0.64,1);
    pointer-events: none;
}
@keyframes badgePop {
    from { transform: scale(0); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

.tab-content { flex: 1; overflow: hidden; position: relative; }
.tab-pane { display: none; height: 100%; flex-direction: column; }
.tab-pane.active { display: flex; }

/* Battle Log */
.battle-log-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.log-entry {
    font-size: 12px;
    color: var(--text-sub);
    padding: 7px 10px;
    border-radius: 6px;
    border-left: 2px solid transparent;
    transition: var(--transition);
    line-height: 1.4;
}
.log-entry:hover { background: var(--surface2); border-left-color: var(--pink); color: var(--text); }

/* Chat */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.message {
    background: var(--surface2);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--pink);
}
.message-header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 3px; }
.message-user { font-size: 11px; font-weight: 700; color: var(--teal); }
.message-time { font-size: 10px; color: var(--text-sub); white-space: nowrap; margin-left: auto; }
.message-text { font-size: 13px; color: var(--text); word-break: break-word; }

.chat-input-form {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.chat-input-form input { flex: 1; }

/* --- Hand Area (Bottom) --- */
.hand-area {
    flex-shrink: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 14px 20px;
}
.hand-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.hand-title { font-size: 13px; font-weight: 700; color: var(--text-sub); text-transform: uppercase; letter-spacing: 0.5px; }

.hand-container {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 6px;
    min-height: 155px;
    align-items: flex-end;
}

/* Hand Cards */
.hand-card {
    flex-shrink: 0;
    width: 90px;
    background: var(--surface2);
    border: 2px solid var(--border2);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: grab;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.hand-card:active { cursor: grabbing; }
.hand-card:hover {
    border-color: var(--pink);
    transform: translateY(-10px);
    box-shadow: 0 12px 28px rgba(255,20,147,0.3);
    z-index: 10;
}
.hand-card.selected {
    border-color: var(--pink);
    box-shadow: 0 0 20px rgba(255,20,147,0.5);
    transform: translateY(-10px);
}

/* New photo-style hand card */
.hand-card-photo { padding: 0; width: 90px; height: auto; }
.hand-card-frame-wrap {
    position: relative;
    width: 90px;
    height: 126px;
}
.hand-member-photo {
    position: absolute;
    inset: 0; width: 100%; height: 100%;
    object-fit: cover;
}
.hand-member-frame {
    position: absolute;
    inset: 0; width: 100%; height: 100%;
    object-fit: fill;
    pointer-events: none;
    z-index: 2;
}
.hand-card-stats-overlay {
    position: absolute;
    bottom: 4px; left: 0; right: 0;
    display: flex;
    justify-content: center;
    gap: 6px;
    z-index: 3;
}
.hstat-atk, .hstat-def {
    font-size: 8px;
    font-weight: 800;
    padding: 1px 5px;
    border-radius: 4px;
    background: rgba(0,0,0,0.7);
}
.hstat-atk { color: var(--pink); }
.hstat-def { color: var(--teal); }
.hand-card-name {
    font-size: 9px;
    font-weight: 700;
    color: var(--text);
    padding: 4px 4px 5px;
    text-align: center;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: var(--surface2);
}

/* Pick card selected state */
.pick-card-option.selected {
    border-color: var(--pink);
    box-shadow: 0 0 0 3px rgba(255,20,147,0.4);
    transform: translateY(-4px) scale(1.03);
}
.pick-card-option .pick-check {
    position: absolute;
    top: 6px; right: 6px;
    width: 22px; height: 22px;
    background: var(--pink);
    border-radius: 50%;
    display: none;
    align-items: center; justify-content: center;
    font-size: 12px;
    font-weight: 900;
    color: #fff;
    z-index: 10;
}
.pick-card-option.selected .pick-check { display: flex; }

/* Confirm button */
.pick-confirm-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============================================================
   GAME FINISHED SCREEN
   ============================================================ */
#finishedScreen {
    align-items: center;
    justify-content: center;
    background: rgba(8,12,30,0.95);
    backdrop-filter: blur(12px);
}

.finished-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 52px 48px;
    text-align: center;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 32px 80px rgba(0,0,0,0.7), var(--shadow-pink);
    animation: cardUp 0.6s cubic-bezier(0.34,1.56,0.64,1);
}
.finished-icon { font-size: 72px; margin-bottom: 16px; filter: drop-shadow(0 0 30px rgba(255,20,147,0.5)); }
.finished-title { font-size: 32px; font-weight: 900; background: linear-gradient(135deg, var(--pink), var(--teal)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; margin-bottom: 28px; }

.game-stats {
    background: var(--surface2);
    border-radius: var(--radius-sm);
    padding: 20px;
    margin-bottom: 24px;
    border: 1px solid var(--border);
    text-align: left;
}
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.stat-row:last-child { border-bottom: none; }
.stat-row span:first-child { color: var(--text-sub); }
.stat-row span:last-child  { color: var(--text); font-weight: 700; }

/* ============================================================
   LIGHT MODE OVERRIDES
   ============================================================ */
body.light-mode #gameScreen::before {
    background: rgba(240, 242, 250, 0.60);
}
body.light-mode .login-card {
    background: rgba(255,255,255,0.92);
    border-color: rgba(255,20,147,0.2);
}
body.light-mode .login-bg .bg-orb { opacity: 0.35; }
body.light-mode .leaderboard-item:hover { background: rgba(0,206,209,0.12); }
body.light-mode .pick-card-modal-card { background: var(--surface); }
body.light-mode .modal-card { background: var(--surface); }
body.light-mode .confirm-modal-card { background: var(--surface); }
body.light-mode .lobby-chat-messages { background: var(--surface2); }
body.light-mode .lobby-chat-input-row input { background: var(--surface2); }
body.light-mode .hand-area { background: var(--surface); border-top-color: var(--border); }
body.light-mode .side-panel { background: var(--surface); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
    .lobby-sidebar { width: 220px; }
    .side-panel { width: 240px; }
}

@media (max-width: 768px) {
    .lobby-layout { flex-direction: column; }
    .lobby-sidebar { width: 100%; height: auto; border-right: none; border-bottom: 1px solid var(--border); padding: 16px; flex-direction: row; flex-wrap: wrap; }
    .sidebar-section { display: none; }
    .lobby-main { padding: 16px; }

    .game-body { flex-direction: column; }
    .side-panel { width: 100%; height: 200px; border-right: none; border-top: 1px solid var(--border); flex-direction: row; }
    .battlefield { padding: 10px; gap: 12px; }
    .players-column { width: 130px; gap: 10px; }
    .player-panel { padding: 10px; }
    .field-card { width: 110px; height: 150px; }
}
