/* UNO Online — Site Styles (mobile-first) */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --c-red:    #ff4055;
    --c-green:  #22d472;
    --c-blue:   #3d87f5;
    --c-yellow: #f5bb3f;
    --c-wild:   #a05ef0;
    --bg:       #0d0c1c;
    --bg-up:    #13122a;
    --surface:  #1c1a32;
    --surf-2:   #252240;
    --surf-3:   #2e2b52;
    --surf-4:   #38345f;
    --accent:   #e8344a;
    --accent-2: #f5bb3f;
    --success:  #22d472;
    --text:     #f0eeff;
    --text-2:   #9490b8;
    --text-3:   #5e5a84;
    --border:   rgba(255,255,255,0.07);
    --border-2: rgba(255,255,255,0.13);
    --r-xs: 6px; --r-sm: 10px; --r: 16px; --r-lg: 22px; --r-xl: 28px;
    --shadow:    0 8px 32px rgba(0,0,0,0.55);
    --shadow-sm: 0 2px 16px rgba(0,0,0,0.35);
    --safe-top:    env(safe-area-inset-top,    0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left:   env(safe-area-inset-left,   0px);
    --safe-right:  env(safe-area-inset-right,  0px);
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    background-image:
        radial-gradient(ellipse at 20%   0%, rgba(232,52,74,0.06)  0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(61,135,245,0.06) 0%, transparent 50%);
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
button { font-family: inherit; }

/* ======= App Header ======= */
.app-header {
    position: sticky; top: 0; z-index: 100;
    height: 56px;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 1rem;
    padding-top: var(--safe-top);
    background: rgba(13,12,28,0.92);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}
.app-logo { display: flex; align-items: center; gap: 0.5rem; text-decoration: none; }
.logo-badge {
    width: 36px; height: 36px;
    background: var(--accent);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; font-weight: 900; color: #fff; letter-spacing: -0.5px;
    box-shadow: 0 4px 12px rgba(232,52,74,0.4);
    flex-shrink: 0;
}
.logo-text { font-size: 1.2rem; font-weight: 800; color: var(--text); letter-spacing: 1px; }
.header-player {
    display: flex; align-items: center; gap: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 0.3rem 0.75rem 0.3rem 0.3rem;
    cursor: pointer;
    transition: border-color 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.header-player:hover, .header-player:focus { border-color: var(--border-2); outline: none; }
.player-avatar {
    width: 30px; height: 30px;
    background: linear-gradient(135deg, var(--accent), var(--c-wild));
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem; font-weight: 700; color: #fff; flex-shrink: 0;
    overflow: hidden;
}
.player-avatar-img {
    width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
}

/* Avatar edit in name overlay */
.avatar-edit-row   { display: flex; justify-content: center; margin-bottom: 1rem; }
.avatar-edit-circle {
    position: relative; width: 64px; height: 64px;
    background: linear-gradient(135deg, var(--accent), var(--c-wild));
    border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem; font-weight: 700; color: #fff;
    overflow: hidden;
}
.avatar-edit-overlay {
    position: absolute; inset: 0; background: rgba(0,0,0,0.45);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; opacity: 0; transition: opacity 0.2s;
}
.avatar-edit-circle:hover .avatar-edit-overlay { opacity: 1; }
.player-label {
    font-size: 0.85rem; font-weight: 600; color: var(--text);
    max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Name Edit Overlay */
.name-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    display: flex; align-items: flex-start; justify-content: flex-end;
    padding: 64px 0.75rem 0;
}
.name-edit-box {
    background: var(--surf-2); border: 1px solid var(--border-2);
    border-radius: var(--r); padding: 1rem;
    width: 260px; box-shadow: var(--shadow);
}
.name-edit-box label { display: block; font-size: 0.8rem; color: var(--text-2); margin-bottom: 0.4rem; }
.name-edit-actions { display: flex; gap: 0.5rem; margin-top: 0.6rem; }

/* ======= Page Content ======= */
.page-content { padding: 0 0 3rem; }

/* ======= Buttons ======= */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
    min-height: 44px; padding: 0 1.25rem;
    border-radius: var(--r-xl);
    font-size: 0.9rem; font-weight: 600;
    cursor: pointer; border: none;
    transition: transform 0.12s, opacity 0.18s, box-shadow 0.18s;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    text-decoration: none;
}
.btn:active { transform: scale(0.95); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-full  { width: 100%; }
.btn-primary  { background: var(--accent); color: #fff; box-shadow: 0 4px 16px rgba(232,52,74,0.35); }
.btn-primary:hover { opacity: 0.9; box-shadow: 0 6px 20px rgba(232,52,74,0.45); }
.btn-secondary { background: var(--surf-3); color: var(--text); border: 1px solid var(--border-2); }
.btn-secondary:hover { background: var(--surf-4); }
.btn-ghost  { background: transparent; color: var(--text-2); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--border-2); color: var(--text); }
.btn-join   { background: var(--success); color: #0d0c1c; font-weight: 700; box-shadow: 0 4px 14px rgba(34,212,114,0.25); }
.btn-join:hover { opacity: 0.88; }
.btn-icon {
    min-height: 38px; height: 38px; width: 38px; padding: 0;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 50%; color: var(--text-2); font-size: 1.1rem;
}
.btn-icon:hover { color: var(--text); border-color: var(--border-2); }

/* ======= Home Page ======= */
.home-view { padding: 0 0 2rem; }
.hero-section { text-align: center; padding: 2rem 1rem 1.5rem; }
.big-uno {
    font-size: 5rem; font-weight: 900; line-height: 1; letter-spacing: -2px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
    filter: drop-shadow(0 4px 20px rgba(232,52,74,0.4));
    display: block;
}
.hero-tagline { color: var(--text-2); font-size: 0.95rem; margin-top: 0.25rem; }
.rooms-section { padding: 0 0.75rem; }
.section-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.5rem 0 0.75rem;
}
.section-title {
    font-size: 1rem; font-weight: 700; color: var(--text);
    display: flex; align-items: center; gap: 0.5rem;
}
.count-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 22px; height: 22px; padding: 0 6px;
    background: var(--surf-3); border-radius: var(--r-xl);
    font-size: 0.72rem; font-weight: 700; color: var(--text-2);
}

/* Room Cards */
.room-list { display: flex; flex-direction: column; gap: 0.6rem; }
.room-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r); padding: 0.9rem 1rem;
    display: flex; align-items: center; gap: 0.75rem;
    transition: border-color 0.2s, background 0.2s;
}
.room-card:hover { background: var(--surf-2); border-color: var(--border-2); }
.room-card-icon {
    width: 42px; height: 42px;
    background: linear-gradient(135deg, var(--accent), var(--c-wild));
    border-radius: var(--r-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; flex-shrink: 0;
}
.room-card-body { flex: 1; min-width: 0; }
.room-card-name {
    font-weight: 700; font-size: 0.95rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 0.2rem;
}
.room-card-meta { display: flex; align-items: center; gap: 0.5rem; font-size: 0.76rem; color: var(--text-2); }
.room-badge { background: var(--surf-3); border-radius: var(--r-xl); padding: 0.1rem 0.5rem; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--text-2); }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 0.75rem; opacity: 0.5; display: block; }
.empty-state p { font-size: 1rem; font-weight: 600; margin-bottom: 0.25rem; color: var(--text); }
.empty-state span { font-size: 0.85rem; }
.join-by-code { margin-top: 1rem; }

