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

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: linear-gradient(165deg, #0c4a6e 0%, #0d9488 48%, #14b8a6 100%);
    min-height: 100vh;
    min-height: 100dvh;
    color: #0f172a;
    padding: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    -webkit-font-smoothing: antialiased;
    touch-action: manipulation;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.wrap {
    max-width: min(440px, 100%);
    margin: 0 auto;
}

.head { text-align: center; margin-bottom: clamp(10px, 2.5vw, 14px); }

.head h1 {
    font-size: clamp(1.28rem, 4.2vw, 1.55rem);
    color: #fff;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.22);
    letter-spacing: 0.04em;
}

.sub {
    margin-top: 6px;
    color: rgba(255, 255, 255, 0.92);
    font-size: 0.95rem;
    font-weight: 600;
}

.stats {
    display: flex;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.stat {
    background: rgba(255, 255, 255, 0.96);
    padding: 10px 18px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    border-radius: 12px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

.stat .lbl { color: #475569; margin-right: 8px; font-size: 0.88rem; }

.controls-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 12px;
}

.lbl-inline {
    color: #fff;
    font-size: 0.92rem;
    display: flex;
    align-items: center;
    gap: 8px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.lbl-inline select {
    min-height: 44px;
    padding: 8px 14px;
    border-radius: 10px;
    border: none;
    font-size: 1rem;
    background: #fff;
    color: #0f766e;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    max-width: min(220px, 70vw);
}

.btn {
    min-height: 44px;
    padding: 10px 18px;
    border: none;
    border-radius: 12px;
    background: #fff;
    color: #0f766e;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: transform 0.08s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.btn:hover { filter: brightness(1.03); }

.btn:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.svg-wrap {
    width: 100%;
    max-width: min(92vw, 400px);
    margin: 0 auto;
    border-radius: 18px;
    background: rgba(15, 23, 42, 0.22);
    box-shadow: inset 0 2px 14px rgba(0, 0, 0, 0.18), 0 10px 32px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    outline: none;
}

.svg-wrap:focus-visible {
    box-shadow: inset 0 2px 14px rgba(0, 0, 0, 0.18), 0 0 0 3px rgba(254, 243, 199, 0.65);
}

.graph {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1;
}

.hint {
    text-align: center;
    color: rgba(255, 255, 255, 0.92);
    font-size: clamp(0.78rem, 2.8vw, 0.88rem);
    margin-top: 12px;
    line-height: 1.55;
    padding: 0 4px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.win-banner {
    margin-top: 14px;
    text-align: center;
    padding: 14px 12px;
    background: rgba(255, 255, 255, 0.96);
    border-radius: 14px;
    font-weight: 700;
    color: #0f766e;
    font-size: clamp(1rem, 3.2vw, 1.12rem);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.win-banner.hidden { display: none; }

.btn-next {
    width: 100%;
    max-width: 280px;
    background: linear-gradient(180deg, #14b8a6 0%, #0d9488 100%);
    color: #fff;
    box-shadow: 0 4px 14px rgba(13, 148, 136, 0.35);
}

.btn-next:hover {
    filter: brightness(1.06);
}

.btn-next:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.shake {
    animation: onestroke-shake 0.35s ease;
}

@keyframes onestroke-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

@media (prefers-reduced-motion: reduce) {
    .btn { transition: none; }
    .btn:active { transform: none; }
    .shake { animation: none; }
}
