/* ==========================================================================
   TRIMLE — SAGA DESIGN SYSTEM (Matches Captures 1–5: Folded Orchard / Paper Meadow)
   Warm cream card (#f5f2e6), deep pine typography (#1d3d33), tactile 3D numbered
   grid tiles (2x3, 3x3, 4x4), winding S-curve level map, and smooth sheet modals.
   ========================================================================== */

:root {
    --bg-outer: #fbfbf9;
    --bg-outer-dot: #d8ddd2;
    --bg-card: #f5f2e6;
    --bg-sheet: #fbfaf5;
    --border-card: #dcd8c8;

    --pine-dark: #1d3d33;
    --pine-muted: #526b61;
    --pine-soft: #788c82;

    --green-main: #46713d;
    --green-hover: #3c6334;
    --green-lip: #2d4f26;
    --green-halo: #e2e7d7;

    --node-cleared: #7f9c6d;
    --node-cleared-lip: #5d784d;

    --node-locked: #e1e4d7;
    --node-locked-lip: #c5cab7;

    --tile-white: #ffffff;
    --tile-border: #d7dccb;
    --tile-lip: #cfd5c2;

    --tan-avatar: #ca9f68;
    --tan-flag: #e8cc8e;
    --tan-flag-lip: #a68243;

    --danger-red: #c0392b;
    --danger-lip: #922b21;

    --font-sans: 'Plus Jakarta Sans', 'Nunito', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    background-color: var(--bg-outer);
    background-image: radial-gradient(var(--bg-outer-dot) 1.25px, transparent 1.25px);
    background-size: 16px 16px;
    color: var(--pine-dark);
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    user-select: none;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

/* ==========================================================================
   OUTER STAGE & DEVICE CARD
   ========================================================================== */
.saga-outer-stage {
    width: 100%;
    height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
}

.saga-device-card {
    position: relative;
    width: 100%;
    max-width: 420px;
    height: 100%;
    max-height: 860px;
    background: var(--bg-card);
    border: 1.5px solid var(--border-card);
    border-radius: 32px;
    box-shadow: 0 18px 48px rgba(29, 61, 51, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

@media (max-width: 480px) {
    .saga-outer-stage {
        padding: 0;
    }
    .saga-device-card {
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        border: none;
    }
}

.saga-screen {
    display: none;
    flex-direction: column;
    width: 100%;
    height: 100%;
    padding: 18px 18px calc(16px + env(safe-area-inset-bottom, 0px));
    animation: screenFadeIn 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}

.saga-screen.active {
    display: flex;
}

@keyframes screenFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.99);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ==========================================================================
   SCREEN 1: TOP HUD BAR & BRAND TITLE (Capture 1)
   ========================================================================== */
.saga-top-hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.saga-avatar-btn {
    width: 46px;
    height: 46px;
    border-radius: 15px;
    background: var(--tan-avatar);
    border: 2.5px solid #ffffff;
    box-shadow: 0 3px 0 #cfcab8;
    color: var(--pine-dark);
    font-size: 1.25rem;
    font-weight: 900;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.1s ease;
    flex-shrink: 0;
}

.saga-avatar-btn:active {
    transform: translateY(2px);
}

.saga-stat-pill {
    flex: 1;
    height: 44px;
    background: #faf8f0;
    border: 1.5px solid var(--tile-border);
    box-shadow: 0 3px 0 var(--tile-lip);
    border-radius: 15px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    color: var(--pine-dark);
    font-size: 1.02rem;
    font-weight: 800;
    transition: transform 0.1s ease;
}

.saga-stat-pill:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 var(--tile-lip);
}

.stat-icon-heart {
    color: #b85d52;
    font-size: 1.05rem;
}

.stat-icon-coin {
    font-size: 1rem;
}

.stat-plus {
    color: var(--pine-muted);
    font-weight: 800;
    margin-left: 1px;
}

.saga-gear-btn {
    width: 42px;
    height: 42px;
    border: none;
    background: transparent;
    color: var(--pine-dark);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 12px;
    transition: transform 0.2s ease, background-color 0.15s ease;
    flex-shrink: 0;
}

.saga-gear-btn:hover {
    background: rgba(29, 61, 51, 0.06);
    transform: rotate(25deg);
}

/* Brand Block */
.saga-brand-block {
    text-align: center;
    margin-bottom: 6px;
    flex-shrink: 0;
}

.saga-brand-logo {
    font-size: 2.4rem;
    font-weight: 900;
    letter-spacing: -0.04em;
    color: var(--pine-dark);
    line-height: 1.05;
}

.saga-chapter-sub {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--pine-muted);
    margin-top: 3px;
}

