/* ShishaBot Mini App — v5 Quiet Premium (+ Arcade on games/level-up) */
/* Inspired by Linear, Revolut Stocks 2025, iOS 18 Wallet, Things 3 */

/* ===== DESIGN TOKENS ===== */
:root, [data-theme="dark"] {
    /* Surfaces — depth via hairline borders, not shadows */
    --bg: #09090B;
    --bg2: #111113;
    --bg3: #18181B;
    --card: #111113;
    --surface-elev: #18181B;
    --border: rgba(255,255,255,0.07);
    --border-strong: rgba(255,255,255,0.12);
    /* Text */
    --text: #FAFAFA;
    --text2: #A1A1AA;
    --text3: #52525B;
    /* Semantic */
    --accent: #10B981;          /* emerald — единственный акцент в quiet-режиме */
    --accent-hover: #34D399;
    --accent-muted: rgba(16,185,129,0.12);
    --positive: #10B981;
    --negative: #F43F5E;
    --warning: #F59E0B;
    --neutral: #71717A;
    /* Back-compat aliases for existing components */
    --green: #10B981;
    --orange: #F59E0B;
    --red: #F43F5E;
    --purple: #A78BFA;
    --yellow: #FACC15;
    /* Arcade accent — used ONLY on games tab and level-up toasts */
    --arcade: #A78BFA;
    --arcade-warm: #FDBA74;
    /* Shadows — near-zero; real depth via borders */
    --shadow: 0 0 0 0.5px var(--border);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.35);
    /* Radii */
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    /* Motion */
    --duration-fast: 120ms;
    --duration: 200ms;
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] {
    --bg: #FAFAFA;
    --bg2: #FFFFFF;
    --bg3: #F4F4F5;
    --card: #FFFFFF;
    --surface-elev: #FFFFFF;
    --border: rgba(0,0,0,0.08);
    --border-strong: rgba(0,0,0,0.14);
    --text: #09090B;
    --text2: #52525B;
    --text3: #A1A1AA;
    --accent-muted: rgba(16,185,129,0.10);
    --shadow: 0 0 0 0.5px var(--border);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
}

/* Dark-first: system light theme is ignored unless user explicitly toggles.
   Light palette above applies only when [data-theme="light"] is set manually. */

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
    font-feature-settings: "tnum", "zero", "ss01", "cv11";
    background: var(--bg);
    color: var(--text);
    padding-bottom: 72px;
    -webkit-overflow-scrolling: touch;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}

/* ===== HEADER ===== */
.header {
    background: var(--bg);
    padding: 20px 16px 8px;
    text-align: left;
}
.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    margin-bottom: 4px;
}
.header-top h1 { font-size: 15px; font-weight: 500; margin: 0; color: var(--text2); letter-spacing: 0.01em; }
.theme-toggle {
    width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border);
    background: transparent; font-size: 14px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--text2);
    transition: opacity var(--duration-fast) var(--ease-out);
}
.theme-toggle:active { opacity: 0.6; }
.header .total { font-size: 44px; font-weight: 550; letter-spacing: -0.03em; line-height: 1.05; color: var(--text); font-variant-numeric: tabular-nums; }
.header .subtitle { color: var(--text2); font-size: 13px; margin-top: 4px; }

/* ===== PERIOD TABS ===== */
.periods {
    display: flex; gap: 4px; padding: 8px 16px 12px; background: var(--bg);
}
.periods button {
    flex: 1; padding: 8px 0; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: transparent; color: var(--text2);
    font-size: 13px; font-weight: 500; cursor: pointer;
    transition: color var(--duration-fast) var(--ease-out),
                border-color var(--duration-fast) var(--ease-out);
}
.periods button.active {
    background: transparent; color: var(--accent);
    border-color: var(--accent);
}
.periods button:active { opacity: 0.7; }

/* ===== CHART ===== */
.chart-container {
    background: var(--card); margin: 12px 16px; padding: 20px;
    border-radius: var(--radius); display: flex; justify-content: center;
    box-shadow: var(--shadow);
}
.chart-container canvas { max-width: 180px; max-height: 180px; }

/* Легенда под doughnut убрана — расшифровка цвета реализована
   круглой цветной иконкой в строке категории (.cat-row__icon-circle).
   Старые .legend-* классы оставлены как no-op на случай старого кеша. */
.legend-dots, .legend-top, .legend-bar { display: none; }

/* Старые классы (.cat-legend*) больше не используются, оставлены
   во избежание FOUC если старый app.js долетит из кэша. */
.cat-legend { padding: 8px 16px 4px; }
.cat-legend-item {
    display: flex; align-items: center; padding: 12px 0; gap: 12px;
    border-bottom: 0.5px solid var(--border);
}
.cat-legend-item:last-child { border-bottom: none; }
.cat-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.cat-legend-icon { font-size: 20px; flex-shrink: 0; }
.cat-legend-name { font-size: 15px; font-weight: 600; flex: 1; }
.cat-legend-pct { font-size: 14px; font-weight: 600; color: var(--text2); }
.cat-legend-amount { font-size: 15px; font-weight: 700; min-width: 70px; text-align: right; }

/* ===== BUDGET BAR ===== */
.budget-bar {
    margin: 0 16px 8px; padding: 14px 16px;
    background: var(--card); border-radius: var(--radius-sm);
}
.budget-bar .label { display: flex; justify-content: space-between; font-size: 14px; font-weight: 500; margin-bottom: 8px; }
.budget-bar .bar { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.budget-bar .bar .fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; }
.budget-bar .bar .fill.ok { background: var(--green); }
.budget-bar .bar .fill.warn { background: var(--orange); }
.budget-bar .bar .fill.danger { background: var(--red); }

/* ===== SECTION TITLE ===== */
.section-title {
    padding: 20px 16px 8px; font-size: 13px; font-weight: 700;
    color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px;
}