/* FAB */
.fab {
    position: fixed;
    bottom: calc(1.25rem + var(--safe-bottom)); right: 1rem;
    z-index: 90;
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0 1.25rem; height: 52px;
    background: var(--accent); color: #fff;
    border: none; border-radius: var(--r-xl);
    font-size: 0.9rem; font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(232,52,74,0.45);
    transition: transform 0.15s, box-shadow 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.fab:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(232,52,74,0.5); }
.fab:active { transform: scale(0.95); }
.fab-icon { font-size: 1.4rem; font-weight: 300; line-height: 1; }

/* ======= Lobby Page ======= */
.lobby-view { padding: 0 0.75rem 2rem; }
.lobby-hero { padding: 1.25rem 0 1rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.lobby-room-name {
    font-size: 1.5rem; font-weight: 800; margin-bottom: 0.5rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lobby-code-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.room-code-display {
    display: inline-flex; align-items: center; gap: 0.35rem;
    background: var(--surf-2); border: 1px solid var(--border-2); border-radius: var(--r-sm);
    padding: 0.3rem 0.75rem;
    font-size: 0.9rem; font-family: 'Courier New', monospace;
    font-weight: 700; letter-spacing: 2px; color: var(--text);
    cursor: pointer; transition: background 0.2s;
}
.room-code-display:hover { background: var(--surf-3); }
.room-code-label { font-size: 0.7rem; color: var(--text-2); font-family: inherit; letter-spacing: 0; }
.players-section { margin-bottom: 1.5rem; }
.players-title {
    font-size: 0.85rem; font-weight: 600; color: var(--text-2);
    text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.75rem;
}
.player-list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.player-item {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-sm); padding: 0.7rem 1rem;
    display: flex; align-items: center; gap: 0.6rem; min-height: 52px;
}
.player-item.you { border-color: var(--accent); background: rgba(232,52,74,0.05); }
.player-item-avatar {
    width: 32px; height: 32px;
    background: var(--surf-3); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem; font-weight: 700; flex-shrink: 0;
    overflow: hidden;
}
.player-item.you .player-item-avatar { background: linear-gradient(135deg, var(--accent), var(--c-wild)); }
.player-item-name { flex: 1; font-weight: 600; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-item-badges { display: flex; gap: 0.35rem; }
.badge {
    display: inline-flex; align-items: center;
    padding: 0.12rem 0.45rem; border-radius: var(--r-xl);
    font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
}
.badge-host    { background: var(--accent-2); color: #0d0c1c; }
.badge-ai      { background: var(--c-wild);   color: #fff; }
.badge-you     { background: var(--accent);   color: #fff; }
.badge-private { background: var(--surf-3);   color: var(--text-2); }
.lobby-actions { display: flex; flex-direction: column; gap: 0.6rem; }
.waiting-msg {
    text-align: center; padding: 1rem;
    color: var(--text-2); font-size: 0.9rem;
    background: var(--surface); border-radius: var(--r-sm); border: 1px solid var(--border);
}

/* ======= Modals (bottom sheet on mobile) ======= */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
    z-index: 400;
    display: flex; align-items: flex-end; justify-content: center;
    animation: oFadeIn 0.2s ease;
}
@keyframes oFadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-sheet {
    background: var(--surf-2);
    border-top: 1px solid var(--border-2);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    width: 100%; max-width: 520px;
    padding: 0 1rem calc(1.25rem + var(--safe-bottom));
    animation: oSlideUp 0.28s cubic-bezier(0.16,1,0.3,1);
    max-height: 90vh; overflow-y: auto;
}
@keyframes oSlideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-handle { width: 36px; height: 4px; background: var(--surf-4); border-radius: var(--r-xl); margin: 0.75rem auto 1.25rem; }
.modal-title  { font-size: 1.2rem; font-weight: 800; margin-bottom: 1.25rem; text-align: center; }
.modal-actions { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 0.5rem; }

/* ======= Forms ======= */
.form-field { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 0.9rem; }
.form-field label {
    font-size: 0.82rem; font-weight: 600; color: var(--text-2);
    text-transform: uppercase; letter-spacing: 0.4px;
}
.form-input {
    width: 100%; height: 48px; padding: 0 0.85rem;
    background: var(--bg-up); border: 1.5px solid var(--border-2);
    border-radius: var(--r-sm); color: var(--text);
    font-size: 1rem; font-family: inherit; outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
}
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232,52,74,0.15); }
.check-label {
    display: flex; align-items: center; gap: 0.65rem;
    cursor: pointer; font-size: 0.9rem; font-weight: 600; color: var(--text);
    min-height: 44px; user-select: none;
}
.check-label input[type="checkbox"] { display: none; }
.check-box {
    width: 22px; height: 22px;
    background: var(--bg-up); border: 1.5px solid var(--border-2); border-radius: 6px;
    flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    transition: background 0.18s, border-color 0.18s;
}
.check-label input:checked ~ .check-box { background: var(--accent); border-color: var(--accent); }
.check-label input:checked ~ .check-box::after { content: '✓'; font-size: 0.75rem; color: #fff; font-weight: 800; }

/* ======= Alerts ======= */
.alert { padding: 0.7rem 1rem; border-radius: var(--r-sm); font-size: 0.875rem; margin-bottom: 0.75rem; border: 1px solid transparent; }
.alert-error { background: rgba(232,52,74,0.12); border-color: rgba(232,52,74,0.3); color: #ff8096; }

/* ======= Toasts ======= */
.toast-container {
    position: fixed;
    bottom: calc(5rem + var(--safe-bottom)); left: 50%;
    transform: translateX(-50%);
    display: flex; flex-direction: column; align-items: center; gap: 0.45rem;
    z-index: 600; pointer-events: none;
    width: calc(100% - 2rem); max-width: 340px;
}
.toast {
    background: var(--surf-3); border: 1px solid var(--border-2);
    border-radius: var(--r); padding: 0.6rem 1rem;
    font-size: 0.875rem;
    animation: toastIn 0.3s cubic-bezier(0.16,1,0.3,1);
    text-align: center; box-shadow: var(--shadow); width: 100%;
}
@keyframes toastIn {
    from { transform: translateY(20px) scale(0.96); opacity: 0; }
    to   { transform: translateY(0)    scale(1);    opacity: 1; }
}

/* Player count radio row */
.player-count-row { display: flex; gap: 0.5rem; }
.count-option { cursor: pointer; }
.count-option input[type="radio"] { display: none; }
.count-option span {
    display: flex; align-items: center; justify-content: center;
    width: 44px; height: 44px;
    background: var(--bg-up); border: 1.5px solid var(--border-2); border-radius: var(--r-sm);
    font-size: 1rem; font-weight: 700; color: var(--text-2);
    transition: background 0.18s, border-color 0.18s, color 0.18s;
}
.count-option input:checked ~ span {
    background: var(--accent); border-color: var(--accent); color: #fff;
    box-shadow: 0 4px 12px rgba(232,52,74,0.3);
}
.count-option:hover span { border-color: var(--border-2); color: var(--text); }

/* Private pill badge in room list */
.badge-private-pill {
    background: rgba(160,94,240,0.18); color: var(--c-wild);
    border: 1px solid rgba(160,94,240,0.3); border-radius: var(--r-xl);
    font-size: 0.7rem; padding: 0.1rem 0.5rem;
}

/* Inline username entry card */
.name-inline-card {
    margin: 0 1rem 1.5rem;
    background: var(--surface-2);
    border: 1px solid var(--border-1);
    border-radius: var(--r-xl);
    padding: 1.75rem 1.5rem;
    text-align: center;
}
.name-inline-title { font-size: 1.3rem; font-weight: 700; margin: 0 0 0.4rem; }
.name-inline-sub   { color: var(--text-muted); font-size: 0.9rem; margin: 0 0 1.2rem; }
.name-inline-form  { display: flex; gap: 0.6rem; max-width: 480px; margin: 0 auto; }
.name-inline-input { flex: 1; }
.name-inline-btn   { flex-shrink: 0; white-space: nowrap; padding-left: 1rem; padding-right: 1rem; }

/* Auth card (şifre / yeni hesap) */
.auth-card         { text-align: center; }
.auth-success-icon { font-size: 2.5rem; margin-bottom: 0.5rem; line-height: 1; }
.password-display  {
    font-size: 1.6rem; font-weight: 700; letter-spacing: 5px;
    background: var(--surface-3, #181825);
    border: 1px solid var(--border-2);
    border-radius: var(--r-md);
    padding: 0.65rem 1.5rem;
    margin: 0.5rem auto 0;
    display: inline-block;
    font-family: monospace;
    user-select: all;
}

/* ======= Desktop / Tablet ======= */
@media (min-width: 640px) {
    .app-header  { height: 60px; padding: 0 1.5rem; }
    .hero-section { padding: 2.5rem 1.5rem 2rem; }
    .big-uno     { font-size: 6.5rem; }
    .rooms-section, .lobby-view { max-width: 640px; margin: 0 auto; padding-left: 1.5rem; padding-right: 1.5rem; }
    .modal-overlay { align-items: center; padding: 1.5rem; }
    .modal-sheet { border-radius: var(--r-xl); border: 1px solid var(--border-2); max-width: 420px; padding: 0 1.5rem 1.5rem; }
    .modal-handle { display: none; }
    .fab { right: 1.5rem; bottom: 1.5rem; }
    .toast-container { bottom: 1.5rem; }
}
