﻿/* ---------- BODY ---------- */
html,
body {
    height: 100%;
}

html {
    box-sizing: border-box;
}

*,
*::before,
*::after {
    box-sizing: inherit;
}

body {
    font-family: Arial, sans-serif;
    text-align: center;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 24px 0;
    min-height: 100vh;
    -webkit-text-size-adjust: 100%;
    overscroll-behavior: none;
}

:root {
    --bg: radial-gradient(1200px 700px at 50% 0%, rgba(28, 175, 116, 0.08), rgba(255, 255, 255, 0)),
        #f6f7fb;
    --text: #0b1220;
    --muted: rgba(11, 18, 32, 0.72);
    --surface: rgba(255, 255, 255, 0.72);
    --surface-strong: rgba(255, 255, 255, 0.92);
    --border: rgba(11, 18, 32, 0.12);
    --shadow: 0 18px 55px rgba(11, 18, 32, 0.12);
    --shadow-soft: 0 10px 26px rgba(11, 18, 32, 0.12);
    --shadow-hover: 0 18px 44px rgba(11, 18, 32, 0.16);
    --primary: #16a34a;
    --primary-2: #22c55e;
    --danger: #ef4444;
    --control: rgba(255, 255, 255, 0.92);
    --radius: 16px;
}

body.dark {
    --bg: radial-gradient(1200px 700px at 50% 0%, rgba(34, 197, 94, 0.12), rgba(0, 0, 0, 0)),
        #0b0f17;
    --text: #f2f5ff;
    --muted: rgba(242, 245, 255, 0.75);
    --surface: rgba(255, 255, 255, 0.06);
    --surface-strong: rgba(255, 255, 255, 0.09);
    --border: rgba(255, 255, 255, 0.10);
    --shadow: 0 18px 55px rgba(0, 0, 0, 0.55);
    --shadow-soft: 0 10px 26px rgba(0, 0, 0, 0.40);
    --shadow-hover: 0 18px 44px rgba(0, 0, 0, 0.48);
    --control: rgba(255, 255, 255, 0.12);
}

/* ---------- CONTAINER ---------- */
.container {
    margin-top: 10px;
    padding: 20px 18px;
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
    background: var(--surface-strong);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

/* ---------- TITLE ---------- */
h1 {
    font-size: 28px;
    margin: 0 0 14px;
}

/* ---------- COUNTER ---------- */
#counter {
    font-size: 84px;
    font-weight: bold;
    margin: 14px 0 8px;
}

.progress {
    width: min(420px, 100%);
    height: 10px;
    margin: 10px auto 0;
    border-radius: 999px;
    background: rgba(11, 18, 32, 0.10);
    overflow: hidden;
    border: 1px solid var(--border);
}

body.dark .progress {
    background: rgba(255, 255, 255, 0.10);
}

.progressBar {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--primary), var(--primary-2));
    transition: width 160ms ease;
}

#targetStatus {
    margin-top: 0;
    min-height: 22px;
    opacity: 0.95;
    color: var(--muted);
}

/* ---------- BUTTON BASE ---------- */
button {
    font-size: 18px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    padding: 15px 25px;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    box-shadow: var(--shadow-soft);
    background: var(--control);
    color: var(--text);
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    box-sizing: border-box;
}

.toggle,
.presets button,
#resetBtn,
#minusBtn,
#modeBtn,
#setCustomTargetBtn {
    touch-action: manipulation;
}

button::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(11, 18, 32, 0.46);
    opacity: 0;
    pointer-events: none;
}

body.dark button::after {
    background: rgba(255, 255, 255, 0.52);
}

button.tap-feedback::after {
    animation: tapFlash 380ms ease-out;
}

@keyframes tapFlash {
    0% {
        opacity: 0;
    }
    30% {
        opacity: 1;
    }
    60% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

#clearTargetBtn.tap-feedback::after,
#setCustomTargetBtn.tap-feedback::after {
    background: rgba(34, 197, 94, 0.48);
}

button:focus-visible {
    outline: 3px solid rgba(22, 163, 74, 0.55);
    outline-offset: 3px;
}

body.dark button:focus-visible {
    outline: 3px solid rgba(255, 255, 255, 0.65);
}

button:hover {
    transform: scale(1.05);
    opacity: 0.95;
    box-shadow: var(--shadow-hover);
}

button:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-soft);
}

button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

/* ---------- CONTROLS ROW ---------- */
.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.settings {
    margin-top: 14px;
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius);
    background: var(--surface-strong);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
    user-select: none;
}

.toggle input {
    width: 18px;
    height: 18px;
}

/* ---------- BIG COUNT BUTTON ---------- */
#countBtn {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, var(--primary-2), var(--primary));
    color: white;
    font-size: 32px;
    font-weight: bold;
    box-shadow: 0 22px 60px rgba(34, 197, 94, 0.25), var(--shadow);
    touch-action: manipulation;
}

/* ---------- DECREASE BUTTON ---------- */
#minusBtn {
    background: var(--control);
    color: var(--text);
    border-radius: var(--radius);
    width: 80px;
    height: 56px;
    padding: 0;
    font-size: 22px;
}

