:root {
    --bg-color: #f0ede4;
    --red: #d9432f;
    --green: #2a8370;
    --tile-size: 75px;
    --target-tile: 38px;
    --gap: 3px;
    --tab-height: 56px;
    --banner-height: 64px;
    --dots-height: 26px;
    --browser-max-width: 420px;
}

@media (max-width: 400px) {
    :root {
        --tile-size: 19vw; 
        --target-tile: 11vw;
    }
}

@media (orientation: landscape) {
    #app-root {
        overflow: hidden;
    }

    #browser-screen {
        min-height: 100%;
    }
}

@media (orientation: landscape) {
    #game-screen {
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 20px;
        padding: 12px 16px;
    }

    #game-status {
        position: absolute;
        top: 8px;
        left: 0;
        right: 0;
        margin-bottom: 0;
    }

    #game-board {
        margin-bottom: 0;
        flex: 0 0 auto;
    }

    #controls-bottom {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 14px;
        width: auto;
        flex: 0 0 auto;
    }

    #target-board {
        order: 1;
    }

    #reload-btn {
        order: 2;
    }

    #back-to-browser-btn {
        order: 3;
    }
}

@media (orientation: landscape) {
    :root {
        --tile-size: 64px;
        --target-tile: 28px;
    }

@media (orientation: landscape) {
    #game-screen.screen-active {
        display: grid;
        grid-template-columns: auto auto;
        grid-template-areas:
            "status status"
            "board side";
        justify-content: center;
        align-content: start;
        column-gap: 20px;
        row-gap: 10px;
        padding: 12px 16px;
    }

    #game-screen.screen-active #game-status {
        grid-area: status;
        position: static;
        margin: 0;
        height: auto;
        min-height: 0;
    }

    #game-screen.screen-active #game-board {
        grid-area: board;
        margin-bottom: 0;
    }

    #game-screen.screen-active #controls-bottom {
        grid-area: side;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: auto;
        gap: 14px;
    }
}
    #game-status {
        grid-area: status;
        position: static;
        margin: 0;
        height: auto;
        min-height: 0;
    }

    #game-board {
        grid-area: board;
        margin-bottom: 0;
    }

    #controls-bottom {
        grid-area: side;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: auto;
        gap: 14px;
    }
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

html,
body {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    overflow: hidden;
    touch-action: manipulation;
    font-family: 'Roboto Condensed', sans-serif;
}

body {
    display: block;
}

button,
input,
textarea,
select {
    font: inherit;
}

a {
    color: inherit;
}

#app-root {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-color);
}

.screen {
    position: absolute;
    inset: 0;
    display: none;
}

.screen-active {
    display: flex;
}

#browser-screen {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
}

#browser-header {
    height: 60px;
    display: grid;
    grid-template-columns: 56px 1fr 56px;
    align-items: center;
    width: 100%;
    max-width: var(--browser-max-width);
    margin: 0 auto;
    padding: 2px 12px 0 12px;
}


.header-side {
    display: flex;
    align-items: center;
    justify-content: center;
}

#browser-title {
    margin: 0;
    text-align: center;
    color: var(--green);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 0.92rem;
    font-weight: 700;
}

.nav-circle-btn {
    width: 38px;
    height: 38px;
    border: 2.5px solid var(--green);
    border-radius: 50%;
    background: transparent;
    color: var(--green);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    font-family: serif;
    font-style: italic;
    font-weight: bold;
    font-size: 22px;
    line-height: 1;
}

.nav-circle-btn-hidden {
    visibility: hidden;
    pointer-events: none;
}

.nav-circle-btn-image {
    background: white;
    overflow: hidden;
    padding: 2px;
}

.nav-circle-btn-image img {
    width: 85%;
    height: auto;
}

#browser-viewport {
    width: 100%;
    max-width: var(--browser-max-width);
    margin: 0 auto;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    flex: 1 1 auto;
    min-height: 0;
}

#tile-pages {
    display: flex;
    height: auto;
    min-height: 100%;
    transition: transform 0.35s cubic-bezier(0.25, 1, 0.5, 1);
    align-items: flex-start;
}

.tile-page {
    min-width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 12px;
    padding: 8px 16px 0 16px;
    align-content: start;
    justify-items: center;
}

.start-page {
    padding-top: 6px;
}

.tile-item {
    -webkit-appearance: none;
    appearance: none;
    border: none;
    background: transparent;
    padding: 0;
    margin: 0;
    width: 124px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
}

.tile-item.disabled {
    cursor: default;
}