/* ==========================================================================
   WINDING S-CURVE MAP AREA & WEEKLY ROUTE WIDGET
   ========================================================================== */
.saga-map-area {
    position: relative;
    flex: 1;
    min-height: 0;
    margin: 4px -6px;
    overflow: hidden;
}

.weekly-route-widget {
    position: absolute;
    top: 14px;
    left: 12px;
    z-index: 15;
    background: transparent;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.weekly-route-widget:hover {
    transform: scale(1.04);
}

.weekly-route-widget:active {
    transform: scale(0.96);
}

.weekly-flag-tile {
    width: 66px;
    height: 60px;
    background: var(--tan-flag);
    border: 2px solid var(--tan-flag-lip);
    box-shadow: 0 4px 0 var(--tan-flag-lip);
    border-radius: 16px;
    transform: rotate(-6deg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #5e4319;
}

.weekly-label {
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--pine-dark);
    margin-top: 2px;
}

.weekly-progress-pill {
    background: #ffffff;
    border: 1px solid var(--tile-border);
    border-radius: 99px;
    padding: 2px 10px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--pine-muted);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

/* Floating Ranking Widget (Top-right of map) */
.ranking-map-widget {
    position: absolute;
    top: 14px;
    right: 12px;
    z-index: 15;
    background: transparent;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.ranking-map-widget:hover {
    transform: scale(1.04);
}

.ranking-map-widget:active {
    transform: scale(0.96);
}

.ranking-trophy-tile {
    width: 66px;
    height: 60px;
    background: linear-gradient(180deg, #fce8a6 0%, #f5cf60 100%);
    border: 2px solid #c99826;
    box-shadow: 0 4px 0 #b88719;
    border-radius: 16px;
    transform: rotate(6deg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #5c3f06;
}

/* Global Ranking List & Username Editor */
.ranking-list-scroll {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 290px;
    overflow-y: auto;
    padding-right: 2px;
    margin: 4px 0;
}

.ranking-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #ffffff;
    border: 1.5px solid #e3ded0;
    border-radius: 14px;
    padding: 10px 12px;
}

.ranking-row.is-me {
    background: #eef8f1;
    border-color: #2f7a4d;
    box-shadow: 0 2px 8px rgba(47, 122, 77, 0.12);
}

.ranking-pos {
    width: 32px;
    font-weight: 900;
    font-size: 0.92rem;
    color: var(--pine-dark);
    text-align: center;
    flex-shrink: 0;
}

.ranking-name-col {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ranking-name-text {
    font-weight: 800;
    font-size: 0.92rem;
    color: var(--pine-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ranking-you-pill {
    background: #2f7a4d;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 99px;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.ranking-stats-col {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--pine-muted);
    flex-shrink: 0;
}

.ranking-stars-badge {
    background: #fef6d8;
    border: 1px solid #ebd07a;
    color: #7c580b;
    padding: 2px 8px;
    border-radius: 99px;
    font-weight: 800;
    font-size: 0.78rem;
}

.username-edit-box {
    background: #f5f2e6;
    border: 1.5px solid #e1dcc8;
    border-radius: 16px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.username-edit-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.username-input {
    flex: 1;
    min-width: 0;
    padding: 9px 12px;
    border-radius: 11px;
    border: 1.5px solid #d5cfc0;
    background: #fff;
    font-size: 0.92rem;
    font-weight: 800;
    color: var(--pine-dark);
    outline: none;
}

.username-input:focus {
    border-color: #2f7a4d;
}

.username-save-btn {
    padding: 9px 14px;
    border-radius: 11px;
    border: none;
    background: #2f7a4d;
    color: #fff;
    font-weight: 800;
    font-size: 0.85rem;
    cursor: pointer;
    flex-shrink: 0;
}

.username-save-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.map-road-scroll {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
}

.map-road-scroll::-webkit-scrollbar {
    display: none;
}

.map-road-canvas {
    position: relative;
    width: 100%;
    margin: 0 auto;
}

.map-road-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* 3D Level Nodes on the Winding Road */
.map-node-wrap {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 5;
}

.map-node-btn {
    position: relative;
    width: 58px;
    height: 54px;
    border-radius: 19px;
    border: none;
    font-family: var(--font-sans);
    font-size: 1.25rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.map-node-btn:active:not(:disabled) {
    transform: translateY(3px);
}

.map-node-btn.node-cleared {
    background: var(--node-cleared);
    color: var(--pine-dark);
    border: 2px solid var(--node-cleared-lip);
    box-shadow: 0 4px 0 var(--node-cleared-lip);
}

.map-node-btn.node-current {
    width: 74px;
    height: 68px;
    border-radius: 24px;
    background: var(--green-main);
    color: #ffffff;
    font-size: 1.55rem;
    border: 2.5px solid var(--green-lip);
    box-shadow: 0 5px 0 var(--green-lip), 0 0 0 8px var(--green-halo);
    animation: nextNodePulse 2.4s ease-in-out infinite;
}

@keyframes nextNodePulse {
    0%, 100% {
        transform: translateY(0);
        box-shadow: 0 5px 0 var(--green-lip), 0 0 0 8px var(--green-halo);
    }
    50% {
        transform: translateY(-3px);
        box-shadow: 0 8px 0 var(--green-lip), 0 0 0 11px var(--green-halo);
    }
}

.map-node-btn.node-locked {
    background: var(--node-locked);
    color: #6b7869;
    border: 2px solid var(--node-locked-lip);
    box-shadow: 0 4px 0 var(--node-locked-lip);
    cursor: pointer;
}

.map-next-pill {
    background: #eef1e4;
    border: 1px solid #d5dcc5;
    color: var(--pine-dark);
    font-size: 0.7rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    padding: 3px 11px;
    border-radius: 99px;
    margin-bottom: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.map-node-stars {
    display: flex;
    gap: 1px;
    margin-bottom: -5px;
    z-index: 6;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.18));
}

.map-star-svg {
    width: 16px;
    height: 16px;
}

/* ==========================================================================
   BOTTOM MAP DOCK: Daily | PLAY LEVEL X | Shop
   ========================================================================== */
.saga-map-dock, .game-bottom-dock {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    padding-top: 8px;
    flex-shrink: 0;
}

.dock-side-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.btn-saga-square {
    width: 56px;
    height: 54px;
    background: var(--tile-white);
    border: 1.5px solid var(--tile-border);
    box-shadow: 0 4px 0 var(--tile-lip);
    border-radius: 17px;
    color: var(--pine-dark);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.btn-saga-square:active:not(:disabled) {
    transform: translateY(3px);
    box-shadow: 0 1px 0 var(--tile-lip);
}

.btn-saga-square:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.dock-side-label {
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--pine-dark);
}

.btn-saga-play {
    flex: 1;
    height: 70px;
    background: var(--green-main);
    border: 2px solid var(--green-lip);
    box-shadow: 0 5px 0 var(--green-lip);
    border-radius: 22px;
    color: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.15s ease;
}

.btn-saga-play:hover {
    background: var(--green-hover);
}

.btn-saga-play:active {
    transform: translateY(4px);
    box-shadow: 0 1px 0 var(--green-lip);
}

.play-main-text {
    font-size: 1.55rem;
    font-weight: 900;
    letter-spacing: 0.04em;
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
    line-height: 1.05;
}

.play-sub-text {
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.92);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
    margin-top: 2px;
}

/* ==========================================================================
   SCREEN 2: ACTIVE TRIMLE GAMEPLAY (Matches Capture 2: 1:1)
   ========================================================================== */
.game-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 2px 12px;
    flex-shrink: 0;
}

.game-pause-btn {
    width: 38px;
    height: 38px;
    border: none;
    background: transparent;
    color: var(--pine-dark);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 10px;
}

.game-pause-btn:hover {
    background: rgba(29, 61, 51, 0.06);
}

.game-level-heading {
    font-size: 0.95rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--pine-dark);
}

.game-timer-label {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--pine-muted);
    font-variant-numeric: tabular-nums;
}

.game-prompt-header {
    text-align: center;
    margin: 6px 0 14px;
    flex-shrink: 0;
}

.game-main-instruction {
    font-size: 1.65rem;
    font-weight: 900;
    color: var(--pine-dark);
    letter-spacing: -0.02em;
}

.game-sub-instruction {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--pine-muted);
    margin-top: 4px;
}

.game-board-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    min-height: 0;
    overflow-y: auto;
    padding: 6px 4px;
}

/* Trimle 2x3, 3x3, and 4x4 Grid */
.trimle-grid-wrap {
    display: grid;
    gap: 12px;
    justify-content: center;
    align-content: center;
    margin: 0 auto;
}

.trimle-grid-wrap.cols-3 {
    grid-template-columns: repeat(3, 88px);
}

.trimle-grid-wrap.cols-4 {
    grid-template-columns: repeat(4, 70px);
    gap: 10px;
}

/* 3D White Numbered Tile (Capture 2) */
.trimle-tile {
    position: relative;
    width: 88px;
    height: 86px;
    border-radius: 22px;
    background: var(--tile-white);
    border: 1.8px solid var(--tile-border);
    box-shadow: 0 5px 0 var(--tile-lip);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-sans);
    font-size: 2.15rem;
    font-weight: 900;
    color: var(--pine-dark);
    cursor: pointer;
    transition: transform 0.1s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.12s ease, border-color 0.12s ease, box-shadow 0.1s ease;
}

