:root {
    --puzzle-font: "Vazirmatn", "IRANSans", "Tahoma", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.puzzle-premium-wrapper {
    font-family: var(--puzzle-font);
    margin: 1.5rem auto;
    max-width: 780px;
}

.puzzle-theme-light {
    --puzzle-bg: #f5f7fb;
    --puzzle-card-bg: #ffffff;
    --puzzle-text: #111827;
    --puzzle-muted: #6b7280;
    --puzzle-border: #cbd5e1;
    /* Default primary color (can be overridden inline on wrapper) */
    --puzzle-primary: #ff7a00;
}

.puzzle-theme-dark {
    --puzzle-bg: #050816;
    --puzzle-card-bg: #0f172a;
    --puzzle-text: #f9fafb;
    --puzzle-muted: #9ca3af;
    --puzzle-border: #1f2933;
    /* Default primary color (can be overridden inline on wrapper) */
    --puzzle-primary: #ff7a00;
}

.puzzle-premium-wrapper {
    background: var(--puzzle-bg);
    padding: 1.5rem;
    border-radius: 1.5rem;
}

body.puzzle-test-page {
    min-height: 100vh;
    background: radial-gradient(circle at 10% 20%, rgba(249, 115, 22, 0.18), transparent 30%),
                radial-gradient(circle at 80% 0%, rgba(14, 165, 233, 0.15), transparent 35%),
                linear-gradient(135deg, var(--puzzle-from, #0f172a), var(--puzzle-to, #f97316));
    background-size: 200% 200%;
    animation: puzzle-bg-shift 14s ease-in-out infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.puzzle-premium-wrapper {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 880px;
}

@keyframes puzzle-bg-shift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
.puzzle-card {
    background: var(--puzzle-card-bg);
    color: var(--puzzle-text);
    border-radius: 1.25rem;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.16);
    padding: 1.5rem 1.75rem;
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
}

.puzzle-title {
    font-size: 1.4rem;
    margin: 0 0 .5rem 0;
}

.puzzle-subtitle {
    margin: 0 0 1.5rem;
    color: var(--puzzle-muted);
}

.puzzle-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.puzzle-field {
    position: relative;
    margin-bottom: 0.5rem;
}

.puzzle-rtl {
    direction: rtl;
    text-align: right;
}

.puzzle-ltr {
    direction: ltr;
    text-align: left;
}

/* Floating labels */
.puzzle-floating input,
.puzzle-floating textarea {
    width: 100%;
    border: 1px solid var(--puzzle-border);
    border-radius: 0.75rem;
    padding: 0.9rem 0.9rem 0.3rem;
    font-size: 0.95rem;
    background: transparent;
    color: var(--puzzle-text);
    outline: none;
    transition: border-color .2s, box-shadow .2s, background .2s;
}

.puzzle-floating textarea {
    min-height: 80px;
    resize: vertical;
}

.puzzle-floating label {
    position: absolute;
    top: 0.95rem;
    left: 0.9rem;
    right: auto;
    font-size: 0.82rem;
    color: var(--puzzle-muted);
    pointer-events: none;
    background: var(--puzzle-card-bg);
    padding: 0 0.25rem;
    transform-origin: left top;
    transition: transform .16s ease, top .16s ease, font-size .16s ease, color .16s ease;
}

.puzzle-theme-light .puzzle-floating label {
    color: var(--puzzle-text);
}


.puzzle-rtl .puzzle-floating label {
    left: auto;
    right: 0.9rem;
    transform-origin: right top;
}

.puzzle-floating input:focus,
.puzzle-floating textarea:focus {
    border-color: var(--puzzle-primary, #ff7a00);
    box-shadow: 0 0 0 1px var(--puzzle-primary, #ff7a00);
}

.puzzle-floating input:not(:placeholder-shown) + label,
.puzzle-floating textarea:not(:placeholder-shown) + label,
.puzzle-floating input:focus + label,
.puzzle-floating textarea:focus + label {
    top: -0.5rem;
    font-size: 0.7rem;
    color: var(--puzzle-primary);
    transform: scale(0.98);
}

.puzzle-btn {
    border-radius: 999px;
    border: none;
    padding: 0.6rem 1.4rem;
    font-size: 0.9rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    position: relative;
    overflow: hidden;
    transition: transform .08s ease, box-shadow .08s ease, background .18s;
    white-space: nowrap;
}

.puzzle-btn-primary {
    background: var(--puzzle-primary, #ff7a00);
    color: #fff;
    box-shadow: 0 12px 22px rgba(249, 115, 22, 0.5);
}

/* In light mode we prefer readable dark button text */
.puzzle-theme-light .puzzle-btn-primary {
    color: var(--puzzle-text);
}

.puzzle-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 30px rgba(249, 115, 22, 0.55);
}

.puzzle-btn-secondary {
    background: transparent;
    border: 1px solid var(--puzzle-primary);
    color: var(--puzzle-primary);
}

.puzzle-btn-secondary:hover {
    background: rgba(249, 115, 22, 0.06);
}

/* Ripple */
.puzzle-btn .puzzle-ripple {
    position: absolute;
    border-radius: 999px;
    transform: scale(0);
    animation: puzzle-ripple 0.6s linear;
    background-color: rgba(255, 255, 255, 0.5);
}

@keyframes puzzle-ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* Question screen */
.puzzle-question-header {
    margin-bottom: 1rem;
}

.puzzle-progress-bar {
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.4);
    overflow: hidden;
    margin-bottom: .5rem;
}

.puzzle-progress-bar-inner {
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--puzzle-primary), #facc15);
    transition: width .25s ease-out;
}

.puzzle-question-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--puzzle-muted);
    gap: .5rem;
}

.puzzle-tag {
    border-radius: 999px;
    padding: 0.1rem 0.5rem;
    font-size: 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.65);
}

