/* Pazun Fox Mini App v3 — iOS-like Telegram UI */

:root {
    --bg: #f2f2f7;
    --bg-elevated: #ffffff;
    --secondary-bg: #f2f2f7;
    --text: #000000;
    --hint: #8e8e93;
    --link: #007aff;
    --button: #ff9f0a;
    --button-text: #ffffff;
    --separator: rgba(60, 60, 67, 0.18);
    --card-radius: 16px;
    --tabbar-h: 64px;
    --accent: #ff9f0a;
    --accent-soft: rgba(255, 159, 10, 0.14);
    --green: #34c759;
    --red: #ff3b30;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
        Roboto, "Helvetica Neue", "Segoe UI", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.35;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}

button, input {
    font: inherit;
    color: inherit;
}

#app {
    min-height: 100%;
    max-width: 480px;
    margin: 0 auto;
    position: relative;
    padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
}

/* ---------- large title header ---------- */

.nav-large {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: calc(12px + var(--safe-top)) 16px 10px;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-bottom: 0.5px solid transparent;
    transition: border-color 0.2s;
}

.nav-large.scrolled {
    border-bottom-color: var(--separator);
}

.nav-large-title {
    font-size: 34px;
    font-weight: 800;
    letter-spacing: -0.4px;
    line-height: 1.1;
}

/* ---------- content / views ---------- */

.content {
    padding: 8px 16px 8px;
}

.view {
    display: none;
    animation: fadeIn 0.22s ease;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---------- cards ---------- */

.card {
    background: var(--bg-elevated);
    border-radius: var(--card-radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 12px;
}

.card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--hint);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 12px;
}

.list-header {
    font-size: 13px;
    font-weight: 600;
    color: var(--hint);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 10px 4px 8px;
}

.list-card {
    padding: 0;
    overflow: hidden;
}

/* ---------- profile ---------- */

.profile-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--bg-elevated);
    border-radius: var(--card-radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 12px;
}

.avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    overflow: hidden;
    flex-shrink: 0;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-name {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.2px;
}

.profile-sub {
    font-size: 14px;
    color: var(--hint);
    margin-top: 2px;
}

/* ---------- hero streak ---------- */

.hero-card {
    background: linear-gradient(145deg, #ff9f0a 0%, #ff6b00 55%, #ff375f 100%);
    color: #fff;
    border-radius: 20px;
    padding: 28px 20px;
    text-align: center;
    margin-bottom: 12px;
    box-shadow: 0 8px 28px rgba(255, 107, 0, 0.28);
}

.hero-flame {
    font-size: 48px;
    line-height: 1;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
}

.hero-num {
    font-size: 64px;
    font-weight: 800;
    letter-spacing: -1.5px;
    line-height: 1;
    margin-top: 6px;
    font-variant-numeric: tabular-nums;
}

.hero-label {
    font-size: 15px;
    font-weight: 600;
    opacity: 0.95;
    margin-top: 4px;
}

.hero-meta {
    font-size: 13px;
    opacity: 0.85;
    margin-top: 8px;
}

.hero-card.cold {
    background: linear-gradient(145deg, #64d2ff 0%, #0a84ff 100%);
    box-shadow: 0 8px 28px rgba(10, 132, 255, 0.25);
}

/* ---------- claim ---------- */

.claim-label {
    font-size: 15px;
    color: var(--hint);
    margin-bottom: 12px;
    text-align: center;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    max-width: 280px;
    margin: 0 auto;
}

.claim-emoji {
    aspect-ratio: 1;
    border: 2px solid rgba(255, 255, 255, 0.08);
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
    border-radius: 18px;
    font-size: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, border-color 0.15s, background 0.15s, box-shadow 0.15s, opacity 0.15s;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    -webkit-tap-highlight-color: transparent;
}

.claim-emoji:active {
    transform: scale(0.9);
}

.claim-emoji.selected {
    border-color: var(--accent);
    background: linear-gradient(160deg, rgba(255, 159, 10, 0.28), rgba(255, 159, 10, 0.1));
    transform: scale(1.06);
    box-shadow: 0 8px 24px rgba(255, 159, 10, 0.35);
}

.claim-emoji:disabled {
    opacity: 0.55;
    pointer-events: none;
}

.claim-emoji:disabled:not(.selected) {
    opacity: 0.3;
}

.btn-primary {
    display: block;
    width: 100%;
    margin-top: 14px;
    border: none;
    border-radius: 14px;
    background: var(--accent);
    color: #fff;
    font-size: 17px;
    font-weight: 700;
    padding: 15px 16px;
    cursor: pointer;
    transition: transform 0.12s, opacity 0.12s;
    min-height: 50px;
}

.btn-primary:active {
    transform: scale(0.98);
    opacity: 0.9;
}

.btn-primary:disabled {
    opacity: 0.4;
    pointer-events: none;
}

.btn-primary.secondary {
    background: var(--secondary-bg);
    color: var(--link);
}

.countdown-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--secondary-bg);
    border-radius: 999px;
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 600;
    color: var(--hint);
    width: 100%;
    justify-content: center;
}

/* ---------- history ---------- */

.emoji-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.emoji-chip {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--secondary-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

/* ---------- list rows ---------- */

.rows {
    display: flex;
    flex-direction: column;
}

.row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 16px;
    min-height: 52px;
    border-bottom: 0.5px solid var(--separator);
    background: transparent;
    width: 100%;
    text-align: left;
    border-left: none;
    border-right: none;
    border-top: none;
    cursor: default;
}