/* ---------- RESET BUTTON ---------- */
#resetBtn {
    background: transparent;
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.45);
    height: 56px;
    border-radius: 999px;
    padding: 0 22px;
}

body.dark #resetBtn {
    border: 1px solid rgba(239, 68, 68, 0.55);
}

/* ---------- MODE BUTTON ---------- */
#modeBtn {
    background: var(--control);
    color: var(--text);
    height: 56px;
    border-radius: 999px;
    padding: 0 22px;
}

/* ---------- PRESET TARGET BUTTONS ---------- */
.presets {
    margin-top: 16px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
}

.customTarget {
    margin-top: 14px;
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: nowrap;
}

#customTargetInput {
    height: 46px;
    width: 170px;
    border: none;
    border-radius: 999px;
    padding: 0 16px;
    background: var(--control);
    color: var(--text);
    box-shadow: var(--shadow-soft);
    font-size: 16px;
    box-sizing: border-box;
    min-width: 0;
    border: 1px solid rgba(11, 18, 32, 0.32);
}

body.dark #customTargetInput {
    background: var(--surface-strong);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.22);
}

#customTargetInput::placeholder {
    color: var(--muted);
}

body.dark #customTargetInput::placeholder {
    color: var(--muted);
}

#setCustomTargetBtn {
    height: 46px;
    border-radius: 999px;
    padding: 0 18px;
    background: var(--control);
    color: var(--text);
    min-width: 74px;
}

.presets button {
    background: var(--surface-strong);
    color: var(--text);
    min-width: 84px;
    border-radius: 999px;
    padding: 12px 18px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
}

.presets button.active {
    background: linear-gradient(180deg, rgba(34, 197, 94, 0.30), rgba(34, 197, 94, 0.14));
    border: 1px solid rgba(34, 197, 94, 0.55);
    box-shadow: 0 18px 44px rgba(34, 197, 94, 0.26), var(--shadow-soft);
    font-weight: 700;
}

.presets button.active::before {
    content: "✓ ";
}

#clearTargetBtn {
    background: var(--control);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
}

#clearTargetBtn.active {
    background: rgba(34, 197, 94, 0.10);
    border: 1px solid rgba(34, 197, 94, 0.28);
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 22px;
    transform: translateX(-50%);
    background: rgba(11, 18, 32, 0.92);
    color: #ffffff;
    padding: 12px 14px;
    border-radius: 12px;
    min-width: 200px;
    max-width: min(520px, calc(100vw - 32px));
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

body.dark .toast {
    background: rgba(11, 18, 32, 0.92);
    color: #ffffff;
    box-shadow: var(--shadow-soft);
}

.toast.show {
    opacity: 1;
}

@keyframes targetPulse {
    0% {
        box-shadow: 0 22px 60px rgba(34, 197, 94, 0.25), var(--shadow);
        transform: scale(1);
    }
    35% {
        box-shadow: 0 26px 72px rgba(34, 197, 94, 0.42), var(--shadow);
        transform: scale(1.06);
    }
    100% {
        box-shadow: 0 22px 60px rgba(34, 197, 94, 0.25), var(--shadow);
        transform: scale(1);
    }
}

#countBtn.target-reached {
    animation: targetPulse 520ms ease-out;
}

/* ---------- MOBILE RESPONSIVE ---------- */
@media(max-width:600px) {

    body {
        padding: 12px 0;
        min-height: 100svh;
        overflow-y: auto;
    }

    .container {
        padding: 16px 12px;
        border-radius: 18px;
        max-height: none;
        overflow: visible;
    }

    h1 {
        font-size: 22px;
        margin: 0 0 12px;
    }

    #counter {
        font-size: 58px;
        margin: 14px 0 8px;
    }

    #countBtn {
        width: 96px;
        height: 96px;
        font-size: 24px;
    }

    .controls {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "minus mode"
            "count count"
            "reset reset";
        align-items: center;
        gap: 10px;
    }

    #minusBtn {
        grid-area: minus;
        width: 100%;
        height: 48px;
    }

    #modeBtn {
        grid-area: mode;
        width: 100%;
        height: 48px;
        padding: 0 18px;
    }

    #countBtn {
        grid-area: count;
        justify-self: center;
    }

    #resetBtn {
        grid-area: reset;
        width: 100%;
        height: 44px;
        padding: 0 18px;
        font-size: 16px;
    }

    .settings {
        margin-top: 10px;
        gap: 10px;
    }

    .toggle {
        padding: 8px 12px;
        border-radius: 14px;
    }

    .presets {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

    .presets button {
        min-width: 0;
        width: 100%;
        padding: 12px 12px;
    }

    .customTarget {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 10px;
        margin-top: 10px;
    }

    #customTargetInput {
        width: 100%;
        height: 44px;
        font-size: 16px;
    }

    #setCustomTargetBtn {
        height: 44px;
    }
}

@media (prefers-reduced-motion: reduce) {
    button {
        transition: none;
    }

    button:hover {
        transform: none;
    }
}

.seo-text {
    max-width: 700px;
    margin: 40px auto;
    font-size: 16px;
    line-height: 1.6;
    text-align: left;
    opacity: 0.9;
}