:root {
    --bg-color: #08080c;
    --card-bg: #121218;
    --text-main: #e0e0e0;
    --text-dim: #707080;
    --accent-blue: #0088cc;
    /* 少し暗く調整 */
    --border: #2a2a35;
    --font-jp: 'Noto Sans JP', sans-serif;
}

body {
    background-color: var(--bg-color);
    background-image:
        radial-gradient(circle at 2px 2px, rgba(255, 255, 255, 0.03) 1px, transparent 0);
    background-size: 24px 24px;
    color: var(--text-main);
    font-family: var(--font-jp);
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    line-height: 1.6;
    overflow-x: hidden;
}

body::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(rgba(0, 180, 255, 0) 0%,
            rgba(0, 180, 255, 0.02) 50%,
            rgba(0, 180, 255, 0) 100%);
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 10000;
    animation: scanline 10s linear infinite;
}

@keyframes scanline {
    0% {
        transform: translateY(-100%);
    }

    100% {
        transform: translateY(100%);
    }
}

.container {
    width: 100%;
    max-width: 480px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 20px;
}

.app-title {
    font-size: 1.4rem;
    font-weight: 900;
    letter-spacing: 0.2rem;
    margin: 0;
}

.subtitle {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 5px;
}

.control-panel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 20px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.panel-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.group-label {
    font-size: 0.7rem;
    color: var(--text-dim);
    font-weight: bold;
    border-left: 3px solid var(--accent-blue);
    padding-left: 8px;
}

.context-switch {
    display: flex;
    gap: 10px;
}

input[type="radio"] {
    display: none;
}

