/* ===== Quiz Editor Responsive ===== */
@media (max-width: 640px) {
    .quiz-editor-title-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .quiz-settings-grid {
        grid-template-columns: 1fr;
    }

    .quiz-preview-info {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .quiz-option-row {
        flex-wrap: wrap;
    }

    .quiz-option-input {
        min-width: 0;
    }
}

/* ============================================================
   Rust Adventures — Game Styles
   ============================================================ */

.adventure-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem;
    --tile-size: 36px;
    background: linear-gradient(
        180deg,
        var(--bg-primary) 0%,
        var(--bg-secondary) 100%
    );
}

.adventure-header {
    width: 100%;
    max-width: 600px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.adventure-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.adventure-logo {
    font-size: 1.5rem;
    color: var(--danger-bright);
    filter: drop-shadow(0 0 6px rgba(248, 113, 113, 0.3));
}

.adventure-title {
    font-size: 1.2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #ff7b5c, #ff5c39, #ffab4d);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.adventure-header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.adventure-moves {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

/* Keys bar */
.adventure-keys-bar {
    width: 100%;
    max-width: 600px;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    padding: 0.4rem 0;
    margin-bottom: 0.5rem;
    min-height: 2rem;
}

.keys-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.key-empty {
    font-size: 0.8rem;
    color: var(--text-muted, #666);
    font-style: italic;
}

.key-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: "SF Mono", "Fira Code", monospace;
    background: rgba(255, 92, 57, 0.15);
    color: var(--accent-purple);
    border: 1px solid rgba(255, 92, 57, 0.3);
    border-radius: 4px;
    animation: keyBadgePop 0.3s ease;
}

@keyframes keyBadgePop {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    60% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Notification toast */
.adventure-notification {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.6rem 1.2rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 1000;
    animation:
        notifySlideIn 0.3s ease,
        notifyFadeOut 0.5s ease 2.5s forwards;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

@keyframes notifySlideIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes notifyFadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* Game grid */
.adventure-grid-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 0.5rem;
    overflow: auto;
    max-width: 100%;
    max-height: 60vh;
    scroll-behavior: smooth;
    border-radius: var(--radius-sm);
    /* Subtle inner shadow for depth */
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.15);
}

.adventure-grid {
    display: grid;
    gap: 1px;
    background: rgba(0, 0, 0, 0.2);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.tile {
    width: var(--tile-size);
    height: var(--tile-size);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--tile-size) * 0.45);
    font-weight: 600;
    user-select: none;
    transition:
        background-color 0.15s ease,
        box-shadow 0.15s ease;
}

.tile-floor {
    background: var(--bg-secondary);
    color: transparent;
}

.tile-wall {
    background: linear-gradient(135deg, #2d2d3f, #1f1f2e);
    color: transparent;
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 255, 0.05),
        inset -1px -1px 0 rgba(0, 0, 0, 0.3);
}

.tile-player {
    font-size: calc(var(--tile-size) * 0.65);
    z-index: 10;
    color: var(--text-primary, inherit);
    filter: drop-shadow(0 0 6px rgba(255, 92, 57, 0.6));
    animation: playerFloat 2s ease-in-out infinite;
}

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

.tile-exit {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
    font-size: calc(var(--tile-size) * 0.55);
}

.tile-key {
    background: rgba(255, 92, 57, 0.12);
    color: var(--accent-purple);
    font-family: "SF Mono", "Fira Code", monospace;
    font-size: calc(var(--tile-size) * 0.32);
    font-weight: 700;
    border: 1px dashed rgba(255, 92, 57, 0.3);
    animation: keyPulse 2s ease-in-out infinite;
}

@keyframes keyPulse {
    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(255, 92, 57, 0);
    }
    50% {
        box-shadow: 0 0 8px 2px rgba(255, 92, 57, 0.3);
    }
}

.tile-npc {
    background: rgba(245, 158, 11, 0.08);
    font-size: calc(var(--tile-size) * 0.6);
    filter: drop-shadow(0 0 3px rgba(245, 158, 11, 0.3));
}

.tile-gate {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
    font-size: calc(var(--tile-size) * 0.55);
}

.tile-gate-open {
    background: var(--bg-secondary);
    color: var(--success);
    opacity: 0.5;
}

.tile-code {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info);
    font-size: calc(var(--tile-size) * 0.45);
    filter: drop-shadow(0 0 3px rgba(59, 130, 246, 0.3));
}

.tile-water {
    background: rgba(59, 130, 246, 0.15);
    color: rgba(59, 130, 246, 0.3);
    animation: waterShimmer 3s ease-in-out infinite;
}

@keyframes waterShimmer {
    0%,
    100% {
        background: rgba(59, 130, 246, 0.12);
    }
    50% {
        background: rgba(59, 130, 246, 0.22);
    }
}

