:root { --bg: #0f1218; --s1: #161a22; --s2: #1d222c; --s3: #262c38; --line: rgba(255, 255, 255, 0.08); --line2: rgba(255, 255, 255, 0.14); --text: #e8ecf3; --dim: #98a1b3; --acc: #3ddc84; --acc2: #ffcb47; --bad: #ff6b6b; --r: 14px; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-family: Rubik, system-ui, -apple-system, 'Segoe UI', sans-serif; display: flex; flex-direction: column; height: 100dvh; overflow: hidden; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
.off { display: none !important; }
.dim { color: var(--dim); } .small { font-size: 13px; } .mono { font-family: ui-monospace, Consolas, monospace; }
h1, h2, h3 { margin: 0; }

/* ---------- шапка ---------- */
.top { flex: none; display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--s1); }
.back { padding: 8px 12px; border-radius: 10px; background: var(--s2); font-weight: 600; font-size: 14px; }
.back:hover { background: var(--s3); }
.brand { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 800; }
.brand svg { width: 34px; height: 34px; }
.topR { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.mechip { font-size: 13px; color: var(--dim); } .mechip b { color: var(--text); }
.ghost { padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line2); font-weight: 600; font-size: 14px; }
.ghost:hover { background: var(--s2); }

/* ---------- загальне ---------- */
main { flex: 1; min-height: 0; position: relative; }
.scr { position: absolute; inset: 0; overflow-y: auto; }
.scr.center { display: flex; align-items: center; justify-content: center; padding: 16px; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 24px 16px; }
.card { background: var(--s1); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.card.narrow { width: min(440px, 100%); display: flex; flex-direction: column; gap: 12px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 11px; background: var(--s2); border: 1px solid var(--line2); font-weight: 600; transition: background 0.15s; }
.btn:hover { background: var(--s3); }
.btn.main { background: var(--acc); color: #06210f; border-color: transparent; font-weight: 700; }
.btn.main:hover { background: #5ae79a; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--dim); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
input, select, textarea { background: var(--bg); border: 1px solid var(--line2); border-radius: 10px; padding: 10px 12px; color: var(--text); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--acc); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bigcroc { width: 88px; height: 88px; align-self: center; }
#gate h1 { text-align: center; font-size: 30px; } #gate p { text-align: center; margin: 0; }

/* ---------- лобі ---------- */
.lobbyHead { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.lobbyHead p { margin: 4px 0 0; }
.lobbyActs { display: flex; gap: 10px; flex-wrap: wrap; }
.joinById { display: flex; gap: 6px; } .joinById input { width: 140px; text-transform: uppercase; }
.lobbyList { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.room { background: var(--s1); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.room .rt { display: flex; justify-content: space-between; gap: 8px; } .room .rt b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room .rid { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--dim); }
.room .rs { font-size: 13px; color: var(--dim); }
.room .rb { display: flex; justify-content: space-between; align-items: center; padding-top: 8px; border-top: 1px solid var(--line); }
.room .cnt { font-weight: 700; color: var(--acc); } .room .cnt.full { color: var(--bad); }
.empty { grid-column: 1 / -1; text-align: center; color: var(--dim); padding: 50px 10px; border: 1px dashed var(--line2); border-radius: var(--r); }

/* ---------- кімната ---------- */
.roomGrid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 14px; max-width: 1180px; margin: 0 auto; padding: 18px 16px; height: 100%; }
.roomMain { display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.roomHead { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; } .roomHead p { margin: 4px 0 0; font-size: 14px; }
.roomHeadActs { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.sub { font-size: 14px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--dim); }
.settings { display: flex; flex-direction: column; gap: 12px; padding: 14px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.settings .srow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 7px 11px; border-radius: 999px; border: 1px solid var(--line2); font-size: 13px; font-weight: 600; color: var(--dim); }
.chip.on { background: rgba(61, 220, 132, 0.14); border-color: var(--acc); color: var(--text); }
button.chip:hover { border-color: var(--acc); }
.words textarea { width: 100%; min-height: 70px; resize: vertical; }
.words .wrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.roomPlayers { display: flex; flex-direction: column; gap: 6px; }
.rp { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 11px; background: var(--s2); }
.rp .av { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #0f1218; flex: none; }
.rp .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp .st { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--s3); color: var(--dim); }
.rp .st.ok { background: rgba(61, 220, 132, 0.16); color: var(--acc); }
.rp .kick { color: var(--bad); font-size: 13px; padding: 4px 8px; border-radius: 8px; } .rp .kick:hover { background: rgba(255, 107, 107, 0.1); }
.roomActs { display: flex; gap: 10px; margin-top: auto; flex-wrap: wrap; } .roomActs .btn { flex: 1; min-width: 120px; }

/* ---------- чат ---------- */
.chatCard { display: flex; flex-direction: column; padding: 0; min-height: 0; overflow: hidden; }
.chatList { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.msg { line-height: 1.4; word-wrap: break-word; } .msg b { color: var(--acc2); font-weight: 600; } .msg.mine b { color: var(--acc); }
.msg.sys { color: var(--dim); font-size: 13px; } .msg.sys.good { color: var(--acc); font-weight: 600; } .msg.sys.hot { color: var(--acc2); }
.chatForm { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); } .chatForm input { flex: 1; min-width: 0; }

/* ---------- гра ---------- */
#scrGame { overflow: hidden; }
.gameGrid { display: grid; grid-template-columns: 210px minmax(0, 1fr) 320px; gap: 12px; padding: 12px; height: 100%; }
.players { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; padding-top: 9px; }
.gp { position: relative; display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 12px; background: var(--s1); border: 1px solid var(--line); }
.gp .av { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #0f1218; flex: none; }
.gp .nm { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gp .nm small { display: block; font-weight: 500; color: var(--dim); font-size: 12px; }
.gp .sc { font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }
.gp.drawer { border-color: var(--acc2); background: rgba(255, 203, 71, 0.08); }
.gp.me .nm { color: var(--acc); }
.gp .pen { width: 16px; height: 16px; color: var(--acc2); vertical-align: -2px; }
.gp .plus { position: absolute; right: 8px; top: -8px; background: var(--acc); color: #06210f; font-weight: 800; font-size: 12px; padding: 1px 7px; border-radius: 999px; animation: pop 0.4s ease-out; }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } }
.stage { display: flex; flex-direction: column; gap: 10px; min-height: 0; min-width: 0; }
.wordbar { flex: none; display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: var(--s1); border: 1px solid var(--line); border-radius: 12px; min-height: 58px; }
.timer { flex: none; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 17px; border: 3px solid var(--acc); font-variant-numeric: tabular-nums; }
.timer.low { border-color: var(--bad); color: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }
.word { flex: 1; text-align: center; font-size: 22px; font-weight: 700; letter-spacing: 0.04em; min-width: 0; }
.word .mask { font-family: ui-monospace, Consolas, monospace; letter-spacing: 0.35em; font-size: 24px; white-space: pre-wrap; }
.word .len { font-size: 13px; color: var(--dim); letter-spacing: 0; font-weight: 500; margin-left: 6px; }
.word .draw { color: var(--acc2); } .word small { display: block; font-size: 12px; font-weight: 500; color: var(--dim); letter-spacing: 0; }
.goal { flex: none; font-size: 12px; text-align: right; }
.canvasWrap { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
#cv { background: #fff; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); touch-action: none; display: block; }
#cv.can { cursor: crosshair; }
.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; pointer-events: none; }
.overlay > div { pointer-events: auto; background: rgba(15, 18, 24, 0.92); border: 1px solid var(--line2); border-radius: 16px; padding: 18px 20px; text-align: center; max-width: 520px; width: 100%; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); }
.overlay h3 { font-size: 20px; margin-bottom: 6px; } .overlay .big { font-size: 30px; font-weight: 800; color: var(--acc); margin: 6px 0; }
.opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.opt { padding: 14px 8px; border-radius: 12px; background: var(--s2); border: 1px solid var(--line2); font-weight: 700; font-size: 17px; display: flex; flex-direction: column; gap: 4px; align-items: center; }
.opt:hover { border-color: var(--acc); background: var(--s3); }
.opt small { font-weight: 600; font-size: 12px; color: var(--acc2); }
.tools { flex: none; display: flex; align-items: center; gap: 12px; padding: 8px 10px; background: var(--s1); border: 1px solid var(--line); border-radius: 12px; flex-wrap: wrap; justify-content: center; }
.palette { display: flex; flex-wrap: wrap; gap: 5px; max-width: 330px; justify-content: center; }
.sw { width: 28px; height: 28px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.15); }
.sw.on { outline: 3px solid var(--acc); outline-offset: 2px; }
.sizes { display: flex; gap: 4px; }
.sz { width: 38px; height: 38px; border-radius: 10px; background: var(--s2); display: grid; place-items: center; }
.sz i { display: block; border-radius: 50%; background: var(--text); }
.sz.on { background: var(--s3); outline: 2px solid var(--acc); }
.toolBtns { display: flex; gap: 4px; }
.tbtn { width: 40px; height: 40px; border-radius: 10px; background: var(--s2); display: grid; place-items: center; }
.tbtn svg { width: 20px; height: 20px; } .tbtn:hover { background: var(--s3); } .tbtn.on { outline: 2px solid var(--acc); background: var(--s3); }
.tbtn.warn { color: var(--bad); }
.gameChat { min-height: 0; }

/* ---------- модалки, тости ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(5, 7, 12, 0.72); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal .card { max-height: 100%; overflow-y: auto; }
.rules p { margin: 0; line-height: 1.5; } .rules b { color: var(--acc); }
.trophy { font-size: 46px; text-align: center; } #mOver h2 { text-align: center; }
.rank { display: flex; flex-direction: column; gap: 6px; }
.rank .rr { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 11px; background: var(--s2); }
.rank .rr.first { background: rgba(255, 203, 71, 0.12); border: 1px solid rgba(255, 203, 71, 0.4); }
.rank .rr i { font-style: normal; width: 20px; color: var(--dim); font-weight: 700; } .rank .rr span { flex: 1; } .rank .rr b { font-size: 18px; }
#toasts { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast { padding: 9px 16px; border-radius: 12px; background: var(--s3); border: 1px solid var(--line2); font-size: 14px; font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); animation: pop 0.25s ease-out; max-width: 90vw; text-align: center; }
.toast.good { border-color: var(--acc); }

/* ---------- телефон / вузько ---------- */
@media (max-width: 1100px) { .gameGrid { grid-template-columns: 180px minmax(0, 1fr) 270px; } }
@media (max-width: 900px) {
    .top { padding: 8px 10px; gap: 8px; } .back span { display: none; } .brand { font-size: 17px; } .brand svg { width: 28px; height: 28px; }
    .roomGrid { grid-template-columns: 1fr; height: auto; } .chatCard { min-height: 280px; }
    .settings .srow { grid-template-columns: 1fr 1fr; }
    #scrGame { overflow-y: auto; }
    .gameGrid { display: flex; flex-direction: column; height: auto; min-height: 100%; padding: 8px; gap: 8px; }
    .players { flex-direction: row; overflow-x: auto; flex: none; order: 2; padding-bottom: 2px; }
    .gp { flex: none; padding: 6px 9px; } .gp .av { width: 26px; height: 26px; font-size: 13px; } .gp .sc { font-size: 15px; }
    .stage { order: 1; } .canvasWrap { flex: none; }
    .gameChat { order: 3; min-height: 230px; flex: 1; }
    .word { font-size: 18px; } .word .mask { font-size: 19px; letter-spacing: 0.25em; }
    .opts { grid-template-columns: 1fr; } .opt { flex-direction: row; justify-content: space-between; padding: 12px 14px; }
    .tools { gap: 8px; } .sw { width: 26px; height: 26px; }
    .goal { display: none; }
}
@media (max-width: 520px) { .mechip { display: none; } .ghost { padding: 7px 10px; } }
