/* ══════════════════════════════════════════════════════════════════════════════
   MOBILE LAYOUT
   Restructures the 3-column desktop layout into a vertical stack:
   [progress + gold + gear] → [puzzle board] → [horizontal tray]

   This file is loaded with media="(max-width: 600px)" so it only applies
   on mobile devices. Desktop styles in styles.css are unaffected.
   ══════════════════════════════════════════════════════════════════════════════ */

html {
    overscroll-behavior: none;
}
body {
    min-width: unset;
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
    height: 100dvh;
    max-height: 100dvh;
    font-size: 17px;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    overscroll-behavior: none;
}

/* Landing page */
.landing-panel .btn-modal-secondary {
    font-size: 1.05rem;
    padding: 16px 28px;
}

.landing-dock-btn {
    padding: 14px 8px;
}

.landing-dock-icon {
    font-size: 1.6rem;
}

.landing-dock-label {
    font-size: 0.68rem;
}

/* Modals */
.modal-content h2 {
    font-size: 1.6rem;
}
.modal-nav-title {
    font-size: 1.2rem;
}

/* Collection cards */
.journey-theme-card-title {
    font-size: 1.05rem;
}

/* Episode titles */
.journey-chapter-title {
    font-size: 1rem;
}

/* Shop items */
.shop-item-name {
    font-size: 1rem;
}

/* Stats */
.stats-card-value {
    font-size: 1.2rem;
}

/* Win modal */
.win-subtitle {
    font-size: 1rem;
}
.container {
    padding: 0;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
}

/* ── Game area: full-height vertical stack ──────────────────────── */
.game-area {
    position: relative;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0 4px;
    padding-top: calc(env(safe-area-inset-top, 12px) + 12px);
    padding-bottom: calc(env(safe-area-inset-bottom, 12px) + 12px);
    height: 100vh;
    height: 100dvh;
    box-sizing: border-box;
    justify-content: space-between;
}

/* ── Board centered, tray pinned to bottom ─────────────────────── */
.puzzle-container {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pieces-panel {
    flex-shrink: 0;
}

/* ── Controls sidebar → single horizontal top bar ─────────────── */
.controls-sidebar {
    width: 100%;
    flex-shrink: 0;
    flex-direction: row;
    align-items: center;
    gap: 0;
    padding: 0 88px 0 0; /* right space for fixed item + settings buttons */
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.07) 0%, rgba(255, 255, 255, 0.02) 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
}
.controls-sidebar .sidebar-section {
    display: none;
}
.controls-sidebar .sidebar-section:first-child {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    width: 100%;
    padding: 0 4px;
    gap: 6px;
    flex-wrap: nowrap;
    background: none;
    border: none;
    box-shadow: none;
    min-height: 44px;
    position: relative;
}
.sidebar-stat--timer #timer {
    display: none;
}
.sidebar-stat--timer {
    flex: 0;
}
.sidebar-stat--timer .gold-badge {
    padding: 0 12px;
    height: 44px;
    border-radius: 0;
    font-size: 1rem;
    background: none;
    border: none;
    box-shadow: none;
}
.sidebar-stat--timer .gold-badge .gold-icon {
    width: 22px;
    height: 22px;
}
.gold-badge-amount {
    font-size: 1rem;
}
.sidebar-stat--accuracy {
    display: none;
}
.sidebar-stat:has(.progress-container) {
    flex: 1;
}
.sidebar-stat .progress-container {
    width: 100%;
    height: 44px;
    padding: 12px 10px;
    border-radius: 0;
    box-sizing: border-box;
    background: none;
    border: none;
    box-shadow: none;
}
.progress-bar {
    height: 100%;
    border-radius: 8px;
}
.progress-text {
    font-size: 0.9rem;
    font-weight: 700;
}
.controls-sidebar .btn-text,
.controls-sidebar .btn-reference,
.controls-sidebar .upload-btn {
    display: none !important;
}
.btn-full {
    width: auto;
    margin-bottom: 0;
}
/* Item bar: hidden from sidebar, accessed via mobile item button */
.controls-sidebar .item-bar-section {
    display: none !important;
}