.tile-sign {
    background: rgba(245, 158, 11, 0.05);
    font-size: calc(var(--tile-size) * 0.5);
}

/* Overlays */
.adventure-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: overlayFadeIn 0.2s ease;
}

@keyframes overlayFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.adventure-overlay-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.adventure-overlay-card h2 {
    font-size: 1.3rem;
    color: var(--text-primary);
    margin: 0 0 0.75rem 0;
}

.adventure-overlay-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0.5rem 0;
}

.adventure-overlay-hint {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 1rem;
}

/* Toggle switch (used in adventure config) */
.quiz-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
}

.quiz-toggle-checkbox {
    display: none;
}

.quiz-toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    background: var(--bg-tertiary, var(--border-hover));
    border-radius: 9999px;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.quiz-toggle-switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s ease;
}

.quiz-toggle-checkbox:checked + .quiz-toggle-switch {
    background: var(--accent);
}

.quiz-toggle-checkbox:checked + .quiz-toggle-switch::after {
    transform: translateX(20px);
}

.quiz-toggle-text {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

.adventure-overlay-card-success {
    border-color: rgba(34, 197, 94, 0.3);
    background: linear-gradient(
        135deg,
        rgba(34, 197, 94, 0.08) 0%,
        var(--bg-card) 100%
    );
}

.adventure-success-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    animation: success-pulse 1.5s ease-in-out infinite;
}

@keyframes success-pulse {
    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.85;
    }
}

.adventure-stars {
    font-size: 1.8rem;
    margin: 0.25rem 0 0.5rem 0;
    letter-spacing: 0.25rem;
}

.adventure-save-status {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0.5rem 0;
    opacity: 0.85;
}

/* Dialog card */
.adventure-dialog-card {
    background: var(--bg-card);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 400px;
    width: 90%;
    text-align: left;
}

.dialog-speaker {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--warning);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.dialog-text {
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.6;
}

/* Puzzle card */
.adventure-overlay-puzzle {
    background: rgba(0, 0, 0, 0.85);
}

.adventure-puzzle-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 92, 57, 0.3);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 480px;
    width: 92%;
    max-height: 85vh;
    overflow-y: auto;
}

.adventure-puzzle-card h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin: 0 0 1rem 0;
}

.puzzle-instruction {
    color: var(--text-primary);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.puzzle-code {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-family: "SF Mono", "Fira Code", monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    margin: 0.5rem 0;
    overflow-x: auto;
    white-space: pre-wrap;
}

.puzzle-code-broken {
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.puzzle-pieces {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin: 0.75rem 0;
}

.puzzle-piece {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-family: "SF Mono", "Fira Code", monospace;
    font-size: 0.8rem;
    border: 1px solid var(--border);
}

.puzzle-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.75rem 0;
}

.puzzle-opt {
    padding: 0.4rem 0.75rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: "SF Mono", "Fira Code", monospace;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.puzzle-opt:hover {
    border-color: var(--accent);
}

.puzzle-opt-selected {
    background: rgba(255, 92, 57, 0.15);
    border-color: var(--accent);
    color: var(--accent-purple);
}

.puzzle-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--code-bg);
    color: var(--code-text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: "SF Mono", "Fira Code", monospace;
    font-size: 0.85rem;
    outline: none;
}

.puzzle-input:focus {
    border-color: var(--accent);
}

.puzzle-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.puzzle-feedback {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    margin: 0.5rem 0;
}

.puzzle-correct {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.2);
    animation: feedbackPop 0.4s ease;
}

.puzzle-wrong {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
    animation: feedbackShake 0.4s ease;
}

