:root {
  color-scheme: dark;
  --bg: #100e16;
  --panel: #1a1623;
  --surface: #1d1827;
  --field: #14111b;
  --border: #342d41;
  --foreground: #f8f6fb;
  --muted: #b4abbe;
  --subtle: #8e849c;
  --lime: #d0fa62;
  --violet: #d2baff;
  --danger: #ff9bae;
  --radius: 17px;
  font-family: Inter, 'Segoe UI', Arial, sans-serif;
  font-synthesis: none;
  line-height: 1.5;
  color: var(--foreground);
  background: var(--bg);
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 300px; min-height: 100vh; display: flex; flex-direction: column; }
body > main { flex: 1; }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { color: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, canvas:focus-visible { outline: 2px solid var(--lime); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
.shell { width: min(1224px, calc(100% - 80px)); margin-inline: auto; }
.site-header { border-bottom: 1px solid #24202d; }
.header-inner { min-height: 72px; display: flex; align-items: center; gap: 49px; }
.brand { display: inline-flex; gap: 10px; align-items: center; font-size: 25px; font-weight: 850; letter-spacing: -.065em; line-height: 1; }
.brand-mark { display: grid; place-items: center; border-radius: 11px; width: 36px; height: 36px; color: #201629; background: var(--lime); }
.brand-mark .icon { width: 23px; height: 23px; }
.brand-period { color: var(--lime); }
.header-inner nav { display: flex; align-self: stretch; gap: 28px; }
.header-inner nav a, .header-inner nav button { position: relative; display: flex; align-items: center; border: 0; padding: 0 2px; background: transparent; color: var(--muted); font-size: .9375rem; font-weight: 630; }
.header-inner nav .nav-active, .header-inner nav a:hover, .header-inner nav button:hover { color: var(--foreground); }
.header-inner nav .nav-active::after { content: ''; height: 2px; background: var(--lime); position: absolute; inset: auto 0 -1px; border-radius: 5px; }
.profile-toggle { margin-left: auto; }
.icon { display: inline-block; width: 18px; height: 18px; flex: none; vertical-align: -.22em; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[data-icon] { flex: none; }
.button { min-height: 43px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 15px; border-radius: 10px; border: 1px solid transparent; background: var(--surface); font-size: .9375rem; font-weight: 710; line-height: 1.2; text-align: center; transition: background .15s, border-color .15s, color .15s; }
.button-quiet { background: transparent; border-color: var(--border); color: var(--muted); }
.button-quiet:hover, .button-secondary:hover { border-color: #786789; color: var(--foreground); background: #2a2237; }
.button-primary { background: var(--lime); border-color: var(--lime); color: #1c2112; }
.button-primary:hover { background: #e2ff9d; border-color: #e2ff9d; }
.button-secondary { background: #20182d; border-color: #4a3a5d; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.lead { display: grid; grid-template-columns: minmax(0, 2.48fr) minmax(270px, 1fr); gap: 16px; margin-top: 29px; }
.hero { position: relative; isolation: isolate; display: flex; align-items: center; min-height: 352px; overflow: hidden; border: 1px solid #3b2a50; border-radius: var(--radius); background: #1a1128; }
.hero-art { z-index: -1; position: absolute; inset: 0 0 0 33%; background: url('/art/dice.webp') center right / cover no-repeat; -webkit-mask-image: linear-gradient(to right,transparent,#000 27%); mask-image: linear-gradient(to right,transparent,#000 27%); }
.hero-content { padding: 33px 36px 35px; position: relative; }
.eyebrow { color: var(--violet); font-size: .75rem; font-weight: 780; letter-spacing: .11em; text-transform: uppercase; }
.spark { color: var(--lime); font-size: 1.125rem; margin-right: 6px; vertical-align: -.05em; }
.hero h1 { font-size: clamp(3.38rem, 5.55vw, 5.1rem); font-weight: 850; letter-spacing: -.082em; line-height: .95; margin-top: 12px; }
.hero h1 em { font-style: normal; color: var(--lime); }
.hero-description { color: #e0d8e9; margin-top: 15px; max-width: 345px; font-size: 1rem; line-height: 1.5; }
.hero .button-row { margin-top: 23px; }
.hero .button { min-height: 45px; padding-inline: 14px; }
.join-panel { padding: 27px; border-radius: var(--radius); background: radial-gradient(ellipse at 6% -5%,#302443 0%,var(--panel) 65%); border: 1px solid #3c304a; display: flex; flex-direction: column; justify-content: center; }
.number-icon { display: grid; place-items: center; width: 47px; height: 47px; color: #d0b4fd; background: #382755; border: 1px solid #563b7b; border-radius: 13px; }
.number-icon .icon { width: 24px; height: 24px; }
.join-panel h2 { font-size: clamp(1.42rem,2.25vw,1.7rem); font-weight: 790; letter-spacing: -.045em; line-height: 1.14; margin-top: 17px; }
.join-panel p { color: var(--muted); font-size: 1rem; line-height: 1.4; margin-top: 8px; }
.join-panel form { display: grid; gap: 9px; margin-top: 21px; }
input, select { min-width: 0; width: 100%; background: var(--field); border: 1px solid var(--border); color: var(--foreground); border-radius: 9px; padding: 10px 12px; }
input::placeholder { color: var(--subtle); opacity: 1; }
.code-input { color: var(--foreground); font-family: Consolas, 'Courier New', monospace; font-weight: 700; text-align: center; letter-spacing: .18em; text-transform: uppercase; min-height: 48px; }
.code-input::placeholder { font-size: .875rem; }
.button-join { background: #ae84fa; color: #1a1027; border-color: #ae84fa; }
.button-join:hover { background: #ceb1ff; border-color: #ceb1ff; }
.catalog { margin-top: 35px; padding-bottom: 52px; scroll-margin-top: 22px; }
.catalog-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 17px; }
.catalog-heading h2 { font-size: clamp(1.85rem, 3vw, 2.35rem); letter-spacing: -.055em; line-height: 1.1; font-weight: 800; }
.catalog-heading p { margin-top: 6px; color: var(--muted); }
.search { position: relative; width: 253px; flex: none; }
.search > span:first-child { position: absolute; top: 50%; left: 13px; translate: 0 -50%; pointer-events: none; color: var(--subtle); }
.search input { height: 42px; background: #17131f; padding: 9px 13px 9px 39px; font-size: .875rem; }
.filters, .filter-selects, .genres { display: flex; align-items: center; gap: 7px; }
.filters { justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.genres { flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border); background: #191522; color: var(--muted); font-size: .875rem; font-weight: 660; white-space: nowrap; }
.chip .icon, .select-filter .icon { width: 15px; height: 15px; }
.chip:hover { border-color: #756185; color: var(--foreground); }
.chip[aria-pressed='true'] { color: var(--lime); background: #252d1b; border-color: #566536; }
.select-filter { flex: none; position: relative; display: grid; align-items: center; color: var(--muted); }
.select-filter select { appearance: none; height: 38px; font-size: .875rem; font-weight: 650; padding: 0 28px 0 31px; border-radius: 8px; color: inherit; background: #191522; }
.select-filter .filter-icon, .select-filter .chevron { position: absolute; pointer-events: none; }
.select-filter .filter-icon { left: 9px; }
.select-filter .chevron { right: 7px; }
.game-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 15px; }
.game-card { min-width: 0; display: flex; flex-direction: column; text-align: left; padding: 0; overflow: hidden; border: 1px solid #392f47; border-radius: 13px; background: var(--surface); color: var(--foreground); transition: border-color .16s, translate .16s; }
.game-card:hover { border-color: #a887d5; translate: 0 -3px; }
.cover { position: relative; width: 100%; aspect-ratio: 1.88; background: url('/art/games.webp') no-repeat; background-size: 200% 250%; }
.cover[data-cover='sketch'] { background-position: left 4%; }
.cover[data-cover='mafia'] { background-position: right 4%; }
.cover[data-cover='quiz'] { background-position: left 96%; }
.cover[data-cover='blocks'] { background-position: right 96%; }
.cover-badge { position: absolute; top: 10px; left: 10px; display: inline-flex; align-items: center; gap: 5px; padding: 4px 7px; border: 1px solid #ffffff3c; border-radius: 6px; background: #140c20e8; color: #faf5ff; font-size: .75rem; font-weight: 650; }
.cover-badge .icon { width: 13px; height: 13px; }
.card-body { display: flex; flex: 1; flex-direction: column; width: 100%; padding: 13px 14px 12px; }
.card-genre { color: var(--violet); font-size: .75rem; font-weight: 740; }
.game-card:nth-child(4n+1) .card-genre { color: #f3a9dc; }
.game-card:nth-child(4n+3) .card-genre { color: #ffd286; }
.game-card:nth-child(4n+4) .card-genre { color: #add9ff; }
.card-title { font-size: 1.3rem; font-weight: 790; letter-spacing: -.045em; line-height: 1.15; margin-top: 4px; }
.card-description { color: var(--muted); font-size: .875rem; margin-top: 6px; line-height: 1.4; }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding-top: 10px; margin-top: auto; color: #cbc2d4; font-size: .8125rem; font-weight: 630; }
.card-meta > span:first-child { display: inline-flex; align-items: center; gap: 6px; }
.card-meta .icon { width: 15px; height: 15px; }
.card-play { color: var(--lime); background: #303928; width: 32px; height: 30px; border-radius: 7px; display: grid; place-items: center; }
.game-card:hover .card-play { background: var(--lime); color: #1c2112; }
.site-footer { border-top: 1px solid #24202d; }
.footer-inner { display: flex; align-items: center; gap: 16px; justify-content: space-between; min-height: 64px; color: var(--subtle); font-size: .8125rem; }
.footer-brand { font-size: 1.125rem; font-weight: 800; letter-spacing: -.055em; color: var(--foreground); }
.muted { color: var(--muted); }
.sr-only { position: absolute; overflow: hidden; width: 1px; height: 1px; padding: 0; margin: -1px; clip-path: inset(50%); white-space: nowrap; }
.empty-grid { grid-column: 1 / -1; padding: 27px; border: 1px dashed var(--border); border-radius: 12px; color: var(--muted); }
.empty-grid .button { margin-top: 13px; }

dialog { width: min(470px,calc(100% - 28px)); max-height: calc(100% - 28px); padding: 0; border: 1px solid #554369; color: var(--foreground); background: var(--panel); border-radius: 17px; box-shadow: 0 15px 80px #0008; }
dialog.wide { width: min(720px,calc(100% - 28px)); }
dialog::backdrop { background: #0a0711b9; backdrop-filter: blur(4px); }
#dialog-content { padding: 25px; }
.dialog-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.dialog-head h2, .room-head h1 { letter-spacing: -.055em; line-height: 1.1; font-size: 2rem; }
.icon-button { padding: 0; min-height: 34px; width: 34px; }
.dialog-body { margin-top: 17px; }
.dialog-body > p { color: var(--muted); margin-bottom: 15px; }
.form { display: grid; gap: 13px; }
.form label { display: grid; gap: 5px; color: var(--muted); font-size: .875rem; font-weight: 650; }
.form .button { justify-self: start; }
.form-actions { margin-top: 4px; }
.error { color: var(--danger); line-height: 1.4; }
.toast { position: fixed; z-index: 2; bottom: 22px; right: 22px; max-width: min(380px,calc(100% - 44px)); border: 1px solid #59466f; border-radius: 11px; padding: 11px 16px; background: #241a34; box-shadow: 0 7px 24px #0005; }
.profile-id { display: block; font-family: Consolas, 'Courier New', monospace; color: var(--lime); margin-block: 6px 12px; overflow-wrap: anywhere; }
.admin-games { display: grid; gap: 10px; }
.admin-game { border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.admin-game h3 { margin-bottom: 8px; }
.admin-game form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.admin-game select, .admin-game input { min-width: 11rem; width: auto; flex: 1; }
.admin-game ul { padding: 0; margin: 8px 0 0; list-style: none; display: grid; gap: 6px; }
.admin-game li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); }
.admin-game li .button { min-height: 31px; }

.play-view { padding-block: 32px 55px; }
.back-button { margin-bottom: 16px; }
.room-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.room-head p { color: var(--muted); margin-top: 5px; }
.room-code { font-family: Consolas, 'Courier New', monospace; letter-spacing: .1em; color: var(--lime); }
.room-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(230px, 1fr); gap: 16px; align-items: start; }
.room-box { border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); padding: 23px; min-width: 0; }
.room-box h2 { letter-spacing: -.035em; line-height: 1.15; font-size: 1.5rem; }
.room-box p { margin-top: 8px; }
.room-box .button-row { margin-top: 16px; }
.room-box .error { margin-top: 8px; }
.player-list { padding: 0; margin: 10px 0 0; list-style: none; }
.player-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 39px; padding: 6px 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.player-list li:last-child { border-bottom: 0; }
.player-list small { color: var(--muted); }
.answer-list { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 15px; }
.answer-list .button { justify-content: start; min-height: 51px; text-align: left; }
.answer-list .correct { border-color: var(--lime); background: #2e3d20; color: var(--lime); }
.answer-list .selected { border-color: var(--violet); }
.answer-list .answer-result { opacity: 1; }
.sketch-canvas { display: block; width: 100%; aspect-ratio: 5 / 3; margin-top: 13px; background: #f9f2ff; border-radius: 9px; }
.sketch-canvas[data-draw] { touch-action: none; cursor: crosshair; }
.paint-color { width: 31px; height: 31px; border-radius: 50%; border: 2px solid var(--border); background: var(--paint); }
.paint-color[aria-pressed='true'] { border-color: var(--lime); }
.guess-form { display: flex; gap: 8px; margin-top: 12px; }
.recent-guesses { display: grid; gap: 4px; max-height: 130px; overflow: auto; color: var(--muted); overflow-wrap: anywhere; }
.recent-guesses p { margin-top: 0; }
.guess-list { margin-top: 12px; }
.block-game { max-width: 590px; margin-inline: auto; }
.score-row { display: flex; flex-wrap: wrap; gap: 15px; margin: 10px 0 15px; color: var(--muted); }
.score-row strong { color: var(--lime); }
.block-board { display: grid; grid-template-columns: repeat(8,minmax(0,1fr)); gap: 3px; padding: 6px; border: 1px solid var(--border); background: var(--field); border-radius: 10px; }
.block-cell { aspect-ratio: 1; min-width: 0; min-height: 0; padding: 0; border: 0; border-radius: 4px; background: var(--block,#292036); }
.block-cell[data-preview] { outline: 2px solid var(--lime); outline-offset: -2px; }
.block-tray { margin-top: 12px; display: flex; gap: 8px; }
.block-piece { width: 33.333%; min-height: 58px; padding: 5px; background: var(--field); border: 1px solid var(--border); border-radius: 8px; display: grid; place-items: center; }
.block-piece[aria-pressed='true'] { border-color: var(--lime); }
.piece-grid { display: grid; grid-template: repeat(3,10px) / repeat(3,10px); gap: 2px; }
.piece-grid span { background: var(--block); border-radius: 2px; }

@media (max-width: 1100px) {
  .shell { width: min(1224px,calc(100% - 48px)); }
  .filters { flex-wrap: wrap; }
  .hero-art { left: 25%; }
}
@media (max-width: 800px) {
  .shell { width: calc(100% - 32px); }
  .lead { grid-template-columns: minmax(0,1.3fr) minmax(225px,1fr); }
  .hero-content { padding-inline: 22px; }
  .hero h1 { font-size: clamp(2.6rem,8vw,4rem); }
  .hero-art { inset-inline: 5% 0; opacity: .68; mask-image: linear-gradient(to right,transparent,#000 85%); }
  .join-panel { padding: 19px; }
  .game-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .room-box { padding: 17px; }
}
@media (max-width: 565px) {
  .header-inner { gap: 12px; min-height: 60px; }
  .header-inner nav { margin-left: auto; gap: 10px; }
  .header-inner nav a, .header-inner nav button { font-size: .8125rem; }
  .brand { gap: 6px; font-size: 21px; }
  .brand-mark { width: 29px; height: 29px; border-radius: 8px; }
  .brand-mark .icon { width: 19px; height: 19px; }
  .profile-toggle { margin-left: 0; padding: 0 8px; min-height: 34px; }
  .profile-toggle > span:last-child { position: absolute; clip-path: inset(50%); }
  .lead { grid-template-columns: minmax(0,1fr); margin-top: 16px; gap: 11px; }
  .hero { min-height: 310px; }
  .hero-art { left: 13%; opacity: .63; }
  .hero-content { padding: 22px 17px; }
  .hero .button { min-height: 42px; font-size: .875rem; }
  .hero-description { max-width: 283px; }
  .join-panel { display: grid; grid-template-columns: 41px 1fr; gap: 6px 10px; }
  .number-icon { width: 41px; height: 41px; grid-row: 1 / 3; }
  .join-panel h2, .join-panel p, .join-panel form { margin: 0; }
  .join-panel form { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; margin-top: 9px; }
  .code-input { min-height: 42px; }
  .catalog { margin-top: 27px; }
  .catalog-heading { align-items: start; flex-direction: column; gap: 10px; margin-bottom: 12px; }
  .search { width: 100%; }
  .filters { gap: 8px; }
  .game-grid { gap: 9px; }
  .card-body { padding: 9px; }
  .card-title { font-size: 1.16rem; }
  .card-description { font-size: .8125rem; }
  .cover-badge { top: 6px; left: 6px; font-size: .6875rem; }
  .room-layout { grid-template-columns: minmax(0,1fr); }
  .room-head { align-items: start; flex-direction: column; }
  .answer-list { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; scroll-behavior: auto !important; }
}
