/* =========================================================
   PLAYROOM — головні налаштування дизайну
   Можеш змінювати ці кольори, щоб створити власний стиль.
========================================================= */
:root {
    --bg: #090b12;
    --surface: #111522;
    --surface-2: #171d2d;
    --surface-3: #20283a;
    --text: #f4f6ff;
    --muted: #929bb2;
    --accent: #9b7bff;
    --accent-2: #54e0c1;
    --border: rgba(173, 187, 220, .13);
    --radius: 20px;
    --content: 1180px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
      radial-gradient(ellipse at 12% 0%, rgba(111, 76, 220, .16), transparent 34rem),
      radial-gradient(ellipse at 92% 20%, rgba(45, 190, 166, .08), transparent 28rem),
      var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, select:focus-visible {
    outline: 2px solid var(--accent-2);
    outline-offset: 3px;
}
.page-shell { opacity: 0; transition: opacity .55s ease; }
.page-shell.ready { opacity: 1; }

/* LOADING SCREEN */
.loader {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    background:
      radial-gradient(ellipse at 50% 42%, rgba(137, 101, 255, .19), transparent 25rem),
      #090b12;
    transition: opacity .55s ease, visibility .55s ease;
}
.loader.done { opacity: 0; visibility: hidden; pointer-events: none; }
.loader-inner { width: min(330px, 82vw); text-align: center; }
.loader-mark {
    width: 76px; height: 76px; margin: 0 auto 22px;
    display: grid; place-items: center;
    border: 1px solid rgba(171, 147, 255, .5);
    border-radius: 24px;
    color: white; font-size: 30px; font-weight: 900;
    background: linear-gradient(145deg, rgba(155,123,255,.35), rgba(84,224,193,.12));
    box-shadow: 0 0 55px rgba(155,123,255,.22), inset 0 0 25px rgba(255,255,255,.05);
    animation: float 1.8s ease-in-out infinite;
}
.loader-name { font-size: 27px; font-weight: 900; letter-spacing: .19em; }
.loader-name span { color: var(--accent); }
.loader-caption { margin: 10px 0 25px; color: var(--muted); font-size: 12px; letter-spacing: .16em; text-transform: uppercase; }
.loader-track { height: 4px; overflow: hidden; border-radius: 20px; background: #252a3a; }
.loader-progress { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-2)); animation: loading 1.35s ease forwards; }
@keyframes loading { to { width: 100%; } }
@keyframes float { 50% { transform: translateY(-6px); } }

/* HEADER */
.topbar {
    position: sticky; top: 0; z-index: 20;
    background: rgba(9, 11, 18, .78);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(18px);
}
.topbar-inner {
    max-width: var(--content); margin: auto; padding: 15px 24px;
    display: flex; align-items: center; gap: 34px;
}
.brand { display: flex; align-items: center; gap: 11px; font-weight: 900; letter-spacing: .12em; white-space: nowrap; }
.brand-symbol {
    width: 35px; height: 35px; display: grid; place-items: center;
    border-radius: 11px; background: linear-gradient(140deg, var(--accent), #6248c9);
    box-shadow: 0 5px 22px rgba(155,123,255,.28); color: white; letter-spacing: 0;
}
.brand-word span { color: var(--accent); }
.nav { display: flex; align-items: center; gap: 25px; flex: 1; }
.nav a { color: var(--muted); font-size: 13px; transition: color .2s; }
.nav a:hover, .nav a.active { color: var(--text); }
.header-actions { display: flex; align-items: center; gap: 10px; }
.online-pill { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.online-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 10px var(--accent-2); }
.btn {
    border: 1px solid transparent; border-radius: 12px; padding: 10px 15px;
    color: #0c0d14; background: var(--accent); font-weight: 750; font-size: 12px;
    transition: transform .2s, filter .2s, border-color .2s;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.1); }
.btn-quiet { color: var(--text); background: var(--surface-2); border-color: var(--border); }
.btn-small { padding: 9px 12px; }
.mobile-menu { display: none; }