/* Mobile top-bar buttons — fixed to align with progress row */
.mobile-item-btn {
    display: flex;
    position: fixed;
    top: calc(env(safe-area-inset-top, 12px) + 12px);
    right: 50px;
    z-index: 100;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 0;
    background: none;
    font-size: 1.3rem;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    color: rgba(255, 215, 0, 0.9);
}
.mobile-item-btn:active {
    opacity: 0.7;
}
.mobile-item-btn-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
}
.mobile-item-armed {
    animation: mobileItemPulse 1.2s ease-in-out infinite;
    opacity: 1 !important;
}
@keyframes mobileItemPulse {
    0%, 100% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.12); filter: brightness(1.4); }
}
.mobile-item-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 199;
    background: rgba(0, 0, 0, 0.5);
}
.mobile-item-panel {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 200;
    width: min(320px, 88vw);
    flex-direction: column;
    background:
        radial-gradient(ellipse at 20% 0%, var(--glow-a) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 100%, var(--glow-b) 0%, transparent 60%),
        linear-gradient(160deg, var(--bg-mid), var(--bg-primary));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 20px 16px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
}
.mobile-item-panel.visible {
    display: flex;
}
.mobile-item-panel-close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    color: rgba(255, 255, 255, 0.35);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0;
    line-height: 28px;
    text-align: center;
}
.mobile-item-panel-close:active {
    color: rgba(255, 255, 255, 0.7);
}
.mobile-item-panel-title {
    font-family: 'Lilita One', sans-serif;
    font-size: 1.5rem;
    color: #fff;
    text-align: center;
    margin-bottom: 14px;
}
.mobile-item-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.mobile-item-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    cursor: pointer;
    transition: background 0.15s;
}
.mobile-item-row:active {
    background: rgba(255, 255, 255, 0.1);
}
.mobile-item-row.locked {
    opacity: 0.35;
    pointer-events: none;
}
.mobile-item-row.empty {
    opacity: 0.5;
    pointer-events: none;
}
.mobile-item-row-icon {
    width: 36px;
    height: 36px;
    object-fit: contain;
    flex-shrink: 0;
}
.mobile-item-row-info {
    flex: 1;
    min-width: 0;
}
.mobile-item-row-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 2px;
}
.mobile-item-row-desc {
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.45);
    line-height: 1.3;
}
.mobile-item-row-count {
    font-size: 0.85rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.6);
    flex-shrink: 0;
    min-width: 24px;
    text-align: center;
}

/* ── Mobile floating menu ─────────────────────────────────────── */
.mobile-menu-btn {
    display: flex;
    position: fixed;
    top: calc(env(safe-area-inset-top, 12px) + 12px);
    right: 8px;
    z-index: 100;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 0;
    background: none;
    font-size: 1.4rem;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}
.mobile-menu-btn:active {
    opacity: 1;
}
/* ── Mobile settings modal ─────────────────────────────────────── */
.mobile-settings-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 199;
    background: var(--overlay-heavy);
}
.mobile-settings-backdrop.hidden {
    display: none !important;
}
.mobile-settings-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 200;
    width: min(320px, 88vw);
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(ellipse at 20% 0%, var(--glow-a) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 100%, var(--glow-b) 0%, transparent 60%),
        linear-gradient(160deg, var(--bg-mid), var(--bg-primary));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 20px 16px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
}
.mobile-settings-panel.hidden {
    display: none;
}
.mobile-settings-header {
    display: flex;
    align-items: center;
    margin-bottom: 24px;
}
.mobile-settings-title {
    font-family: 'Lilita One', sans-serif;
    font-size: 1.5rem;
    color: #fff;
    flex: 1;
    text-align: center;
}
.mobile-settings-close {
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 1.8rem;
    cursor: pointer;
    padding: 0;
    line-height: 36px;
    text-align: center;
}
.mobile-settings-close:active {
    color: rgba(255, 255, 255, 0.7);
}
.mobile-settings-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.mobile-settings-action {
    flex: 1;
    padding: 12px 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
}
.mobile-settings-action:active {
    background: rgba(255, 255, 255, 0.12);
}
.mobile-settings-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 16px 0;
}
.mobile-settings-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.mobile-settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
}
.mobile-settings-toggle,
.mobile-settings-select {
    width: 110px;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    box-sizing: border-box;
}
.mobile-settings-toggle:active {
    background: rgba(255, 255, 255, 0.12);
}

