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

:root {
    --bg: var(--tg-theme-bg-color, #1a1a1a);
    --fg: var(--tg-theme-text-color, #ffffff);
    --secondary-bg: var(--tg-theme-secondary-bg-color, #2a2a2a);
    --hint: var(--tg-theme-hint-color, #888);
    --button: var(--tg-theme-button-color, #3b82f6);
    --button-text: var(--tg-theme-button-text-color, #fff);
    --destructive: var(--tg-theme-destructive-text-color, #ef4444);
    --link: var(--tg-theme-link-color, #6ab4f8);
}

body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.4;
    user-select: none;
    -webkit-user-select: none;
}

#app { padding: 16px; padding-bottom: 32px; max-width: 600px; margin: 0 auto; }

#status-card {
    background: var(--secondary-bg);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 20px;
}

.row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 6px 0;
}
.row.meta { font-size: 14px; color: var(--hint); }
.label { color: var(--hint); font-size: 14px; }
.value { font-weight: 500; }
.value.big { font-size: 28px; font-weight: 700; }

.progress-wrap {
    position: relative;
    background: rgba(255,255,255,0.08);
    border-radius: 8px;
    height: 28px;
    margin: 12px 0;
    overflow: hidden;
}
.progress-bar {
    position: absolute; left: 0; top: 0; bottom: 0;
    background: linear-gradient(90deg, #22c55e 0%, #84cc16 50%, #f59e0b 80%, #ef4444 100%);
    transition: width 0.4s ease;
    border-radius: 8px;
}
.progress-text {
    position: relative;
    text-align: center;
    line-height: 28px;
    font-weight: 600;
    font-size: 14px;
    text-shadow: 0 0 4px rgba(0,0,0,0.5);
}

#flags {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.flag {
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    background: rgba(239,68,68,0.15);
    color: #fca5a5;
}

.section { margin-bottom: 20px; }
.section-title {
    font-size: 13px;
    color: var(--hint);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding-left: 4px;
}

.btn-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
.section:nth-of-type(2) .btn-row {
    grid-template-columns: repeat(3, 1fr);
}

.btn {
    border: none;
    border-radius: 10px;
    padding: 14px 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--button-text);
    background: var(--button);
    cursor: pointer;
    transition: opacity 0.15s, transform 0.05s;
    width: 100%;
    font-family: inherit;
}
.btn:active { transform: scale(0.96); opacity: 0.85; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-reset {
    background: var(--secondary-bg);
    color: var(--destructive);
    border: 1px solid rgba(239,68,68,0.4);
    width: 100%;
    padding: 14px;
}

#toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(34,197,94,0.95);
    color: #fff;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 100;
    max-width: 90%;
    text-align: center;
}
#toast.show { opacity: 1; }
#toast.error { background: rgba(239,68,68,0.95); }
