/* Reverse Challenge Game Styles */

body:has(.game-container) {
    background: linear-gradient(180deg, #faf8ff 0%, #ffffff 280px);
}

.game-container {
    max-width: 700px;
    padding: 0.75rem 2rem 80px;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.game-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.game-main:has(#screen-intro.active) {
    justify-content: center;
}

/* Header - override main.css global header styles */
.game-header {
    text-align: center;
    margin-bottom: 0.5rem;
    position: relative;
    padding: 0;
}

header.game-header {
    margin-bottom: 0.5rem;
    padding: 0;
}

.game-header h1 {
    font-size: 1.75rem;
    margin: 0.125rem 0 0.125rem;
}

.game-header h1 .heading-icon {
    -webkit-text-fill-color: initial;
    background: none;
    -webkit-background-clip: initial;
    background-clip: initial;
}

.game-header h1 [data-i18n="page.headingText"] {
    background: linear-gradient(135deg, var(--color-purple), var(--color-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.game-header .subtitle {
    color: #888;
    font-size: 0.8125rem;
    margin: 0;
    line-height: 1.3;
}

.back-link {
    display: block;
    text-align: left;
    color: var(--color-purple);
    text-decoration: none;
    font-size: 0.8125rem;
    margin-bottom: 0.25rem;
    line-height: 1.2;
    transition: opacity 0.2s;
}

.back-link:hover {
    opacity: 0.7;
}

/* Step Indicator */
.step-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin: 0.375rem 0 1.25rem;
    padding: 0 0.5rem;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    opacity: 0.55;
    transition: all 0.3s ease;
}

.step.active {
    opacity: 1;
}

.step.completed {
    opacity: 0.7;
}

.step-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #e8e5f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8125rem;
    color: #6b6380;
    transition: all 0.3s ease;
}

.step.active .step-num {
    background: linear-gradient(135deg, var(--color-purple), var(--color-blue));
    color: white;
    box-shadow: 0 2px 12px rgba(187, 145, 255, 0.4);
}

.step.completed .step-num {
    background: var(--color-purple);
    color: white;
}

.step-label {
    font-size: 0.6875rem;
    color: #6b6380;
    white-space: nowrap;
}

.step.active .step-label {
    color: var(--color-purple);
    font-weight: 600;
    font-size: 0.75rem;
}

.step-line {
    flex: 1;
    height: 2px;
    background: #e2dff0;
    margin: 0 0.5rem;
    margin-bottom: 0.875rem;
    min-width: 20px;
    max-width: 48px;
    transition: background 0.5s ease;
}

.step.completed + .step-line {
    background: linear-gradient(90deg, var(--color-purple), var(--color-blue));
}

/* Screens */
.screen {
    display: none;
    animation: fadeIn 0.3s ease;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.screen-title {
    text-align: center;
    font-size: 1.125rem;
    margin-bottom: 0.25rem;
    color: var(--color-black);
}

.screen-desc {
    text-align: center;
    color: #7c7891;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    line-height: 1.45;
}

/* Intro Card */
.intro-card {
    background: white;
    border-radius: 16px;
    padding: 1.25rem 1rem;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    text-align: center;
}

.intro-icon {
    font-size: 2.25rem;
    margin-bottom: 0.5rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.intro-card h2 {
    margin-bottom: 0.75rem;
    font-size: 1.125rem;
    color: var(--color-black);
}

.intro-steps {
    text-align: left;
    max-width: 400px;
    margin: 0 auto 0.75rem;
}

.intro-step {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin-bottom: 0.5rem;
    opacity: 0;
    animation: slideUp 0.4s ease forwards;
}

.intro-step:nth-child(1) { animation-delay: 0.1s; }
.intro-step:nth-child(2) { animation-delay: 0.2s; }
.intro-step:nth-child(3) { animation-delay: 0.3s; }
.intro-step:nth-child(4) { animation-delay: 0.4s; }

@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.intro-step-num {
    min-width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-purple), var(--color-blue));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
}

.intro-step p {
    margin: 0;
    font-size: 0.95rem;
    color: #444;
}

.privacy-note {
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.625rem;
    background: rgba(187, 145, 255, 0.05);
    border-radius: 8px;
}

/* Waveform */
.waveform-container {
    background: rgba(187, 145, 255, 0.02);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid rgba(187, 145, 255, 0.12);
    overflow: hidden;
}

.waveform-canvas {
    width: 100%;
    height: 120px;
    display: block;
    border-radius: 8px;
}

.waveform-canvas.waveform-small {
    height: 80px;
}

/* Timer */
.timer {
    text-align: center;
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 1rem;
}

/* Record Button */
.record-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.btn-record {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 4px solid #e2dff0;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
}

.btn-record:not(.recording) {
    animation: idlePulse 2.5s ease-in-out infinite;
}

@keyframes idlePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}

.btn-record:hover {
    border-color: var(--color-purple);
    transform: scale(1.05);
    animation: none;
}

.btn-record .record-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #FF4B4B;
    transition: all 0.3s ease;
}

.btn-record.recording {
    border-color: #FF4B4B;
    animation: recordPulse 1.5s ease-in-out infinite;
}

.btn-record.recording .record-icon {
    border-radius: 4px;
    width: 22px;
    height: 22px;
}

@keyframes recordPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 75, 75, 0.4); }
    50% { box-shadow: 0 0 0 12px rgba(255, 75, 75, 0); }
}