/* ── Pieces: keep 3D bevels, remove expensive drop-shadow ─────── */
.puzzle-piece {
    filter: none !important;
    transition: none !important;
}
.puzzle-piece.dragging {
    z-index: 9999 !important;
}
.puzzle-piece:hover {
    filter: none !important;
}
/* ── Restore item visual effects killed by filter:none ─────────── */

/* Focus mode: glow on snap targets */
.puzzle-piece.focus-snap-target {
    filter: drop-shadow(0 0 14px rgba(167, 139, 250, 0.85)) drop-shadow(0 0 5px rgba(255, 255, 255, 0.35)) !important;
}
.puzzle-piece.focus-snap-close {
    filter: drop-shadow(0 0 20px rgba(167, 139, 250, 1)) drop-shadow(0 0 8px rgba(255, 255, 255, 0.6)) !important;
}
/* Focus mode: glow on dragged piece */
.focus-mode-active .puzzle-piece.dragging {
    filter: drop-shadow(0 0 14px rgba(167, 139, 250, 0.9)) drop-shadow(0 0 6px rgba(255, 255, 255, 0.4)) saturate(1.3) !important;
}

/* Golden charge: glow on armed piece */
.puzzle-piece.golden-charge-glow {
    filter: drop-shadow(0 0 14px rgba(255, 210, 0, 0.95)) drop-shadow(0 0 6px rgba(255, 160, 0, 0.6)) saturate(1.2) !important;
}

/* Golden pieces: pulse glow */
.puzzle-piece.golden {
    filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.7)) drop-shadow(0 0 3px rgba(255, 200, 0, 0.5)) !important;
    animation: goldenPulse 1.5s ease-in-out infinite !important;
}

/* Precision pick: eligible/ineligible tray pieces */
.precision-pick-active .puzzle-piece.tray-piece.precision-eligible {
    filter: drop-shadow(0 0 8px rgba(100, 200, 255, 0.6)) !important;
}
.precision-pick-active .puzzle-piece.tray-piece.precision-ineligible {
    filter: grayscale(0.5) !important;
    opacity: 0.35;
}
/* Precision pick: flying piece */
.puzzle-piece.precision-flying {
    filter: drop-shadow(0 0 12px rgba(100, 200, 255, 0.7)) !important;
    transition: left 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), top 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
}

/* Vacancy fill: ghost preview */
.vacancy-ghost {
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.35)) !important;
}
.vacancy-ghost.ghost-snapped {
    filter: drop-shadow(0 0 14px rgba(76, 175, 80, 0.85)) drop-shadow(0 4px 10px rgba(0, 0, 0, 0.35)) !important;
}
/* Vacancy fill: locked tray dim */
.vacancy-fill-locked .puzzle-piece.tray-piece {
    filter: grayscale(0.5) !important;
    opacity: 0.35;
}
/* Remove SVG stroke transitions */
.puzzle-piece .piece-outline,
.puzzle-piece .piece-bevel-dark,
.puzzle-piece .piece-bevel-light {
    transition: none !important;
}
/* Remove tray slot transitions */
.tray-slot {
    transition: none !important;
}
/* Replace expensive backdrop-filter blur with solid background */
.btn-reference,
.btn-modal-secondary {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: rgba(30, 30, 55, 0.85) !important;
}
/* Simplify board background */
.free-form-board {
    box-shadow: none !important;
}
/* Simplify sidebar/tray container shadows */
.sidebar-section,
.pieces-container {
    box-shadow: none !important;
}

