@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@600;700&family=Outfit:wght@300;400;600;800&display=swap');

:root {
    --bg-color: #fafbfc;
    --card-bg: #ffffff;
    --card-border: #eef2f5;
    --text-main: #1e293b;
    --text-muted: #64748b;
    
    --color-blue: #3ba4d6;
    --color-yellow: #f5b027;
    --color-purple: #8660a4;
    
    --color-success: #1fa560;
    --color-error: #334155;
    
    --bg-green-light: #eaf5ef;
    --text-green-dark: #123f25;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 1rem;
    position: relative;
    overflow-x: hidden;
}

@media (min-width: 600px) {
    body {
        padding: 2rem;
    }
}

.background-elements {
    display: none;
}

.container {
    width: 100%;
    max-width: 600px;
    z-index: 1;
}

header {
    text-align: center;
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
}

@media (min-width: 600px) {
    header {
        margin-bottom: 2.5rem;
        gap: 0.8rem;
    }
}

header h1 {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: 2rem;
    color: var(--text-green-dark);
    background-color: var(--bg-green-light);
    padding: 0.3rem 1.5rem;
    border-radius: 12px;
    letter-spacing: 1px;
}

@media (min-width: 600px) {
    header h1 {
        font-size: 2.5rem;
        padding: 0.3rem 2rem;
    }
}

header p {
    font-family: 'Caveat', cursive;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-green-dark);
    background-color: var(--bg-green-light);
    padding: 0.2rem 1.2rem;
    border-radius: 8px;
}

@media (min-width: 600px) {
    header p {
        font-size: 1.6rem;
        padding: 0.2rem 1.5rem;
    }
}

.glass {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}

.card {
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

@media (min-width: 600px) {
    .card {
        padding: 2.5rem;
        margin-bottom: 2rem;
    }
}

.hidden {
    display: none !important;
    opacity: 0;
    pointer-events: none;
}

h2 {
    font-size: 1.2rem;
    margin-bottom: 0.4rem;
    font-weight: 600;
    color: var(--text-main);
}

@media (min-width: 600px) {
    h2 {
        font-size: 1.4rem;
        margin-bottom: 0.5rem;
    }
}

h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.8rem;
}

@media (min-width: 600px) {
    h3 {
        font-size: 1.1rem;
        margin-bottom: 1rem;
    }
}

.subtitle {
    color: var(--text-muted);
    margin-bottom: 1.2rem;
    font-size: 0.9rem;
}

@media (min-width: 600px) {
    .subtitle {
        margin-bottom: 1.5rem;
        font-size: 0.95rem;
    }
}

.code-inputs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    flex-direction: row;
    align-items: center;
}

@media (min-width: 600px) {
    .code-inputs {
        gap: 1.5rem;
        margin-bottom: 2.5rem;
    }
}

.input-field {
    width: 100%;
    max-width: 300px;
    padding: 0.8rem 1.2rem;
    font-size: 1.2rem;
    text-align: center;
    border-radius: 50px;
    border: 2px solid var(--card-border);
    background: #ffffff;
    outline: none;
    font-weight: 600;
    color: var(--text-muted);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    font-family: 'Outfit', sans-serif;
    letter-spacing: 0.5px;
}

.input-field:focus {
    border-color: #a8d5b5;
    box-shadow: 0 0 0 4px rgba(31, 165, 96, 0.08);
    color: var(--text-main);
}

.input-field.short {
    max-width: 140px;
    text-transform: uppercase;
}

.input-field.xs {
    max-width: 120px;
}

.action-buttons {
    display: flex;
    gap: 0.8rem;
    margin-top: 1rem;
    justify-content: center;
    flex-direction: row;
    flex-wrap: wrap;
}

.action-buttons > * {
    flex: 1;
    min-width: 130px;
}

@media (max-width: 359px) {
    .action-buttons {
        flex-direction: column;
    }
    .action-buttons > * {
        min-width: unset;
    }
}

.btn-primary {
    width: 100%;
    padding: 0.8rem;
    border-radius: 12px;
    border: none;
    background: var(--bg-green-light);
    color: var(--text-green-dark);
    font-family: 'Caveat', cursive;
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 1px;
}

@media (min-width: 600px) {
    .btn-primary {
        padding: 1rem;
        font-size: 1.8rem;
    }
}

.btn-primary:hover {
    background: #dcf0e5;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(31, 165, 96, 0.1);
}

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

.btn-secondary {
    background: var(--card-border);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: #e2e8f0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.btn-dark {
    background: var(--text-main);
    color: white;
}

