/* Decoder Game Styles */

/* Main Container */
.decoder-main {
    min-height: calc(100vh - 80px - 200px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background: #F9FAFB;
}

.decoder-container {
    width: 100%;
    max-width: 1000px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    position: relative;
}

/* Screen Management */
.screen {
    display: none;
    padding: 3rem 2rem;
    min-height: 500px;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

/* Setup Screen */
.setup-content {
    text-align: center;
    width: 100%;
    max-width: 600px;
}

.game-title {
    font-size: 3rem;
    font-weight: 800;
    color: #111827;
    margin-bottom: 0.5rem;
}

.game-subtitle {
    font-size: 1.25rem;
    color: #666;
    margin-bottom: 2rem;
    font-weight: 500;
}

.instructions-panel {
    background: #f9fafb;
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    text-align: left;
}

.instructions-panel h3 {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: #333;
}

.instructions-panel p {
    color: #666;
    margin-bottom: 1rem;
}

.color-guide {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.guide-item {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.color-box {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    flex-shrink: 0;
}

.color-box.green {
    background: #22C55E;
}

.color-box.yellow {
    background: #F59E0B;
}

.color-box.red {
    background: #EF4444;
}

.guide-item span {
    font-size: 0.938rem;
    color: #333;
    font-weight: 500;
}

/* Difficulty Selection */
.difficulty-selection {
    margin-bottom: 2rem;
}

.difficulty-selection h3 {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: #333;
}

.difficulty-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.difficulty-btn {
    padding: 1.5rem 1rem;
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.difficulty-btn:hover {
    border-color: #3B82F6;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.difficulty-btn.active {
    background: #3B82F6;
    border-color: #3B82F6;
    color: white;
}

.difficulty-name {
    font-size: 1.125rem;
    font-weight: 700;
}

.difficulty-desc {
    font-size: 0.875rem;
    opacity: 0.8;
}

/* Buttons */
.game-btn {
    padding: 1rem 2.5rem;
    font-size: 1.125rem;
    font-weight: 700;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 56px;
    font-family: inherit;
}

.game-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.game-btn:active {
    transform: translateY(0);
}

.game-btn-primary {
    background: #3B82F6;
    color: white;
}

.game-btn-primary:hover {
    background: #2563EB;
}

.game-btn-secondary {
    background: #f3f4f6;
    color: #333;
}

.game-btn-secondary:hover {
    background: #e5e7eb;
}

/* Playing Screen */
.playing-content {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

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

.header-stats {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
    padding: 1rem;
    background: #f9fafb;
    border-radius: 12px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-icon {
    font-size: 1.5rem;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #333;
}

.difficulty-badge {
    padding: 0.5rem 1rem;
    background: #3B82F6;
    color: white;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 700;
}

/* Input Area */
.input-area {
    margin-bottom: 2rem;
    padding: 2rem;
    background: #f9fafb;
    border-radius: 16px;
}

.input-title {
    font-size: 1.25rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 1.5rem;
    color: #333;
}

.digit-inputs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.digit-input {
    width: 60px;
    height: 80px;
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
    border: 3px solid #e5e7eb;
    border-radius: 12px;
    background: white;
    color: #333;
    transition: all 0.2s ease;
}

.digit-input:focus {
    outline: none;
    border-color: #3B82F6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    transform: scale(1.05);
}

.digit-input:hover {
    border-color: #3B82F6;
}

/* Shake animation for invalid input */
.digit-inputs.shake {
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-8px); }
    20%, 40%, 60%, 80% { transform: translateX(8px); }
}

.input-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

/* Guess History */
.history-area {
    margin-bottom: 2rem;
}

.history-title {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: #333;
}

.guess-history {
    max-height: 400px;
    overflow-y: auto;
    padding: 1rem;
    background: #f9fafb;
    border-radius: 12px;
}

.empty-message {
    text-align: center;
    color: #9ca3af;
    padding: 2rem;
    font-size: 0.938rem;
}

.guess-entry {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.guess-entry:last-child {
    margin-bottom: 0;
}

.attempt-number {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e5e7eb;
    border-radius: 8px;
    font-weight: 700;
    color: #6b7280;
    flex-shrink: 0;
}

.guess-digits {
    display: flex;
    gap: 0.5rem;
    flex: 1;
}

.digit-box {
    width: 50px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.875rem;
    font-weight: 700;
    border-radius: 8px;
    color: white;
    animation: flipIn 0.6s ease backwards;
}

.digit-box.green {
    background: #22C55E;
}

.digit-box.yellow {
    background: #F59E0B;
}

.digit-box.red {
    background: #EF4444;
}

/* Flip animation */
@keyframes flipIn {
    0% {
        transform: rotateX(-90deg);
        opacity: 0;
    }
    50% {
        transform: rotateX(-45deg);
    }
    100% {
        transform: rotateX(0);
        opacity: 1;
    }
}

/* End Screen */
.end-content {
    text-align: center;
    width: 100%;
    max-width: 600px;
}

.end-title {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 2rem;
}

.end-title.victory {
    color: #10B981;
}

.end-title.gameover {
    color: #ef4444;
}

.secret-reveal {
    margin-bottom: 2rem;
}

.secret-reveal h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #666;
}

.secret-display {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
}

.secret-digit {
    width: 60px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 700;
    background: #3B82F6;
    color: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    animation: popIn 0.5s ease backwards;
}

.secret-digit:nth-child(1) { animation-delay: 0s; }
.secret-digit:nth-child(2) { animation-delay: 0.1s; }
.secret-digit:nth-child(3) { animation-delay: 0.2s; }
.secret-digit:nth-child(4) { animation-delay: 0.3s; }
.secret-digit:nth-child(5) { animation-delay: 0.4s; }

@keyframes popIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.final-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: #f9fafb;
    padding: 1.5rem 1rem;
    border-radius: 12px;
    border: 2px solid #e5e7eb;
}

.stat-card-label {
    font-size: 0.875rem;
    color: #6b7280;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.stat-card-value {
    font-size: 2rem;
    font-weight: 800;
    color: #111827;
}

.end-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Confetti Animation */
.confetti {
    position: fixed;
    top: -10px;
    animation: confettiFall 3s linear forwards;
    pointer-events: none;
    z-index: 9999;
}

@keyframes confettiFall {
    to {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

/* Responsive Design */

/* Tablet */
@media (max-width: 768px) {
    .decoder-main {
        padding: 1rem 0.5rem;
    }

    .screen {
        padding: 2rem 1.5rem;
        min-height: 400px;
    }

    .game-title {
        font-size: 2.5rem;
    }

    .difficulty-buttons {
        grid-template-columns: 1fr;
    }

    .digit-input {
        width: 50px;
        height: 70px;
        font-size: 2rem;
    }

    .digit-box {
        width: 44px;
        height: 54px;
        font-size: 1.5rem;
    }

    .final-stats {
        grid-template-columns: 1fr;
    }

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

    .stat-card-value {
        font-size: 1.75rem;
    }
}

/* Mobile */
@media (max-width: 480px) {
    .decoder-main {
        padding: 0.5rem 0.25rem;
        min-height: calc(100vh - 70px - 150px);
    }

    .decoder-container {
        border-radius: 16px;
    }

    .screen {
        padding: 1.5rem 1rem;
        min-height: 350px;
    }

    .game-title {
        font-size: 2rem;
    }

    .game-subtitle {
        font-size: 1rem;
    }

    .instructions-panel {
        padding: 1rem;
    }

    .instructions-panel h3 {
        font-size: 1rem;
    }

    .color-box {
        width: 32px;
        height: 32px;
    }

    .guide-item span {
        font-size: 0.875rem;
    }

    .difficulty-btn {
        padding: 1rem 0.75rem;
    }

    .difficulty-name {
        font-size: 1rem;
    }

    .difficulty-desc {
        font-size: 0.813rem;
    }

    .header-stats {
        gap: 1rem;
        padding: 0.75rem;
    }

    .stat-icon {
        font-size: 1.25rem;
    }

    .stat-value {
        font-size: 1rem;
    }

    .difficulty-badge {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
    }

    .input-area {
        padding: 1.5rem 1rem;
    }

    .digit-inputs {
        gap: 0.5rem;
    }

    .digit-input {
        width: 48px;
        height: 60px;
        font-size: 1.75rem;
        border-width: 2px;
    }

    .input-controls {
        flex-direction: column;
        width: 100%;
    }

    .game-btn {
        width: 100%;
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
        min-height: 48px;
    }

    .guess-entry {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .attempt-number {
        width: 32px;
        height: 32px;
        font-size: 0.875rem;
    }

    .digit-box {
        width: 40px;
        height: 50px;
        font-size: 1.375rem;
    }

    .secret-digit {
        width: 48px;
        height: 64px;
        font-size: 2rem;
    }

    .end-title {
        font-size: 2.5rem;
    }
}

/* Touch-friendly enhancements */
@media (hover: none) and (pointer: coarse) {
    .game-btn,
    .difficulty-btn {
        -webkit-tap-highlight-color: rgba(59, 130, 246, 0.3);
    }

    .digit-input {
        font-size: 2rem;
    }
}

/* Accessibility */
.game-btn:focus,
.digit-input:focus,
.difficulty-btn:focus {
    outline: 3px solid #3B82F6;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print */
@media print {
    .decoder-main {
        display: none;
    }
}