/* ── Puzzle board: full width, max height = width for square aspect ── */
.puzzle-container {
    min-width: 100% !important;
    width: 100% !important;
    max-width: 100%;
    max-height: calc(100vw - 8px);
    flex: 1 1 auto;
    overflow: visible;
    touch-action: none;
    box-sizing: border-box;
}

/* ── Pieces panel → horizontal bottom tray ─────────────────────── */
.pieces-panel {
    width: 100%;
    flex-direction: row;
    align-items: stretch;
    gap: 0;
    padding: 4px 4px 6px;
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.07) 0%, rgba(255, 255, 255, 0.02) 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    overflow: visible;
}
/* Keep tray visible even when empty — player can still drag pieces back */
.pieces-title {
    display: none;
}
.pieces-container {
    max-width: unset;
    flex: 1 1 0;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    grid-auto-flow: column;
    grid-template-rows: 1fr;
    grid-template-columns: none;
    padding: 6px;
    gap: 4px;
    touch-action: none;
    align-items: center;
    background: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
}
.draw-pile-indicator.hidden {
    display: flex;
    visibility: hidden;
}
.draw-pile-indicator {
    flex-shrink: 0;
    align-self: center;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    margin: 0 0 0 6px;
    width: auto;
    min-width: auto;
    background: none;
    border: none;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0;
    box-shadow: none;
    gap: 4px;
}
.pile-stack {
    width: 34px;
    height: 34px;
    margin: 0;
    transform: none;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pile-card--2,
.pile-card--3 {
    display: none;
}
.pile-card,
.pile-card--1 {
    position: static;
    top: auto;
    left: auto;
    width: 34px;
    height: 34px;
    transform: none;
    box-shadow: none;
    background: none;
    border: none;
    border-radius: 0;
    padding: 0;
    opacity: 1;
}
.pile-card img {
    width: 34px !important;
    height: 34px !important;
    opacity: 0.8;
}
.pile-text {
    font-size: 0;
    color: transparent;
}
.pile-count {
    font-size: 1.1rem !important;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.5) !important;
}

/* ── Cookie/analytics consent banner ───────────────────────────── */
.cookie-banner {
    width: 92vw;
    flex-wrap: wrap;
    justify-content: center;
    white-space: normal;
    bottom: 16px;
    padding: 10px 14px;
    font-size: 0.8rem;
    gap: 8px;
}

/* ── Snap celebration text ──────────────────────────────────────── */
.snap-float-text {
    font-size: 56px;
    max-width: 92vw;
}

/* ── Hint / premium banners ────────────────────────────────────── */
.hint-banner,
.premium-banner {
    white-space: nowrap;
    width: 92vw;
    padding: 8px 12px;
    font-size: 0.8rem;
    gap: 6px;
    flex-wrap: nowrap;
    justify-content: center;
    bottom: 16px;
}
.hint-banner .hint-banner-icon,
.premium-banner .premium-banner-icon {
    font-size: 0.9rem;
    flex-shrink: 0;
}
.hint-banner .btn-hint,
.premium-banner .btn-hint {
    padding: 6px 14px;
    font-size: 0.78rem;
    flex-shrink: 0;
}