.tile-label {
    font-weight: 700;
    font-size: 12px;
    line-height: 1.15;
    text-align: center;
    color: #2c2c2c;
    min-height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tile-item.completed .tile-label {
    color: #666;
}

.tile-item.completed .thumb-preview,
.tile-item.completed .lock-tile {
    opacity: 0.68;
    filter: grayscale(0.25);
}

.thumb-preview,
.lock-tile {
    width: 124px;
    min-width: 124px;
    height: 124px;
    border-radius: 8px;
}

.thumb-preview {
    display: grid;
    grid-template-columns: repeat(4, 28px);
    gap: 1.5px;
    padding: 5px;
    background: rgba(0, 0, 0, 0.05);
    border: 2px solid transparent;
    justify-content: center;
    align-content: center;
}

.tile-item.active .thumb-preview {
    border-color: var(--red);
    background: white;
}

.preview-dot {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: white;
    border-radius: 2px;
    background-size: 400% 400%;
}

.lock-bg-cell {
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 2px;
}

.lock-overlay-content {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px;
    text-align: center;
}

.lock-icon-wrap {
    margin-top: 2px;
    line-height: 0;
}

.lock-icon {
    width: 54px;
    height: 54px;
    color: var(--green);
    opacity: 0.96;
    display: block;
}

.lock-tile {
    position: relative;
    width: 124px;
    min-width: 124px;
    height: 124px;
    display: grid;
    grid-template-columns: repeat(4, 28px);
    grid-template-rows: repeat(4, 28px);
    gap: 1.5px;
    padding: 5px;
    background: #e3e1db;
    border: 2px solid #c8c4ba;
    border-radius: 8px;
    overflow: hidden;
    justify-content: center;
    align-content: center;
}

.lock-title {
    font-size: 13px;
    line-height: 1.05;
    font-weight: 700;
    color: #4a4a4a;
    text-align: center;
}

#page-dots-row {
    min-height: var(--dots-height);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    max-width: var(--browser-max-width);
    margin: 4px auto 0 auto;
}

.nav-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #c9c7c0;
    transition: transform 0.12s ease;
}

.nav-dot.active {
    background: var(--green);
    transform: scale(1.15);
}

#bottom-tabs {
    height: var(--tab-height);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    width: 100%;
    max-width: var(--browser-max-width);
    margin: 0 auto;
    padding: 0 8px;
    gap: 6px;
    align-items: center;
}

.bottom-tab {
    height: 42px;
    border: none;
    background: transparent;
    color: #555;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    border-radius: 10px;
    cursor: pointer;
}

.bottom-tab.active {
    color: white;
    background: var(--green);
}

.tab-icon {
    width: 35px;
    height: 35px;
    display: block;
    margin: 0 auto;
}

#banner-slot {
    height: var(--banner-height);
    width: 100%;
    max-width: var(--browser-max-width);
    margin: 0 auto;
    padding: 8px 12px 12px 12px;
}

.banner-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    border: 1.5px dashed #c6c1b5;
    background: rgba(0, 0, 0, 0.03);
    color: #777;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.banner-hidden {
    visibility: hidden;
}

.banner-slot-hidden {
    height: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    overflow: hidden;
}

#game-screen {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    height: 100%;
    padding-top: 10px;
}

#game-status {
    height: 24px;
    min-height: 1.2em;
    margin-bottom: 10px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--green);
}

@keyframes shake {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(-2px, -2px); }
    50% { transform: translate(2px, 2px); }
    75% { transform: translate(-2px, 2px); }
}

.shaking {
    animation: shake 0.12s infinite;
}

@keyframes glimmer {
    0% { transform: translateX(-150%) skewX(-25deg); opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { transform: translateX(150%) skewX(-25deg); opacity: 0; }
}

.won-tile {
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
    filter: brightness(1.1);
    pointer-events: none;
    z-index: 10;
}

.animate-glimmer::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.8), transparent);
    animation: glimmer 0.8s ease-out 1 forwards;
}

#game-board {
    position: relative;
    width: calc((var(--tile-size) * 4) + (var(--gap) * 3));
    height: calc((var(--tile-size) * 4) + (var(--gap) * 3));
    margin-bottom: 70px;
    touch-action: manipulation;
}

.tile {
    position: absolute;
    width: var(--tile-size);
    height: var(--tile-size);
    overflow: hidden;
    border-radius: 4px;
    transition: transform 0.2s cubic-bezier(0.25, 1, 0.5, 1), left 0.2s, top 0.2s;
}

.tile-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--tile-size) * 0.7);
    font-weight: 700;
    color: white;
    filter: url(#grainy);
    background-size: 400% 400%;
}

#controls-bottom {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 25px;
    width: 100%;
}