.trimle-grid-wrap.cols-4 .trimle-tile,
.trimle-grid-wrap.cols-4 .trimle-hole {
    width: 70px;
    height: 68px;
    border-radius: 18px;
    font-size: 1.75rem;
}

body.large-digits .trimle-tile {
    font-size: 2.45rem;
}
body.large-digits .trimle-grid-wrap.cols-4 .trimle-tile {
    font-size: 2.05rem;
}

.trimle-tile:active {
    transform: translateY(3px);
    box-shadow: 0 2px 0 var(--tile-lip);
}

/* Orthogonal Next Legal Step Highlight when building path */
.trimle-tile.tile-adjacent-ready {
    border-color: #9cb993;
    background: #fcfdf9;
}

/* Selected Tile in Current Path Preview */
.trimle-tile.tile-selected {
    background: #e3eedb;
    border: 2.5px solid var(--green-main);
    box-shadow: 0 4px 0 var(--green-lip);
    color: var(--pine-dark);
    transform: translateY(1px);
}

/* Final Tile in Path (Endpoint that sets next required length!) */
.trimle-tile.tile-endpoint {
    background: var(--green-main);
    border: 2.5px solid var(--green-lip);
    box-shadow: 0 4px 0 var(--green-lip), 0 0 0 4px rgba(70, 113, 61, 0.22);
    color: #ffffff;
}