.record-label {
    font-size: 0.85rem;
    color: #666;
}

/* Playback Controls */
.playback-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.playback-controls.hidden {
    display: none;
}

/* Buttons */
.btn-primary {
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, var(--color-purple), var(--color-blue));
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(187, 145, 255, 0.4);
}

.btn-primary:active:not(:disabled) {
    transform: scale(0.96);
    transition: transform 0.1s ease;
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    padding: 0.6rem 1.2rem;
    background: white;
    color: var(--color-purple);
    border: 2px solid var(--color-purple);
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: rgba(187, 145, 255, 0.1);
    transform: translateY(-1px);
}

.btn-secondary:active {
    transform: scale(0.96);
    transition: transform 0.1s ease;
}

.btn-play {
    padding: 0.6rem 1.2rem;
    background: rgba(73, 123, 255, 0.1);
    color: var(--color-blue);
    border: 2px solid var(--color-blue);
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-play:hover {
    background: rgba(73, 123, 255, 0.2);
}

.btn-play-large {
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--color-blue), var(--color-purple));
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-play-large:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(73, 123, 255, 0.4);
}

/* Hint Text */
.hint-text {
    text-align: center;
    color: #888;
    font-size: 0.85rem;
    margin: 1rem 0;
}

/* Nav Controls */
.nav-controls {
    display: flex;
    justify-content: center;
    margin-top: 1.5rem;
}

/* Results */
.result-comparison {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.75rem 0;
    flex-wrap: wrap;
    justify-content: center;
}

.result-card {
    flex: 1;
    min-width: 0;
    max-width: 100%;
    background: white;
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    text-align: center;
    overflow: hidden;
}

.result-card h3 {
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    color: #444;
}

.result-card .waveform-canvas {
    max-width: 100%;
    width: 100%;
}

.result-vs {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-orange);
    padding: 0 0.5rem;
}

/* All Playback Section */
.all-playback-section {
    margin: 0.75rem 0;
    padding: 0.75rem;
    background: rgba(73, 123, 255, 0.03);
    border-radius: 12px;
    border: 1px solid rgba(73, 123, 255, 0.1);
}

.all-playback-section h4 {
    text-align: center;
    margin: 0 0 0.75rem;
    font-size: 0.9375rem;
    font-weight: 700;
    color: #333;
}

.all-playback-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.all-playback-grid .btn-play-compact:nth-child(3) {
    margin-top: 0.375rem;
    position: relative;
}

.all-playback-grid .btn-play-compact:nth-child(3)::before {
    content: '';
    position: absolute;
    top: -0.4375rem;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(73, 123, 255, 0.15);
}

.all-playback-grid .btn-play-compact:nth-child(4) {
    margin-top: 0.375rem;
}

