@font-face { font-family: 'Lalezar'; src: url('../fonts/Lalezar-Regular.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Cairo'; src: url('../fonts/Cairo.ttf') format('truetype'); font-weight: 200 900; font-display: swap; }

:root {
  --bg: #0B0E14; --card: #111826; --card2: #0F1420; --border: #273043; --border2: #3A4458;
  --gold: #E3B341; --gold-l: #F6D77A; --gold-d: #A87B1C; --gold-bg: #15110A; --gold-border: #5C4A1A;
  --red: #E8463A; --red-l: #FF8A7A; --red-bg: #1A0F10; --red-border: #7A2A22;
  --blue: #5FB3F5; --blue-l: #7CC4FF; --blue-bg: #0E1724; --blue-border: #1F4D73;
  --purple: #C86BFA; --purple-l: #D89BFF; --purple-bg: #180F24; --purple-border: #5E2F7A;
  --ice: #9ED3FF; --text: #F2EFE6; --text2: #D5DAE3; --muted: #9AA3B2; --muted2: #6F7889;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: 'Cairo', system-ui, sans-serif; }
body { background: radial-gradient(ellipse 90% 40% at 50% 0%, #1A2340 0%, var(--bg) 70%) fixed; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body.night { background: radial-gradient(ellipse 90% 35% at 50% 0%, #141A33 0%, #07090F 70%) fixed; }
body.day { background: radial-gradient(ellipse 90% 38% at 50% 0%, #2A2410 0%, var(--bg) 70%) fixed; }
a { color: var(--gold); }
button, input { font-family: inherit; }

.screen { position: relative; max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; padding: 40px 20px 28px; display: flex; flex-direction: column; gap: 14px; }
.screen .top, .screen .view { display: flex; flex-direction: column; gap: 14px; }
.screen .view { flex: 1; }
.screen .top:empty { display: none; }
.corner { position: absolute; width: 34px; height: 34px; pointer-events: none; border-color: #C9A035; border-style: solid; border-width: 0; }
.corner.tr { top: 14px; right: 14px; border-top-width: 2px; border-right-width: 2px; }
.corner.tl { top: 14px; left: 14px; border-top-width: 2px; border-left-width: 2px; }
.corner.br { bottom: 14px; right: 14px; border-bottom-width: 2px; border-right-width: 2px; }
.corner.bl { bottom: 14px; left: 14px; border-bottom-width: 2px; border-left-width: 2px; }

.display { font-family: 'Lalezar', 'Cairo', sans-serif; line-height: 1; }
.gold-text { background: linear-gradient(180deg, #F8DF8E 0%, var(--gold) 50%, var(--gold-d) 100%); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent; }
.title-row { display: flex; align-items: center; justify-content: center; gap: 10px; }
.title-row .line { height: 1px; flex: 1; background: linear-gradient(90deg, transparent, #C9A035); }
.title-row .line.r { background: linear-gradient(90deg, #C9A035, transparent); }
.divider { display: flex; align-items: center; gap: 10px; }
.divider span { height: 1px; flex: 1; background: #223047; }
.diamond { width: 7px; height: 7px; background: var(--gold); transform: rotate(45deg); flex: none; }

.logo { width: 108px; height: 108px; border-radius: 50%; border: 3px solid var(--gold); box-shadow: 0 0 44px rgba(227,179,65,.28), inset 0 0 28px rgba(227,179,65,.14); background: radial-gradient(circle at 50% 35%, #2A3352 0%, #0D1220 72%); display: flex; align-items: center; justify-content: center; margin: 0 auto; }
.ring { width: 116px; height: 116px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto; border: 3px solid var(--blue); box-shadow: 0 0 34px rgba(95,179,245,.35); background: radial-gradient(circle at 50% 35%, #1C3454 0%, #0C1424 72%); }
.ring.mafia { border-color: var(--red); box-shadow: 0 0 34px rgba(232,70,58,.35); background: radial-gradient(circle at 50% 35%, #3A1612 0%, #140A0A 72%); }
.ring.special { border-color: var(--purple); box-shadow: 0 0 34px rgba(200,107,250,.35); background: radial-gradient(circle at 50% 35%, #2E1A44 0%, #130B1C 72%); }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.card.gold { background: linear-gradient(180deg, #15120C 0%, var(--card2) 100%); border-color: #3B3220; }
.card.mafia { border-color: var(--red-border); background: linear-gradient(180deg, var(--red-bg) 0%, var(--bg) 100%); box-shadow: 0 0 28px rgba(232,70,58,.12); }
.card.good { border-color: #2D6A9F; background: linear-gradient(180deg, #0F1A2A 0%, var(--bg) 100%); box-shadow: 0 0 28px rgba(95,179,245,.12); }
.card.special { border-color: var(--purple-border); background: linear-gradient(180deg, var(--purple-bg) 0%, var(--bg) 100%); box-shadow: 0 0 28px rgba(200,107,250,.12); }
.card.info { background: var(--blue-bg); border-color: var(--blue-border); color: var(--text2); font-size: 14px; line-height: 1.6; }
.card.warn { background: var(--gold-bg); border-color: var(--gold-border); color: var(--gold); font-size: 13px; }
.card h3 { margin: 0; font-size: 15px; color: var(--gold); }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; color: var(--muted2); }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.ltr { direction: ltr; unicode-bidi: isolate; }

label { font-size: 14px; color: #C9CFDA; font-weight: 600; }
input[type=text] { width: 100%; height: 48px; border-radius: 12px; border: 1px solid var(--border2); background: #0C1019; color: var(--text); padding: 0 16px; font-size: 16px; }
input.code { height: 52px; border-color: var(--gold); color: var(--gold-l); font-family: 'Lalezar', sans-serif; font-size: 26px; letter-spacing: 8px; text-align: center; text-transform: uppercase; }
input[type=number] { width: 70px; height: 40px; border-radius: 10px; border: 1px solid var(--border2); background: #0C1019; color: var(--text); padding: 0 10px; font-size: 16px; text-align: center; }

.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 52px; border-radius: var(--radius); border: 0; font-weight: 700; font-size: 17px; cursor: pointer; text-decoration: none; }
.btn.primary { background: linear-gradient(180deg, #F1C957 0%, #D9A62E 100%); color: #15110A; box-shadow: 0 6px 18px rgba(227,179,65,.25); }
.btn.outline { background: transparent; border: 1px solid var(--gold); color: var(--gold); font-weight: 600; font-size: 16px; }
.btn.danger { background: transparent; border: 1px solid var(--red-border); color: var(--red-l); font-weight: 600; font-size: 16px; }
.btn.blue { background: transparent; border: 1px solid var(--blue-border); color: var(--blue-l); font-weight: 600; font-size: 16px; }
.btn.sm { height: 40px; font-size: 14px; width: auto; padding: 0 16px; }
.sound-toggle { width: 40px; height: 40px; padding: 0; flex: none; border-radius: 50%; }
.sound-toggle.muted { color: var(--muted); border-color: var(--border2); }
.host-heading .sound-toggle { margin-right: auto; margin-left: 8px; }
.btn[disabled] { background: #141925; border: 1px solid var(--border2); color: var(--muted2); box-shadow: none; cursor: not-allowed; }

.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border2); background: #141925; border-radius: 999px; padding: 4px 12px; font-size: 12px; color: #C9CFDA; white-space: nowrap; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }
.chip.gold { border-color: var(--gold); background: var(--gold-bg); color: var(--gold-l); }
.chip.red { border-color: var(--red-border); background: var(--red-bg); color: var(--red-l); }
.chip.blue { border-color: var(--blue-border); background: var(--blue-bg); color: var(--blue-l); }
.chip.purple { border-color: var(--purple-border); background: var(--purple-bg); color: var(--purple-l); }
.chip.ice { border-color: #2E5F7A; background: #0E1A24; color: var(--ice); }
.chip.dim { color: var(--muted2); text-decoration: line-through; }

.avatar { width: 34px; height: 34px; border-radius: 50%; background: #1C2740; border: 1px solid #3A4A6A; display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--gold); flex: none; font-size: 14px; }
.avatar.dead { background: #141925; border-color: var(--border2); color: var(--muted2); }
.list { display: flex; flex-direction: column; gap: 8px; }
.list-btn { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--card); color: var(--text); text-align: right; cursor: pointer; font-size: 15px; font-weight: 600; }
.list-btn.selected { border-color: var(--gold); background: #1C1A12; box-shadow: inset 0 0 0 1px var(--gold); }
.list-btn[disabled] { opacity: .45; cursor: not-allowed; }
.list-btn .name { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.list-btn .sub { font-size: 11px; color: var(--muted); font-weight: 400; }
.bar { width: 100%; height: 4px; border-radius: 2px; background: #1C2233; overflow: hidden; }
.bar > div { height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--gold-d), var(--gold-l)); }
.count { font-family: 'Lalezar', sans-serif; font-size: 22px; color: var(--gold); min-width: 22px; text-align: left; line-height: 1; }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.pchip { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 0 10px; height: 48px; font-size: 14px; font-weight: 600; min-width: 0; }
.pchip .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pchip.off { opacity: .5; }

.timer { width: 150px; height: 150px; border-radius: 50%; border: 3px solid var(--gold); box-shadow: 0 0 36px rgba(227,179,65,.22), inset 0 0 24px rgba(227,179,65,.1); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; margin: 8px auto; background: radial-gradient(circle, #1A1A12 0%, var(--bg) 75%); }
.timer .t { font-family: 'Lalezar', sans-serif; font-size: 44px; line-height: 1; color: var(--gold-l); }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.phase { font-family: 'Lalezar', sans-serif; font-size: 34px; line-height: 1; }
.toast { position: fixed; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); background: var(--red-bg); border: 1px solid var(--red-border); color: var(--red-l); padding: 10px 18px; border-radius: 12px; font-size: 14px; z-index: 50; max-width: 90%; text-align: center; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.toast.ok { background: var(--blue-bg); border-color: var(--blue-border); color: var(--blue-l); }
.modal { position: fixed; inset: 0; background: rgba(5,7,12,.86); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 40; }
.modal > div { width: 100%; max-width: 440px; }
.exit-card { display: flex; align-items: center; gap: 14px; }
.exit-card .who { display: flex; flex-direction: column; gap: 3px; }
.exit-card .nm { font-family: 'Lalezar', sans-serif; font-size: 28px; line-height: 1; }
.dev { font-size: 12px; }
.dev a { text-decoration: none; }

/* المشرف */
.host { max-width: 1280px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.host-header { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; width: 100%; height: auto; flex-shrink: 0; padding: 14px 24px; border-bottom: 1px solid #223047; background: linear-gradient(180deg, #121A2B 0%, var(--bg) 100%); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; }
.host-heading { flex: 1 1 220px; min-width: 0; }
.host-heading .logo { flex: none; }
.host-heading .stack { min-width: 0; }
.host-heading .display { line-height: 1.25; }
.host-controls { display: flex; flex: 0 1 auto; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; max-width: 100%; }
.host-controls .btn { flex-shrink: 0; height: auto; min-height: 44px; max-width: 100%; padding: 8px 16px; white-space: normal; line-height: 1.5; text-align: center; }
.host-controls .chip { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.host .body { display: flex; flex-wrap: wrap; gap: 20px; padding: 18px 24px 28px; }
.host .main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.host .side { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.tablebox { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card2); }
table { width: 100%; min-width: 680px; border-collapse: collapse; font-size: 14px; }
th { padding: 10px 12px; font-weight: 600; font-size: 12px; color: var(--muted); border-bottom: 1px solid #223047; text-align: right; }
td { padding: 8px 12px; border-bottom: 1px solid #1A2232; vertical-align: middle; }
tr.dead td { color: var(--muted2); }
.rolechip { display: inline-flex; border-radius: 999px; padding: 2px 10px; font-size: 12px; border: 1px solid var(--border2); background: #141925; color: #C9CFDA; }
.rolechip.mafia { border-color: var(--red-border); background: var(--red-bg); color: var(--red-l); }
.rolechip.good { border-color: var(--blue-border); background: var(--blue-bg); color: var(--blue-l); }
.rolechip.special { border-color: var(--purple-border); background: var(--purple-bg); color: var(--purple-l); }
.log { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card2); max-height: 420px; overflow: auto; display: flex; flex-direction: column-reverse; }
.log div { display: flex; gap: 10px; padding: 8px 14px; border-bottom: 1px solid #1A2232; font-size: 13px; }
.log .t { color: var(--muted2); font-family: 'Lalezar', sans-serif; flex: none; min-width: 60px; }
.log .secret { color: var(--gold); }
.stat { flex: 1 1 160px; border-radius: 12px; padding: 10px 14px; display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--border); background: var(--card); }
.stat .v { font-family: 'Lalezar', sans-serif; font-size: 28px; line-height: 1; }
.qr { width: 160px; height: 160px; border-radius: 12px; border: 1px solid var(--gold); background: var(--text); padding: 6px; }
.cfg { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.cfg label { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px; font-size: 13px; }
@media (max-width: 600px) {
  .host-header { padding: 12px 14px; }
  .host-heading { flex-basis: 100%; }
  .host-controls { width: 100%; }
  .host-controls .btn { flex: 1 1 160px; }
  .host .body { padding: 14px; }
  .screen { padding: 34px 16px 24px; }
}