/* MAIN LAYOUT */
main { max-width: var(--content); margin: auto; padding: 0 24px 70px; }
.hero {
    position: relative; overflow: hidden; min-height: 310px;
    margin: 34px 0 28px; padding: 55px 54px;
    display: flex; align-items: center;
    border: 1px solid rgba(173,187,220,.16); border-radius: 28px;
    background:
      radial-gradient(circle at 82% 48%, rgba(155,123,255,.27), transparent 18rem),
      linear-gradient(115deg, #171a2b 0%, #111827 58%, #13212a 100%);
}
.hero::after {
    content: "✦"; position: absolute; right: 11%; top: 3%;
    font-size: 220px; line-height: 1; color: rgba(255,255,255,.035);
    transform: rotate(12deg); pointer-events: none;
}
.hero-content { position: relative; z-index: 1; max-width: 590px; }
.eyebrow { color: var(--accent-2); font-size: 10px; font-weight: 800; letter-spacing: .2em; text-transform: uppercase; }
.hero h1 { margin: 15px 0 12px; font-size: clamp(38px, 6vw, 66px); line-height: .99; letter-spacing: -.055em; }
.hero h1 span { color: var(--accent); }
.hero p { max-width: 440px; margin: 0; color: #aab2c7; line-height: 1.7; font-size: 14px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 25px; }
.hero-art {
    position: absolute; right: 8%; top: 50%; transform: translateY(-50%);
    width: 205px; height: 205px; border: 1px solid rgba(190,174,255,.25);
    border-radius: 48px; rotate: 9deg;
    background: linear-gradient(145deg, rgba(155,123,255,.19), rgba(84,224,193,.07));
    box-shadow: 0 20px 80px rgba(0,0,0,.25), inset 0 0 50px rgba(155,123,255,.1);
    display: grid; place-items: center; font-size: 94px;
}
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 43px 0 18px; }
.section-heading h2 { margin: 0; font-size: 22px; letter-spacing: -.03em; }
.section-heading p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.section-kicker { color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; margin-bottom: 7px; }
.games { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 17px; }
.game-card {
    overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius);
    background: linear-gradient(160deg, rgba(27,33,50,.98), rgba(17,21,34,.98));
    transition: transform .22s, border-color .22s, box-shadow .22s;
}
.game-card:hover { transform: translateY(-5px); border-color: rgba(155,123,255,.55); box-shadow: 0 16px 40px rgba(0,0,0,.2); }
.game-art {
    height: 150px; display: grid; place-items: center; position: relative; overflow: hidden;
    background: radial-gradient(circle at 50% 55%, rgba(155,123,255,.24), transparent 58%), #171b2b;
    font-size: 65px;
}
.game-art::before, .game-art::after { content: ""; position: absolute; border: 1px solid rgba(255,255,255,.08); border-radius: 50%; width: 190px; height: 190px; }
.game-art::after { width: 135px; height: 135px; }
.game-art span { position: relative; z-index: 1; filter: drop-shadow(0 8px 20px rgba(0,0,0,.35)); }
.game-info { padding: 18px; }
.game-topline { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.game-info h3 { margin: 0; font-size: 15px; }
.game-tag { color: var(--accent-2); font-size: 9px; text-transform: uppercase; letter-spacing: .1em; font-weight: 800; }
.game-info p { min-height: 38px; margin: 10px 0 16px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.game-info .btn { width: 100%; }
.btn:disabled { cursor: not-allowed; opacity: .45; transform: none; }

/* AUTHENTICATION */
.auth-tabs { display:grid; grid-template-columns:repeat(2,1fr); gap:6px; margin:15px 0 6px; padding:5px; background:var(--surface-2); border-radius:12px; }
.auth-tab { padding:10px; border:0; border-radius:9px; background:transparent; color:var(--muted); font-weight:700; }
.auth-tab.selected { background:var(--accent); color:#111522; }
.auth-link { display:block; margin:12px auto 0; padding:8px; border:0; background:transparent; color:var(--accent); font-size:12px; }
.auth-link:hover { text-decoration:underline; }
/* PLAYER PROFILE */
.profile-form { display:grid; gap:12px; text-align:left; margin-top:16px; }
.profile-form label { font-size:12px; color:var(--muted); display:grid; gap:6px; }
.profile-form input, .profile-form textarea {
    width:100%; padding:12px; border:1px solid var(--border); border-radius:10px;
    background:var(--surface-2); color:var(--text); font:inherit;
}
.profile-form textarea { min-height:80px; resize:vertical; }
.profile-form input[type=file] { font-size:11px; }
.profile-form .btn { width:100%; }
.profile-preview { width:82px; height:82px; border-radius:24px; object-fit:cover; display:block; margin:0 auto 12px; border:2px solid var(--accent); }
.auth-message { font-size:12px; color:var(--accent-2); min-height:18px; line-height:1.5; }
.auth-message.error { color:#ff9a9a; }
.profile-stats { display:flex; gap:8px; justify-content:center; margin:14px 0; }
.profile-stats span { padding:10px; background:var(--surface-2); border-radius:10px; font-size:12px; }
[hidden] { display:none !important; }

/* BOTTOM INFO PANELS */
.feature-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 17px; margin-top: 20px; }
.info-panel { padding: 22px; border: 1px solid var(--border); border-radius: var(--radius); background: rgba(17,21,34,.75); }
.info-panel h3 { margin: 0 0 8px; font-size: 15px; }
.info-panel p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.feature-icon { font-size: 22px; margin-bottom: 13px; }

/* MODALS */
.modal {
    display: none; position: fixed; inset: 0; z-index: 100;
    align-items: center; justify-content: center; padding: 16px;
    background: rgba(2,4,9,.78); backdrop-filter: blur(9px);
}
.modal.active { display: flex; }
.modal-content {
    position: relative; width: min(100%, 430px); max-height: 90vh; overflow-y: auto;
    padding: 27px; text-align: center; border: 1px solid var(--border);
    border-radius: 23px; background: #151a29; box-shadow: 0 25px 90px rgba(0,0,0,.5);
}
.modal-content h2 { margin: 5px 30px 12px; font-size: 21px; }
.close {
    position: absolute; right: 14px; top: 12px; width: 34px; height: 34px;
    border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
    color: var(--text); font-size: 21px;
}
.game-select {
    margin: 10px 0; padding: 10px 12px; width: 100%; border-radius: 10px;
    border: 1px solid var(--border); color: var(--text); background: var(--surface-2);
}
.board { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin: 18px 0; }
.cell {
    aspect-ratio: 1; padding: 0; border: 1px solid var(--border); border-radius: 13px;
    background: #20283a; color: var(--accent); font-size: clamp(34px, 9vw, 48px); font-weight: 800;
}
.cell.o { color: var(--accent-2); }
.status { min-height: 22px; color: #c5cbe0; font-size: 13px; }
.score { margin: 15px 0 18px; color: var(--muted); font-size: 12px; }
.profile-placeholder { margin: 18px 0; padding: 18px; border-radius: 15px; background: var(--surface-2); color: var(--muted); font-size: 13px; line-height: 1.7; }
.profile-avatar { width: 68px; height: 68px; margin: 0 auto 12px; display: grid; place-items: center; border-radius: 22px; background: linear-gradient(140deg, var(--accent), #5540ad); font-size: 29px; }
footer { border-top: 1px solid var(--border); padding: 25px 24px; text-align: center; color: #707991; font-size: 11px; }
footer strong { color: var(--accent); letter-spacing: .12em; }

@media (max-width: 800px) {
    .topbar-inner { gap: 18px; }
    .nav { gap: 15px; }
    .online-pill { display: none; }
    .hero { padding: 45px 35px; }
    .hero-art { right: 4%; width: 155px; height: 155px; font-size: 70px; opacity: .75; }
    .games { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 560px) {
    .topbar-inner { padding: 12px 16px; flex-wrap: wrap; justify-content: space-between; }
    .nav { order: 3; width: 100%; justify-content: center; padding-top: 10px; border-top: 1px solid var(--border); }
    .nav a { font-size: 12px; }
    .header-actions .btn { padding: 9px 11px; font-size: 11px; }
    main { padding: 0 15px 48px; }
    .hero { min-height: 300px; margin-top: 18px; padding: 36px 24px; border-radius: 22px; }
    .hero-art { right: -25px; top: auto; bottom: -40px; transform: none; width: 135px; height: 135px; font-size: 60px; opacity: .38; }
    .hero-content { max-width: 100%; }
    .hero p { max-width: 290px; }
    .games { grid-template-columns: 1fr; }
    .game-art { height: 165px; }
    .feature-grid { grid-template-columns: 1fr; }
    .section-heading { align-items: start; flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* PLAYROOM V4: аватар у шапці та друзі */
.account-chip { display:flex; align-items:center; gap:8px; max-width:185px; padding:5px 11px 5px 5px; }
.header-avatar { width:28px; height:28px; border-radius:9px; object-fit:cover; background:linear-gradient(135deg,var(--accent),#4a3ba8); display:grid; place-items:center; color:white; flex:none; }
.header-name { max-width:115px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.friend-count { margin-left:3px; background:var(--accent); color:#111; padding:1px 5px; border-radius:10px; font-size:10px; }
.friends-dialog { max-width:520px; text-align:left; }
.friends-dialog h2 { margin:5px 35px 14px 0; }
.friends-search { display:flex; gap:8px; }
.friends-search input { flex:1; min-width:0; padding:11px; background:var(--surface-2); color:var(--text); border:1px solid var(--border); border-radius:10px; }
.friends-section { margin-top:20px; }
.friends-section h3 { font-size:13px; margin:0 0 10px; color:var(--muted); }
.friend-row { display:flex; gap:11px; align-items:center; border:1px solid var(--border); background:var(--surface-2); border-radius:13px; padding:10px; margin:8px 0; }
.friend-avatar { width:38px; height:38px; object-fit:cover; border-radius:12px; background:#333048; display:grid; place-items:center; flex:none; }
.friend-detail { flex:1; min-width:0; }
.friend-detail strong { display:block; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; font-size:13px; }
.friend-detail small { color:var(--muted); font-size:11px; }
.friend-actions { display:flex; gap:5px; }
.friend-actions .btn { padding:7px 9px; }
.friend-dot { display:inline-block; width:7px; height:7px; border-radius:50%; background:#6d7788; margin-right:5px; }
.friend-dot.online { background:var(--accent-2); box-shadow:0 0 8px var(--accent-2); }
.empty-hint { color:var(--muted); font-size:12px; line-height:1.5; }
@media(max-width:560px) { .header-actions { gap:5px; } .account-chip { max-width:136px; } .header-name { max-width:66px; } .friends-dialog { padding:19px; } }

/* PLAYROOM V6 — публічний ID гравця */
.player-id-chip { margin:10px auto; display:flex; justify-content:center; align-items:center; gap:9px; flex-wrap:wrap; color:var(--muted); font-size:12px; }
.player-id-chip strong { font-size:15px; color:var(--accent-2); letter-spacing:.08em; }