.btn-play-compact {
    padding: 0.6rem 1rem;
    background: white;
    color: var(--color-blue);
    border: 1.5px solid rgba(73, 123, 255, 0.3);
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.btn-play-compact:hover {
    background: rgba(73, 123, 255, 0.1);
    border-color: var(--color-blue);
}

.btn-play-compact:active {
    transform: scale(0.97);
}

/* Similarity Section */
.similarity-section {
    text-align: center;
    margin: 1rem 0;
    padding: 1rem;
    background: rgba(187, 145, 255, 0.03);
    border-radius: 16px;
    border: 1px dashed rgba(187, 145, 255, 0.3);
}

.similarity-section.computing {
    position: relative;
    overflow: hidden;
    min-height: 180px;
}

.similarity-section.computing::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        110deg,
        rgba(187, 145, 255, 0.04) 30%,
        rgba(187, 145, 255, 0.12) 50%,
        rgba(187, 145, 255, 0.04) 70%
    );
    background-size: 200% 100%;
    animation: shimmer 1.8s ease-in-out infinite;
    border-radius: 16px;
    z-index: 1;
}

.similarity-section.computing > *:not(.computing-loader) {
    visibility: hidden;
}

.computing-loader {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 2;
}

.computing-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(187, 145, 255, 0.2);
    border-top-color: var(--color-purple);
    border-radius: 50%;
    animation: spinLoader 1s linear infinite;
}

.computing-text {
    font-size: 0.875rem;
    color: #7c7891;
    font-weight: 500;
}

.computing-progress {
    width: 70%;
    max-width: 200px;
    height: 6px;
    background: rgba(187, 145, 255, 0.15);
    border-radius: 3px;
    overflow: hidden;
}

.computing-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--color-purple), var(--color-blue));
    border-radius: 3px;
    transition: width 0.3s linear;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes spinLoader {
    to { transform: rotate(360deg); }
}

.beta-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: rgba(255, 189, 128, 0.2);
    color: #e67e22;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 1rem;
    letter-spacing: 0.5px;
}

.similarity-ring {
    position: relative;
    width: 100px;
    height: 100px;
    margin: 0 auto 0.5rem;
}

.similarity-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.ring-bg {
    fill: none;
    stroke: #e8e5f0;
    stroke-width: 8;
}

.ring-progress {
    fill: none;
    stroke: url(#ring-gradient);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 326.73;
    stroke-dashoffset: 326.73;
    transition: stroke-dashoffset 1s ease;
}

.similarity-score {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-purple);
}

.similarity-label {
    font-size: 0.9rem;
    color: #666;
    margin: 0;
}

.similarity-note {
    font-size: 0.75rem;
    color: #757575;
    margin: 0.5rem 0 0;
}

/* Result Actions */
.result-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
    .game-container {
        padding: 0.75rem 1rem;
        padding-bottom: 80px;
    }

    .game-header h1 {
        font-size: 1.5rem;
    }

    .step-label {
        font-size: 0.625rem;
    }

    .step-num {
        width: 26px;
        height: 26px;
        font-size: 0.75rem;
    }

    .intro-card {
        padding: 1.25rem 1rem;
    }

    .result-comparison {
        flex-direction: column;
    }

    .result-card {
        min-width: unset;
        width: 100%;
    }

    .result-vs {
        padding: 0.25rem 0;
    }
}

@media (max-width: 480px) {
    .game-container {
        padding-top: 0.5rem;
        padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
    }

    .game-header {
        margin-bottom: 0.375rem;
    }

    .game-header h1 {
        font-size: 1.25rem;
    }

    .step-indicator {
        margin: 0.25rem 0 1rem;
    }

    .step-label {
        font-size: 0.6875rem;
    }

    .playback-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-primary, .btn-secondary, .btn-play, .btn-play-large {
        width: 100%;
        text-align: center;
        min-height: 44px;
    }

    .btn-play-compact {
        min-height: 44px;
        padding: 0.625rem 0.875rem;
        font-size: 0.875rem;
    }

    .result-actions {
        flex-direction: column;
        margin-bottom: 0.5rem;
    }

    .all-playback-section {
        margin-bottom: 0.5rem;
    }

    .all-playback-grid {
        grid-template-columns: 1fr;
    }
}

/* Accessibility: reduce motion */
@media (prefers-reduced-motion: reduce) {
    .intro-icon,
    .intro-step,
    .btn-record:not(.recording),
    .computing-spinner {
        animation: none;
    }

    .similarity-section.computing::after {
        animation: none;
    }

    .intro-step {
        opacity: 1;
    }

    .screen {
        animation: none;
    }

    .step-line,
    .ring-progress,
    .computing-progress-bar {
        transition: none;
    }
}