/* Path Trace Hint Highlight */
.trimle-tile.tile-hinted {
    border: 2.5px dashed #d49c3d;
    box-shadow: 0 5px 0 #b88228, 0 0 0 4px rgba(212, 156, 61, 0.22);
}

/* Order Badge (1..k) on Selected or Hinted Tile */
.tile-order-badge {
    position: absolute;
    top: 6px;
    left: 7px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 99px;
    background: var(--green-main);
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 900;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.trimle-tile.tile-endpoint .tile-order-badge {
    background: #ffffff;
    color: var(--pine-dark);
}

.tile-hint-badge {
    position: absolute;
    bottom: 5px;
    right: 6px;
    min-width: 19px;
    height: 19px;
    padding: 0 5px;
    border-radius: 99px;
    background: #d49c3d;
    color: #ffffff;
    font-size: 0.66rem;
    font-weight: 900;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Endpoint Next-Length Tag ("→ 3") */
.tile-next-tag {
    position: absolute;
    bottom: 5px;
    right: 6px;
    background: rgba(14, 36, 27, 0.26);
    color: #ffffff;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 99px;
}

/* Permanent Removed Hole (Fixed Coordinates, Non-Interactive) */
.trimle-hole {
    width: 88px;
    height: 86px;
    border-radius: 22px;
    background: rgba(215, 220, 203, 0.36);
    border: 2px dashed #cfd5c2;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.trimle-hole::after {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 99px;
    background: rgba(120, 140, 130, 0.25);
}

/* Status Line ("0 / 3 selected · Next: —") */
.game-selection-status {
    text-align: center;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--pine-muted);
    margin: 2px 0;
}

.game-selection-status.prompt-hint {
    color: var(--green-main);
    font-weight: 800;
}

.game-selection-status.prompt-error {
    color: var(--danger-red);
    font-weight: 800;
}

/* Selection Quick-Edit Chips (Back step / Clear selection) */
.trimle-edit-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-edit-chip {
    background: #eaece0;
    border: 1px solid var(--tile-border);
    color: var(--pine-dark);
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 800;
    padding: 6px 12px;
    border-radius: 99px;
    cursor: pointer;
}

.btn-edit-chip:active {
    transform: translateY(1px);
}

/* Center "Cut" Action Button in Gameplay Bottom Dock (Matches Capture 2) */
.btn-game-center-action {
    flex: 1;
    height: 58px;
    background: #d5dcc8;
    border: 1.5px solid #bfc8b0;
    box-shadow: 0 4px 0 #bfc8b0;
    border-radius: 19px;
    color: #496658;
    font-family: var(--font-sans);
    font-size: 1.25rem;
    font-weight: 900;
    cursor: not-allowed;
    transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.15s ease, color 0.15s ease;
}

.btn-game-center-action.cut-ready {
    background: var(--green-main);
    border: 2px solid var(--green-lip);
    box-shadow: 0 5px 0 var(--green-lip);
    color: #ffffff;
    cursor: pointer;
}

.btn-game-center-action.cut-ready:hover {
    background: var(--green-hover);
}

.btn-game-center-action.cut-ready:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 var(--green-lip);
}

