/* Streak Torch (shop), Daily Archive and the daily leaderboard. 8-bit stone look like dungeon.css. */

.pixel-panel,
.streak-item-card,
.archive-month,
.win-leaderboard {
    background-color: #2b2521;
    border: 4px solid #15110e;
    box-shadow:
        inset 4px 4px 0 #4a4038,
        inset -4px -4px 0 #1d1815,
        4px 4px 0 rgba(0, 0, 0, 0.6);
    border-radius: 0;
    image-rendering: pixelated;
}

/* ===== Streak Torch ===== */

.shop-streak-items {
    margin: 0 0 1rem;
}

.streak-item-card {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.9rem;
    padding: 0.9rem;
}

.streak-item-card .skin-action {
    flex: 1 0 100%;
    display: flex;
    justify-content: flex-end;
}

.streak-item-icon {
    flex: 0 0 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #15110e;
    box-shadow: inset 3px 3px 0 #000, inset -3px -3px 0 #3a322c;
}

/* 4px pixel torch: flame on a wooden handle */
.pixel-torch {
    position: relative;
    width: 4px;
    height: 4px;
    transform: translateY(-14px);
    box-shadow:
        0 0 0 #ffe27a,
        -4px 4px 0 #ff9f1c, 0 4px 0 #ffe27a, 4px 4px 0 #ff9f1c,
        -4px 8px 0 #e8590c, 0 8px 0 #ffb733, 4px 8px 0 #e8590c,
        0 12px 0 #e8590c,
        -4px 16px 0 #5c3a1e, 0 16px 0 #8b5a2b, 4px 16px 0 #5c3a1e,
        0 20px 0 #8b5a2b, 0 24px 0 #5c3a1e, 0 28px 0 #5c3a1e;
    animation: pixel-torch-flicker 0.6s steps(1) infinite;
}

@keyframes pixel-torch-flicker {
    50% { filter: brightness(1.25) hue-rotate(-8deg); }
}

.streak-item-info {
    flex: 1;
    min-width: 0;
}

.streak-item-desc {
    font-size: 0.6rem;
    line-height: 1.6;
    color: #b9ab97;
    margin: 0.25rem 0 0.4rem;
}

.torch-slots {
    display: flex;
    gap: 6px;
}

.torch-slot {
    width: 14px;
    height: 14px;
    background: #15110e;
    box-shadow: inset 2px 2px 0 #000;
}

.torch-slot.lit {
    background: #ff9f1c;
    box-shadow: inset -3px -3px 0 #e8590c, inset 3px 3px 0 #ffe27a;
}

/* ===== Daily Archive ===== */

.archive-intro {
    color: #cdbfa9;
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 0.75rem;
}

.archive-legend {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.8rem;
    color: #b9ab97;
    margin-bottom: 0.5rem;
}