/* ── Gallery / reveal overlay: full-screen vertical stack ─────── */
.puzzle-gallery-overlay {
    padding: 0;
}
.puzzle-gallery-wrapper {
    flex-direction: column;
    max-width: 100vw;
    max-height: 100vh;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
}
.puzzle-gallery-image {
    max-width: 100%;
    max-height: 55vh;
    min-width: unset;
    width: 100%;
    object-fit: cover;
    border-radius: 0;
    flex-shrink: 0;
}
.puzzle-gallery-text {
    width: auto;
    flex: 1;
    padding: 16px 20px;
    overflow-y: auto;
    justify-content: flex-start;
}
.puzzle-gallery-label {
    font-size: 0.8rem;
    margin-bottom: 8px;
}
.puzzle-gallery-title {
    font-size: 1.4rem;
    margin-bottom: 10px;
}
.puzzle-gallery-desc {
    font-size: 0.95rem;
    flex: 0;
}
.puzzle-gallery-continue {
    margin-top: auto;
    padding-bottom: 20px;
    font-size: 1.05rem;
}
.puzzle-gallery-bottom-close {
    display: block;
    margin-top: auto;
    padding-bottom: 20px;
    border: none;
    background: none;
    color: rgba(255, 255, 255, 0.35);
    font-size: 1.05rem;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    width: 100%;
}
.puzzle-gallery-close {
    top: 12px;
    right: 14px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.6rem;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* ── Daily reward: wrap the 7-day strip ────────────────────────── */
.daily-reward-card {
    width: min(380px, 92vw);
    padding: 28px 20px 24px;
}
.daily-reward-strip {
    flex-wrap: wrap;
    gap: 8px;
}
.daily-reward-day {
    flex: 0 0 calc(25% - 6px);
    min-width: unset;
}

/* ── Landing page adjustments ──────────────────────────────────── */
.landing-mascot {
    width: 100px;
    height: 100px;
}
.landing-title h1 {
    font-size: 2.4rem;
}
.landing-panel {
    gap: 8px;
}
.landing-settings-btn {
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    line-height: 40px;
}

/* ── Stats grid ───────────────────────────────────────────────── */
.stats-content {
    width: min(380px, 94vw);
}
.stats-grid {
    gap: 8px;
}

/* ── Collections / journey modals ─────────────────────────────── */
.journey-content {
    min-width: unset;
    max-width: 94vw;
}
/* Disable hover effects on touch — prevents highlight during scroll */
.journey-theme-card:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.09);
    transform: none;
}
.journey-theme-card:active {
    background: rgba(255, 255, 255, 0.09);
    border-color: var(--accent);
}
/* Disable hover on puzzle cards during scroll */
.journey-puzzle-card.unlocked:hover,
.journey-puzzle-card.completed:hover {
    transform: none;
    box-shadow: none;
    border-color: transparent;
}
.journey-puzzle-card.completed:hover {
    border-color: rgba(52, 211, 153, 0.28);
}

/* ── Puzzle slot equal widths ─────────────────────────────────── */
.journey-puzzle-slot {
    flex: 1 1 0;
    min-width: 0;
}
/* Completed cards: subtle dot indicator with large tap area */
.journey-puzzle-view-btn {
    opacity: 1;
    width: 44px;
    height: 44px;
    top: -4px;
    right: -4px;
    background: none;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 15px 15px 0 0;
    box-sizing: border-box;
}
.journey-puzzle-view-btn svg {
    display: none;
}
.journey-puzzle-view-btn::after {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.3);
}

/* ── Win modal ─────────────────────────────────────────────────── */
.win-modal-content {
    width: min(340px, 94vw);
}

/* ── Settings modal ────────────────────────────────────────────── */
.settings-content {
    min-width: unset;
    max-width: 92vw;
}
.settings-content h2 {
    font-family: 'Lilita One', sans-serif;
    font-size: 1.5rem;
}

/* ── Shop modal ────────────────────────────────────────────────── */
.shop-content {
    width: min(380px, 94vw);
}

/* ── Achievement toast ─────────────────────────────────────────── */
.achievement-toast {
    max-width: calc(100vw - 32px);
    padding: 10px 14px;
    top: env(safe-area-inset-top, 8px);
}

/* ── Modal base ────────────────────────────────────────────────── */
.modal-content {
    padding: 20px 16px;
    max-width: 94vw;
}