/* Inline Win / Deadlock Card */
.sc-win-box {
    width: 100%;
    background: #ecf2e4;
    border: 2px solid #b8cba4;
    border-radius: 20px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
    animation: modalPopIn 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

.sc-win-title {
    font-size: 0.96rem;
    font-weight: 800;
    color: var(--pine-dark);
    line-height: 1.35;
}

/* ==========================================================================
   MODAL SHEETS (Matches Captures 3, 4, 5: Puzzle tools, Weekly route, Settings)
   Note: When modal is active during gameplay, opaque backdrop conceals the board!
   ========================================================================== */
.saga-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(92, 108, 92, 0.56);
    backdrop-filter: blur(3px);
    z-index: 100;
    display: none;
    align-items: flex-end;
    justify-content: center;
    padding: 16px;
}

.saga-modal-backdrop.opaque-cover {
    background: #dde2d3;
    backdrop-filter: none;
}

.saga-modal-backdrop.active {
    display: flex;
    animation: fadeBackdrop 0.18s ease;
}

@keyframes fadeBackdrop {
    from { opacity: 0; }
    to { opacity: 1; }
}

.saga-sheet-card {
    width: 100%;
    max-height: 88%;
    overflow-y: auto;
    background: var(--bg-sheet);
    border: 1.5px solid var(--tile-border);
    box-shadow: 0 10px 30px rgba(29, 61, 51, 0.18);
    border-radius: 26px;
    padding: 22px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    animation: modalPopIn 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes modalPopIn {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sheet-title {
    font-size: 1.5rem;
    font-weight: 900;
    color: #0b1914;
    letter-spacing: -0.02em;
}

.sheet-close-btn {
    border: none;
    background: transparent;
    color: var(--pine-dark);
    font-size: 1.25rem;
    font-weight: 700;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sheet-close-btn:hover {
    background: rgba(29, 61, 51, 0.07);
}

.sheet-subtitle {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--pine-muted);
    line-height: 1.38;
    margin-top: -4px;
}

.sheet-progress-track {
    width: 100%;
    height: 14px;
    background: #dce0d1;
    border-radius: 99px;
    overflow: hidden;
    margin: 2px 0;
}

.sheet-progress-fill {
    height: 100%;
    background: var(--green-main);
    border-radius: 99px;
    transition: width 0.35s ease;
}

.sheet-rows-list {
    display: flex;
    flex-direction: column;
}

.sheet-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 2px;
    border-bottom: 1px solid #e6e8de;
    font-size: 0.95rem;
    background: transparent;
    border-left: none;
    border-right: none;
    border-top: none;
    width: 100%;
    text-align: left;
    font-family: var(--font-sans);
}

.sheet-row.clickable {
    cursor: pointer;
    border-radius: 8px;
    padding-left: 6px;
    padding-right: 6px;
    transition: background-color 0.12s ease;
}

.sheet-row.clickable:hover {
    background: rgba(70, 113, 61, 0.07);
}

.sheet-row-label {
    font-weight: 800;
    color: var(--pine-dark);
}

.sheet-row-val {
    font-weight: 800;
    color: var(--pine-muted);
}

.btn-saga-green {
    width: 100%;
    min-height: 52px;
    background: var(--green-main);
    border: 2px solid var(--green-lip);
    box-shadow: 0 4px 0 var(--green-lip);
    border-radius: 16px;
    color: #ffffff;
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 900;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.15s ease;
    margin-top: 4px;
}

.btn-saga-green:hover:not(:disabled) {
    background: var(--green-hover);
}

.btn-saga-green:active:not(:disabled) {
    transform: translateY(3px);
    box-shadow: 0 1px 0 var(--green-lip);
}

.btn-saga-secondary {
    width: 100%;
    min-height: 46px;
    background: #ffffff;
    border: 1.5px solid var(--tile-border);
    box-shadow: 0 3px 0 var(--tile-lip);
    border-radius: 14px;
    color: var(--pine-dark);
    font-family: var(--font-sans);
    font-size: 0.92rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
}

.btn-saga-secondary:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 var(--tile-lip);
}