.btn-dark:hover {
    background: #0f172a;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.status-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.8rem 1rem;
    background: var(--bg-green-light);
    border-radius: 12px;
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-green-dark);
    justify-content: space-between;
}

@media (min-width: 600px) {
    .status-bar {
        gap: 0.8rem;
        padding: 1rem 1.2rem;
        margin-bottom: 2.5rem;
        font-size: 0.95rem;
    }
}

.status-indicators {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    flex-wrap: wrap;
    flex: 1;
}

.badge {
    font-weight: bold;
    padding: 0.3rem 0.6rem;
    border-radius: 12px;
    color: white;
}

@media (min-width: 600px) {
    .badge {
        padding: 0.3rem 0.8rem;
    }
}

.badge-success { background: var(--color-success); }
.badge-blue { background: var(--color-blue); }
.badge-purple { background: var(--color-purple); }

.status-indicator {
    width: 10px;
    height: 10px;
    background: var(--color-success);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(31, 165, 96, 0.4);
}

@media (min-width: 600px) {
    .status-indicator {
        width: 12px;
        height: 12px;
    }
}

.status-bar span.text { flex-grow: 1; font-weight: 600; color: var(--text-muted); }

.btn-text {
    background: none;
    border: none;
    color: var(--text-green-dark);
    cursor: pointer;
    text-decoration: underline;
    font-size: 0.85rem;
    font-weight: 600;
    transition: color 0.2s;
}

@media (min-width: 600px) {
    .btn-text { font-size: 0.9rem; }
}

.btn-text:hover { color: var(--color-success); }

.code-picker-container {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    height: 120px;
    position: relative;
    background: #ffffff;
    border: 2px solid var(--card-border);
    border-radius: 16px;
    padding: 0 1rem;
    width: fit-content;
    margin: 0 auto 1.5rem auto;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.02);
}

@media (min-width: 600px) {
    .code-picker-container {
        gap: 2.5rem;
        height: 150px;
        padding: 0 1.5rem;
        margin: 0 auto 2.5rem auto;
    }
}

.code-column {
    width: 50px;
    height: 100%;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 2;
    scroll-behavior: smooth;
}

@media (min-width: 600px) {
    .code-column { width: 60px; }
}

.code-column::-webkit-scrollbar { display: none; }

.code-column.locked {
    overflow-y: hidden;
    pointer-events: none;
    opacity: 0.8;
}

.picker-spacer {
    min-height: 40px;
    width: 100%;
}

@media (min-width: 600px) {
    .picker-spacer { min-height: 50px; }
}

.picker-item {
    height: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 800;
    scroll-snap-align: center;
    color: var(--card-border);
    transition: all 0.2s ease;
    user-select: none;
}

@media (min-width: 600px) {
    .picker-item {
        height: 50px;
        min-height: 50px;
        font-size: 2.5rem;
    }
}

