/* База: отступы и скрытие через атрибут hidden */
body { margin: 0; }
[hidden] { display: none !important; }
img { max-width: 100%; }

  /* Клуб всегда ночью: одна тёмная тема из палитры «Бардовской летописи». */
  :root {
    color-scheme: dark;
    --night: #0b1020;
    --ground: #121a33;
    --raised: #1a2446;
    --lapis: #2e4a8f;
    --ink: #ece6d6;
    --ink-muted: #a8aec2;
    --gilt: #d4af5a;
    --on-gilt: #121a33;
    --rubric: #e0674c;
    --rule: #2c3861;
    --ui: "Golos Text", "PT Sans", system-ui, sans-serif;
    --serif: Alegreya, Georgia, "Times New Roman", serif;
  }
  html, body { height: 100%; }
  body { background: var(--night); color: var(--ink); font: 400 15px/1.5 var(--ui); display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; }
  button, input { font: inherit; color: inherit; }
  :where(a, button, input, canvas, [tabindex]):focus-visible { outline: 2px solid var(--gilt); outline-offset: 2px; }

  .topbar { position: relative; display: flex; align-items: center; gap: 10px 20px; padding: 8px 16px; background: var(--ground); border-bottom: 2px solid var(--rule); min-width: 0; }
  .brand { display: grid; gap: 2px; font: 700 17px/1.15 var(--ui); color: var(--gilt); white-space: nowrap; }
  .brand img { display: block; width: 150px; height: auto; }
  .brand small { display: block; font: 400 12px/1.3 var(--ui); color: var(--ink-muted); }
  .places { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; padding-block: 3px; min-width: 0; }
  .places button { white-space: nowrap; background: var(--raised); border: 1px solid var(--rule); padding: 4px 10px; cursor: pointer; font-size: 14px; }
  .places button:hover { border-color: var(--gilt); }
  .places button.me { border-color: var(--gilt); color: var(--gilt); }

  .online { display: inline-flex; align-items: center; gap: 7px; background: none; border: 0; padding: 4px 6px; font-size: 13px; color: var(--ink-muted); white-space: nowrap; cursor: pointer; }
  .online:hover { color: var(--ink); }
  .online .dot { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--ink-muted); flex: none; }
  .online.live .dot { background: #5bbf6a; border-color: #5bbf6a; box-shadow: 0 0 0 3px rgba(91, 191, 106, 0.2); }
  .online.live { color: var(--ink); }
  .online-short { display: none; align-items: center; gap: 4px; }
  .tabs { display: flex; gap: 2px; }
  .tabs [role="tab"] { background: none; border: 0; border-bottom: 2px solid transparent; padding: 4px 8px; cursor: pointer; font: 600 14px/1.3 var(--ui); color: var(--ink-muted); }
  .tabs [aria-selected="true"] { color: var(--gilt); border-bottom-color: var(--gilt); }
  .pane { display: flex; flex-direction: column; flex: 1; min-height: 0; }
  .chat-alone { margin: 8px 14px 0; padding: 8px 10px; background: var(--raised); font-size: 13px; color: var(--ink-muted); }
  .guest-list { list-style: none; margin: 0; padding: 8px 14px; overflow-y: auto; display: grid; gap: 2px; }
  .guest-list li { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--rule); font-size: 14px; }
  .guest-list .dot { width: 8px; height: 8px; border-radius: 50%; background: #5bbf6a; }
  .guest-list .away .dot { background: none; border: 1.5px solid var(--ink-muted); }
  .guest-list .where { display: block; font-size: 12px; color: var(--ink-muted); }
  .guest-list .away b { color: var(--ink-muted); }
  .guest-list .btn { padding: 2px 10px; font-size: 13px; }
  .lbl.guest { color: var(--ink); }
  .lang-btn { background: none; border: 1px solid var(--rule); color: var(--ink-muted); padding: 5px 10px; cursor: pointer; font-weight: 600; min-height: 34px; }
  .lang-btn:hover { color: var(--ink); border-color: var(--gilt); }
  .lang-switch { display: flex; gap: 6px; }
  .lang-switch [aria-pressed="true"] { border-color: var(--gilt); color: var(--gilt); }
  .account-btn { margin-left: auto; background: none; border: 1px solid var(--gilt); color: var(--gilt); padding: 5px 12px; cursor: pointer; white-space: nowrap; min-height: 34px; }
  .account-btn:hover { background: var(--raised); }
  .intro-options .btn { padding: 12px 14px; font-size: 16px; }
  .menu-btn { display: none; align-items: center; gap: 8px; background: var(--raised); border: 1px solid var(--rule); padding: 6px 12px; cursor: pointer; margin-left: auto; min-height: 40px; }
  .menu-btn[aria-expanded="true"] { border-color: var(--gilt); color: var(--gilt); }

  /* Чат клуба: выдвижная панель справа, сворачивается в иконку посередине правого края */
  .chat-drawer { position: absolute; top: 12px; right: 12px; bottom: 12px; width: min(300px, calc(100% - 24px)); display: flex; flex-direction: column; background: rgba(18, 26, 51, 0.94); border: 1px solid var(--rule); z-index: 4; }
  .chat-drawer header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px 8px 14px; border-bottom: 1px solid var(--rule); }
  .chat-drawer h2 { margin: 0; font: 600 15px/1.3 var(--ui); color: var(--gilt); }
  .chat-drawer .btn { padding: 3px 10px; font-size: 13px; }
  .chat-list { list-style: none; margin: 0; padding: 8px 14px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 6px; font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }
  .chat-list b { color: var(--gilt); font-weight: 600; }
  .chat-list .mine b { color: var(--ink); }
  .chat-list time { color: var(--ink-muted); font-size: 12px; margin-right: 6px; font-variant-numeric: tabular-nums; }
  .chat-list .keeper b { color: #e8c56a; }
  .chat-list .keeper { background: rgba(212, 175, 90, 0.08); margin-inline: -6px; padding-inline: 6px; }
  .chat-list .sys { color: var(--rubric); }
  .chat-empty { margin: 0; padding: 0 14px 14px; font-size: 13px; color: var(--ink-muted); }
  .chat-toggle { position: absolute; right: 0; top: 50%; transform: translateY(-50%); width: 46px; height: 58px; display: grid; place-items: center; background: var(--ground); color: var(--gilt); border: 1px solid var(--gilt); border-right: 0; cursor: pointer; z-index: 4; }
  .chat-toggle:hover { background: var(--raised); }
  .chat-toggle .badge { position: absolute; top: 4px; left: 4px; min-width: 18px; height: 18px; padding: 0 4px; background: var(--rubric); color: var(--night); font: 700 11px/18px var(--ui); text-align: center; }
  .stage { position: relative; min-height: 0; overflow: hidden; }
  #game { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; display: block; }
  #labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
  .lbl { position: absolute; left: 0; top: 0; white-space: nowrap; font: 500 12px/1.25 var(--ui); padding: 1px 6px; background: rgba(11, 16, 32, 0.78); color: var(--ink-muted); will-change: transform; }
  .lbl.sign { color: var(--gilt); font-weight: 600; font-size: 13px; }
  .lbl.me { color: var(--ink); font-weight: 600; }
  .lbl.npc-ai { color: var(--gilt); }
  .lbl.hover { color: var(--gilt); font-weight: 600; background: rgba(11, 16, 32, 0.92); font-size: 13px; }
  .lbl.prompt { background: var(--gilt); color: var(--on-gilt); font-weight: 600; font-size: 13px; }
  .lbl.bubble { background: var(--ink); color: var(--night); font-size: 14px; white-space: normal; width: max-content; max-width: 220px; padding: 4px 8px; }
  .zoom { position: absolute; left: 12px; bottom: 12px; display: grid; gap: 4px; z-index: 3; }
  .zoom button { width: 34px; height: 34px; background: var(--ground); border: 1px solid var(--rule); cursor: pointer; font-size: 18px; line-height: 1; }
  .zoom button:hover { border-color: var(--gilt); }

  .bottombar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding: 8px 16px calc(8px + env(safe-area-inset-bottom, 0px)); background: var(--ground); border-top: 2px solid var(--rule); }
  .chat { display: flex; gap: 6px; flex: 1 1 320px; min-width: 0; }
  .chat input { flex: 1; min-width: 0; background: var(--night); border: 1px solid var(--rule); padding: 5px 9px; }
  .chat input:focus { border-color: var(--gilt); outline: none; }
  .btn { background: var(--raised); border: 1px solid var(--rule); padding: 5px 12px; cursor: pointer; }
  .btn:hover { border-color: var(--gilt); }
  .btn-gilt { background: var(--gilt); color: var(--on-gilt); border-color: var(--gilt); font-weight: 600; }
  .btn-gilt:hover { filter: brightness(1.08); }
  .btn[disabled] { opacity: 0.5; cursor: not-allowed; }
  .hint { font-size: 13px; color: var(--ink-muted); flex: 1 1 380px; margin: 0; }
  .hint kbd { font: inherit; color: var(--ink); border: 1px solid var(--rule); padding: 0 4px; }

  .panel { position: absolute; top: 12px; left: 12px; bottom: 12px; width: min(440px, calc(100% - 24px)); background: var(--ground); border: 2px solid var(--gilt); box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.45); display: flex; flex-direction: column; z-index: 5; }
  .panel header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; background: var(--raised); border-bottom: 1px solid var(--rule); }
  .panel h2 { margin: 0; font: 700 19px/1.25 var(--ui); color: var(--gilt); }
  .panel .body { overflow-y: auto; padding: 14px; display: grid; gap: 14px; align-content: start; }
  .panel p { margin: 0; }
  .panel h3 { margin: 0; font: 600 16px/1.3 var(--ui); color: var(--gilt); }
  .say { background: var(--raised); border-left: 3px solid var(--gilt); padding: 10px 12px; }
  .say b { display: block; color: var(--gilt); font-weight: 600; }
  .options { display: grid; gap: 6px; }
  .options .btn { text-align: left; }
  .note { font-size: 13px; color: var(--ink-muted); }
  .reading { font: 400 19px/1.6 var(--serif); display: grid; gap: 12px; }
  .reading h3 { font: 700 24px/1.25 var(--serif); color: var(--ink); }
  .reading .first::first-letter { font: 800 64px/0.8 "Alegreya SC", var(--serif); color: var(--gilt); float: left; margin: 6px 8px 0 0; }
  .list { list-style: none; margin: 0; padding: 0; display: grid; }
  .list li { display: grid; grid-template-columns: 3.4em 1fr; gap: 10px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--rule); }
  .list .year { color: var(--rubric); font-weight: 600; font-variant-numeric: tabular-nums; }
  .list button { background: none; border: 0; padding: 0; text-align: left; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
  .list .sub { display: block; font-size: 13px; color: var(--ink-muted); }
  .discs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .disc { display: grid; gap: 2px; background: none; border: 1px solid transparent; padding: 4px; cursor: pointer; text-align: left; font-size: 13px; line-height: 1.3; align-content: start; }
  .disc:hover { border-color: var(--gilt); }
  .disc img, .album-head img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; image-rendering: auto; background: var(--raised); }
  .disc .year { color: var(--rubric); font-weight: 600; }
  .album-head { display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: end; }
  .album-head .year { color: var(--rubric); font-weight: 600; }
  .tracks { margin: 0; padding-left: 1.8em; display: grid; gap: 0; font-variant-numeric: tabular-nums; }
  .tracks li { padding: 4px 0; border-bottom: 1px solid var(--rule); }
  .tracks li::marker { color: var(--ink-muted); }
  .tracks li { display: list-item; }
  .tracks li > span:first-child { display: inline; }
  .tracks .dur { float: right; color: var(--ink-muted); margin-left: 12px; }
  .photos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .photos figure { margin: 0; background: var(--ink); padding: 6px 6px 8px; color: var(--on-gilt); font-size: 13px; line-height: 1.3; }
  .photos .ph { aspect-ratio: 4 / 3; background: var(--lapis); display: grid; place-items: center; color: var(--ink); font-size: 12px; margin-bottom: 6px; }
  .pager, .row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
  .row { justify-content: flex-start; }
  .members { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  fieldset { border: 1px solid var(--rule); margin: 0; padding: 8px 10px 10px; display: flex; flex-wrap: wrap; gap: 6px; }
  legend { padding: 0 4px; color: var(--ink-muted); font-size: 13px; }
  .swatch { position: relative; }
  .swatch input { position: absolute; opacity: 0; }
  .swatch > span { display: inline-block; min-width: 28px; height: 28px; border: 2px solid var(--rule); padding: 0 7px; line-height: 24px; font-size: 13px; cursor: pointer; }
  .swatch input:checked + span { border-color: var(--gilt); box-shadow: inset 0 0 0 2px var(--night); }
  .swatch input:focus-visible + span { outline: 2px solid var(--gilt); outline-offset: 2px; }
  .wardrobe { display: grid; grid-template-columns: 160px 1fr; gap: 14px; align-items: start; }
  .wardrobe-side { display: grid; gap: 10px; }
  #preview-holder { width: 160px; height: 210px; background: var(--night); border: 1px solid var(--rule); }
  #preview-holder canvas { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
  .field { display: grid; gap: 4px; }
  .field input { background: var(--night); border: 1px solid var(--rule); padding: 5px 9px; }
  .panel.modal { top: 50%; left: 50%; bottom: auto; right: auto; transform: translate(-50%, -50%); width: min(640px, calc(100% - 24px)); max-height: calc(100% - 24px); z-index: 30; box-shadow: 0 0 0 100vmax rgba(5, 8, 18, 0.6); }
  .save-block { display: grid; gap: 8px; border: 1px solid var(--gilt); padding: 12px; }
  .panel.wide { width: min(720px, calc(100% - 24px)); }
  .reading.history h1 { font: 800 26px/1.2 "Alegreya SC", var(--serif); color: var(--gilt); margin: 0 0 8px; text-wrap: balance; }
  .reading .source { font: 400 13px/1.5 var(--ui); color: var(--ink-muted); border-top: 1px solid var(--rule); padding-top: 8px; }
  .panel .body a { color: var(--gilt); }
  .menu-extra { display: none; }
  .music-chip { position: absolute; left: 56px; bottom: 12px; z-index: 3; display: flex; background: var(--ground); border: 1px solid var(--gilt); }
  .music-chip button { background: none; border: 0; color: var(--gilt); padding: 6px 10px; cursor: pointer; font: 500 13px/1.3 var(--ui); }
  .music-chip button + button { border-left: 1px solid var(--rule); color: var(--ink); }
  .list .now { color: var(--gilt); font-size: 12px; font-weight: 600; margin-left: 6px; }
  .credit { margin: 0; font-size: 13px; color: var(--ink-muted); display: flex; flex-wrap: wrap; gap: 4px 14px; }
  .credit a { color: var(--ink-muted); text-underline-offset: 3px; }
  .credit a:hover { color: var(--gilt); }
  .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .fallback { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; }

  @media (max-width: 640px) {
    .topbar { flex-wrap: wrap; gap: 4px 12px; padding-block: 6px; }
    .brand { font-size: 15px; }
    .brand img { width: 120px; }
    /* На телефоне в шапке только логотип и меню: остальное внутри меню */
    .online, .lang-btn, .account-btn, .credit { display: none; }
    .menu-btn { display: inline-flex; }
    .menu-extra { display: grid; gap: 4px; margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--rule); }
    .menu-extra button { display: flex; align-items: center; gap: 8px; }
    .menu-extra .dot { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--ink-muted); flex: none; }
    .menu-extra .live .dot { background: #5bbf6a; border-color: #5bbf6a; }
    .menu-credit { margin: 6px 12px 0; font-size: 13px; }
    .menu-credit a { color: var(--ink-muted); }
    .places { display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; gap: 4px; padding: 8px 12px 12px; background: var(--ground); border-bottom: 2px solid var(--gilt); z-index: 20; max-height: 70vh; overflow-y: auto; }
    .places.open { display: flex; }
    .places button { text-align: left; font-size: 16px; padding: 10px 12px; min-height: 44px; }
    .chat-drawer { top: 8px; right: 8px; bottom: 8px; width: auto; left: 8px; }
    .panel { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 72%; }
    .hint { display: none; }
    .wardrobe { grid-template-columns: 1fr; justify-items: center; }
    .panel.modal { top: 8px; left: 8px; right: 8px; bottom: 8px; transform: none; width: auto; max-height: none; }
  }