@keyframes feedbackPop {
    0% {
        transform: scale(0.9);
        opacity: 0;
    }
    60% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes feedbackShake {
    0%,
    100% {
        transform: translateX(0);
    }
    20% {
        transform: translateX(-4px);
    }
    40% {
        transform: translateX(4px);
    }
    60% {
        transform: translateX(-3px);
    }
    80% {
        transform: translateX(3px);
    }
}

.puzzle-hint {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 0.75rem;
    font-style: italic;
}

/* D-pad */
.adventure-dpad {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    margin-top: 1rem;
    padding: 0.5rem;
}

.dpad-row {
    display: flex;
    gap: 2px;
    align-items: center;
}

.dpad-btn {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    transition: all 0.1s ease;
    /* Larger touch target */
    padding: 4px;
}

.dpad-btn:active {
    background: var(--accent);
    transform: scale(0.95);
}

.dpad-center {
    width: 56px;
    height: 56px;
}

/* Show D-pad on touch devices */
@media (hover: none) and (pointer: coarse) {
    .adventure-dpad {
        display: flex;
    }
    .adventure-page {
        --tile-size: 28px;
    }
    .dpad-btn {
        width: 68px;
        height: 68px;
        font-size: 1.5rem;
    }
    .dpad-center {
        width: 68px;
        height: 68px;
    }
}

/* Fallback: show D-pad on small screens regardless of hover/pointer capability */
@media (max-width: 768px) {
    .adventure-dpad {
        display: flex;
    }
    .adventure-page {
        --tile-size: 28px;
    }
    .dpad-btn {
        width: 68px;
        height: 68px;
        font-size: 1.5rem;
    }
    .dpad-center {
        width: 68px;
        height: 68px;
    }
}

/* Controls hint */
.adventure-controls-hint {
    margin-top: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Footer */
.adventure-footer {
    margin-top: auto;
    padding: 1rem 0;
}

.adventure-back {
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-decoration: none;
}

.adventure-back:hover {
    color: var(--accent);
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .adventure-page {
        --tile-size: 26px;
        padding: 0.5rem;
    }

    .adventure-header {
        padding: 0.25rem 0;
    }

    .adventure-title {
        font-size: 1rem;
    }

    .adventure-overlay-card,
    .adventure-dialog-card,
    .adventure-puzzle-card {
        padding: 1rem;
        max-width: 95%;
    }

    .adventure-puzzle-card {
        max-height: 80vh;
    }
}

@media (max-width: 359px) {
    .adventure-page {
        --tile-size: 22px;
    }

    .adventure-header-right {
        gap: 0.4rem;
    }

    .adventure-moves {
        font-size: 0.75rem;
    }
}

/* ============================================================
   Rust Adventures — Phase 2 Styles
   ============================================================ */

/* Timer */
.adventure-timer {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    font-family: "SF Mono", "Fira Code", monospace;
    min-width: 3.5em;
}

/* Level name */
.adventure-level-name {
    width: 100%;
    max-width: 600px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-align: center;
    margin-bottom: 0.25rem;
}

/* Hint bar (missing keys) */
.adventure-hint-bar {
    width: 100%;
    max-width: 600px;
    font-size: 0.75rem;
    color: var(--warning);
    padding: 0.2rem 0;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

/* Exit tile glow when unlocked */
.tile-exit-unlocked {
    background: rgba(34, 197, 94, 0.2);
    animation: exitPulse 1.5s ease-in-out infinite;
}

@keyframes exitPulse {
    0%,
    100% {
        box-shadow: inset 0 0 4px rgba(34, 197, 94, 0.3);
    }
    50% {
        box-shadow: inset 0 0 10px rgba(34, 197, 94, 0.5);
    }
}

/* Gate animation on solve */
.tile-gate-animating {
    animation: gateOpen 0.6s ease forwards;
}

@keyframes gateOpen {
    0% {
        background: rgba(239, 68, 68, 0.12);
        transform: scale(1);
    }
    50% {
        background: rgba(34, 197, 94, 0.2);
        transform: scale(1.1);
    }
    100% {
        background: var(--bg-secondary);
        transform: scale(1);
        opacity: 0.4;
    }
}

/* === Level Success Overlay === */
.adventure-overlay-success {
    background: rgba(0, 0, 0, 0.8);
}

/* === Info Banner (no-token demo mode) === */
.adventure-banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    border-bottom: 1px solid;
}
.adventure-banner-info {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-bottom-color: var(--border-hover);
}
.adventure-banner-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}
.adventure-banner b {
    color: var(--warning);
}
.adventure-banner-success {
    background: linear-gradient(
        135deg,
        rgba(74, 222, 128, 0.15),
        rgba(34, 197, 94, 0.1)
    );
    color: var(--success);
    border-bottom-color: var(--success);
    font-weight: 600;
}
.adventure-banner-link {
    color: var(--warning);
    text-decoration: none;
    font-weight: 700;
    white-space: nowrap;
}
.adventure-banner-link:hover {
    text-decoration: underline;
}

/* === Claim Button (golden) === */
.adventure-claim-btn {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border: none;
    color: white;
    font-weight: 700;
    font-size: 1rem;
    padding: 0.65rem 1.5rem;
    text-decoration: none;
    display: inline-block;
    border-radius: var(--radius-sm);
    box-shadow: 0 0 16px rgba(245, 158, 11, 0.3);
    animation: claimGlow 2s ease-in-out infinite;
}

@keyframes claimGlow {
    0%,
    100% {
        box-shadow: 0 0 12px rgba(245, 158, 11, 0.2);
    }
    50% {
        box-shadow: 0 0 24px rgba(245, 158, 11, 0.5);
    }
}

.adventure-claim-btn:hover {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    transform: translateY(-1px);
}