.puzzle-tag-section {
    border-color: rgba(56, 189, 248, 0.8);
    color: #0891b2;
}

.puzzle-tag-difficulty {
    border-color: rgba(94, 234, 212, 0.8);
    color: #0f766e;
}

.puzzle-question-text {
    font-size: 1rem;
    margin-bottom: 1rem;
}

.puzzle-options {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.puzzle-option {
    border-radius: 0.9rem;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--puzzle-border);
    background: linear-gradient(135deg, rgba(249, 250, 251, 0.4), rgba(255, 255, 255, 0.9));
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    transition: transform .08s ease, box-shadow .12s ease, border-color .12s ease, background .12s ease;
}

.puzzle-theme-dark .puzzle-option {
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.9), rgba(30, 64, 175, 0.3));
}

.puzzle-option-label {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: rgba(249, 115, 22, 0.09);
    color: var(--puzzle-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
}

.puzzle-option-text {
    flex: 1;
    text-align: inherit;
}

.puzzle-option:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(148, 163, 184, 0.35);
    border-color: rgba(249, 115, 22, 0.6);
}

.puzzle-option-correct {
    border-color: #22c55e !important;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.06), rgba(22, 163, 74, 0.18));
}

.puzzle-option-incorrect {
    border-color: #ef4444 !important;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.06), rgba(220, 38, 38, 0.18));
}

.puzzle-option-disabled {
    pointer-events: none;
    opacity: 0.95;
}

.puzzle-feedback {
    margin-top: 0.75rem;
    font-size: 0.9rem;
    min-height: 1.2em;
}

.puzzle-feedback-correct {
    color: #16a34a;
}

.puzzle-feedback-error {
    color: #dc2626;
}

.puzzle-question-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 1rem;
}

.puzzle-next-disabled {
    opacity: 0.55;
    box-shadow: none;
    cursor: not-allowed;
}

/* Loader */
.puzzle-loader {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    border: 3px solid rgba(148, 163, 184, 0.3);
    border-top-color: var(--puzzle-primary);
    animation: puzzle-spin 0.9s linear infinite;
    margin: 2rem auto;
}

@keyframes puzzle-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Result screen */
.puzzle-result-layout {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: center;
    margin-top: 1rem;
}

.puzzle-result-circle {
    flex: 0 0 180px;
    display: flex;
    justify-content: center;
}

.puzzle-result-info {
    flex: 1 1 220px;
    font-size: 0.95rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.puzzle-user-name {
    margin-top: .3rem;
    margin-bottom: 0.7rem;
    font-weight: 700;
    color: var(--puzzle-primary);
}

/* Highlight box for code */

.puzzle-code-highlight {
    margin-top: 1.3rem;
    border-radius: 1.25rem;
    padding: 1.4rem 1.6rem;
    max-width: 420px;
    background: linear-gradient(135deg, #140b33, #42275a, #ff7a00);
    color: #f9fafb;
    border: none;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.55);
    position: relative;
    overflow: hidden;
}

/* Credit card style for result code */

.puzzle-credit-card {
    position: relative;
    border-radius: 1.2rem;
    padding: 1.4rem 1.6rem;
    max-width: 460px;
    aspect-ratio: 3.5 / 2.2;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    overflow: hidden;
    background: linear-gradient(135deg, #0b1c2c, #0d2542 40%, #0f345c 75%, #123f6f);
    box-shadow: 0 18px 50px rgba(12, 18, 38, 0.35);
    color: #e9f0f7;
}

.puzzle-credit-card::before {
    content: '';
    position: absolute;
    inset: 12px;
    border-radius: 1rem;
    background: linear-gradient(120deg, rgba(255, 255, 255, 0.08), transparent 40%);
    pointer-events: none;
}

.puzzle-credit-card::after {
    content: '';
    position: absolute;
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,0.25), transparent 60%);
    top: -50px;
    right: -30px;
    opacity: 0.65;
}

