/* puzzle.css — puzzle landing page styles */

html,
body {
    overflow-x: hidden !important;
    overflow-y: auto !important;
    height: auto !important;
}

.puzzle-page {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    position: relative;
    z-index: 2;
    overflow-x: hidden;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* Back button — prominent, always visible */
.back-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    width: 100%;
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .6rem 1.1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-bright);
    text-decoration: none;
    font-size: .9rem;
    font-weight: 600;
    transition: all .2s;
    box-sizing: border-box;
}

.btn-back:hover {
    border-color: var(--accent);
    background: rgba(59, 130, 246, .08);
    transform: translateX(-2px);
}

.btn-back svg {
    flex-shrink: 0;
}

.breadcrumb {
    display: flex;
    gap: .5rem;
    font-size: .85rem;
    color: var(--text-dim);
    flex-wrap: wrap;
    min-width: 0;
    flex: 1;
}

.breadcrumb a {
    color: inherit;
    text-decoration: none;
    transition: color .2s;
}

.breadcrumb a:hover {
    color: var(--accent-light);
}

.breadcrumb span {
    color: var(--text-muted);
}

.breadcrumb .crumb-current {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: bottom;
}

.puzzle-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 2.5rem;
    align-items: start;
    width: 100%;
    box-sizing: border-box;
}