.lang-switcher {
    display: inline-flex;
    background: #e8ebde;
    padding: 3px;
    border-radius: 10px;
    border: 1px solid var(--tile-border);
    gap: 2px;
}

.lang-pill {
    border: none;
    background: transparent;
    color: var(--pine-muted);
    font-size: 0.74rem;
    font-weight: 800;
    padding: 4px 9px;
    border-radius: 7px;
    cursor: pointer;
}

.lang-pill.active {
    background: var(--green-main);
    color: #ffffff;
}

.input-field {
    width: 100%;
    min-height: 44px;
    padding: 8px 12px;
    border-radius: 12px;
    border: 1.5px solid var(--tile-border);
    background: #ffffff;
    color: var(--pine-dark);
    font-family: var(--font-sans);
    font-size: 0.92rem;
    font-weight: 600;
}

.toast-container {
    position: absolute;
    top: 72px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 150;
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 88%;
    pointer-events: none;
}

.toast {
    background: var(--pine-dark);
    color: #ffffff;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.85rem;
    font-weight: 800;
    text-align: center;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16);
}

.toast-error {
    background: var(--danger-red);
}

/* ==========================================================================
   MANDATORY PWA / HOME SCREEN INSTALL GATE
   ========================================================================== */
body.require-install-gate {
    overflow: hidden;
}

body.require-install-gate #main-app-shell {
    display: none !important;
}

.pwa-gate-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.pwa-gate-card {
    max-width: 400px;
    height: auto;
    max-height: 92dvh;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    text-align: center;
    overflow-y: auto;
}

.pwa-gate-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.saga-logo-sm {
    font-size: 1.45rem;
    font-weight: 900;
    letter-spacing: -0.04em;
    color: var(--pine-dark);
}

.pwa-gate-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.pwa-gate-icon {
    width: 72px;
    height: 72px;
    border-radius: 18px;
    box-shadow: 0 4px 0 var(--tile-lip);
    border: 2px solid #ffffff;
}

.pwa-gate-title {
    font-size: 1.25rem;
    font-weight: 900;
    color: var(--pine-dark);
    line-height: 1.25;
}

.pwa-gate-desc {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--pine-muted);
    line-height: 1.42;
}

.pwa-platform-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    background: #e8ebde;
    padding: 4px;
    border-radius: 14px;
    border: 1px solid var(--tile-border);
}