.control-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.1s;
    color: var(--green);
    border: none;
    background: transparent;
}

.icon-button {
    border: 2.5px solid var(--green);
    border-radius: 50%;
    width: 38px;
    height: 38px;
    overflow: hidden;
    padding: 2px;
    background: white;
}

.icon-button img {
    width: 100%;
    height: auto;
}

#target-board {
    display: grid;
    grid-template-columns: repeat(4, var(--target-tile));
    gap: 2px;
    padding: 5px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 4px;
}

.target-tile {
    width: var(--target-tile);
    height: var(--target-tile);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--target-tile) * 0.55);
    color: white;
    font-weight: 700;
    border-radius: 1px;
    background-size: 400% 400%;
}

.overlay {
    position: fixed;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    z-index: 4000;
    background: var(--bg-color);
    padding: 18px 16px 24px 16px;
    overflow-y: auto;
}

.overlay-visible {
    display: flex;
}

.overlay-center {
    justify-content: center;
    padding: 24px 16px;
    background: rgba(240, 237, 228, 0.96);
    backdrop-filter: blur(3px);
}

.overlay-heading {
    color: var(--green);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 0.9rem;
    margin: 18px 0 0 0;
}

#info-close-btn {
    align-self: flex-end;
    margin-bottom: 6px;
}

.version-badge {
    background: rgba(0, 0, 0, 0.06);
    color: #777;
    padding: 3px 12px;
    border-radius: 15px;
    font-size: 0.65rem;
    margin-top: 10px;
    margin-bottom: 25px;
    display: inline-block;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.info-text {
    max-width: 320px;
    line-height: 1.5;
    color: #333;
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.red-box,
.blue-box {
    width: 100%;
    max-width: 320px;
    margin: 20px 0;
    padding: 20px;
    border-radius: 15px;
    text-align: center;
}

.red-box {
    background: #fff5f5;
    border: 1.5px solid #ffeded;
}

.blue-box {
    background: #f0f7ff;
    border: 1.5px solid #e0eeff;
}

.box-title {
    margin: 0 0 10px 0;
}

.qr-placeholder {
    width: 130px;
    height: 130px;
    background: #fff;
    border: 1px solid #eee;
    margin: 15px auto;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-inner {
    width: 100%;
    height: 100%;
    border: 2px dashed #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 0.6rem;
}

.coffee-btn,
.tipsa-btn {
    display: inline-block;
    margin-top: 15px;
    padding: 12px 25px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: bold;
    color: white;
    border: none;
    cursor: pointer;
}

.coffee-btn {
    background: #ffb3ba;
    box-shadow: 0 3px 0 #ff8a95;
}

.tipsa-btn {
    background: #b3d1ff;
    box-shadow: 0 3px 0 #8ab4f8;
}

.coffee-btn:active,
.tipsa-btn:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #ff8a95;
}

.info-footer {
    max-width: 320px;
    margin-top: 40px;
    padding-top: 15px;
    border-top: 1px solid #ddd;
    font-size: 0.75rem;
    line-height: 1.4;
    color: #888;
    text-align: left;
}

.footer-heading {
    color: #555;
}

.offer-card {
    position: relative;
    width: 100%;
    max-width: 360px;
    padding: 24px 20px 20px 20px;
    border-radius: 18px;
    background: white;
    border: 1px solid #ddd8cc;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
}

.offer-close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    border: none;
    background: transparent;
    color: #666;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}

.offer-title {
    margin: 0 0 10px 0;
    color: var(--green);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-size: 1rem;
}

.offer-text {
    margin: 0 0 16px 0;
    color: #333;
    line-height: 1.4;
    font-size: 0.95rem;
}

.offer-category-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.offer-category-btn {
    height: 38px;
    border: 1.5px solid #c9c4b8;
    border-radius: 10px;
    background: #f7f5ee;
    color: #444;
    font-weight: 700;
    cursor: pointer;
}

.offer-category-btn.active {
    background: var(--green);
    color: white;
    border-color: var(--green);
}

.offer-primary-btn,
.offer-secondary-btn {
    width: 100%;
    border: none;
    border-radius: 12px;
    height: 46px;
    font-weight: 700;
    cursor: pointer;
}

.offer-primary-btn {
    background: var(--green);
    color: white;
    margin-bottom: 10px;
}

.offer-secondary-btn {
    background: #ede9df;
    color: #333;
}

.offer-footnote {
    margin: 14px 0 0 0;
    font-size: 0.75rem;
    color: #777;
    line-height: 1.35;
}

svg.defs-only {
    width: 0;
    height: 0;
    position: absolute;
}