.puzzle-credit-chip {
    width: 54px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(145deg, #d6b46c, #b4883c);
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.2), 0 8px 18px rgba(0,0,0,0.25);
    position: relative;
    overflow: hidden;
}
.puzzle-credit-chip::before,
.puzzle-credit-chip::after {
    content: '';
    position: absolute;
    inset: 7px;
    border: 1px solid rgba(255,255,255,0.5);
    border-radius: 6px;
}
.puzzle-credit-chip::after {
    inset: 14px 10px;
}

.puzzle-credit-card-inner {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto auto;
    gap: 0.6rem 1rem;
    width: 100%;
    position: relative;
    z-index: 2;
}

.puzzle-credit-card-label {
    grid-column: 2 / 3;
    font-size: 0.9rem;
    opacity: 0.9;
    margin: 0;
}

.puzzle-credit-card-code {
    grid-column: 1 / -1;
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    word-spacing: 0.25em;
}

.puzzle-credit-card-amount {
    grid-column: 1 / -1;
    font-size: 1rem;
    font-weight: 700;
    color: #ffcf70;
}

.puzzle-credit-card-note {
    grid-column: 1 / -1;
    font-size: 0.9rem;
    opacity: 0.9;
    color: #e1e7ef;
}

/* Result action buttons below credit card */

.puzzle-result-actions {
    margin-top: 1.4rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Mobile tweaks for result layout & actions */
@media (max-width: 640px) {
    .puzzle-credit-card {
        max-width: 100%;
        aspect-ratio: auto;
        padding: 1.2rem 1.3rem;
    }

    .puzzle-credit-card-code {
        font-size: 1.4rem;
    }

    .puzzle-result-actions {
        margin-top: 1.2rem;
        flex-direction: column;
        align-items: stretch;
    }

    .puzzle-result-actions .puzzle-btn {
        width: 100%;
        text-align: center;
    }
}




.puzzle-code-label {
    font-size: 0.85rem;
    color: rgba(249, 250, 251, 0.82);
    margin-bottom: 0.4rem;
}

.puzzle-code-value {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: #fef3c7;
    text-align: center;
    margin-bottom: 0.2rem;
}

.puzzle-code-amount {
    margin-top: 0.35rem;
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    color: #fefce8;
}

.puzzle-code-amount .puzzle-gift-emoji {
    font-size: 1.2rem;
}

.puzzle-code-note {
    margin-top: 0.4rem;
    font-size: 0.85rem;
    color: rgba(249, 250, 251, 0.85);
    text-align: center;
}

/* Circular Progress */
.puzzle-progress-ring {
    width: 160px;
    height: 160px;
}

.puzzle-progress-ring__bg {
    fill: transparent;
    stroke: rgba(148, 163, 184, 0.35);
    stroke-width: 8;
}

.puzzle-progress-ring__value {
    fill: transparent;
    stroke: var(--puzzle-primary);
    stroke-width: 8;
    stroke-linecap: round;
    transform-origin: center;
    transform: rotate(-90deg);
    stroke-dasharray: 339.292;
    stroke-dashoffset: 339.292;
    transition: stroke-dashoffset 0.9s ease-out;
}

.puzzle-progress-text {
    fill: var(--puzzle-text);
    font-size: 0.9rem;
}

.puzzle-question-explanation{
    margin-top: 1rem;
    padding: 1rem 1.25rem;
    border-radius: 16px;
    background: rgba(255,255,255,0.9);
    box-shadow: 0 18px 40px rgba(15,23,42,0.15);
    font-size: .9rem;
    line-height: 1.8;
}

.puzzle-report-card {
    margin-top: 0.5rem;
    padding: 1rem 1.25rem;
    border-radius: 18px;
    background: var(--puzzle-card-bg);
    box-shadow: 0 18px 40px rgba(15,23,42,0.12);
}

.puzzle-report-card ul {
    margin: 0.25rem 0 0;
    padding-left: 1rem;
    line-height: 1.7;
}

/* Error card */
.puzzle-error-card {
    border-left: 4px solid #ef4444;
}
.puzzle-error-card p {
    white-space: pre-line;
}

/* Utility */
.puzzle-hidden {
    display: none;
}

.puzzle-honeypot {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Responsive */
@media (max-width: 640px) {
    .puzzle-premium-wrapper {
        padding: 1rem;
        max-width: 100%;
        border-radius: 0;
    }
    .puzzle-card {
        padding: 1rem 1.1rem;
    }
    .puzzle-result-layout {
        flex-direction: column;
        align-items: flex-start;
    }
    .puzzle-result-circle {
        align-self: center;
    }
}

/* Modernized layout additions */
.puzzle-card-head {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.puzzle-brand-chip {
    align-self: flex-start;
    background: var(--puzzle-primary);
    color: #fff;
    border-radius: 999px;
    padding: 0.25rem 0.8rem;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.puzzle-question-shell {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.puzzle-question-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.puzzle-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--puzzle-muted);
    font-weight: 600;
}

.puzzle-live-timer {
    background: rgba(249, 115, 22, 0.08);
    color: var(--puzzle-primary);
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-variant-numeric: tabular-nums;
}

.puzzle-question-text {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    line-height: 1.7;
}

.puzzle-options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0.75rem;
}

.puzzle-option-card {
    border: 1px solid var(--puzzle-border);
    background: var(--puzzle-card-bg);
    padding: 0.85rem 1rem;
    border-radius: 1rem;
    text-align: inherit;
    display: flex;
    gap: 0.65rem;
    align-items: flex-start;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}

.puzzle-option-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 30px rgba(15, 23, 42, 0.12);
    border-color: var(--puzzle-primary);
}

.puzzle-option-label {
    background: var(--puzzle-primary);
    color: #fff;
    border-radius: 12px;
    padding: 0.25rem 0.6rem;
    font-weight: 700;
    min-width: 34px;
    text-align: center;
}

.puzzle-option-text {
    line-height: 1.6;
    font-weight: 600;
}

.puzzle-option-disabled {
    opacity: 0.6;
    pointer-events: none;
}

.puzzle-option-correct {
    border-color: #10b981;
    box-shadow: 0 12px 24px rgba(16, 185, 129, 0.15);
}

.puzzle-option-incorrect {
    border-color: #ef4444;
    box-shadow: 0 12px 24px rgba(239, 68, 68, 0.18);
}

.puzzle-question-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.puzzle-muted-mini {
    color: var(--puzzle-muted);
    font-size: 0.85rem;
}

.puzzle-next-disabled {
    opacity: 0.6;
    pointer-events: none;
}

.puzzle-feedback-modal {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at 20% 20%, rgba(249, 115, 22, 0.15), transparent 35%),
                radial-gradient(circle at 80% 0%, rgba(14, 165, 233, 0.12), transparent 45%),
                rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    padding: 1rem;
}