/* Critical fixes to absolutely prevent horizontal blowout */
.hero-left,
.hero-info {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.hero-img-wrap {
    width: 100%;
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 15px 40px rgba(0, 0, 0, .4);
    border: 1px solid rgba(255, 255, 255, .05);
    aspect-ratio: 4/3;
    background: var(--bg-surface);
    box-sizing: border-box;
}

.hero-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.hero-info h1 {
    font-family: 'Delius Swash Caps', cursive;
    font-size: 2.4rem;
    margin-bottom: 1rem;
    color: var(--text-bright);
    line-height: 1.2;
    word-wrap: break-word;
    overflow-wrap: break-word;
    min-width: 0;
}

.hero-desc {
    color: var(--text);
    font-size: 1.05rem;
    line-height: 1.7;
    margin-bottom: 1.5rem;
    word-wrap: break-word;
}

.hero-desc p {
    margin: 0 0 .7rem;
}

/* Best-score card */
.best-card {
    background: linear-gradient(135deg, rgba(250, 204, 21, .08), rgba(245, 158, 11, .04));
    border: 1px solid rgba(250, 204, 21, .22);
    border-radius: 14px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    width: 100%;
    box-sizing: border-box;
}

.best-card.empty {
    background: rgba(255, 255, 255, .03);
    border-color: var(--border);
}

.best-icon {
    font-size: 1.8rem;
    line-height: 1;
    flex-shrink: 0;
}

.best-text {
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

.best-label {
    font-size: .78rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 600;
    margin-bottom: .15rem;
}

.best-detail {
    color: var(--text-bright);
    font-weight: 700;
    font-size: 1rem;
}

.best-motivation {
    color: #facc15;
    font-size: .88rem;
    font-weight: 600;
    margin-top: .2rem;
}

.best-card.empty .best-motivation {
    color: var(--accent-light);
}

.diff-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: .75rem;
    margin-bottom: 1.75rem;
    width: 100%;
    box-sizing: border-box;
}

.diff-btn {
    background: var(--bg-surface);
    border: 2px solid var(--border);
    border-radius: 14px;
    padding: 1rem .5rem;
    text-align: center;
    cursor: pointer;
    transition: all .24s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .3rem;
    font-family: inherit;
    color: inherit;
    position: relative;
    overflow: hidden;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/* Difficulty-specific borders */
.diff-btn.easy { border-color: rgba(34, 197, 94, 0.3); }
.diff-btn.normal { border-color: rgba(59, 130, 246, 0.3); }
.diff-btn.hard { border-color: rgba(245, 158, 11, 0.3); }
.diff-btn.expert { border-color: rgba(239, 68, 68, 0.3); }
.diff-btn.master { border-color: rgba(245, 209, 66, 0.4); border-width: 2px; }

.diff-btn:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}

.diff-btn.easy:hover { border-color: #22c55e; background: rgba(34, 197, 94, 0.05); }
.diff-btn.normal:hover { border-color: #3b82f6; background: rgba(59, 130, 246, 0.05); }
.diff-btn.hard:hover { border-color: #f59e0b; background: rgba(245, 158, 11, 0.05); }
.diff-btn.expert:hover { border-color: #ef4444; background: rgba(239, 68, 68, 0.05); }
.diff-btn.master:hover { border-color: #f5d142; background: rgba(245, 209, 66, 0.08); }

.diff-btn.selected {
    transform: translateY(0) !important;
    box-shadow: 
        0 0 25px rgba(59, 130, 246, 0.4), 
        inset 0 4px 10px rgba(0, 0, 0, 0.3);
    background: rgba(15, 23, 42, 0.6) !important;
    z-index: 2;
}

.diff-btn.easy.selected { 
    border-color: #22c55e; 
    animation: breatheGlowEasy 1.5s ease-in-out infinite alternate;
    background: rgba(20, 30, 20, 0.7) !important;
}
.diff-btn.normal.selected { 
    border-color: #3b82f6; 
    animation: breatheGlowNormal 1.5s ease-in-out infinite alternate;
    background: rgba(20, 25, 45, 0.7) !important;
}
.diff-btn.hard.selected { 
    border-color: #f59e0b; 
    animation: breatheGlowHard 1.5s ease-in-out infinite alternate;
    background: rgba(35, 25, 15, 0.7) !important;
}
.diff-btn.expert.selected { 
    border-color: #ef4444; 
    animation: breatheGlowExpert 1.5s ease-in-out infinite alternate;
    background: rgba(35, 15, 15, 0.7) !important;
}
.diff-btn.master.selected { 
    border-color: #f5d142; 
    animation: breatheGlowMaster 1.5s ease-in-out infinite alternate;
    background: rgba(40, 35, 10, 0.7) !important;
}

@keyframes breatheGlowEasy { 0% { box-shadow: 0 0 10px rgba(34,197,94,0.3), inset 0 2px 8px rgba(0,0,0,0.4); } 100% { box-shadow: 0 0 35px rgba(34,197,94,0.7), inset 0 4px 12px rgba(0,0,0,0.5); } }
@keyframes breatheGlowNormal { 0% { box-shadow: 0 0 10px rgba(59,130,246,0.3), inset 0 2px 8px rgba(0,0,0,0.4); } 100% { box-shadow: 0 0 35px rgba(59,130,246,0.7), inset 0 4px 12px rgba(0,0,0,0.5); } }
@keyframes breatheGlowHard { 0% { box-shadow: 0 0 10px rgba(245,158,11,0.3), inset 0 2px 8px rgba(0,0,0,0.4); } 100% { box-shadow: 0 0 35px rgba(245,158,11,0.7), inset 0 4px 12px rgba(0,0,0,0.5); } }
@keyframes breatheGlowExpert { 0% { box-shadow: 0 0 10px rgba(239,68,68,0.3), inset 0 2px 8px rgba(0,0,0,0.4); } 100% { box-shadow: 0 0 35px rgba(239,68,68,0.7), inset 0 4px 12px rgba(0,0,0,0.5); } }
@keyframes breatheGlowMaster { 0% { box-shadow: 0 0 15px rgba(245,209,66,0.4), inset 0 2px 10px rgba(0,0,0,0.5); } 100% { box-shadow: 0 0 45px rgba(245,209,66,0.8), inset 0 5px 15px rgba(0,0,0,0.6); } }

@keyframes jigsawSelectedShimmer {
    0% { background-position: -200% 0; opacity: 0; }
    10% { opacity: 0.6; }
    25% { opacity: 0.8; }
    50% { background-position: 200% 0; opacity: 0.8; }
    65% { opacity: 0.6; }
    80% { opacity: 0; }
    100% { background-position: 200% 0; opacity: 0; }
}

.diff-btn.selected::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(100deg,
            transparent 0%,
            transparent 40%,
            rgba(255, 255, 255, 0.14) 47%,
            rgba(147, 197, 253, 0.32) 50%,
            rgba(255, 255, 255, 0.16) 53%,
            transparent 60%,
            transparent 100%);
    background-size: 250% 100%;
    background-repeat: no-repeat;
    animation: jigsawSelectedShimmer 5s ease-in-out infinite;
    animation-delay: 0.5s;
    border-radius: inherit;
    mix-blend-mode: screen;
    z-index: 1;
    filter: blur(0.8px) brightness(1.08);
}

.diff-btn>* {
    position: relative;
    z-index: 2;
}

@media (prefers-reduced-motion: reduce) {
    .diff-btn.selected::before {
        animation: none;
        opacity: 0;
    }
}

.diff-name {
    font-weight: 700;
    color: var(--text-bright);
    font-size: 1rem;
}

.diff-meta {
    font-size: .82rem;
    color: var(--text-dim);
}

.diff-best {
    font-size: .72rem;
    color: #facc15;
    font-weight: 700;
    margin-top: .15rem;
}

.btn-continue,
.btn-play-main {
    display: inline-flex;
    align-items: center;
    gap: .7rem;
    padding: 1rem 2.5rem;
    color: white;
    border-radius: 14px;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.15rem;
    transition: all .3s;
    width: 100%;
    justify-content: center;
    box-sizing: border-box;
    min-width: 0;
}

.btn-continue {
    background: linear-gradient(135deg, #16a34a, #22c55e);
    box-shadow: 0 8px 25px rgba(34, 197, 94, .3);
    font-size: 1.05rem;
}

.btn-continue:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(34, 197, 94, .4);
}

.btn-play-main {
    background: linear-gradient(135deg, var(--accent), #2563eb);
    box-shadow: 0 8px 25px rgba(37, 99, 235, .3);
}

.btn-play-main:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(37, 99, 235, .4);
}

.btn-divider {
    color: var(--text-muted);
    font-size: .85rem;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.saved-info {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-size: .78rem;
    color: #fff;
    background: rgba(255, 255, 255, .22);
    border: 1px solid rgba(255, 255, 255, .4);
    padding: .25rem .65rem;
    border-radius: 20px;
    margin-left: .6rem;
    font-weight: 700;
    letter-spacing: .02em;
}

.master-btn {
    position: relative;
    overflow: hidden;
    border-color: rgba(234, 179, 8, .3);
}

.master-btn.locked {
    opacity: .6;
    cursor: not-allowed;
    filter: grayscale(0.8);
}

.play-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
    box-sizing: border-box;
    flex-wrap: wrap;
}

.master-note {
    font-size: .88rem;
    color: var(--text-dim);
    line-height: 1.5;
    width: 100%;
    box-sizing: border-box;
    word-wrap: break-word;
}

/* ── Star rating widget ── */
.rating-widget {
    display: flex;
    align-items: center;
    gap: .85rem;
    margin: .25rem 0 1rem;
    flex-wrap: wrap;
}

.rating-stars {
    display: inline-flex;
    gap: .15rem;
    color: #f5d142;
    line-height: 0;
}

.rating-star {
    background: none;
    border: 0;
    padding: 2px;
    cursor: default;
    color: inherit;
    line-height: 0;
    transition: transform .12s ease;
}

.rating-widget.can-rate .rating-star {
    cursor: pointer;
}

.rating-widget.can-rate .rating-star:hover,
.rating-widget.can-rate .rating-star:focus-visible {
    transform: scale(1.18);
    outline: none;
}

.rating-widget.locked .rating-stars,
.rating-widget.anon .rating-stars {
    opacity: .55;
    filter: saturate(.6);
}

.rating-meta {
    display: inline-flex;
    flex-direction: column;
    gap: .15rem;
    font-size: .88rem;
    color: var(--text-dim);
    line-height: 1.3;
}

.rating-aggregate {
    color: var(--text-bright);
    font-weight: 600;
}

.rating-aggregate.empty {
    color: var(--text-dim);
    font-weight: 500;
}

.rating-hint {
    font-size: .78rem;
    opacity: .8;
}

@media (max-width: 640px) {
    .rating-widget {
        gap: .6rem;
    }
    .rating-meta {
        font-size: .82rem;
    }
    .rating-hint {
        font-size: .72rem;
    }
}

.puzzle-desc-section {
    font-size: 1.05rem;
    line-height: 1.75;
    margin-top: 1.5rem;
    width: 100%;
    box-sizing: border-box;
    word-wrap: break-word;
}

.puzzle-desc-section p {
    margin-bottom: .9rem;
}

.related-section {
    margin-top: 3rem;
    width: 100%;
    box-sizing: border-box;
}

.related-title {
    font-size: 1.4rem;
    color: var(--text-bright);
    margin-bottom: 1.5rem;
    font-family: 'Delius Swash Caps', cursive;
}

.header-nav {
    margin-left: auto;
    display: flex;
    gap: 1.2rem;
    align-items: center;
}

.nav-link {
    color: var(--text-dim);
    text-decoration: none;
    font-size: .88rem;
    display: flex;
    align-items: center;
    gap: .4rem;
    transition: color .2s;
}

.nav-link:hover {
    color: var(--accent-light);
}

/* Tablet / Landscape + Small Laptops — Single column stack */
@media(max-width:1023px) {
    .puzzle-hero {
        grid-template-columns: minmax(0, 1fr);
        gap: 1.5rem;
    }

    .puzzle-page {
        padding: 1.25rem 1rem;
    }

    .hero-info h1 {
        font-size: 2.1rem;
    }
}

/* Mobile — compact everything */
@media(max-width:640px) {
    .puzzle-page {
        padding: 1rem .85rem 2rem;
    }

    .back-bar {
        gap: .6rem;
        margin-bottom: 1rem;
    }

    .btn-back {
        padding: .55rem .9rem;
        font-size: .85rem;
    }

    .breadcrumb {
        font-size: .78rem;
        gap: .35rem;
    }

    .breadcrumb .crumb-current {
        max-width: 140px;
    }

    .puzzle-hero {
        gap: 1.25rem;
    }

    .hero-img-wrap {
        border-radius: 16px;
    }

    .hero-info h1 {
        font-size: 1.6rem;
        margin-bottom: .7rem;
    }

    .hero-desc {
        font-size: .95rem;
        line-height: 1.6;
        margin-bottom: 1.25rem;
    }

    .puzzle-desc-section {
        font-size: .95rem;
    }

    .puzzle-desc-section p {
        margin-bottom: .75rem;
    }

    .best-card {
        padding: .85rem 1rem;
        gap: .75rem;
    }

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

    .best-detail {
        font-size: .92rem;
    }

    .best-motivation {
        font-size: .82rem;
    }

    .diff-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: .5rem;
    }

    .diff-btn {
        padding: .85rem .5rem;
    }

    .diff-name {
        font-size: .92rem;
    }

    .diff-meta {
        font-size: .76rem;
    }

    .btn-play-main,
    .btn-continue {
        padding: .9rem 1.25rem;
        font-size: 1.05rem;
    }

    .btn-divider {
        width: 100%;
        text-align: center;
    }

    .saved-info {
        font-size: .72rem;
        padding: .2rem .55rem;
    }

    .master-note {
        font-size: .82rem;
    }

    .play-row {
        gap: .75rem;
        flex-direction: column;
        align-items: stretch;
    }

    .related-section {
        margin-top: 2.25rem;
    }

    .related-title {
        font-size: 1.2rem;
        margin-bottom: 1rem;
    }

    .header-nav {
        gap: .6rem;
    }

    .nav-link {
        font-size: .78rem;
    }

    .main-header {
        height: 52px !important;
    }

    .main-header .header-inner {
        padding: 0 .85rem !important;
        height: 52px !important;
    }

    .logo img {
        height: 26px !important;
        width: 26px !important;
    }

    .logo span {
        font-size: 1rem !important;
    }
}

/* Extra-small phones */
@media(max-width:400px) {
    .header-nav {
        display: none;
    }

    .logo span {
        font-size: .95rem !important;
    }

    .hero-info h1 {
        font-size: 1.4rem;
    }
}

/* ── Light theme overrides ── */
[data-theme="light"] #auroraCanvas { display: none; }

[data-theme="light"] .hero-img-wrap {
    border-color: var(--border);
    box-shadow: 0 8px 25px rgba(0,0,0,.1);
}

[data-theme="light"] .diff-btn.selected {
    box-shadow: 0 0 20px rgba(59,130,246,.2), inset 0 2px 6px rgba(0,0,0,.06) !important;
}
[data-theme="light"] .diff-btn.easy.selected    { background: rgba(34,197,94,.1) !important; }
[data-theme="light"] .diff-btn.normal.selected  { background: rgba(59,130,246,.1) !important; }
[data-theme="light"] .diff-btn.hard.selected    { background: rgba(245,158,11,.1) !important; }
[data-theme="light"] .diff-btn.expert.selected  { background: rgba(239,68,68,.1) !important; }
[data-theme="light"] .diff-btn.master.selected  { background: rgba(245,209,66,.12) !important; }

[data-theme="light"] .hero-credit a             { color: #1d4ed8 !important; text-decoration-color: rgba(29,78,216,.35) !important; }
[data-theme="light"] .hero-credit a:hover       { color: #1e40af !important; text-decoration-color: #1e40af !important; }

[data-theme="light"] .best-card.empty           { background: rgba(0,0,0,.03); }
[data-theme="light"] .best-motivation           { color: #1d4ed8; }
[data-theme="light"] .diff-best                 { color: #92400e; }
[data-theme="light"] .master-note               { color: var(--text); }
[data-theme="light"] .breadcrumb                { color: var(--text-dim); }