.context-switch label {
    flex: 1;
    background: #1a1a24;
    border: 1px solid var(--border);
    padding: 12px 0;
    text-align: center;
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

input[name="context"]:checked+label {
    background: rgba(0, 136, 204, 0.15);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    font-weight: bold;
}

input[type="text"] {
    background: #1a1a24;
    border: 1px solid var(--border);
    color: white;
    padding: 15px;
    font-size: 1rem;
    border-radius: 4px;
    width: 100%;
    box-sizing: border-box;
}

button {
    width: 100%;
    background: linear-gradient(135deg, #8800ff, #3300ff, #000088);
    color: #fff;
    border: none;
    padding: 16px;
    font-weight: 900;
    font-size: 1.1rem;
    cursor: pointer;
    margin-top: 15px;
    border-radius: 4px;
    letter-spacing: 0.5rem;
    box-shadow: 0 4px 15px rgba(0, 136, 204, 0.3);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

button:active {
    transform: scale(0.96);
}

/* Mashing States */
button.warning {
    background: linear-gradient(135deg, #ffcc00, #ff8800);
    box-shadow: 0 4px 15px rgba(255, 136, 0, 0.4);
}

button.danger {
    background: linear-gradient(135deg, #ff4400, #cc0000);
    box-shadow: 0 4px 20px rgba(255, 68, 0, 0.5);
}

button.critical {
    background: linear-gradient(135deg, #ff0000, #660000);
    box-shadow: 0 4px 25px rgba(255, 0, 0, 0.6);
    animation: pulse 0.5s infinite alternate;
}

@keyframes pulse {
    from {
        filter: brightness(1);
    }

    to {
        filter: brightness(1.5);
    }
}

/* Result Area */
.hidden {
    display: none;
}

.result-area {
    margin-top: 25px;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
}

.report-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 24px;
    border-radius: 8px;
    border-top: 4px solid var(--accent-blue);
    position: relative;
    overflow: hidden;
}



.report-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.6rem;
    color: var(--text-dim);
    margin-bottom: 20px;
}

.diagnosis-section {
    margin-bottom: 30px;
}

.label {
    font-size: 0.65rem;
    color: var(--text-dim);
    margin-bottom: 8px;
}

.diagnosis-text {
    font-size: 1.5rem;
    margin: 5px 0;
    color: #fff;
    font-weight: 900;
    position: relative;
    display: inline-block;
}

.diagnosis-text.glitch {
    animation: glitch-skew 4s infinite linear alternate-reverse;
}

.diagnosis-text.glitch::before,
.diagnosis-text.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.8;
}

.diagnosis-text.glitch::before {
    color: #0ff;
    z-index: -1;
    animation: glitch-anim 2s infinite linear alternate-reverse;
}

.diagnosis-text.glitch::after {
    color: #f0f;
    z-index: -2;
    animation: glitch-anim2 3s infinite linear alternate-reverse;
}

@keyframes glitch-anim {
    0% {
        clip: rect(20px, 9999px, 10px, 0);
        transform: skew(3deg);
    }

    20% {
        clip: rect(40px, 9999px, 50px, 0);
        transform: skew(1deg);
    }

    40% {
        clip: rect(10px, 9999px, 30px, 0);
        transform: skew(-2deg);
    }

    60% {
        clip: rect(60px, 9999px, 20px, 0);
        transform: skew(2deg);
    }

    80% {
        clip: rect(30px, 9999px, 70px, 0);
        transform: skew(-1deg);
    }

    100% {
        clip: rect(50px, 9999px, 40px, 0);
        transform: skew(0deg);
    }
}

@keyframes glitch-anim2 {
    0% {
        clip: rect(50px, 9999px, 40px, 0);
        transform: skew(-2deg);
    }

    30% {
        clip: rect(10px, 9999px, 30px, 0);
        transform: skew(3deg);
    }

    60% {
        clip: rect(70px, 9999px, 10px, 0);
        transform: skew(-1deg);
    }

    90% {
        clip: rect(40px, 9999px, 60px, 0);
        transform: skew(2deg);
    }

    100% {
        clip: rect(20px, 9999px, 50px, 0);
        transform: skew(0deg);
    }
}

@keyframes glitch-skew {
    0% {
        transform: skew(0deg);
    }

    90% {
        transform: skew(0deg);
    }

    95% {
        transform: skew(-3deg);
    }

    100% {
        transform: skew(3deg);
    }
}

.diagnosis-desc {
    font-size: 0.8rem;
    color: #b0b0c0;
    line-height: 1.5;
}

.score-container {
    display: flex;
    align-items: baseline;
}

.score {
    font-family: 'Orbitron', sans-serif;
    font-size: 4rem;
    font-weight: 400;
    line-height: 1;
    letter-spacing: -2px;
    background: linear-gradient(135deg, #8a2be2, #00d4ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.unit {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2rem;
    margin-left: 5px;
    font-weight: 400;
    background: linear-gradient(135deg, #8a2be2, #00d4ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.score.danger,
.unit.danger {
    background: linear-gradient(135deg, #ff0000, #ff4d4d);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.brain-bar-row {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.8rem;
}

.bar-label {
    width: 90px;
    color: #fff;
}

.bar-track {
    flex: 1;
    background: #20202a;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4b0082, #8a2be2, #00d4ff);
    transition: width 1s cubic-bezier(0.1, 0, 0, 1);
}

.bar-fill.danger {
    background: linear-gradient(90deg, #8b0000, #ff0000, #ff4500);
}

.env-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 15px 0 25px 0;
}

.env-tags span {
    background: #1a1a24;
    border: 1px solid #3a3a45;
    padding: 3px 10px;
    font-size: 0.7rem;
    color: #a0a0b0;
    border-radius: 20px;
}

/* --- 🔮 Prediction Section --- */
details.prediction-section {
    margin: 20px 0 30px 0;
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    border: 1px dashed #333;
    transition: all 0.3s;
}

details.prediction-section[open] {
    background: rgba(0, 0, 0, 0.4);
}

details.prediction-section summary {
    list-style: none;
    cursor: pointer;
    font-size: 0.65rem;
    color: var(--text-dim);
    outline: none;
}

details.prediction-section summary::-webkit-details-marker {
    display: none;
}

.prediction-timeline {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.7rem;
    color: #0088cc;
    /* 暗めの青 */
    line-height: 1.4;
    margin: 10px 0;
    letter-spacing: 1px;
}

.timeline-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 4px;
}

.timeline-row .time {
    width: 40px;
}

.timeline-row .bar {
    color: #555;
}

.timeline-row .bar b {
    color: var(--accent-blue);
    font-weight: normal;
}

.timeline-row .perc {
    width: 35px;
    text-align: right;
}

.return-time-wrapper {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    color: #fff;
    border-top: 1px solid #222;
    padding-top: 10px;
    margin-top: 5px;
}

.return-time {
    color: #0088cc;
    /* 暗めの青 */
    font-weight: 900;
}

body.retro-mode .prediction-timeline {
    color: #00ff41;
}

body.retro-mode .timeline-row .bar b {
    color: #00ff41;
}

body.retro-mode .return-time {
    color: #00ff41;
}

.satori-theme .prediction-section {
    background: rgba(255, 255, 255, 0.5);
    border-color: #ffe082;
}

.satori-theme .prediction-timeline,
.satori-theme .return-time {
    color: #827717;
}

/* --- 💊 Affiliate Section --- */
.affiliate-section {
    margin: 20px 0;
    padding: 15px;
    background: rgba(0, 136, 204, 0.05);
    border: 1px double #004466;
    border-radius: 4px;
    display: none;
    /* Initially hidden until result */
}

.affiliate-section.active {
    display: block;
    animation: slideIn 0.5s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.affiliate-label {
    font-size: 0.6rem;
    color: #0088cc;
    font-weight: bold;
    margin-bottom: 10px;
    letter-spacing: 1px;
    display: flex;
    justify-content: space-between;
}

.product-card {
    display: flex;
    gap: 15px;
    align-items: center;
}

.product-info {
    flex: 1;
}

.product-name {
    font-size: 0.85rem;
    font-weight: 900;
    color: #fff;
    margin-bottom: 4px;
}

.product-desc {
    font-size: 0.7rem;
    color: var(--text-dim);
    line-height: 1.3;
}

.buy-btn {
    padding: 8px 15px;
    background: #0088cc;
    color: #fff;
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 900;
    border-radius: 2px;
    white-space: nowrap;
    transition: all 0.2s;
    box-shadow: 0 0 10px rgba(0, 136, 204, 0.3);
}

.buy-btn:hover {
    background: #00b4ff;
    box-shadow: 0 0 15px rgba(0, 180, 255, 0.5);
    transform: translateY(-1px);
}

body.retro-mode .affiliate-section {
    border: 1px solid #00ff41;
    background: transparent;
}

body.retro-mode .buy-btn {
    background: #00ff41;
    color: #000;
}

.satori-theme .affiliate-section {
    background: #fdfcf0;
    border-color: #daa520;
    color: #827717;
}

.satori-theme .buy-btn {
    background: #daa520;
}

.share-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.share-btn {
    display: inline-block;
    box-sizing: border-box;
    background: #000;
    color: #fff;
    padding: 16px;
    text-align: center;
    text-decoration: none;
    font-weight: 900;
    border-radius: 4px;
    font-size: 0.95rem;
    border: 1px solid #333;
    letter-spacing: 0.2rem;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 0 #1a1a1a;
    width: 100%;
    cursor: pointer;
    font-family: inherit;
    line-height: 1.2;
    vertical-align: middle;
}

.download-btn {
    border-color: #555;
    background: linear-gradient(135deg, #050505, #111);
}

.share-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
    transition: 0.5s;
}

.share-btn:hover {
    background: #0a0a0a;
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 136, 204, 0.2);
}

.share-btn:hover::before {
    left: 100%;
}

.share-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #000;
}

footer {
    text-align: center;
    padding: 30px 20px;
    opacity: 0.6;
    font-size: 0.75rem;
}

.footer-links {
    margin-top: 8px;
}

.footer-links a {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dotted rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.footer-links a:hover {
    opacity: 1;
    border-bottom-style: solid;
    color: var(--accent-blue);
}

/* --- ✨ Satori (Enlightenment) Theme --- */
.report-card.satori-theme {
    background: linear-gradient(135deg, #fff, #fffaf0) !important;
    border: 2px solid #daa520 !important;
    box-shadow: 0 0 40px rgba(218, 165, 32, 0.3) !important;
}

.satori-theme .report-header .report-id,
.satori-theme .report-header .report-date,
.satori-theme #diagnosis-text,
.satori-theme #diagnosis-desc,
.satori-theme .bar-label,
.satori-theme .label {
    color: #443300 !important;
}

.satori-theme .score-container .score,
.satori-theme .score-container .unit {
    background: linear-gradient(135deg, #daa520, #ffd700) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    background-clip: text !important;
    color: transparent !important;
}

.satori-theme .bar-track {
    background: #eee !important;
}

.satori-theme .bar-fill {
    background: linear-gradient(90deg, #daa520, #ffd700) !important;
}

.satori-theme .env-tags span {
    background: #fff8e1 !important;
    border-color: #ffe082 !important;
    color: #827717 !important;
}

.satori-gold {
    background: linear-gradient(135deg, #daa520, #ffd700, #daa520) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    background-clip: text !important;
    color: transparent !important;
    font-weight: 700 !important;
}

/* --- 📟 Retro / Konami Mode --- */
body.retro-mode {
    background: #001100 !important;
    font-family: 'Courier New', Courier, monospace !important;
    color: #00ff41 !important;
}

body.retro-mode * {
    border-color: #00ff41 !important;
    box-shadow: none !important;
}

body.retro-mode .report-card {
    background: #000 !important;
    border: 2px solid #00ff41 !important;
}

body.retro-mode .score,
body.retro-mode .unit,
body.retro-mode #diagnosis-text {
    background: none !important;
    -webkit-text-fill-color: #00ff41 !important;
    color: #00ff41 !important;
}

body.retro-mode .bar-fill {
    background: #00ff41 !important;
}

body.retro-mode .bar-track {
    background: #002200 !important;
}

body.retro-mode .share-btn {
    background: #000 !important;
    color: #00ff41 !important;
}

body.retro-mode::after {
    content: " ";
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 1, 0.06));
    z-index: 9999;
    background-size: 100% 4px, 3px 100%;
    pointer-events: none;
}

body.retro-mode::before {
    content: " ";
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: rgba(18, 16, 16, 0.1);
    opacity: 0;
    z-index: 10000;
    pointer-events: none;
    animation: flicker 0.15s infinite;
}

@keyframes flicker {
    0% {
        opacity: 0.1;
    }

    5% {
        opacity: 0.2;
    }

    10% {
        opacity: 0.15;
    }

    100% {
        opacity: 0.1;
    }
}