/* ===== EXPENSE LIST ===== */
.expense-list {
    background: var(--card); margin: 0 16px; border-radius: var(--radius);
    overflow: hidden; box-shadow: var(--shadow);
}
.expense-item {
    display: flex; align-items: center; padding: 14px 16px;
    border-bottom: 0.5px solid var(--border);
}
.expense-item:last-child { border-bottom: none; }
.expense-item .icon {
    width: 44px; height: 44px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; margin-right: 12px; background: var(--bg); flex-shrink: 0;
}
.expense-item > .cat-ico { margin-right: 12px; }
.expense-item .info { flex: 1; min-width: 0; }
.expense-item .info .desc { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.expense-item .info .cat { font-size: 13px; color: var(--text2); margin-top: 2px; }
.expense-item .amount { font-size: 17px; font-weight: 800; margin-left: 8px; white-space: nowrap; }

/* ===== CATEGORIES ACCORDION (Expenses tab) ===== */
.cat-accordion {
    background: var(--card); margin: 0 16px; border-radius: var(--radius);
    overflow: hidden; box-shadow: var(--shadow);
}
.cat-row {
    display: flex; align-items: center; gap: 10px; padding: 14px 16px;
    border-bottom: 0.5px solid var(--border); cursor: pointer;
    -webkit-tap-highlight-color: transparent; user-select: none;
}
.cat-row:active { background: var(--bg3); }
.cat-row__icon { font-size: 22px; width: 28px; text-align: center; flex-shrink: 0; }
.cat-row__main { flex: 1; min-width: 0; }

/* Универсальный цветной круг с SVG-пиктограммой.
   Используется и в строке категории (.cat-ico--lg 40px), и в каждой
   записи расхода (32px). Цвет — inline через style="background:…",
   фигура — inline SVG внутри. */
.cat-ico {
    width: 32px; height: 32px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.cat-ico--lg { width: 40px; height: 40px; }
.cat-ico svg {
    width: 56%; height: 56%;
    stroke: #fff; fill: none;
    stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
    color: #fff;
}
.cat-row__name { font-size: 15px; font-weight: 600; color: var(--text); text-transform: capitalize; }
.cat-row__meta { font-size: 12px; color: var(--text3); margin-top: 2px; }
.cat-row__sum  { font-size: 15px; font-weight: 700; color: var(--text); margin-left: 8px; white-space: nowrap; }
.cat-row__chev { margin-left: 6px; color: var(--text3); font-size: 13px;
                 display: inline-block; transition: transform .2s ease; }
.cat-row.expanded .cat-row__chev { transform: rotate(90deg); color: var(--text); }
.cat-body { display: none; background: var(--bg2); border-bottom: 0.5px solid var(--border); }
.cat-row.expanded + .cat-body { display: block; }
.cat-body .expense-item { padding-left: 48px; border-bottom: 0.5px solid var(--border); }
.cat-body .expense-item:last-child { border-bottom: none; }
.cat-accordion > .cat-row:last-of-type { border-bottom: none; }
.cat-accordion > .cat-body:last-child { border-bottom: none; }

/* ===== TAB BAR ===== */
.tab-bar {
    position: fixed; bottom: 0; left: 0; right: 0; display: flex;
    background: var(--bg);
    border-top: 0.5px solid var(--border);
    height: 56px;
    padding-bottom: max(env(safe-area-inset-bottom), 0px); z-index: 100;
}
.tab-bar button {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 3px;
    border: none; background: none; color: var(--text3);
    font-size: 10px; font-weight: 500; cursor: pointer; padding: 4px;
    position: relative;
    transition: color var(--duration-fast) var(--ease-out);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.tab-bar button .icon { font-size: 20px; }
.tab-bar button.active { color: var(--accent); }
.tab-bar button.active::before {
    content: ''; position: absolute; top: 0; left: 50%;
    transform: translateX(-50%); width: 28px; height: 2px;
    background: var(--accent); border-radius: 0 0 2px 2px;
}

/* ===== SHOPPING — unified list with sticky sections ===== */
.list-header {
    padding: 20px 16px 12px; display: flex;
    align-items: baseline; justify-content: space-between; background: var(--bg);
}
.list-header h1 {
    font-size: 26px; font-weight: 600;
    letter-spacing: -0.02em; color: var(--text);
}
.list-header__count {
    font-size: 14px; color: var(--text2);
    font-variant-numeric: tabular-nums; font-weight: 500;
}

.list-input-wrap {
    padding: 0 16px 12px;
    position: sticky; top: 0; background: var(--bg); z-index: 20;
}
.list-input__field {
    width: 100%; height: 44px; padding: 0 14px;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--bg2); color: var(--text);
    font-size: 15px; font-family: inherit; outline: none;
    transition: border-color var(--duration-fast) var(--ease-out);
}
.list-input__field::placeholder { color: var(--text3); }
.list-input__field:focus { border-color: var(--accent); }

.list-preview {
    margin-top: 8px; padding: 10px 12px;
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 13px;
    display: flex; flex-direction: column; gap: 4px;
}
.list-preview__row {
    display: grid; grid-template-columns: 18px minmax(70px, auto) 1fr;
    gap: 10px; padding: 2px 0; align-items: baseline;
}
.list-preview__icon { font-size: 14px; text-align: center; }
.list-preview__section {
    color: var(--text2); font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.06em;
}
.list-preview__name { color: var(--text); font-size: 13px; }
.list-preview__hint {
    padding: 3px 0 0; color: var(--text3); font-size: 11px;
    border-top: 0.5px solid var(--border); margin-top: 4px; padding-top: 6px;
}

.list-page { padding: 0; }

.list-section { margin-bottom: 4px; }
.list-section__header {
    position: sticky; top: 68px;
    background: var(--bg); padding: 18px 16px 10px;
    font-size: 17px; font-weight: 600; letter-spacing: -0.01em;
    color: var(--text);
    display: flex; justify-content: space-between; align-items: baseline;
    z-index: 10;
    font-variant-numeric: tabular-nums;
}
.list-section__header::after {
    content: ''; position: absolute; left: 16px; right: 16px; bottom: 0;
    height: 0.5px; background: var(--border);
}
.list-section__count {
    color: var(--text2); font-weight: 500; font-size: 14px;
}

.list-item {
    display: flex; align-items: center; gap: 12px;
    padding: 13px 16px;
    border-bottom: 0.5px solid var(--border);
    cursor: pointer; -webkit-tap-highlight-color: transparent;
    transition: opacity var(--duration-fast) var(--ease-out);
    touch-action: manipulation;
}
.list-item:active { opacity: 0.6; }
.list-item__check {
    width: 20px; height: 20px; border-radius: 50%;
    border: 1.5px solid var(--text3); flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 0; color: transparent;
    transition: background-color var(--duration-fast) var(--ease-out),
                border-color var(--duration-fast) var(--ease-out),
                color var(--duration-fast) var(--ease-out),
                font-size var(--duration-fast) var(--ease-out);
}
.list-item.done .list-item__check {
    background: var(--accent); border-color: var(--accent);
    color: #000; font-size: 11px; font-weight: 700;
}
.list-item__name { flex: 1; font-size: 15px; color: var(--text); }
.list-item.done .list-item__name {
    text-decoration: line-through; color: var(--text3);
}
.list-item__user {
    font-size: 12px; color: var(--text2);
    font-weight: 500;
}
.list-empty {
    padding: 80px 24px; text-align: center;
    color: var(--text2); font-size: 14px; line-height: 1.5;
}

/* Sticky CTA for shopping mode */
.list-cta-wrap {
    position: fixed;
    bottom: calc(60px + env(safe-area-inset-bottom));
    left: 0; right: 0;
    padding: 10px 16px 14px;
    background: linear-gradient(to top, var(--bg) 70%, rgba(9,9,11,0));
    z-index: 99;
    display: none;
    touch-action: manipulation;
}
#page-shopping.active ~ .list-cta-wrap,
.list-cta-wrap.visible { display: block; }

.btn-primary {
    width: 100%; height: 52px; border: none;
    background: var(--accent); color: #08140F;
    font-size: 16px; font-weight: 600; letter-spacing: -0.01em;
    border-radius: var(--radius); cursor: pointer;
    transition: opacity var(--duration-fast) var(--ease-out),
                background-color var(--duration-fast) var(--ease-out);
    font-family: inherit;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
.btn-primary:active { opacity: 0.75; }
.btn-primary.shopping-active {
    background: var(--arcade); color: #1A0F2E;
}

/* In active shopping mode, make items feel "tap to collect" */
.list-page.mode-shopping .list-item { padding: 16px; }
.list-page.mode-shopping .list-item__check {
    width: 24px; height: 24px; border-width: 2px;
}
.list-page:not(.mode-shopping) .list-item {
    cursor: default;
}
.list-page:not(.mode-shopping) .list-item__check {
    opacity: 0.4;
}

/* Progress inside section header while in shopping mode */
.list-section__progress {
    font-size: 12px; color: var(--accent);
    font-weight: 600; font-variant-numeric: tabular-nums;
    margin-left: 8px;
}

/* Add bottom padding to list so CTA doesn't overlap last item */
#page-shopping.active.has-cta #shop-list { padding-bottom: 80px; }

/* Legacy .shop-* — kept minimal for any residual HTML */
.shop-list { padding: 0 16px; }

/* ===== PAGES ===== */
.page { display: none; }
.page.active { display: block; }

/* ===== LOADING / EMPTY ===== */
.loading { text-align: center; padding: 40px 16px; color: var(--text2); font-size: 15px; }
.empty-state { text-align: center; padding: 60px 16px; color: var(--text2); }
.empty-state .emoji { font-size: 48px; margin-bottom: 12px; }
.empty-state .text { font-size: 16px; }
.empty-hint { text-align: center; padding: 20px; color: var(--text2); font-size: 14px; }

/* ===== HABITS ===== */
.info-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 50%; border: none;
    background: var(--bg); color: var(--text2); font-size: 16px; cursor: pointer;
    vertical-align: middle; margin-left: 6px;
}
.info-btn.active { background: var(--accent); color: #FFF; }
.habit-info-panel { max-height: 0; overflow: hidden; transition: max-height 0.35s ease; margin: 0 16px; }
.habit-info-panel.open { max-height: 500px; }
.info-content { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.info-content h3 { font-size: 14px; font-weight: 700; margin-bottom: 8px; margin-top: 12px; }
.info-content h3:first-child { margin-top: 0; }
.info-items { display: flex; flex-direction: column; gap: 6px; }
.info-item { font-size: 13px; line-height: 1.4; }
.info-icon { display: inline-block; width: 20px; text-align: center; }
.info-quote { font-size: 12px; font-style: italic; color: var(--text2); margin-top: 12px; padding: 10px; background: var(--bg); border-radius: 10px; text-align: center; }

.habit-list { padding: 0 16px; }
.habit-card {
    background: var(--card); border-radius: var(--radius); padding: 16px;
    margin-bottom: 10px; box-shadow: var(--shadow);
}
.habit-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.habit-header .habit-name { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 700; }
.habit-header .habit-name .icon { font-size: 22px; }
.habit-header .streak { font-size: 17px; font-weight: 800; color: var(--text2); }
.habit-header .streak.active { color: var(--orange); }

.habit-meta { font-size: 12px; color: var(--text2); margin-bottom: 8px; font-weight: 500; }

.habit-level {
    font-size: 12px; font-weight: 700; margin-bottom: 8px; padding: 3px 10px;
    background: var(--bg); border-radius: 8px; display: inline-block;
}

.habit-week { display: flex; gap: 4px; margin-bottom: 10px; }
.habit-day {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    gap: 4px; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.habit-day .day-label { font-size: 10px; color: var(--text2); text-transform: uppercase; font-weight: 600; }
.habit-day .day-dot {
    width: 36px; height: 36px; border-radius: 10px; background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700; transition: all 0.2s;
}
.habit-day .day-dot.done { background: var(--green); color: #FFF; box-shadow: 0 2px 8px rgba(52,199,89,0.4); }
.habit-day .day-dot.today { border: 2px solid var(--accent); }
.habit-day .day-dot.done.today { border-color: var(--green); }

.habit-progress { display: flex; align-items: center; gap: 10px; }
.habit-progress .bar { flex: 1; height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.habit-progress .bar .fill { height: 100%; background: linear-gradient(90deg, var(--green), var(--accent)); border-radius: 3px; transition: width 0.5s; }
.habit-progress .pct { font-size: 13px; font-weight: 700; color: var(--text2); width: 35px; text-align: right; }

.habit-auto { font-size: 11px; color: var(--text2); margin-top: 6px; text-align: center; }
.habit-auto.achieved { color: var(--green); font-weight: 600; }

/* Habit detail */
.habit-detail { padding: 16px; }
.habit-detail-header { text-align: center; margin-bottom: 16px; }
.habit-detail-header .icon { font-size: 40px; }
.habit-detail-header h2 { font-size: 20px; margin: 8px 0 4px; }
.habit-detail-header .schedule { color: var(--text2); font-size: 13px; }
.habit-level-badge { font-size: 16px; font-weight: 700; margin-top: 8px; }
.habit-next-level { font-size: 12px; color: var(--text2); margin-top: 2px; }
.habit-auto-detail { text-align: center; font-size: 13px; color: var(--text2); margin-bottom: 12px; padding: 8px; background: var(--bg); border-radius: 10px; }
.habit-auto-detail.achieved { color: var(--green); font-weight: 600; }

.habit-stats { display: flex; gap: 8px; margin-bottom: 16px; }
.habit-stat { flex: 1; background: var(--card); border-radius: var(--radius-sm); padding: 12px; text-align: center; box-shadow: var(--shadow); }
.habit-stat .value { font-size: 22px; font-weight: 800; }
.habit-stat .label { font-size: 11px; color: var(--text2); margin-top: 2px; }

.habit-calendar { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.habit-cal-month { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.habit-cal-grid { display: flex; flex-wrap: wrap; gap: 3px; }
.habit-cal-day { width: 12px; height: 12px; border-radius: 2px; background: var(--bg); }
.habit-cal-day.done { background: var(--green); }
.habit-cal-day.today { outline: 1px solid var(--accent); }

/* Analytics */
.analytics-section { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.analytics-section h3 { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.month-compare { display: flex; align-items: center; justify-content: space-around; }
.month-col { text-align: center; }
.month-pct { font-size: 28px; font-weight: 800; }
.month-label { font-size: 11px; color: var(--text2); margin-top: 4px; line-height: 1.3; }
.month-diff { font-size: 16px; font-weight: 700; padding: 6px 12px; border-radius: 10px; background: var(--bg); }
.month-diff.positive { color: var(--green); }
.month-diff.negative { color: var(--red); }
.weeks-chart { display: flex; gap: 4px; align-items: flex-end; height: 80px; margin-bottom: 8px; }
.week-bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.week-fill { width: 100%; background: var(--green); border-radius: 4px 4px 0 0; min-height: 2px; transition: height 0.3s; }
.week-bar span { font-size: 10px; color: var(--text2); margin-top: 2px; }
.compound-note { font-size: 12px; color: var(--text2); text-align: center; padding: 8px; background: var(--bg); border-radius: 8px; }

/* Settings panel */
.habit-settings-panel { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.habit-settings-panel h3 { font-size: 15px; font-weight: 600; margin-bottom: 10px; }

.habit-actions { display: flex; gap: 8px; margin-top: 16px; }
.habit-actions button { flex: 1; padding: 14px; border-radius: var(--radius-sm); border: none; font-size: 15px; font-weight: 700; cursor: pointer; }
.habit-actions .btn-back { background: var(--bg); color: var(--text); }
.habit-actions .btn-danger { background: var(--red); color: white; }
.habit-actions .btn-settings { background: var(--accent); color: white; }

.habit-add-btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    background: var(--card); border-radius: var(--radius); padding: 18px;
    margin: 0 16px 12px; border: 2px dashed var(--border);
    color: var(--text2); font-size: 15px; font-weight: 600; cursor: pointer;
}

/* Freq chips + day picker */
.form-label { font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 4px; }
.freq-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.freq-chip {
    padding: 8px 16px; border-radius: 20px; border: 1.5px solid var(--border);
    background: var(--bg); color: var(--text); font-size: 13px; font-weight: 600;
    cursor: pointer; transition: all 0.2s; -webkit-tap-highlight-color: transparent;
}
.freq-chip.active { background: var(--accent); color: #FFF; border-color: var(--accent); }
.day-picker { display: flex; gap: 4px; max-height: 0; overflow: hidden; transition: max-height 0.25s ease; }
.day-picker.open { max-height: 50px; margin-bottom: 8px; }
.day-pick {
    flex: 1; padding: 8px 0; border-radius: 10px; border: 1.5px solid var(--border);
    background: var(--bg); color: var(--text); font-size: 12px; font-weight: 700;
    cursor: pointer; text-align: center;
}
.day-pick.active { background: var(--green); color: #FFF; border-color: var(--green); }
.remind-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.remind-toggle { display: flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.remind-toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.remind-time { padding: 8px 12px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg); color: var(--text); font-size: 14px; }
.remind-time:disabled { opacity: 0.3; }

/* Habit add view */
.habit-add-view { padding: 16px; }
.habit-add-view h2 { font-size: 20px; margin-bottom: 16px; }
.habit-add-view h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.habit-manual-add { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.habit-form { display: flex; flex-direction: column; gap: 8px; }
.habit-form input { padding: 14px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); font-size: 15px; background: var(--bg); color: var(--text); }
.habit-form .btn-primary { padding: 14px; border-radius: var(--radius-sm); border: none; background: var(--accent); color: #FFF; font-size: 15px; font-weight: 700; cursor: pointer; }
.two-min-hint { font-size: 13px; color: var(--orange); padding: 10px 12px; background: rgba(255,149,0,0.1); border-radius: 10px; }
.two-min-hint b { font-weight: 600; }

/* Templates */
.habit-templates { margin-bottom: 16px; }
.tmpl-subtitle { font-size: 13px; color: var(--text2); margin-bottom: 12px; }
.template-card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.tmpl-title { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.tmpl-desc { font-size: 13px; color: var(--text2); font-style: italic; margin-bottom: 10px; }
.tmpl-habits { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.tmpl-habit { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.tmpl-mini { font-size: 11px; color: var(--text2); max-width: 50%; text-align: right; }
.tmpl-btn { width: 100%; padding: 12px; border-radius: var(--radius-sm); border: none; background: var(--accent); color: #FFF; font-size: 15px; font-weight: 700; cursor: pointer; }
.tmpl-btn:disabled { opacity: 0.5; }

/* ===== FAB ===== */
.fab {
    position: fixed; bottom: 72px; right: 16px; width: 56px; height: 56px;
    border-radius: 50%; background: var(--accent); color: #FFF; border: none;
    font-size: 28px; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 16px rgba(0,122,255,0.4); cursor: pointer; z-index: 50;
    transition: transform 0.2s;
}
.fab:active { transform: scale(0.9); }

/* ===== SWIPE ===== */
.expense-item-wrap { position: relative; overflow: hidden; }
.expense-item-wrap .swipe-delete {
    position: absolute; right: 0; top: 0; bottom: 0; width: 80px;
    background: var(--red); color: #FFF; display: flex; align-items: center;
    justify-content: center; font-size: 13px; font-weight: 600; cursor: pointer;
}
.expense-item-wrap .swipe-edit {
    position: absolute; left: 0; top: 0; bottom: 0; width: 80px;
    background: var(--accent); color: #FFF; display: flex; align-items: center;
    justify-content: center; font-size: 13px; font-weight: 600; cursor: pointer;
}
.expense-item-wrap .expense-item { position: relative; z-index: 1; background: var(--card); transition: transform 0.2s; }

/* ===== ALWAYS-ON ACTION BUTTONS (iOS Reminders-style) =====
   Видимые иконки ✏ 🗑 справа от amount. Пользователь не обязан
   знать про swipe — действия обнаружимы сразу. Swipe оставлен
   параллельно для привыкших. */
.expense-item .actions {
    display: flex; align-items: center; gap: 4px;
    margin-left: 8px; flex-shrink: 0;
}
.expense-item .act-btn {
    width: 32px; height: 32px; border-radius: 8px; border: none;
    background: var(--bg2); color: var(--text2);
    font-size: 14px; line-height: 1; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    -webkit-tap-highlight-color: transparent;
}
.expense-item .act-btn:active { background: var(--bg3); transform: scale(0.92); }
.expense-item .act-btn.danger { color: var(--red); }

/* ===== MODAL ===== */
.modal-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 200; align-items: flex-end; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--card); border-radius: 20px 20px 0 0; width: 100%;
    padding: 24px 16px 40px; max-height: 80vh; box-shadow: var(--shadow-lg);
}
.modal h3 { font-size: 18px; text-align: center; margin-bottom: 16px; }
.modal input {
    width: 100%; padding: 14px 16px; border: 1.5px solid var(--border);
    border-radius: var(--radius-sm); font-size: 16px; background: var(--bg); color: var(--text);
    margin-bottom: 12px; outline: none;
}
.modal input:focus { border-color: var(--accent); }
.modal .btn-row { display: flex; gap: 12px; }
.modal button { flex: 1; padding: 14px; border-radius: var(--radius-sm); border: none; font-size: 16px; font-weight: 700; cursor: pointer; }
.modal .btn-primary { background: var(--accent); color: #FFF; }
.modal .btn-cancel { background: var(--bg); color: var(--text); }

.cat-scroll { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 12px; -webkit-overflow-scrolling: touch; }
.cat-chip {
    flex-shrink: 0; padding: 8px 14px; border-radius: 20px;
    border: 2px solid var(--border); background: var(--bg); color: var(--text);
    font-size: 13px; cursor: pointer; white-space: nowrap; transition: all 0.2s;
}
.cat-chip.active { border-color: var(--accent); background: var(--accent); color: #FFF; }

/* ===== GAMES (v5 Arcade redesign) ===== */
/* Game-specific palette — extends root with board/piece colors.
   Used only on #page-games; rest of the app stays in quiet-premium. */
:root, [data-theme="dark"] {
    --x-color: #FDBA74;              /* peach */
    --o-color: #A78BFA;              /* violet */
    --c4-red: #F87171;
    --c4-red-dark: #DC2626;
    --c4-yellow: #FBBF24;
    --c4-yellow-dark: #D97706;
    --c4-board: #1D4ED8;
    --c4-board-dark: #1E3A8A;
    --gmk-board: #C9A36B;
    --gmk-board-dark: #8B6B3F;
    --gmk-line: rgba(62, 42, 24, 0.55);
    --gmk-hoshi: #2A1A0E;
    --gmk-stone-black: #1A1A1A;
    --gmk-stone-white: #F5F5F5;
    --win-glow: #FDE047;
    --game-card-ttt: linear-gradient(135deg, #2D1B4E 0%, #18181B 100%);
    --game-card-c4: linear-gradient(135deg, #0F2A5C 0%, #18181B 100%);
    --game-card-gmk: linear-gradient(135deg, #3D2817 0%, #18181B 100%);
}

/* Lobby: game-type cards */
.game-types { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.game-type-btn {
    display: flex; align-items: center; gap: 14px;
    border-radius: var(--radius); padding: 16px 18px;
    border: 1px solid rgba(255,255,255,0.06);
    cursor: pointer; text-align: left; width: 100%;
    -webkit-tap-highlight-color: transparent; color: var(--text);
    transition: transform var(--duration-fast) var(--ease-out),
                border-color var(--duration-fast) var(--ease-out);
    touch-action: manipulation; font-family: inherit;
    position: relative; overflow: hidden;
}
.game-type-btn:active { transform: scale(0.98); }
.game-type-btn[data-type="tictactoe"] { background: var(--game-card-ttt); }
.game-type-btn[data-type="connect4"]  { background: var(--game-card-c4); }
.game-type-btn[data-type="gomoku"]    { background: var(--game-card-gmk); }
.game-type-btn::after {
    content: '›'; position: absolute; right: 18px; top: 50%;
    transform: translateY(-50%); color: var(--text2); font-size: 24px;
    font-weight: 300;
}
.gt-icon {
    width: 48px; height: 48px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 28px;
}
.gt-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.gt-name { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
.gt-desc { font-size: 12px; color: var(--text2); letter-spacing: 0.02em; }

/* Opponent choice pills */
.opponent-choice {
    display: flex; gap: 8px; padding: 0 16px; margin: -4px 0 6px;
}
.opp-btn {
    flex: 1; padding: 14px; border-radius: var(--radius-sm); border: none;
    font-size: 15px; font-weight: 600; cursor: pointer; color: #0A0A0A;
    font-family: inherit; touch-action: manipulation;
    transition: opacity var(--duration-fast) var(--ease-out);
}
.opp-btn[data-opp="ai"]    { background: var(--arcade-warm); }
.opp-btn[data-opp="human"] { background: var(--arcade); }
.opp-btn:active { opacity: 0.75; }

/* Stats cards */
.game-stats-section, .active-games-section {
    margin: 0 16px 8px;
}
.game-stat-row {
    display: grid; grid-template-columns: 1fr auto;
    align-items: center; gap: 10px;
    padding: 12px 16px; background: var(--card);
    border: 1px solid var(--border); border-bottom: none;
    font-size: 14px; font-weight: 500;
    position: relative;
}
.game-stat-row:first-child { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.game-stat-row:last-child  { border-radius: 0 0 var(--radius-sm) var(--radius-sm); border-bottom: 1px solid var(--border); }
.game-stat-row::after {
    content: ''; position: absolute; left: 16px; right: 16px; bottom: 0;
    height: 2px; background: linear-gradient(90deg, var(--accent) var(--win-pct, 0%), transparent var(--win-pct, 0%));
    opacity: 0.5;
}
.game-stat-row:last-child::after { bottom: -1px; }
.game-stat-nums { display: flex; gap: 8px; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.gs-w { color: var(--accent); }
.gs-l { color: var(--negative); }
.gs-d { color: var(--text3); }
.gs-opp { font-size: 11px; color: var(--text2); margin-left: 6px; font-weight: 500; }
.active-game-row {
    display: grid; grid-template-columns: auto 1fr auto;
    gap: 10px; padding: 12px 16px; background: var(--card);
    border: 1px solid var(--border); border-bottom: none;
    font-size: 14px; font-weight: 500; cursor: pointer;
    touch-action: manipulation;
    transition: background var(--duration-fast) var(--ease-out);
}
.active-game-row:first-child { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.active-game-row:last-child { border-radius: 0 0 var(--radius-sm) var(--radius-sm); border-bottom: 1px solid var(--border); }
.active-game-row:active { background: var(--bg3); }
.ag-opp { color: var(--text2); font-weight: 500; }
.ag-st { display: inline-flex; align-items: center; gap: 6px; }

/* Свежее входящее приглашение — левая жёлтая полоса + мягкий pulse. */
.active-game-row--new {
    border-left: 3px solid var(--accent);
    background: linear-gradient(90deg, rgba(52,199,89,0.10) 0%, transparent 40%);
    animation: ag-pulse 2s ease-in-out infinite;
}
@keyframes ag-pulse {
    0%, 100% { box-shadow: inset 3px 0 0 var(--accent); }
    50% { box-shadow: inset 3px 0 0 var(--accent), 0 0 12px rgba(52,199,89,0.25); }
}
.ag-badge {
    display: inline-block; margin-left: 6px; padding: 1px 6px;
    border-radius: 10px; background: var(--accent); color: #fff;
    font-size: 10px; font-weight: 700; line-height: 14px; vertical-align: middle;
}
.ag-cancel {
    border: none; background: transparent; color: var(--text3);
    font-size: 20px; font-weight: 400; line-height: 1; cursor: pointer;
    padding: 0 6px; margin-left: 4px; border-radius: 4px;
    font-family: inherit;
}
.ag-cancel:hover { color: var(--red); background: var(--bg3); }

/* Кнопка «Отменить приглашение» на экране ожидания. */
.waiting-cancel-btn {
    display: block; margin: 24px auto 0; padding: 10px 22px;
    border: 1px solid var(--border); background: transparent;
    color: var(--text2); font-size: 14px; font-weight: 500;
    border-radius: var(--radius-sm); cursor: pointer;
    font-family: inherit; touch-action: manipulation;
    transition: color var(--duration-fast), border-color var(--duration-fast);
}
.waiting-cancel-btn:active { color: var(--red); border-color: var(--red); }

/* ----- Board view top bar ----- */
.game-bar {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; background: var(--bg);
    border-bottom: 0.5px solid var(--border);
}
.game-back-btn {
    font-size: 14px; border: 1px solid var(--border);
    background: transparent; color: var(--text2); cursor: pointer;
    padding: 6px 12px; border-radius: var(--radius-sm); font-weight: 500;
    font-family: inherit; touch-action: manipulation;
    transition: color var(--duration-fast) var(--ease-out),
                border-color var(--duration-fast) var(--ease-out);
}
.game-back-btn:active { color: var(--text); border-color: var(--text3); }
.game-turn-status {
    flex: 1; text-align: right; font-size: 14px; font-weight: 600;
    color: var(--text2); letter-spacing: 0.02em;
    display: flex; align-items: center; justify-content: flex-end; gap: 8px;
}
.game-turn-status.your-turn { color: var(--accent); text-transform: uppercase; letter-spacing: 0.06em; }
.turn-dot {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%;
    background: var(--accent);
    animation: turn-pulse 1.2s ease-in-out infinite;
}
@keyframes turn-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%      { transform: scale(1.4); opacity: 0.5; }
}

/* Players strip */
.game-players {
    display: flex; justify-content: center; align-items: center;
    gap: 12px; padding: 14px 16px; font-size: 14px;
}
.gp {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: var(--radius-sm);
    background: var(--card); border: 1px solid var(--border);
    font-weight: 500; color: var(--text2);
    transition: all var(--duration) var(--ease-out);
}
.gp.active {
    border-color: currentColor; color: var(--text);
    box-shadow: 0 0 0 1px currentColor, 0 0 16px -4px currentColor;
}
.gp.p-x { color: var(--x-color); }
.gp.p-o { color: var(--o-color); }
.gp.p-red { color: var(--c4-red); }
.gp.p-yellow { color: var(--c4-yellow); }
.gp.p-black { color: #BBB; }
.gp.p-white { color: var(--gmk-stone-white); }
.gp.me { font-weight: 700; }
.gp-vs { color: var(--text3); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.1em; }

/* ===== BOARDS ===== */
.game-board { display: flex; justify-content: center; padding: 16px 8px; }
.gboard { display: grid; width: min(94vw, 400px); margin: 0 auto; }

/* --- Tic-tac-toe --- */
.gboard-ttt { gap: 6px; }
.gboard-ttt .gcell {
    background: #141419; border: 1px solid rgba(255,255,255,0.05);
    border-radius: 14px; aspect-ratio: 1;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.15s var(--ease-out), border-color 0.2s;
    -webkit-tap-highlight-color: transparent; touch-action: manipulation;
    position: relative; overflow: hidden;
}
.gboard-ttt .gcell.clickable { cursor: pointer; }
.gboard-ttt .gcell.clickable:active { transform: scale(0.94); }
.gboard-ttt .gcell.last { border-color: var(--accent); }
.gboard-ttt .gcell.win { animation: win-pulse 1.4s ease-in-out infinite; border-color: var(--win-glow); }
@keyframes win-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(253,224,71,0); }
    50%      { box-shadow: 0 0 24px 2px rgba(253,224,71,0.6); }
}
.gcell svg.mark-x, .gcell svg.mark-o { width: 60%; height: 60%; }
.mark-x path, .mark-o circle {
    fill: none; stroke-linecap: round; stroke-width: 10;
    stroke-dasharray: 200; stroke-dashoffset: 200;
    animation: draw-mark 0.35s ease-out forwards;
}
.mark-x path { stroke: var(--x-color); }
.mark-o circle { stroke: var(--o-color); }
@keyframes draw-mark {
    to { stroke-dashoffset: 0; }
}

/* --- Connect4 --- */
.gboard-c4 {
    gap: 4px; padding: 10px;
    background: linear-gradient(135deg, var(--c4-board) 0%, var(--c4-board-dark) 100%);
    border-radius: 16px;
    box-shadow: inset 0 1px 2px rgba(255,255,255,0.15),
                inset 0 -4px 8px rgba(0,0,0,0.3),
                0 4px 16px rgba(0,0,0,0.4);
    position: relative;
}
.gboard-c4 .gcell {
    background: #0A1428; border-radius: 50%; aspect-ratio: 1;
    display: flex; align-items: center; justify-content: center;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.6);
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent; touch-action: manipulation;
    overflow: visible;
}
.gboard-c4 .gcell.clickable { cursor: pointer; }
.gboard-c4 .gcell.win { animation: c4-win-glow 1.4s ease-in-out infinite; }
@keyframes c4-win-glow {
    0%, 100% { box-shadow: inset 0 2px 4px rgba(0,0,0,0.6), 0 0 0 0 rgba(253,224,71,0); }
    50%      { box-shadow: inset 0 2px 4px rgba(0,0,0,0.6), 0 0 18px 2px rgba(253,224,71,0.8); }
}
.c4-chip {
    width: 88%; height: 88%; border-radius: 50%;
    box-shadow: inset -3px -3px 7px rgba(0,0,0,0.35),
                inset 3px 3px 7px rgba(255,255,255,0.2),
                0 2px 4px rgba(0,0,0,0.4);
}
.c4-chip.red {
    background: radial-gradient(circle at 30% 30%, #FCA5A5, var(--c4-red-dark) 72%);
}
.c4-chip.yellow {
    background: radial-gradient(circle at 30% 30%, #FEF3C7, var(--c4-yellow-dark) 72%);
}
.c4-chip.drop {
    animation: c4-drop 0.42s cubic-bezier(0.5, 0.05, 0.5, 1.4);
}
@keyframes c4-drop {
    0%   { transform: translateY(calc(-108% * var(--fall-rows, 6))); }
    85%  { transform: translateY(5%); }
    100% { transform: translateY(0); }
}

/* --- Gomoku --- */
.gboard-gmk-wrap {
    position: relative; width: min(94vw, 400px); margin: 0 auto;
    background: linear-gradient(135deg, var(--gmk-board), var(--gmk-board-dark));
    border-radius: 10px; padding: 14px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4), inset 0 0 40px rgba(0,0,0,0.15);
}
.gmk-grid-overlay {
    position: absolute; inset: 14px; pointer-events: none;
    width: calc(100% - 28px); height: calc(100% - 28px);
}
.gboard-gmk {
    gap: 0; width: 100%; aspect-ratio: 1;
    position: relative; z-index: 1;
}
.gboard-gmk .gcell {
    background: transparent; border: none; aspect-ratio: 1;
    display: flex; align-items: center; justify-content: center;
    -webkit-tap-highlight-color: transparent; touch-action: manipulation;
    position: relative;
}
.gboard-gmk .gcell.clickable { cursor: pointer; }
.gboard-gmk .gcell.last::before {
    content: ''; position: absolute; inset: 15%;
    border: 2px solid var(--win-glow); border-radius: 4px;
    pointer-events: none;
}
.gboard-gmk .gcell.win .gmk-stone {
    animation: gmk-win-glow 1.4s ease-in-out infinite;
}
@keyframes gmk-win-glow {
    0%, 100% { box-shadow: 0 1px 2px rgba(0,0,0,0.5); }
    50%      { box-shadow: 0 0 20px 4px rgba(253,224,71,0.7); }
}
.gmk-stone {
    width: 80%; height: 80%; border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.5);
    animation: stone-place 0.22s ease-out;
}
.gmk-stone.black {
    background: radial-gradient(circle at 30% 30%, #4A4A4A, var(--gmk-stone-black) 70%);
}
.gmk-stone.white {
    background: radial-gradient(circle at 30% 30%, #FFF, var(--gmk-stone-white) 70%);
}
@keyframes stone-place {
    0%   { transform: scale(0.2); opacity: 0; }
    60%  { transform: scale(1.08); opacity: 1; }
    100% { transform: scale(1); }
}

/* ----- Reactions ----- */
.game-reactions {
    display: flex; justify-content: center; gap: 10px;
    padding: 10px 16px 14px;
}
.react-btn {
    width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border);
    background: var(--card); font-size: 20px; cursor: pointer;
    transition: transform var(--duration-fast) var(--ease-out),
                border-color var(--duration-fast) var(--ease-out);
    touch-action: manipulation;
}
.react-btn:active { transform: scale(0.88); border-color: var(--accent); }

/* Flying reaction emoji */
.reaction-fly {
    position: absolute; bottom: 100%; left: 50%;
    transform: translateX(-50%); font-size: 32px;
    pointer-events: none; opacity: 1;
    animation: react-fly 0.9s ease-out forwards;
}
@keyframes react-fly {
    0%   { transform: translate(-50%, 0) scale(0.6); opacity: 0; }
    15%  { opacity: 1; transform: translate(-50%, -20px) scale(1); }
    100% { transform: translate(-50%, -280px) scale(0.9); opacity: 0; }
}

.game-toast {
    position: fixed; top: 72px; left: 50%; transform: translateX(-50%);
    background: var(--card); color: var(--text); padding: 10px 18px;
    border-radius: 999px; border: 1px solid var(--border);
    font-size: 14px; font-weight: 500; opacity: 0;
    transition: opacity var(--duration) var(--ease-out);
    pointer-events: none; z-index: 200;
}
.game-toast.show { opacity: 1; }

/* ----- Game Over ----- */
.game-over-panel {
    margin: 20px 16px; padding: 28px 20px 24px;
    background: var(--card); border: 1px solid var(--border);
    border-radius: 20px; text-align: center;
    position: relative; overflow: hidden;
}
.go-emoji {
    font-size: 56px; margin-bottom: 8px;
    animation: go-bounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes go-bounce {
    0%   { transform: scale(0.3); opacity: 0; }
    60%  { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); }
}
.go-title {
    font-size: 28px; font-weight: 700; margin-bottom: 4px;
    letter-spacing: -0.03em; text-transform: uppercase;
    color: var(--text);
}
.go-title.win { text-shadow: 0 0 24px rgba(253,224,71,0.45); }
.go-subtitle { font-size: 13px; color: var(--text2); margin-bottom: 18px; }
.go-buttons { display: flex; gap: 10px; margin-top: 14px; }
.go-btn {
    flex: 1; padding: 14px; border-radius: var(--radius); border: none;
    font-size: 15px; font-weight: 600; cursor: pointer;
    font-family: inherit; touch-action: manipulation;
    transition: opacity var(--duration-fast) var(--ease-out);
}
.go-btn-primary { background: var(--accent); color: #08140F; }
.go-btn-secondary {
    background: transparent; color: var(--text);
    border: 1px solid var(--border);
}
.go-btn:active { opacity: 0.75; }

/* ----- Confetti ----- */
.confetti-host {
    position: absolute; inset: 0; pointer-events: none;
    overflow: hidden;
}
.confetti-piece {
    position: absolute; top: -20px; width: 8px; height: 12px;
    background: var(--c-color, var(--arcade));
    border-radius: 1px;
    animation: confetti-fall var(--c-dur, 1.8s) linear var(--c-delay, 0s) forwards,
               confetti-spin 0.8s linear infinite;
}
@keyframes confetti-fall {
    0%   { transform: translateY(-20px) translateX(0); opacity: 1; }
    100% { transform: translateY(380px) translateX(var(--c-drift, 0px)); opacity: 0; }
}
@keyframes confetti-spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* reduced motion: disable flashy animations */
@media (prefers-reduced-motion: reduce) {
    .c4-chip.drop { animation: none; }
    .gmk-stone { animation: none; }
    .mark-x path, .mark-o circle { stroke-dashoffset: 0; animation: none; }
    .confetti-piece { animation: none; display: none; }
    .go-emoji { animation: none; }
    .turn-dot { animation: none; }
    .gboard-ttt .gcell.win, .gboard-c4 .gcell.win, .gboard-gmk .gcell.win .gmk-stone {
        animation: none;
        box-shadow: 0 0 12px 2px rgba(253,224,71,0.5);
    }
}

/* ===== Admin control panel ===== */
.admin-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 0 16px 20px;
}
.acard {
    background: var(--card);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow);
    border-left: 3px solid var(--border);
}
.acard__label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text3);
    font-weight: 600;
    margin-bottom: 6px;
}
.acard__value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}
.acard__sub {
    font-size: 11px;
    color: var(--text3);
    margin-top: 4px;
}
.acard--ok { border-left-color: #34C759; }
.acard--warn { border-left-color: #FFCE56; }
.acard--bad { border-left-color: #FF3B30; }
.acard--muted { border-left-color: var(--border); }

.admin-feed {
    background: var(--card);
    margin: 0 16px 20px;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.afeed-row {
    display: grid;
    grid-template-columns: auto auto 1fr;
    column-gap: 10px;
    padding: 10px 14px;
    border-bottom: 0.5px solid var(--border);
    font-size: 13px;
    align-items: center;
}
.afeed-row:last-child { border-bottom: none; }
.afeed-amt { font-weight: 700; color: var(--text); white-space: nowrap; }
.afeed-cat {
    font-size: 10px;
    background: var(--bg2);
    padding: 2px 8px;
    border-radius: 10px;
    color: var(--text2);
    white-space: nowrap;
}
.afeed-desc { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.afeed-who { grid-column: 1 / -1; font-size: 11px; color: var(--text3); margin-top: 2px; }
.admin-latest { padding-bottom: 100px; }

/* ===== Развлечения: pill-переключатель + sub-pages ===== */
.fun-pills {
    display: flex; gap: 6px; padding: 0 16px 12px;
    overflow-x: auto;
}
.fun-pill {
    padding: 8px 14px; border-radius: 999px;
    border: 1px solid var(--border); background: transparent;
    color: var(--text2); font-size: 13px; font-weight: 600;
    cursor: pointer; white-space: nowrap;
    transition: color var(--duration-fast), border-color var(--duration-fast),
                background var(--duration-fast);
}
.fun-pill.active {
    color: var(--accent); border-color: var(--accent);
    background: var(--accent-muted);
}
.fun-sub { display: none; }
.fun-sub.active { display: block; }

/* ===== Книги ===== */
.book-filters {
    display: flex; gap: 6px; padding: 0 16px 8px; overflow-x: auto;
}
.book-filter {
    padding: 6px 12px; border-radius: 999px;
    border: 1px solid var(--border); background: transparent;
    color: var(--text2); font-size: 12px; font-weight: 500;
    cursor: pointer; white-space: nowrap;
}
.book-filter.active { color: var(--accent); border-color: var(--accent); }
.book-search {
    width: calc(100% - 32px); margin: 4px 16px 12px;
    height: 38px; padding: 0 12px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--card); color: var(--text);
    font-size: 13px; font-family: inherit;
}
.book-list {
    display: flex; flex-direction: column; gap: 10px;
    padding: 0 16px 100px;
}
.book-card {
    background: var(--card); border-radius: var(--radius);
    padding: 14px; box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
.bk-row { display: flex; gap: 12px; align-items: flex-start; }
.bk-fmt {
    flex-shrink: 0; width: 38px; height: 38px;
    background: var(--bg2); border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; color: var(--text2);
    letter-spacing: 0.04em;
}
.bk-main { flex: 1; min-width: 0; }
.bk-title { font-size: 15px; font-weight: 700; color: var(--text); }
.bk-author { font-size: 12px; color: var(--text2); margin-top: 2px; }
.bk-desc { font-size: 13px; color: var(--text2); margin-top: 6px; line-height: 1.45; }
.bk-meta {
    display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px;
    font-size: 11px; color: var(--text3);
}
.bk-status {
    background: var(--bg2); padding: 2px 8px; border-radius: 10px;
    color: var(--text2); font-weight: 500;
}
.bk-my-rate { color: var(--accent); font-weight: 700; }
.bk-size { color: var(--text3); }
.bk-other {
    background: var(--accent-muted); color: var(--text2);
    padding: 2px 8px; border-radius: 10px;
}
.bk-actions {
    display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap;
}
.bk-act {
    flex: 1; min-width: 80px;
    height: 32px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: transparent;
    color: var(--text2); font-size: 12px; font-weight: 500;
    cursor: pointer; font-family: inherit;
    transition: color var(--duration-fast), border-color var(--duration-fast);
}
.bk-act:active { color: var(--accent); border-color: var(--accent); }
.book-empty-hint {
    text-align: center; padding: 40px 24px; color: var(--text2);
    font-size: 14px;
}
.text-muted { color: var(--text3); font-size: 12px; }

/* Read-modal: ratings */
.modal--book { max-width: 92vw; max-height: 80vh; overflow-y: auto; }
.rating-rows { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.rate-row {
    display: flex; align-items: center; gap: 12px;
    padding: 8px 0; border-bottom: 0.5px solid var(--border);
}
.rate-row:last-child { border-bottom: none; }
.rate-label { font-size: 13px; min-width: 110px; color: var(--text); }
.rate-stars { display: flex; flex-wrap: nowrap; gap: 3px; flex: 1; }
.rate-star {
    width: 22px; height: 26px;
    border: 1px solid var(--border); border-radius: 4px;
    background: transparent; color: var(--text3);
    font-size: 11px; font-weight: 600; cursor: pointer;
    font-family: inherit; padding: 0;
}
.rate-star.on {
    background: var(--accent-muted);
    border-color: var(--accent); color: var(--accent);
}
.modal--book textarea {
    width: 100%; padding: 10px; margin-top: 8px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--bg2); color: var(--text);
    font-size: 13px; font-family: inherit; resize: vertical;
}

/* ===== Цитаты ===== */
.quotes-feed {
    display: flex; flex-direction: column; gap: 10px;
    padding: 0 16px 100px;
}
.quote-card {
    background: var(--card); border-radius: var(--radius);
    padding: 14px 16px; box-shadow: var(--shadow);
    border-left: 3px solid var(--accent);
}
.qt-text {
    font-size: 14px; line-height: 1.55; color: var(--text);
    font-style: italic;
}
.qt-meta {
    font-size: 11px; color: var(--text3); margin-top: 8px;
}

/* ===== Книги: компактный список (новая раскладка) ===== */
.book-card--compact {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    cursor: pointer;
    transition: background var(--duration-fast);
}
.book-card--compact:active { background: var(--bg3); }
.bk-compact-main { min-width: 0; }
.bk-meta-compact {
    display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px;
    font-size: 11px;
}
.bk-pill, .bk-fam, .bk-rate-pill {
    background: var(--bg2); padding: 2px 8px; border-radius: 10px;
    color: var(--text2); font-weight: 500; white-space: nowrap;
}
.bk-pill--ok { background: var(--accent-muted); color: var(--accent); }
.bk-pill--mid { background: rgba(245,158,11,0.15); color: #F59E0B; }
.bk-rate-pill { background: var(--accent-muted); color: var(--accent); font-weight: 700; }
.bk-fam { background: var(--bg3); }
.bk-chev { font-size: 22px; color: var(--text3); padding: 0 4px; }

/* ===== Книги: детальная страница ===== */
.bk-detail-back { padding: 12px 16px 0; }
.back-link {
    background: transparent; border: none; color: var(--accent);
    font-size: 14px; font-weight: 500; cursor: pointer; padding: 8px 0;
    font-family: inherit;
}
.bk-detail {
    padding: 0 16px 100px;
    display: flex; flex-direction: column; gap: 16px;
}
.bk-detail-head {
    display: flex; gap: 14px; align-items: flex-start;
    background: var(--card); padding: 16px;
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.bk-detail-fmt {
    width: 56px; height: 70px; flex-shrink: 0;
    background: var(--bg2); border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: var(--text2);
    letter-spacing: 0.05em;
}
.bk-detail-title { font-size: 18px; font-weight: 700; color: var(--text); line-height: 1.25; }
.bk-detail-author { font-size: 13px; color: var(--text2); margin-top: 4px; }
.bk-detail-sub { font-size: 11px; color: var(--text3); margin-top: 4px; }
.bk-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.bk-tag {
    font-size: 10px; padding: 1px 7px; border-radius: 8px;
    background: var(--bg2); color: var(--text2);
}
.bk-detail-desc {
    background: var(--card); padding: 14px 16px;
    border-radius: var(--radius); box-shadow: var(--shadow);
    font-size: 14px; line-height: 1.55; color: var(--text);
}
.bk-detail-actions {
    display: flex; gap: 8px; flex-wrap: wrap;
}
.bk-detail-btn {
    flex: 1 1 calc(50% - 4px); min-width: 0;
    padding: 10px 14px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--card);
    color: var(--text); font-size: 13px; font-weight: 500;
    cursor: pointer; font-family: inherit; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}
.bk-detail-btn:active { color: var(--accent); border-color: var(--accent); }

.bk-detail-section {
    background: var(--card); border-radius: var(--radius);
    padding: 14px 16px; box-shadow: var(--shadow);
}
.bk-section-title {
    font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em;
    font-weight: 600; color: var(--text2); margin-bottom: 10px;
}
.bk-empty { font-size: 13px; color: var(--text3); text-align: center; padding: 8px 0; }

.bk-read-card {
    padding: 10px 0;
    border-bottom: 0.5px solid var(--border);
}
.bk-read-card:last-child { border-bottom: none; }
.bk-read-card--me { border-left: 2px solid var(--accent); padding-left: 10px; }
.bk-read-head {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 6px;
}
.bk-read-name { font-size: 14px; font-weight: 600; color: var(--text); }
.bk-read-status { font-size: 11px; color: var(--text2); }
.bk-ratings {
    display: flex; flex-wrap: wrap; gap: 6px;
    font-size: 11px; color: var(--text2); margin-bottom: 6px;
}
.bk-rate { background: var(--bg2); padding: 2px 7px; border-radius: 8px; }
.bk-rate b { color: var(--accent); }
.bk-review {
    font-size: 13px; color: var(--text); line-height: 1.5;
    background: var(--bg2); padding: 8px 12px; border-radius: var(--radius-sm);
    margin-top: 4px;
}

.bk-quote {
    padding: 8px 0;
    border-bottom: 0.5px dashed var(--border);
}
.bk-quote:last-child { border-bottom: none; }
.bk-quote-text { font-style: italic; font-size: 13px; line-height: 1.55; color: var(--text); }
.bk-quote-meta { font-size: 11px; color: var(--text3); margin-top: 4px; }

/* ===== Recommend & Delete modals ===== */
.recommend-members {
    display: flex; flex-direction: column; gap: 8px; margin: 8px 0;
}
.rec-member {
    padding: 12px 14px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: transparent;
    color: var(--text); font-size: 14px; font-weight: 500;
    cursor: pointer; font-family: inherit; text-align: left;
}
.rec-member.on { border-color: var(--accent); color: var(--accent); background: var(--accent-muted); }
.modal-text { font-size: 13px; color: var(--text2); margin: 8px 0; }
.btn-danger {
    background: var(--red); color: #fff;
}