.picker-blue .picker-item { color: #bae0f5; }
.picker-yellow .picker-item { color: #fce7b6; }
.picker-purple .picker-item { color: #dcd0e8; }

.picker-blue .picker-item.active { color: var(--color-blue); transform: scale(1.2); }
.picker-yellow .picker-item.active { color: var(--color-yellow); transform: scale(1.2); }
.picker-purple .picker-item.active { color: var(--color-purple); transform: scale(1.2); }

.picker-selection-window {
    position: absolute;
    top: 40px;
    left: 0;
    width: 100%;
    height: 40px;
    border-top: 2px solid var(--card-border);
    border-bottom: 2px solid var(--card-border);
    background: rgba(0,0,0,0.02);
    pointer-events: none;
    z-index: 1;
}

@media (min-width: 600px) {
    .picker-selection-window {
        top: 50px;
        height: 50px;
    }
}

.card-picker-container { margin-bottom: 1.5rem; }

@media (min-width: 600px) {
    .card-picker-container { margin-bottom: 2.5rem; }
}

.card-picker {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    padding: 1rem 0;
}

@media (min-width: 450px) {
    .card-picker {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 600px) {
    .card-picker {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 1.5rem;
    }
}

.card-item {
    cursor: pointer;
    border-radius: 12px;
    border: 2px solid var(--card-border);
    transition: all 0.2s ease-in-out;
    opacity: 0.7;
    background: #ffffff;
    padding: 4px;
    position: relative;
    width: 100%;
}

@media (min-width: 600px) {
    .card-item {
        flex: 0 0 160px;
        width: auto;
    }
}

.card-item img {
    width: 100%;
    height: auto;
    border-radius: 6px;
    pointer-events: none;
    display: block;
}

.card-item:hover {
    opacity: 0.9;
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.card-item.selected {
    opacity: 1;
    border-color: var(--color-success);
    transform: scale(1.05) translateY(-3px);
    box-shadow: 0 8px 16px rgba(31, 165, 96, 0.15);
}

.selected-card-preview {
    margin-top: 1rem;
    text-align: center;
    animation: fadeIn 0.4s ease;
}

@media (min-width: 600px) {
    .selected-card-preview { margin-top: 1.5rem; }
}

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

.selected-card-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    border: 1px solid var(--card-border);
}

@media (min-width: 600px) {
    .selected-card-preview img { max-height: 250px; }
}

.result-display {
    margin-top: 1.5rem;
    padding: 1.5rem 1rem;
    border-radius: 16px;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    transition: all 0.4s ease;
    border: 2px dashed var(--card-border);
}

@media (min-width: 600px) {
    .result-display {
        margin-top: 2.5rem;
        padding: 2.5rem 2rem;
        min-height: 180px;
    }
}

.result-icon {
    font-size: 4rem;
    margin-bottom: 0.5rem;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform: scale(0.5);
    opacity: 0;
    height: 0;
    overflow: hidden;
    font-family: 'Caveat', cursive;
}

@media (min-width: 600px) {
    .result-icon {
        font-size: 5rem;
        margin-bottom: 1rem;
    }
}

.result-text {
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    color: var(--text-muted);
}

@media (min-width: 600px) {
    .result-text { font-size: 1.2rem; }
}

.result-display.success { border: 2px solid var(--color-success); border-style: solid; background: var(--bg-green-light); }
.result-display.success .result-icon { color: var(--color-success); transform: scale(1); opacity: 1; height: auto; overflow: visible;}
.result-display.success .result-text { color: var(--text-green-dark); }

.result-display.error { border: 2px solid #cbd5e1; border-style: solid; background: #f8f9fa; }
.result-display.error .result-icon { color: var(--color-error); transform: scale(1); opacity: 1; height: auto; overflow: visible;}
.result-display.error .result-text { color: var(--text-main); }

.history-log {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

@media (min-width: 600px) {
    .history-log { gap: 0.8rem; }
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1rem;
    background: #ffffff;
    border-radius: 12px;
    font-size: 0.85rem;
    border: 1px solid var(--card-border);
    box-shadow: 0 2px 6px rgba(0,0,0,0.02);
    animation: slideIn 0.3s ease forwards;
    gap: 0.5rem;
}

@media (min-width: 600px) {
    .history-item {
        padding: 1rem 1.2rem;
        font-size: 0.95rem;
        gap: 1rem;
    }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.history-code {
    display: flex;
    gap: 0.3rem;
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 1.1rem;
}

@media (min-width: 600px) {
    .history-code {
        gap: 0.4rem;
        font-size: 1.3rem;
    }
}

.history-code span:nth-child(1) { color: var(--color-blue); }
.history-code span:nth-child(2) { color: var(--color-yellow); }
.history-code span:nth-child(3) { color: var(--color-purple); }

.history-card { 
    color: var(--text-muted); 
    flex-grow: 1; 
    padding: 0 0.5rem; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    font-size: 0.85rem;
}

@media (min-width: 600px) {
    .history-card { 
        padding: 0 1.5rem; 
        font-size: 0.9rem;
    }
}

.history-result { font-family: 'Caveat', cursive; font-size: 1.2rem; font-weight: 700; }
@media (min-width: 600px) {
    .history-result { font-size: 1.4rem; }
}

.history-result.success { color: var(--color-success); }
.history-result.error { color: var(--color-error); }

.divider {
    margin: 1.5rem 0;
    border: none;
    border-top: 1px solid var(--card-border);
}

@media (min-width: 600px) {
    .divider { margin: 2rem 0; }
}

.game-over-stats {
    font-size: 2rem;
    letter-spacing: 0.5rem;
    margin-bottom: 2rem;
    font-weight: 800;
    font-family: 'Outfit', sans-serif;
}

@media (min-width: 600px) {
    .game-over-stats {
        font-size: 3rem;
        letter-spacing: 0.8rem;
        margin-bottom: 2.5rem;
    }
}

.game-over-title {
    font-size: 2.2rem;
    margin-bottom: 0.8rem;
    font-family: 'Caveat', cursive;
}

@media (min-width: 600px) {
    .game-over-title {
        font-size: 3rem;
        margin-bottom: 1rem;
    }
}

.game-over-msg {
    font-size: 1rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 600px) {
    .game-over-msg {
        font-size: 1.2rem;
        margin-bottom: 2rem;
    }
}