.puzzle-feedback-dialog {
    background: #ffffff;
    color: var(--puzzle-text);
    border-radius: 1.5rem;
    padding: 1.6rem 1.9rem;
    width: min(600px, 100%);
    box-shadow: 0 32px 85px rgba(15, 23, 42, 0.35);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.puzzle-feedback-icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 0.6rem;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 1.3rem;
}

.puzzle-positive .puzzle-feedback-icon {
    background: #ecfdf3;
    color: #10b981;
}
.puzzle-negative .puzzle-feedback-icon {
    background: #fef2f2;
    color: #ef4444;
}

.puzzle-feedback-title {
    font-weight: 800;
    margin-bottom: 0.4rem;
}

.puzzle-feedback-message {
    font-size: 1.05rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.puzzle-feedback-extra {
    color: var(--puzzle-muted);
    font-size: 0.9rem;
    margin-bottom: 0.9rem;
    line-height: 1.7;
    text-align: center;
}

.puzzle-feedback-next {
    width: 100%;
    margin-top: 0.5rem;
    background: var(--puzzle-primary);
    color: #fff;
}

.puzzle-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.puzzle-result-grid {
    display: grid;
    grid-template-columns: minmax(240px, 260px) 1fr;
    gap: 1rem;
    align-items: center;
}

.puzzle-credit-card {
    margin: 0.6rem 0 0.8rem;
    border-radius: 1.1rem;
    overflow: hidden;
    border: 1px solid var(--puzzle-border);
}

.puzzle-credit-card-inner {
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.12), rgba(12, 74, 110, 0.12));
    padding: 1rem;
}

.puzzle-credit-card-label {
    font-weight: 700;
    margin-bottom: 0.35rem;
}

.puzzle-credit-card-code {
    font-family: "Fira Code", "JetBrains Mono", Consolas, monospace;
    font-size: 1.1rem;
    letter-spacing: 1px;
    margin-bottom: 0.25rem;
}

.puzzle-credit-card-amount {
    font-weight: 800;
    color: var(--puzzle-primary);
    margin-bottom: 0.25rem;
}

.puzzle-credit-card-note {
    color: var(--puzzle-muted);
    font-size: 0.9rem;
}

.puzzle-card-active {
    border-color: var(--puzzle-primary);
}
.puzzle-card-muted {
    opacity: 0.8;
}


@media (max-width: 640px) {
    .puzzle-result-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        gap: 1rem;
    }
    .puzzle-result-info {
        width: 100%;
    }
    .puzzle-result-circle {
        align-self: center;
        justify-self: center;
    }
}