.pwa-plat-tab {
    background: transparent;
    border: none;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 0.84rem;
    font-weight: 800;
    color: var(--pine-muted);
    cursor: pointer;
}

.pwa-plat-tab.active {
    background: var(--green-main);
    color: #ffffff;
}

.pwa-steps-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}

.pwa-step-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: #ffffff;
    border: 1.5px solid var(--tile-border);
    box-shadow: 0 3px 0 var(--tile-lip);
    border-radius: 14px;
    padding: 10px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--pine-dark);
    line-height: 1.38;
}

.pwa-step-num {
    width: 24px;
    height: 24px;
    border-radius: 99px;
    background: var(--green-main);
    color: #ffffff;
    font-size: 0.78rem;
    font-weight: 900;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.pwa-gate-note {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--pine-muted);
    background: #e8ede0;
    border: 1px dashed #b9c6aa;
    border-radius: 12px;
    padding: 10px 12px;
}

@media (max-width: 360px) {
    .trimle-grid-wrap.cols-3 {
        grid-template-columns: repeat(3, 76px);
    }
    .trimle-tile, .trimle-hole {
        width: 76px;
        height: 74px;
    }
    .trimle-grid-wrap.cols-4 {
        grid-template-columns: repeat(4, 62px);
    }
    .trimle-grid-wrap.cols-4 .trimle-tile,
    .trimle-grid-wrap.cols-4 .trimle-hole {
        width: 62px;
        height: 60px;
        font-size: 1.5rem;
    }
}


/* Top Bar Visual Hearts Pill & Modal Hearts Hero */
.game-board-stage {
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.game-board-stage::-webkit-scrollbar {
    display: none;
}
.saga-hearts-pill {
    flex: 0 1 auto !important;
    padding: 0 16px !important;
    min-width: 108px;
    border-radius: 999px !important;
    background: linear-gradient(180deg, #fffdf9 0%, #f5ece4 100%) !important;
    border: 1.5px solid #dfc5bc !important;
    box-shadow: 0 3px 0 #cfb3a8, inset 0 1px 0 #ffffff !important;
}
.hud-hearts-row,
.game-hearts-row,
.modal-hearts-row {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    line-height: 1;
}
.game-hearts-row {
    gap: 3.5px;
}
.modal-hearts-row {
    gap: 8px;
}
.heart-svg {
    display: block;
    flex-shrink: 0;
    transition: transform 0.18s ease;
}
.heart-svg.is-full {
    filter: drop-shadow(0 1px 2px rgba(184, 37, 30, 0.24));
}
.game-top-right-group {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}
.game-hearts-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #fff9f7 0%, #f5e6e1 100%);
    border: 1.5px solid #debab2;
    border-radius: 999px;
    padding: 5px 10px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85), 0 2px 5px rgba(80, 28, 22, 0.08);
    cursor: pointer;
}
.game-hearts-pill:active {
    transform: translateY(1px);
}
.hearts-modal-hero {
    background: linear-gradient(180deg, #fffaf7 0%, #f6ebe4 100%);
    border: 1.5px solid #e2c7be;
    border-radius: 18px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}
.hearts-timer-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 13px;
    border-radius: 999px;
    font-size: 0.84rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}
