:root {
    --bg-gradient-start: #040715;
    --bg-gradient-mid: #211a4f;
    --bg-gradient-end: #5b21b6;
    --panel-overlay: rgba(12, 16, 41, 0.82);
    --panel-border: rgba(124, 58, 237, 0.45);
    --text-primary: #f4f3ff;
    --accent-gold: #facc15;
    --accent-lime: #22c55e;
    --accent-rose: #fb7185;
    --accent-sky: #38bdf8;
    --accent-iris: #8b5cf6;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', sans-serif;
    background:
        radial-gradient(120% 120% at 15% 0%, rgba(56, 189, 248, 0.28) 0%, transparent 60%),
        radial-gradient(110% 110% at 85% 18%, rgba(139, 92, 246, 0.35) 0%, transparent 62%),
        linear-gradient(150deg, var(--bg-gradient-start) 0%, var(--bg-gradient-mid) 48%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
    color: var(--text-primary);
    padding-top: 4rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.site-header {
    background: linear-gradient(105deg, rgba(17, 24, 39, 0.92) 0%, rgba(76, 29, 149, 0.88) 100%);
    color: var(--text-primary);
    padding: 0.75rem 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    backdrop-filter: blur(14px);
    box-shadow: 0 14px 34px rgba(8, 11, 28, 0.65);
}

.site-header__link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0 1.5rem;
    font-weight: 700;
    color: inherit;
    text-decoration: none;
    font-size: 1.1rem;
    letter-spacing: 0.02em;
}

.site-header__logo {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

.main-content {
    min-height: calc(100vh - 4rem);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.main-layout {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    justify-content: center;
    align-items: stretch;
    width: min(1100px, 92%);
    margin-top: 2rem;
}

.container {
    text-align: center;
    padding: 2.6rem 2.4rem;
    background: var(--panel-overlay);
    border-radius: 28px;
    box-shadow: 0 28px 55px rgba(5, 10, 32, 0.65);
    border: 1.5px solid var(--panel-border);
    max-width: 540px;
    width: min(100%, 540px);
    margin-top: 4rem;
    position: relative;
    overflow: hidden;
}

.container::before {
    content: '';
    position: absolute;
    inset: -35% -45% auto auto;
    width: 320px;
    height: 320px;
    background: radial-gradient(circle at center, rgba(88, 28, 135, 0.55), transparent 70%);
    opacity: 0.55;
    filter: blur(0.5px);
    pointer-events: none;
}

.container::after {
    content: '';
    position: absolute;
    inset: auto auto -25% -30%;
    width: 280px;
    height: 280px;
    background: radial-gradient(circle at center, rgba(14, 116, 144, 0.4), transparent 72%);
    opacity: 0.55;
    pointer-events: none;
}

.challenge-panel {
    flex: 1 1 340px;
}

.achievements-panel {
    flex: 1 1 300px;
    padding: 2.4rem 2.1rem;
    background: var(--panel-overlay);
    border-radius: 28px;
    border: 1.5px solid var(--panel-border);
    box-shadow: 0 24px 48px rgba(5, 10, 32, 0.55);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    gap: 1.4rem;
    margin-top: 4rem;
    position: relative;
    overflow: hidden;
}

.achievements-panel::before {
    content: '';
    position: absolute;
    inset: -25% -35% auto auto;
    width: 260px;
    height: 260px;
    background: radial-gradient(circle at center, rgba(250, 204, 21, 0.35), transparent 70%);
    opacity: 0.65;
    pointer-events: none;
}

.achievements-panel::after {
    content: '';
    position: absolute;
    inset: auto auto -28% -40%;
    width: 220px;
    height: 220px;
    background: radial-gradient(circle at center, rgba(56, 189, 248, 0.28), transparent 70%);
    opacity: 0.55;
    pointer-events: none;
}

.achievements-panel > * {
    position: relative;
    z-index: 1;
}

.achievements-panel h2 {
    font-size: 1.9rem;
    text-align: left;
    text-shadow: 0 10px 24px rgba(2, 6, 23, 0.65);
}

.achievements-note {
    font-size: 0.95rem;
    color: rgba(226, 232, 240, 0.82);
    line-height: 1.6;
}

.achievements-progress {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent-sky);
    padding: 0.75rem 1rem;
    background: rgba(37, 99, 235, 0.18);
    border-radius: 18px;
    border: 1px solid rgba(56, 189, 248, 0.35);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.achievements-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 0;
    margin: 0;
}

.achievement-item {
    padding: 1rem 1.1rem;
    border-radius: 22px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(15, 23, 42, 0.55);
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.08);
    display: flex;
    gap: 0.85rem;
    align-items: flex-start;
    transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.achievement-item.locked {
    opacity: 0.65;
}

.achievement-item.unlocked {
    border-color: rgba(250, 204, 21, 0.65);
    background: rgba(65, 17, 88, 0.55);
    box-shadow: 0 0 28px rgba(250, 204, 21, 0.28);
    transform: translateY(-2px);
}

.achievement-icon {
    font-size: 1.6rem;
    line-height: 1;
}

.achievement-content {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.achievement-title {
    font-weight: 700;
    font-size: 1.1rem;
}

.achievement-desc {
    font-size: 0.9rem;
    color: rgba(226, 232, 240, 0.82);
}

.achievement-status {
    font-size: 0.8rem;
    color: rgba(148, 163, 184, 0.9);
}

.achievement-item.unlocked .achievement-status {
    color: var(--accent-gold);
}

h1 {
    font-size: 2.6rem;
    margin-bottom: 1.1rem;
    text-shadow: 0 12px 28px rgba(2, 6, 23, 0.78);
    letter-spacing: 0.04em;
}

.target {
    font-size: 3rem;
    color: var(--accent-gold);
    margin: 1rem 0;
    text-shadow: 0 0 18px rgba(250, 204, 21, 0.6);
}

.timer-display {
    font-size: 4.2rem;
    font-weight: bold;
    margin: 2.2rem 0;
    font-family: 'Courier New', ui-monospace, monospace;
    color: #f8fafc;
    text-shadow: 0 0 24px rgba(148, 163, 184, 0.75);
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 0.08em;
}

.button {
    font-size: 1.35rem;
    padding: 1rem 2.2rem;
    margin: 0.6rem;
    border: none;
    border-radius: 48px;
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease, filter 0.25s ease;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #070a1f;
    box-shadow: 0 16px 28px rgba(3, 7, 18, 0.45);
}

.button:focus-visible {
    outline: 3px solid rgba(56, 189, 248, 0.65);
    outline-offset: 4px;
}

.button:hover {
    transform: translateY(-3px) scale(1.01);
    filter: brightness(1.08);
}

.main-button {
    background: linear-gradient(140deg, #38bdf8 0%, #0ea5e9 48%, #6366f1 100%);
}

.main-button.stop-mode {
    background: linear-gradient(140deg, #fb7185 0%, #f43f5e 50%, #be123c 100%);
}

.result {
    margin-top: 2.1rem;
    font-size: 1.55rem;
    font-weight: 700;
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0.4rem;
    text-align: center;
}

.perfect {
    color: var(--accent-gold);
    animation: glow 1.2s ease-in-out infinite alternate;
    text-shadow: 0 0 24px rgba(250, 204, 21, 0.75);
}

.close {
    color: var(--accent-lime);
    text-shadow: 0 0 18px rgba(34, 197, 94, 0.55);
}

.far {
    color: var(--accent-rose);
    text-shadow: 0 0 20px rgba(251, 113, 133, 0.5);
}

@keyframes glow {
    from {
        text-shadow: 0 0 18px rgba(250, 204, 21, 0.6), 0 0 34px rgba(250, 204, 21, 0.45);
    }
    to {
        text-shadow: 0 0 30px rgba(250, 204, 21, 0.85), 0 0 56px rgba(250, 204, 21, 0.55);
    }
}

.instructions {
    margin-top: 1.25rem;
    font-size: 1rem;
    opacity: 0.9;
    line-height: 1.7;
    color: rgba(226, 232, 240, 0.92);
}

.instructions small {
    color: var(--accent-sky);
    font-size: 0.95rem;
}

.best-score {
    margin-top: 1.1rem;
    font-size: 1.2rem;
    color: var(--accent-sky);
    text-shadow: 0 0 16px rgba(56, 189, 248, 0.48);
}

/* モーダル */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: linear-gradient(135deg, rgba(88, 28, 135, 0.95) 0%, rgba(76, 29, 149, 0.95) 100%);
    border-radius: 32px;
    padding: 3rem 2.5rem;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.7);
    border: 2px solid rgba(250, 204, 21, 0.6);
    position: relative;
    animation: modalSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px) scale(0.9);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.modal-fireworks {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.firework {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: fireworkExplosion 2s ease-out infinite;
}

.firework:nth-child(1) {
    top: 20%;
    left: 20%;
    background: var(--accent-gold);
    animation-delay: 0s;
}

.firework:nth-child(2) {
    top: 30%;
    right: 15%;
    background: var(--accent-sky);
    animation-delay: 0.5s;
}

.firework:nth-child(3) {
    bottom: 25%;
    left: 25%;
    background: var(--accent-rose);
    animation-delay: 1s;
}

.firework:nth-child(4) {
    bottom: 20%;
    right: 20%;
    background: var(--accent-lime);
    animation-delay: 1.5s;
}

@keyframes fireworkExplosion {
    0% {
        transform: scale(0);
        opacity: 1;
        box-shadow: 0 0 0 0 currentColor;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: scale(20);
        opacity: 0;
        box-shadow: 0 0 40px 20px currentColor;
    }
}

.modal-header {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    animation: bounce 1s ease infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-15px);
    }
}

.modal-title {
    font-size: 2.5rem;
    color: var(--accent-gold);
    margin-bottom: 1.5rem;
    text-shadow: 0 0 30px rgba(250, 204, 21, 0.8);
    animation: glow 1.5s ease-in-out infinite alternate;
}

.modal-score {
    font-size: 3.5rem;
    font-weight: bold;
    color: #fff;
    margin: 1.5rem 0;
    font-family: 'Courier New', monospace;
    text-shadow: 0 0 40px rgba(255, 255, 255, 0.8);
    letter-spacing: 0.1em;
}

.modal-message {
    font-size: 1.3rem;
    line-height: 1.8;
    margin: 1.5rem 0 2rem;
    color: rgba(255, 255, 255, 0.95);
}

.modal-close-btn {
    background: linear-gradient(140deg, var(--accent-gold) 0%, #f59e0b 100%);
    color: #1a1a2e;
    font-size: 1.3rem;
    padding: 1rem 2.5rem;
    margin-top: 1rem;
}

@media (max-width: 820px) {
    .main-layout {
        width: 90%;
    }

    .achievements-panel,
    .challenge-panel {
        flex: 1 1 100%;
    }
    
    .modal-content {
        padding: 2.5rem 2rem;
    }
    
    .modal-title {
        font-size: 2rem;
    }
    
    .modal-score {
        font-size: 2.8rem;
    }
}