.archive-legend span {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.archive-dot {
    width: 12px;
    height: 12px;
    display: inline-block;
}

.archive-summary {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.65rem;
    color: var(--dungeon-gold, #ffcf4a);
    margin: 0.75rem 0;
}

.archive-loading {
    color: #b9ab97;
    text-align: center;
    padding: 2rem 0;
}

.archive-month {
    padding: 0.9rem;
    margin-bottom: 1rem;
}

.archive-month h3 {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.75rem;
    color: #efe3cf;
    margin: 0 0 0.75rem;
}

.archive-weekdays,
.archive-grid {
    display: grid;
    /* minmax(0, 1fr): columns may shrink below the button's text width, so small phones fit */
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
}

.archive-weekdays span {
    text-align: center;
    font-size: 0.7rem;
    color: #8a7d6c;
}

.archive-day {
    min-width: 0;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.6rem;
    border: 0;
    border-radius: 0;
    padding: 0;
    color: #efe3cf;
}

.archive-day.empty {
    color: #4a4038;
    background: transparent;
}

button.archive-day {
    cursor: pointer;
}

.archive-day.missed,
.archive-dot.missed {
    background: #4b4139;
    box-shadow: inset 3px 3px 0 #6e6156, inset -3px -3px 0 #2f2823;
}

/* Cleared is always green; cleared on the day itself gets a gold rim */
.archive-day.done,
.archive-dot.done {
    background: #3f7a3a;
    box-shadow: inset 0 0 0 2px #ffcf4a, inset 5px 5px 0 #6fbf5f, inset -5px -5px 0 #24481f;
}

.archive-day.archived,
.archive-dot.archived {
    background: #3f7a3a;
    box-shadow: inset 3px 3px 0 #6fbf5f, inset -3px -3px 0 #24481f;
}

button.archive-day:hover,
button.archive-day:focus-visible {
    outline: 3px solid #efe3cf;
    outline-offset: 0;
}

button.archive-day:active {
    transform: translate(2px, 2px);
}

/* mobile.css forces 16px on every button (iOS zoom guard); calendar days aren't inputs */
@media (max-width: 768px) {
    #archive-screen button.archive-day { font-size: 0.6rem !important; }
}

@media (max-width: 480px) {
    #archive-screen button.archive-day,
    #archive-screen .archive-day { font-size: 0.5rem !important; }
    .archive-month { padding: 0.6rem; }
    .archive-weekdays,
    .archive-grid { gap: 4px; }
    .archive-day.missed,
    .archive-day.archived { box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.22), inset -2px -2px 0 rgba(0, 0, 0, 0.35); }
    .archive-day.done { box-shadow: inset 0 0 0 2px #ffcf4a, inset 4px 4px 0 rgba(255, 255, 255, 0.22), inset -4px -4px 0 rgba(0, 0, 0, 0.35); }
}

/* ===== Daily leaderboard (win screen) ===== */

.win-leaderboard {
    margin: 1rem 0;
    padding: 0.75rem;
    text-align: left;
}

.lb-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.65rem;
    color: var(--dungeon-gold, #ffcf4a);
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.lb-total {
    color: #8a7d6c;
}

.lb-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 13rem;
    overflow-y: auto;
}

.lb-row {
    display: grid;
    grid-template-columns: 2rem 1fr 4.5rem 3rem;
    gap: 0.4rem;
    padding: 0.3rem 0.25rem;
    font-size: 0.8rem;
    color: #efe3cf;
    border-bottom: 2px solid #1d1815;
}

.lb-row.lb-head {
    color: #8a7d6c;
    font-size: 0.7rem;
}

.lb-row.me {
    background: #4a3a14;
    box-shadow: inset 3px 0 0 var(--dungeon-gold, #ffcf4a);
}

.lb-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-time,
.lb-moves {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.lb-gap {
    text-align: center;
    color: #8a7d6c;
}

.lb-note {
    font-size: 0.8rem;
    color: #b9ab97;
    margin: 0.25rem 0;
}

/* ===== Monthly quest path ===== */

.quest-banner {
    text-align: center;
    padding: 1rem 0.75rem;
    margin-bottom: 1.25rem;
    background-color: #2b2521;
    border: 4px solid #15110e;
    box-shadow:
        inset 4px 4px 0 #4a4038,
        inset -4px -4px 0 #1d1815,
        4px 4px 0 rgba(0, 0, 0, 0.6);
}

.quest-theme-icon {
    font-size: 2.2rem;
    line-height: 1;
    margin-bottom: 0.4rem;
}

.quest-banner h3 {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.9rem;
    color: var(--theme-accent, #ffcf4a);
    margin: 0 0 0.5rem;
}

.quest-banner p {
    color: #cdbfa9;
    font-size: 0.85rem;
    line-height: 1.5;
    margin: 0;
}

.quest-meter {
    height: 12px;
    margin: 0.75rem auto 0.5rem;
    max-width: 280px;
    background: #15110e;
    box-shadow: inset 2px 2px 0 #000;
}

.quest-meter span {
    display: block;
    height: 100%;
    background: var(--theme-accent, #ffcf4a);
    box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.25);
}

.quest-banner .quest-meta {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.55rem;
    color: #b9ab97;
}

/* The trail: a dotted line down the left, the stones sit on it */
.quest-path {
    list-style: none;
    margin: 0;
    padding: 0 0 1rem;
    position: relative;
}

.quest-path::before {
    content: '';
    position: absolute;
    left: 18px;
    top: 20px;
    bottom: 36px;
    width: 4px;
    background: repeating-linear-gradient(180deg, #6e6156 0 4px, transparent 4px 10px);
}

.quest-step {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0 0 12px;
}

.quest-stone {
    position: relative;
    z-index: 1;
    flex: 0 0 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.6rem;
    color: #8a7d6c;
    background: #3a322c;
    box-shadow:
        inset 4px 4px 0 #554b42,
        inset -4px -4px 0 #231e1a,
        0 0 0 4px #15110e;
}

.quest-step.milestone .quest-stone,
.quest-step.final .quest-stone {
    flex-basis: 40px;
    color: #ffcf4a;
}

.quest-step.done .quest-stone {
    font-family: inherit;
    font-size: 1rem;
    font-weight: bold;
    color: #15110e;
    background: var(--theme-accent, #ffcf4a);
    box-shadow:
        inset 4px 4px 0 rgba(255, 255, 255, 0.35),
        inset -4px -4px 0 rgba(0, 0, 0, 0.3),
        0 0 0 4px #15110e;
}

.quest-step.current .quest-stone {
    color: #efe3cf;
    box-shadow:
        inset 4px 4px 0 #554b42,
        inset -4px -4px 0 #231e1a,
        0 0 0 4px var(--theme-accent, #ffcf4a),
        0 0 14px var(--theme-accent, #ffcf4a);
    animation: quest-pulse 1.4s steps(2) infinite;
}

@keyframes quest-pulse {
    50% { transform: translateY(-3px); }
}

.quest-card {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.7rem;
    background-color: #2b2521;
    border: 4px solid #15110e;
    box-shadow: inset 3px 3px 0 #4a4038, inset -3px -3px 0 #1d1815;
}

.quest-step.current .quest-card {
    border-color: var(--theme-accent, #ffcf4a);
}

.quest-step.locked .quest-card {
    opacity: 0.6;
}

.quest-step.done .quest-text {
    color: #9d917f;
    text-decoration: line-through;
    text-decoration-thickness: 2px;
}

.quest-icon {
    flex: 0 0 auto;
    font-size: 1.1rem;
}

.quest-text {
    flex: 1;
    color: #efe3cf;
    font-size: 0.85rem;
    line-height: 1.35;
}

.quest-count {
    display: inline-block;
    margin-left: 0.4rem;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.55rem;
    color: var(--theme-accent, #ffcf4a);
}

.quest-prize {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.55rem;
    color: #ffcf4a;
    white-space: nowrap;
}

.quest-prize.chest::before { content: '🎁'; margin-right: 4px; font-size: 0.9rem; }
.quest-prize.final::before { content: '👑'; margin-right: 4px; font-size: 0.9rem; }

@media (max-width: 480px) {
    .quest-step { gap: 0.5rem; }
    .quest-card { flex-wrap: wrap; gap: 0.3rem 0.5rem; padding: 0.45rem 0.55rem; }
    .quest-text { flex: 1 1 calc(100% - 2rem); font-size: 0.62rem; line-height: 1.45; }
    .quest-prize { margin-left: auto; }
}

@media (prefers-reduced-motion: reduce) {
    .pixel-torch { animation: none; }
    .quest-step.current .quest-stone { animation: none; }
}

/* ===== Sunday Boss Dungeon: cursed stone with a blood-red gate ===== */

.menu-play-btn.boss {
    color: #ff6b6b;
    border-color: #120408;
    background-color: #2a1420;
    background-image:
        repeating-linear-gradient(90deg, transparent 0 14px, #120408 14px 18px),
        linear-gradient(0deg, rgba(160, 20, 40, 0.5), transparent 60%),
        var(--dungeon-slab);
    background-size: auto, auto, 32px 32px;
    box-shadow:
        inset 4px 4px 0 #4a2433,
        inset -4px -4px 0 #16070d,
        0 0 0 4px #7a1424,
        4px 4px 0 4px rgba(0, 0, 0, 0.6);
    animation: boss-glow 1.6s steps(4) infinite;
}

.menu-play-btn.boss:hover {
    border-color: #120408;
    box-shadow:
        inset 4px 4px 0 #5c2c40,
        inset -4px -4px 0 #16070d,
        0 0 0 4px #c0243a,
        6px 6px 0 4px rgba(0, 0, 0, 0.6),
        0 0 24px rgba(220, 30, 60, 0.5);
}

.menu-play-btn.boss .btn-subtitle {
    color: #f3b0b8;
}

.menu-play-btn.boss.boss-cleared {
    color: #9fdc8f;
    animation: none;
    box-shadow:
        inset 4px 4px 0 #4a2433,
        inset -4px -4px 0 #16070d,
        0 0 0 4px #6aaa64,
        4px 4px 0 4px rgba(0, 0, 0, 0.6);
}

.menu-play-btn.boss.boss-cleared .btn-subtitle {
    color: #b9e6ad;
}

.menu-play-btn.boss.boss-locked {
    /* no lives left: still playable for a smaller reward */
    animation: none;
    filter: grayscale(0.45);
}

.menu-play-btn.boss.boss-locked .btn-subtitle {
    color: #8a7f86;
}

@keyframes boss-glow {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.2); }
}

@media (prefers-reduced-motion: reduce) {
    .menu-play-btn.boss {
        animation: none;
    }
}

/* Boss and challenge lives stay on one line on phones */
#lives-display {
    white-space: nowrap;
}

/* ===== Game modes button: glows red while the Sunday boss is open ===== */

.menu-play-btn.modes.boss-day {
    border-color: #5a0f12;
    box-shadow:
        inset 4px 4px 0 #554b42,
        inset -4px -4px 0 #231e1a,
        0 0 0 4px #8b1a1f,
        4px 4px 0 4px rgba(0, 0, 0, 0.6),
        0 0 18px rgba(220, 40, 40, 0.35);
}

.menu-play-btn.modes.boss-day .btn-subtitle {
    color: #ff8a80;
}

/* ===== Daily win screen: streak reminder offer ===== */

.streak-nudge {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    margin: 0.75rem 0;
    padding: 0.6rem 0.75rem;
    background: #2b2521;
    border: 3px solid #15110e;
    box-shadow: inset 3px 3px 0 #4a4038, inset -3px -3px 0 #1d1815;
    flex-wrap: wrap;
    font-size: 0.65rem;
    line-height: 1.5;
    text-align: left;
}

.streak-nudge-text {
    flex: 1 1 12rem;
}

.streak-nudge.hidden {
    display: none;
}

.streak-nudge-buttons {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
    margin-left: auto;
}

.streak-nudge button {
    padding: 0.4rem 0.6rem;
    font-family: inherit;
    font-size: 0.65rem;
    background: #3d2f22;
    color: var(--dungeon-gold, #ffcf4a);
    border: 2px solid #6b5132;
    cursor: pointer;
}

.streak-nudge button.streak-nudge-no {
    color: #b8b0a6;
    border-color: #4a4038;
}

/* ===== Accessibility (Settings > Display), classes set on <html> by ui/accessibility.js ===== */

/* Colour-blind helpers: spike states also differ in pattern, not only in colour.
   rising next = dotted white border, deadly = hatched tile + dashed border,
   deadly but sinking next = the same hatch, fainter. */
.a11y-colorblind .tile.spikes.spikes-warn {
    border-style: dotted !important;
    border-color: #fff !important;
}

.a11y-colorblind .tile.spikes.spikes-up {
    border-style: dashed !important;
    border-color: #fff !important;
}

.a11y-colorblind .tile.spikes.spikes-up:not(.broken):not(.wall)::before {
    background-image: repeating-linear-gradient(
        45deg,
        rgba(0, 0, 0, 0.55) 0 4px,
        rgba(255, 255, 255, 0.35) 4px 6px
    );
    background-size: auto;
    opacity: 1;
}

.a11y-colorblind .tile.spikes.spikes-up.spikes-sinking:not(.broken):not(.wall)::before {
    opacity: 0.45;
}

/* High contrast: bright outlined numbers, darker cleared tiles, stronger labels */
.a11y-contrast .tile .tile-value {
    color: #fff !important;
    text-shadow:
        2px 0 0 #000, -2px 0 0 #000, 0 2px 0 #000, 0 -2px 0 #000,
        1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
}

.a11y-contrast .tile[data-value="0"]:not(.path) {
    background: #1c1c1c;
    border-color: #000;
}

.a11y-contrast .tile[data-value="0"]:not(.path) .tile-value {
    color: #9a9a9a !important;
}

.a11y-contrast .tile:not(.wall):not(.path) {
    outline: 1px solid rgba(0, 0, 0, 0.9);
    outline-offset: -1px;
}

.a11y-contrast .info-item .label,
.a11y-contrast .btn-subtitle,
.a11y-contrast .settings-label,
.a11y-contrast .notif-toggle-label span {
    color: #f2f2f2 !important;
}

.settings-hint {
    font-size: 0.7rem;
    color: #aaa;
    margin: -0.25rem 0 0.75rem;
    line-height: 1.4;
}