.hearts-timer-pill.is-regen {
    background: #fff1d6;
    color: #8f4e0c;
    border: 1px solid #ecc98b;
}
.hearts-timer-pill.is-full {
    background: #e3f3e6;
    color: #236335;
    border: 1px solid #b8dec0;
}
.stripe-price-pill {
    background: var(--green-main, #2f6b55);
    color: #ffffff;
    padding: 5px 11px;
    border-radius: 999px;
    font-size: 0.84rem;
    font-weight: 900;
    flex-shrink: 0;
}
.stripe-price-pill.is-owned {
    background: #d8e5dc;
    color: #2b5a46;
}



.heart-svg.heart-full,
.heart-svg.is-full {
    filter: drop-shadow(0 1px 2px rgba(184, 37, 30, 0.28));
}
.heart-svg.heart-full path,
.heart-svg.is-full path {
    fill: #e03a3c;
    stroke: #a61e20;
    stroke-width: 1.5px;
    stroke-linejoin: round;
}
.heart-svg.heart-empty,
.heart-svg.is-empty {
    opacity: 0.42;
}
.heart-svg.heart-empty path,
.heart-svg.is-empty path {
    fill: rgba(165, 148, 140, 0.16);
    stroke: #b59e95;
    stroke-width: 1.8px;
    stroke-linejoin: round;
}

/* ==========================================================================
   UNIFIED GAMEPLAY TOP BAR, PROMPT + MOVES PILL (0/8), & RYNLE ROUND DOCK
   ========================================================================== */
.unified-top-bar {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 6px 4px 10px !important;
    flex-shrink: 0;
}

.unified-top-bar .game-pause-btn {
    width: 38px !important;
    height: 38px !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    color: var(--pine-dark, #1d3d33) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer;
    border-radius: 10px !important;
    padding: 0 !important;
}

.unified-top-bar .game-pause-btn:hover {
    background: rgba(29, 61, 51, 0.06) !important;
}

.fimle-level-pill {
    background: linear-gradient(180deg, #f3ecdc 0%, #e7dec8 100%) !important;
    border: 1.5px solid #d3c5a9 !important;
    border-radius: 999px !important;
    padding: 4px 15px !important;
    font-size: 0.78rem !important;
    font-weight: 800 !important;
    letter-spacing: 0.06em !important;
    text-transform: uppercase !important;
    color: #35574a !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.78), 0 2px 4px rgba(60, 48, 28, 0.08) !important;
    line-height: 1.2 !important;
}

.unified-top-bar .game-timer-label {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 2px !important;
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    color: var(--pine-muted, #5c7467) !important;
    font-variant-numeric: tabular-nums !important;
}

.unified-prompt-header {
    text-align: center !important;
    margin: 2px 0 8px !important;
    padding: 0 10px !important;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.unified-prompt-header .game-main-instruction {
    font-size: 1.44rem !important;
    font-weight: 900 !important;
    color: var(--pine-dark, #1d3d33) !important;
    letter-spacing: -0.02em !important;
    margin: 0 !important;
    line-height: 1.15 !important;
}

.unified-prompt-header .game-sub-instruction {
    font-size: 0.82rem !important;
    font-weight: 600 !important;
    color: var(--pine-muted, #5c7467) !important;
    margin: 3px 0 0 !important;
    line-height: 1.3 !important;
}

.unified-moves-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 7px;
}

.unified-moves-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #f5efe0 0%, #eae0cb 100%);
    border: 1.5px solid #d4c6aa;
    border-radius: 999px;
    padding: 3px 15px;
    font-size: 0.88rem;
    font-weight: 900;
    letter-spacing: 0.03em;
    color: #1f483a;
    font-variant-numeric: tabular-nums;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.82), 0 2px 4px rgba(60, 48, 28, 0.07);
}

.unified-moves-pill.moves-over {
    background: #fce8e4;
    border-color: #e4b4ab;
    color: #9e2a1b;
}

.rynle-bottom-dock {
    display: flex !important;
    align-items: flex-end !important;
    justify-content: space-around !important;
    padding: 6px 24px 12px !important;
    flex-shrink: 0;
}

.rynle-round-action {
    width: 52px !important;
    height: 52px !important;
    border-radius: 50% !important;
    background: #ede4d3 !important;
    border: 1.5px solid rgba(185, 168, 138, 0.55) !important;
    color: var(--pine-deep, #1d3d33) !important;
    box-shadow: 0 4px 10px rgba(72, 58, 35, 0.11) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    cursor: pointer;
    transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.rynle-round-action:active:not(:disabled) {
    transform: translateY(2px) scale(0.96) !important;
}

.rynle-round-action:disabled {
    opacity: 0.42 !important;
    cursor: not-allowed !important;
}

.rynle-round-action.preview-active,
.rynle-round-action.cut-ready {
    background: linear-gradient(180deg, #357a61 0%, #245b47 100%) !important;
    color: #ffffff !important;
    border-color: #1a4435 !important;
    box-shadow: 0 5px 14px rgba(36, 91, 71, 0.32) !important;
    opacity: 1 !important;
}

.rynle-help-action {
    background: #0f4638 !important;
    color: #ffffff !important;
    border-color: #0a3328 !important;
}
