/* Вікно Time Town. Айдентика та сама, що у вікні Мафії: ніч кольору індиго, латунь, тепле світло ліхтаря. */
:root {
  --bg: #0F1220; --card: #171B2B; --inset: #121626; --line: #272C40; --line2: #1F2436; --chip: #262B40;
  --text: #ECE7DA; --muted: #9A95A3; --soft: #C9C3B8; --gold: #E2BE6A; --gold2: #F2D28E; --goldbg: #262019;
  --green: #7FC9A0; --ink: #1A1407; --night: #8FB2F5;
  --serif: 'Playfair Display', Georgia, serif;
  --num: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --safe-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  --hd-h: 72px;
  --nav-h: calc(58px + env(safe-area-inset-bottom));
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif; overflow-x: hidden; }
body { min-height: 100vh; }
button { font: inherit; color: inherit; }
button:focus-visible, a:focus-visible, [role="button"]:focus-visible { outline: 2px solid var(--gold2); outline-offset: 2px; }
#app { padding-bottom: var(--nav-h); }
#appBody { max-width: 640px; margin: 0 auto; }
[hidden] { display: none !important; }

/* шапка: смуга нічного міста з вежею-годинником і назвою вкладки поверх неба (як у вікні Мафії) */
.th { position: relative; overflow: hidden; padding-top: var(--safe-top); }
.th-in { position: relative; z-index: 1; min-height: var(--hd-h); max-width: 640px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.th h2 { margin: 0; font-family: var(--serif); font-size: 22px; font-weight: 800; letter-spacing: -.01em; line-height: 1.15; text-shadow: 0 1px 14px rgba(9,12,24,.9); }
.th-sub { font-size: 13px; color: var(--soft); margin-top: 2px; text-shadow: 0 1px 10px rgba(9,12,24,.9); }
.th-r { flex: none; display: flex; gap: 6px; }
.th-r:empty { display: none; }
.sky { position: absolute; inset: 0; overflow: hidden; pointer-events: none; background: linear-gradient(180deg, #4B3243 0%, #9C5B3B 42%, #DDA055 100%); }
.sky::before { content: ""; position: absolute; inset: 0; opacity: 0; background: linear-gradient(180deg, #060915 0%, #0E1530 60%, #1A2548 100%); }
.sky.night::before { opacity: 1; }
.sky .stars { position: absolute; inset: 0; opacity: 0;
  background-image: radial-gradient(1.5px 1.5px at 8% 22%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 21% 48%, #fff 50%, transparent 51%), radial-gradient(1.5px 1.5px at 37% 14%, #cfd9ff 50%, transparent 51%), radial-gradient(1px 1px at 52% 36%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 64% 12%, #fff 50%, transparent 51%), radial-gradient(1.5px 1.5px at 78% 30%, #cfd9ff 50%, transparent 51%), radial-gradient(1px 1px at 91% 18%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 46% 8%, #fff 50%, transparent 51%); }
.sky.night .stars { opacity: .75; }
.sky .moon { position: absolute; right: var(--moon, 16%); top: 12px; width: 22px; height: 22px; border-radius: 50%; box-shadow: inset -7px -3px 0 0 #F1E3AE; filter: drop-shadow(0 0 8px rgba(241,227,174,.45)); transition: right 1.1s cubic-bezier(.4, 0, .2, 1); }
.city { position: absolute; left: 50%; bottom: -1px; transform: translateX(-50%); width: auto; min-width: 100%; max-width: none; height: 66%; display: block; }
.city .c-far { fill: #172039; }
.city .c-near { fill: var(--bg); }
.city .c-win rect { fill: #F2CF85; }
.city .c-win { opacity: .9; }
.city .clk { fill: #F2CF85; }
.city .clk-h { fill: none; stroke: #1A1407; stroke-width: 1.8; stroke-linecap: round; }
.city .c-win .tw { animation: wink 3.4s ease-in-out infinite alternate; }
.city .c-win .tw2 { animation: wink 4.8s 1.2s ease-in-out infinite alternate; }
@keyframes wink { from { opacity: 1; } to { opacity: .2; } }
.hd-sky::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(9,12,24,.8) 0%, rgba(9,12,24,.4) 34%, rgba(9,12,24,0) 62%); }

/* нижнє меню */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: var(--nav-h); padding-bottom: env(safe-area-inset-bottom); display: flex; justify-content: center;
  background: rgba(15,18,32,.94); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-top: 1px solid var(--line2); }
.nav-b { position: relative; flex: 1; max-width: 150px; min-width: 0; min-height: 44px; border: 0; background: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; cursor: pointer; font-size: 11.5px; font-weight: 600; }
.nav-i { font-size: 20px; line-height: 1; filter: grayscale(.8); opacity: .65; transition: transform .2s, opacity .2s, filter .2s; }
.nav-b.on { color: var(--gold2); }
.nav-b.on .nav-i { filter: none; opacity: 1; transform: translateY(-1px) scale(1.08); }
.nav-b.on::before { content: ""; position: absolute; top: -1px; left: 50%; width: 30px; height: 2px; margin-left: -15px; background: var(--gold); border-radius: 2px; }

/* спільне */
.pane-in { animation: panein .24s ease-out; }
@keyframes panein { from { opacity: 0; transform: translateY(8px); } }
.section { padding: 14px 16px; }
.label { font-family: var(--serif); font-size: 17px; font-weight: 700; line-height: 1.25; color: var(--text); margin: 0 0 10px; }
.label.mt { margin-top: 22px; }
.cap { font-size: 13px; color: var(--muted); line-height: 1.45; }
.note { font-size: 13px; color: var(--muted); line-height: 1.5; margin-top: 10px; }
.card { background: var(--card); border: 1px solid var(--line2); border-radius: 18px; padding: 14px 16px; }
.card + .card { margin-top: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--card); border: 1px solid var(--line2); border-radius: 12px; padding: 12px 6px; text-align: center; min-width: 0; }
.stat b { display: block; font-size: 22px; font-weight: 600; line-height: 1.2; font-family: var(--num); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat span { display: block; font-size: 13px; line-height: 1.25; color: var(--muted); }
.card .stat { background: var(--inset); border-color: transparent; }
.btn { flex: 1; min-height: 46px; padding: 8px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-weight: 600; font-size: 15px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; text-align: center; }
.btn.primary { background: var(--gold); color: var(--ink); border-color: var(--gold); }
.btn:disabled { background: var(--line); color: var(--muted); border-color: var(--line); cursor: default; }
.btn:active:not(:disabled) { transform: scale(.98); }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.btns .btn { flex: 1 1 140px; }
.pill { display: inline-flex; align-items: center; gap: 5px; min-height: 30px; padding: 4px 10px; border-radius: 999px; background: rgba(15,18,32,.72); border: 1px solid var(--line); font-family: var(--num); font-variant-numeric: tabular-nums; font-size: 14px; font-weight: 600; white-space: nowrap; }
.pill.gold { color: var(--gold2); }
.pill.night { color: var(--night); }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.5; white-space: nowrap; border: 1px solid var(--line); color: var(--soft); }
.badge.available { color: var(--green); border-color: rgba(127,201,160,.45); background: rgba(127,201,160,.08); }
.badge.test { color: var(--gold2); border-color: rgba(226,190,106,.5); background: rgba(226,190,106,.08); }
.badge.soon { color: var(--night); border-color: rgba(143,178,245,.4); background: rgba(143,178,245,.07); }
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--nav-h)); transform: translateX(-50%); background: #2B2519; border: 1px solid var(--gold); color: var(--gold2); padding: 10px 16px; border-radius: 12px; font-size: 13px; line-height: 1.4; max-width: 90vw; z-index: 40; text-align: center; }
.gate { min-height: 60vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 32px 24px; text-align: center; }
.gate .em { font-size: 44px; line-height: 1; }
.gate h1 { margin: 0; font-family: var(--serif); font-size: 22px; line-height: 1.2; }
.gate p { margin: 0; max-width: 320px; color: var(--soft); font-size: 15px; line-height: 1.5; }
.gate .btn { flex: none; min-width: 200px; margin-top: 8px; }

/* ігри */
.gcard { display: flex; gap: 12px; align-items: flex-start; width: 100%; padding: 14px; background: var(--card); border: 1px solid var(--line2); border-radius: 18px; cursor: pointer; text-align: left; }
.gcard + .gcard { margin-top: 10px; }
.gcard:active { border-color: var(--line); }
.g-em { flex: none; width: 52px; height: 52px; border-radius: 14px; background: var(--inset); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 28px; line-height: 1; }
.g-main { flex: 1; min-width: 0; }
.g-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.g-title b { font-family: var(--serif); font-size: 18px; font-weight: 700; line-height: 1.2; }
.g-short { margin-top: 4px; font-size: 14px; line-height: 1.4; color: var(--soft); }
.g-meta { margin-top: 6px; font-size: 13px; color: var(--muted); }
.g-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.g-foot .more { font-size: 13px; color: var(--muted); }
.g-play { flex: none; min-height: 44px; min-width: 96px; padding: 8px 16px; border-radius: 12px; border: 1px solid var(--gold); background: var(--gold); color: var(--ink); font-weight: 700; font-size: 15px; cursor: pointer; }
.gcard.soon { align-items: center; padding: 10px 14px; min-height: 64px; }
.gcard.soon .g-em { width: 44px; height: 44px; font-size: 22px; filter: saturate(.6); }
.gcard.soon .g-title b { font-size: 16px; }
.gcard.soon .g-short { font-size: 13px; color: var(--muted); }
.gcard .chev { flex: none; align-self: center; color: var(--muted); font-size: 20px; }

/* сторінка гри */
.back { min-height: 44px; padding: 0 12px 0 6px; margin: 8px 8px 0; border: 0; background: none; color: var(--soft); font-size: 15px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.g-hero { display: flex; gap: 14px; align-items: center; }
.g-hero .g-em { width: 68px; height: 68px; border-radius: 18px; font-size: 36px; }
.g-hero h1 { margin: 0 0 6px; font-family: var(--serif); font-size: 24px; line-height: 1.15; overflow-wrap: anywhere; }
.g-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.g-about { margin: 14px 0 0; font-size: 15px; line-height: 1.55; color: var(--soft); }
.where { display: flex; align-items: center; gap: 12px; min-height: 48px; }
.where + .where { border-top: 1px solid var(--line2); margin-top: 8px; padding-top: 8px; }
.where .ic { flex: none; width: 36px; height: 36px; border-radius: 10px; background: var(--inset); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.where b { display: block; font-size: 15px; font-weight: 600; }
.where span { display: block; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }

/* профіль */
.hero { display: flex; flex-direction: column; align-items: center; padding: 16px 16px 4px; gap: 6px; text-align: center; }
.hero h1 { margin: 10px 0 0; font-family: var(--serif); font-size: 22px; line-height: 1.15; overflow-wrap: anywhere; }
.sub { font-size: 14px; color: var(--soft); }
.patron { display: inline-block; margin-top: 4px; padding: 3px 10px; border-radius: 999px; font-size: 13px; color: var(--gold); border: 1px solid rgba(226,190,106,.6); background: rgba(226,190,106,.08); }
.char { border-radius: 22px; padding: 4px; background: linear-gradient(160deg, #F2D28E, #8A6B2E); }
.char svg { display: block; width: 100%; height: 100%; border-radius: 18px; background: var(--inset); }
.xp { width: 100%; max-width: 420px; margin-top: 10px; }
.bar { height: 8px; border-radius: 999px; background: var(--line2); overflow: hidden; }
.bar > div { height: 100%; background: var(--gold); border-radius: 999px; }
.xp-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--muted); margin-top: 8px; font-family: var(--num); font-variant-numeric: tabular-nums; }
.bal { display: flex; gap: 8px; justify-content: center; margin-top: 10px; }
.bal .pill { background: var(--card); min-height: 36px; padding: 6px 14px; font-size: 15px; }
.bio { font-size: 15px; line-height: 1.5; color: var(--soft); overflow-wrap: anywhere; }
.st-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.st-head b { font-size: 15px; font-weight: 600; }
.ach { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.ach + .ach { border-top: 1px solid var(--line2); }
.ach .ic { flex: none; width: 40px; height: 40px; border-radius: 12px; background: var(--inset); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 20px; }
.ach.done .ic { border-color: var(--gold); }
.ach b { display: block; font-size: 14px; font-weight: 600; }
.ach span { display: block; font-size: 13px; color: var(--muted); line-height: 1.35; }
.ach.locked { opacity: .5; }
.ach .ok { margin-left: auto; flex: none; color: var(--gold); font-size: 16px; }

/* гардероб: редактор персонажа v3 (як у вікні Мафії) */
.sexrow { display: flex; align-items: center; gap: 8px; padding: 0 16px; margin-top: 14px; }
.sexrow .cap { margin-right: 4px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 44px; padding: 8px 16px; border-radius: 999px; background: var(--card); border: 1px solid var(--line2); color: var(--muted); font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--chip); color: var(--text); border-color: var(--line); }
.chips.slots { padding: 0 16px; margin: 14px 0 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.chips.slots::-webkit-scrollbar { display: none; }
.chips.slots .chip { flex: none; }
.witem { background: var(--card); border: 2px solid transparent; border-radius: 14px; padding: 8px 6px 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; text-align: center; min-height: 44px; min-width: 0; }
.witem.sel { border-color: var(--gold); }
.witem .thumb { width: 88px; max-width: 100%; height: 105px; border-radius: 12px; overflow: hidden; background: var(--inset); }
.witem .thumb svg { width: 100%; height: 100%; display: block; }
.witem.locked .thumb { opacity: .45; }
.witem.locked.sel .thumb { opacity: 1; }
.witem .n { font-size: 13px; font-weight: 600; line-height: 1.2; }
.witem .t { font-size: 12px; line-height: 1.25; }
.sws { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 2px 0 14px; }
.csw { flex: none; width: 44px; height: 44px; padding: 0; border-radius: 50%; border: 3px solid var(--line); cursor: pointer; }
.csw.on { border-color: var(--bg); box-shadow: 0 0 0 3px var(--gold); }
.bottom { position: sticky; bottom: var(--nav-h); z-index: 5; padding: 12px 16px; background: var(--bg); border-top: 1px solid var(--line2); }
.bottom .btn { width: 100%; min-height: 50px; }
.l3-reset { width: 100%; min-height: 44px; margin-top: 4px; background: none; border: 0; color: var(--soft); font: inherit; font-size: 14px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* склад */
.item { display: flex; align-items: center; gap: 12px; }
.item .ic { flex: none; width: 48px; height: 48px; border-radius: 14px; background: var(--inset); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 24px; }
.item .tx { flex: 1; min-width: 0; }
.item b { display: block; font-size: 15px; font-weight: 600; }
.item .tx span { display: block; font-size: 13px; color: var(--muted); line-height: 1.4; margin-top: 2px; }
.item .cnt { flex: none; min-width: 44px; text-align: right; font-family: var(--num); font-variant-numeric: tabular-nums; font-size: 18px; font-weight: 700; color: var(--gold2); }
.item.none { opacity: .55; }
.item.none .cnt { color: var(--muted); }

@media (prefers-reduced-motion: reduce) { .pane-in, .city .c-win .tw, .city .c-win .tw2 { animation: none; } .sky .moon { transition: none; } }