.row:last-child {
    border-bottom: none;
}

button.row {
    cursor: pointer;
    transition: background 0.12s;
}

button.row:active {
    background: var(--secondary-bg);
}

.row-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--secondary-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.row-body {
    flex: 1;
    min-width: 0;
}

.row-title {
    font-size: 16px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.row-sub {
    font-size: 13px;
    color: var(--hint);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.row-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--accent);
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.row-value.muted {
    color: var(--hint);
    font-weight: 500;
}

.row-chevron {
    color: var(--hint);
    font-size: 14px;
    opacity: 0.5;
}

.list-empty {
    padding: 24px 16px;
    text-align: center;
    color: var(--hint);
    font-size: 15px;
}

/* ---------- forms ---------- */

.form-card {
    padding: 16px;
}

.text-input {
    width: 100%;
    border: none;
    background: var(--secondary-bg);
    border-radius: 12px;
    padding: 14px 16px;
    font-size: 17px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.text-input:focus {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
}

/* ---------- streams / events ---------- */

.event-area {
    min-height: 120px;
}

.empty-state {
    text-align: center;
    padding: 28px 12px;
}

.empty-emoji {
    font-size: 44px;
    margin-bottom: 10px;
}

.empty-text {
    font-size: 17px;
    font-weight: 600;
}

.empty-sub {
    font-size: 14px;
    color: var(--hint);
    margin-top: 6px;
}

.poll-option {
    display: block;
    width: 100%;
    margin-bottom: 10px;
    padding: 14px 16px;
    border: none;
    border-radius: 14px;
    background: var(--secondary-bg);
    text-align: left;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: transform 0.12s;
    min-height: 50px;
}

.poll-option:active {
    transform: scale(0.98);
}

.poll-option .bar {
    position: absolute;
    inset: 0 auto 0 0;
    background: color-mix(in srgb, var(--accent) 28%, transparent);
    width: 0;
    transition: width 0.5s ease;
    z-index: 0;
}

.poll-option .label {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
}

.poll-option .pct {
    color: var(--hint);
    font-variant-numeric: tabular-nums;
}

.poll-option.voted {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.big-cta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px;
}

.big-cta-btn {
    width: 100%;
    border: none;
    border-radius: 16px;
    background: linear-gradient(145deg, #ff9f0a, #ff375f);
    color: #fff;
    font-size: 20px;
    font-weight: 800;
    padding: 28px;
    cursor: pointer;
    transition: transform 0.1s;
    box-shadow: 0 6px 20px rgba(255, 55, 95, 0.25);
}

.big-cta-btn:active {
    transform: scale(0.97);
}

.big-cta-meta {
    font-size: 14px;
    color: var(--hint);
    font-weight: 600;
}

.versus-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.versus-btn {
    border: none;
    border-radius: 16px;
    background: var(--secondary-bg);
    padding: 24px 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.12s;
}

.versus-btn:active {
    transform: scale(0.96);
}

.versus-btn .votes {
    display: block;
    font-size: 24px;
    margin-top: 6px;
    color: var(--accent);
}

/* ---------- tab bar ---------- */

.tabbar {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(8px + var(--safe-bottom));
    width: min(480px - 24px, calc(100% - 24px));
    height: var(--tabbar-h);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 6px;
    background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-radius: 22px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 0 0 0.5px var(--separator);
    z-index: 50;
}

.tab {
    border: none;
    background: transparent;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    cursor: pointer;
    color: var(--hint);
    transition: background 0.15s, color 0.15s, transform 0.1s;
    padding: 0;
    min-width: 0;
    user-select: none;
    -webkit-user-select: none;
}

.tab:active {
    transform: scale(0.94);
}

.tab.active {
    background: var(--accent-soft);
    color: var(--accent);
}

.tab-icon {
    font-size: 20px;
    line-height: 1;
    filter: grayscale(1) opacity(0.7);
    transition: filter 0.15s;
}

.tab.active .tab-icon {
    filter: none;
}

.tab-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.2px;
}

/* ---------- toast ---------- */

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 24px);
    transform: translateX(-50%) translateY(20px);
    background: rgba(30, 30, 30, 0.92);
    color: #fff;
    padding: 12px 18px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 100;
    max-width: 90%;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ---------- boot ---------- */

.boot-screen {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 200;
    transition: opacity 0.3s;
}

.boot-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.boot-logo {
    font-size: 56px;
    animation: pulse 1.2s ease infinite;
}

.boot-text {
    color: var(--hint);
    font-weight: 600;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

/* ---------- skeleton ---------- */

.skeleton {
    background: linear-gradient(90deg, var(--secondary-bg) 25%, #e8e8ed 50%, var(--secondary-bg) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.2s infinite;
    border-radius: 8px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ---------- responsive ---------- */

@media (max-width: 360px) {
    .nav-large-title { font-size: 30px; }
    .hero-num { font-size: 56px; }
    .emoji-grid { grid-template-columns: repeat(3, 1fr); }
    .tab-label { font-size: 9px; }
}

@media (min-width: 481px) {
    #app { border-left: 0.5px solid var(--separator); border-right: 0.5px solid var(--separator); }
}
