@media (orientation: portrait) {
  body {
    background-image: url("../images/portrait-bg.jpg");
    background-size: cover;
    background-position: center;
  }
}

@media (orientation: landscape) {
  body {
    background-image: url("../images/landscape-bg.jpg");
    background-size: cover;
    background-position: center;
  }
}

@font-face {
    font-family: "ParksFont";
    src: url("../fonts/d3_streetism.ttf") format("truetype");
    font-weight: normal;
    font-style: normal;
}


html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    font-family: 'ParksFont';
    color: white;
}

/* ===== Main Menu ===== */
.main-menu {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding: 2.5rem 1rem 1.5rem 1rem;
}

.main-menu-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    width: 100%;
    overflow: hidden;
    transform-origin: top;
    animation: difficultyRollDown 420ms ease-out;
}

.main-menu-grid > * {
    transform-origin: top;
    animation: difficultyButtonRollDown 320ms ease-out both;
}

.main-menu-grid > :nth-child(1) { animation-delay: 0.02s; }
.main-menu-grid > :nth-child(2) { animation-delay: 0.05s; }
.main-menu-grid > :nth-child(3) { animation-delay: 0.08s; }


.main-menu .logo {
    font-size: clamp(2rem, 8vw, 5rem);
    font-weight: 700;
    color: #EAD85D;
    text-shadow: 2px 4px 8px rgba(0,0,0,0.5);
    letter-spacing: 0.3em;
    margin-top: 0.7em;
}

.game-button {
    display: inline-block;
    background: linear-gradient(180deg, #2a7a2a, #1a5a1a);
    border: 2px solid #4a4a2a;
    color: white;
    font-family: 'ParksFont';
    font-size: clamp(0.9rem, 2.5vw, 1.3rem);
    font-weight: 700;
    padding: 0.7em 2.5em;
    border-radius: 8px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    transition: all 0.15s;
    min-width: 200px;
    text-align: center;
}

.game-button:hover {
    background: linear-gradient(180deg, #3a9a3a, #2a7a2a);
    transform: scale(1.04);
}

.game-button:active {
    transform: scale(0.97);
}

/* ===== Difficulty & Level Selection ===== */
.selection-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    height: 100vh;
    height: 100dvh;
    box-sizing: border-box;
    padding: 1.5rem 1rem;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
    -webkit-overflow-scrolling: touch;
}

.selection-page h2 {
    color: #EAD85D;
    font-size: clamp(1.8rem, 5vw, 3rem);
    text-shadow: 2px 4px 8px rgba(0, 0, 0, 0.5);
    letter-spacing: 0.1em;
    margin: 0;
    text-align: center;
    text-transform: uppercase;
}

.selection-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
    gap: 1rem;
}

.difficulty-grid {
    display: flex;
    flex-direction: column;
    width: 90%;
    max-width: 400px;
    gap: 0.6rem;
    overflow: hidden;
    transform-origin: top;
    animation: difficultyRollDown 420ms ease-out;
}

.difficulty-grid > * {
    transform-origin: top;
    animation: difficultyButtonRollDown 320ms ease-out both;
}

.difficulty-grid > :nth-child(1) { animation-delay: 0.02s; }
.difficulty-grid > :nth-child(2) { animation-delay: 0.05s; }
.difficulty-grid > :nth-child(3) { animation-delay: 0.08s; }
.difficulty-grid > :nth-child(4) { animation-delay: 0.11s; }
.difficulty-grid > :nth-child(5) { animation-delay: 0.14s; }
.difficulty-grid > :nth-child(6) { animation-delay: 0.17s; }
.difficulty-grid > :nth-child(7) { animation-delay: 0.20s; }
.difficulty-grid > :nth-child(8) { animation-delay: 0.23s; }

@keyframes difficultyRollDown {
    0% {
        max-height: 0;
        opacity: 0;
    }

    100% {
        max-height: 1000px;
        opacity: 1;
    }
}

@keyframes difficultyButtonRollDown {
    0% {
        transform: scaleY(0.1);
        opacity: 0;
    }

    100% {
        transform: scaleY(1);
        opacity: 1;
    }
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
}

.level-grid > * {
    animation: levelButtonPopIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.level-grid > :nth-child(1) { animation-delay: 0ms; }
.level-grid > :nth-child(2) { animation-delay: 20ms; }
.level-grid > :nth-child(3) { animation-delay: 40ms; }
.level-grid > :nth-child(4) { animation-delay: 60ms; }
.level-grid > :nth-child(5) { animation-delay: 80ms; }
.level-grid > :nth-child(6) { animation-delay: 100ms; }
.level-grid > :nth-child(7) { animation-delay: 120ms; }
.level-grid > :nth-child(8) { animation-delay: 140ms; }
.level-grid > :nth-child(9) { animation-delay: 160ms; }
.level-grid > :nth-child(10) { animation-delay: 180ms; }
.level-grid > :nth-child(11) { animation-delay: 200ms; }
.level-grid > :nth-child(12) { animation-delay: 220ms; }
.level-grid > :nth-child(13) { animation-delay: 240ms; }
.level-grid > :nth-child(14) { animation-delay: 260ms; }
.level-grid > :nth-child(15) { animation-delay: 280ms; }
.level-grid > :nth-child(16) { animation-delay: 300ms; }
.level-grid > :nth-child(17) { animation-delay: 320ms; }
.level-grid > :nth-child(18) { animation-delay: 340ms; }
.level-grid > :nth-child(19) { animation-delay: 360ms; }
.level-grid > :nth-child(20) { animation-delay: 380ms; }
.level-grid > :nth-child(21) { animation-delay: 400ms; }
.level-grid > :nth-child(22) { animation-delay: 420ms; }
.level-grid > :nth-child(23) { animation-delay: 440ms; }
.level-grid > :nth-child(24) { animation-delay: 460ms; }
.level-grid > :nth-child(25) { animation-delay: 480ms; }

@keyframes levelButtonPopIn {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ===== Game Board ===== */
.game-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem;
}

.game-header {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 500px;
    padding: 0 0.5rem;
    font-size: clamp(0.7rem, 2vw, 1rem);
}

.game-header span {
    font-weight: 700;
}

.board-container {
    display: inline-grid;
    gap: 1px;
    border-radius: 24px;
    background: white;
    padding: 8px;
    touch-action: none;
}

.board-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1px solid rgba(0,0,0,0.25);
    border-radius: 10%;
    margin: 1%;
    transition: filter 0.1s;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
}

.board-cell:hover {
    filter: brightness(1.15);
}

.board-cell.no-area {
    cursor: default;
    background: #222 !important;
}

.board-cell .cell-icon {
    font-size: clamp(1rem, 4vw, 2rem);
    line-height: 1;
    pointer-events: none;
}

.cell-icon {
    height: auto;
    width: 60%;
    object-fit: contain;
}

.unallowed {
    opacity: 0.4
}

.game-info-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    font-size: clamp(0.7rem, 2vw, 1rem);
    padding: 0.3rem 0;
}

.game-info-bar .tree-icon {
    color: #1a5a1a;
}

.status-bar {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 1.6rem;
    margin-top: 0.3rem;
    padding: 0.5rem;
    border: 2px solid white;
    border-radius: 12px;
    background-color: rgba(0, 0, 0, 0.2);
}

.layer {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    width: 100%;
}

.status-bar .layer:nth-child(1) {
    z-index: 1;
}

.status-bar .layer:nth-child(2) {
    z-index: 2;
}

.flex {
    display: flex;
    align-items: center;
}

.justify-left {
    display: flex;
    align-items: center;
    flex: 1;
    justify-content: flex-start;
}

.justify-center {
    display: flex;
    width: 100%;
    justify-content: center;
}

.justify-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.time-red {
    color: #ff4444 !important;
}

/* ===== Solved overlay ===== */
.solved-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.75);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    cursor: pointer;
    animation: fadeIn 0.5s ease;
    outline: none;
}

.solved-text {
    font-weight: 700;
    background: linear-gradient(135deg, #F2ECC6, #F4D613);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: slideDown 0.5s ease;
}

.solved-stars {
    display: flex;
}

.solved-stars .star-animate {
    display: block;
}

.solved-stars .cell-icon {
    height: auto;
}

.solved-stars .star-icon.filled {
    color: #EAD85D;
    animation: popIn 0.4s ease;
}

.solved-stars .star-icon:nth-child(2) { animation-delay: 0.25s; }
.solved-stars .star-icon:nth-child(3) { animation-delay: 0.5s; }

.solved-stars .star-icon.empty {
    color: #555;
}

.improved-image {
    max-width: 90%;
    height: auto;
    object-fit: contain;
    animation: zoomAndFadeIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.1) 0.8s both;
}

.click-hint {
    color: #888;
    animation: fadeIn 1s ease 1.5s both;
}

/* Portrait / mobile orientation layout */
@media (orientation: portrait) {
    .solved-text {
        font-size: clamp(2.5rem, 18vw, 8rem);
        margin-bottom: 2vh;
    }
    .solved-stars {
        gap: 2vw;
        margin-top: 1vh;
        margin-bottom: 2vh;
    }
    .solved-stars .cell-icon {
        width: clamp(3rem, 24vw, 10rem);
    }
    .improved-image {
        width: clamp(10rem, 75vw, 28rem);
        margin-top: 2vh;
    }
    .click-hint {
        font-size: clamp(0.7rem, 2vw, 1.1rem);
        margin-top: 4vh;
    }
}

/* Landscape / desktop orientation layout */
@media (orientation: landscape) {
    .solved-text {
        font-size: clamp(2rem, 16vh, 6rem);
        margin-bottom: 1vh;
    }
    .solved-stars {
        gap: 2vh;
        margin-top: 0.5vh;
        margin-bottom: 1vh;
    }
    .solved-stars .cell-icon {
        width: clamp(2rem, 18vh, 7rem);
    }
    .improved-image {
        width: clamp(8rem, 45vh, 18rem);
        margin-top: 1.5vh;
    }
    .click-hint {
        font-size: clamp(0.6rem, 1.5vh, 0.9rem);
        margin-top: 2vh;
    }
}

@keyframes zoomAndFadeIn {
    0% {
        opacity: 0;
        transform: scale(3.5);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* ===== Rules popup ===== */
.rules-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 0;
    box-sizing: border-box;
    outline: none;
    animation: fadeIn 0.3s ease;
}

.rules-modal {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    /* Portrait: use ~96% of the viewport width. */
    width: 96%;
    max-width: none;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
    padding: 1.5rem;
    border: 2px solid white;
    border-radius: 16px;
    background: rgba(28, 11, 43, 0.85);
    text-align: center;
}

/* Landscape / wide displays: use ~80% of the available width. */
@media (orientation: landscape) {
    .rules-modal {
        width: 80%;
    }
}

.rules-close {
    position: absolute;
    top: 0.6rem;
    right: 0.8rem;
    background: none;
    border: none;
    color: #ccc;
    font-family: 'ParksFont';
    font-size: clamp(1.4rem, 4vw, 2rem);
    line-height: 1;
    cursor: pointer;
    transition: color 0.15s;
}

.rules-close:hover {
    color: #EAD85D;
}

.rules-title {
    color: #EAD85D;
    font-size: clamp(1.8rem, 4.5vw, 3rem);
    margin: 0;
}

.rules-section {
    width: 100%;
    max-width: none;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    text-align: left;
}

/* Keep loose prose/lists at a comfortable reading width, centered within a
   wide modal, while cards below can span the full width. */
.rules-section > .rules-body,
.rules-section > .rules-list,
.rules-section > .rules-notice {
    width: 100%;
    max-width: 90%;
    margin-left: auto;
    margin-right: auto;
}

/* Rule/strategy cards flow into as many responsive columns as fit, so wide
   displays actually use the horizontal space instead of one narrow column. */
.rule-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 0.6rem;
    width: 100%;
    margin-top: 1rem;
}

.rules-heading {
    color: #EAD85D;
    font-size: clamp(1.5rem, 3.6vw, 2.1rem);
    margin: 0.4rem 0 0;
    text-align: center;
}

.rules-body {
    font-size: clamp(1.05rem, 2.7vw, 1.5rem);
    line-height: 1.6;
    color: #ccc;
    margin: 0;
}

.rule-card {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 0.7rem 1rem;
    border: 2px solid white;
    border-radius: 12px;
    background-color: rgba(0, 0, 0, 0.2);
}

.rule-card h4 {
    color: #EAD85D;
    font-size: clamp(1.2rem, 3vw, 1.65rem);
    margin: 0;
}

.rule-card p {
    font-size: clamp(1.05rem, 2.7vw, 1.5rem);
    line-height: 1.6;
    color: #ccc;
    margin: 0;
}

.rules-list {
    text-align: left;
    font-size: clamp(1.05rem, 2.7vw, 1.5rem);
    color: #ccc;
    line-height: 2;
    list-style: none;
    padding: 0;
    margin: 0;
}

.rules-list li::before {
    content: "🌳 ";
}

.rules-notice {
    font-size: clamp(0.9rem, 2.25vw, 1.275rem);
    color: #999;
    font-style: italic;
    text-align: center;
    margin: 0;
}

.rules-footer {
    margin-top: 1rem;
}

/* ===== Confirm popup ===== */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 110;
    padding: 1rem;
    box-sizing: border-box;
    outline: none;
    animation: fadeIn 0.3s ease;
}

.confirm-modal {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2rem;
    width: 100%;
    max-width: 420px;
    box-sizing: border-box;
    padding: 1.5rem;
    border: 2px solid white;
    border-radius: 16px;
    background: rgba(28, 11, 43, 0.85);
    text-align: center;
}

.confirm-message {
    color: #ccc;
    font-size: clamp(1.05rem, 2.7vw, 1.4rem);
    line-height: 1.5;
    margin: 0;
}

.confirm-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ===== Finished page ===== */
.finished-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    box-sizing: border-box;
    padding: 2rem;
    text-align: center;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.finished-card {
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 24px;
    padding: 3rem 2.5rem;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), 0 0 30px rgba(234, 216, 93, 0.1);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    max-width: 540px;
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    animation: popIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.finished-card:hover {
    border-color: rgba(234, 216, 93, 0.4);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), 0 0 40px rgba(234, 216, 93, 0.2);
}

.finished-icon-container {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    width: 100%;
    animation: floatCup 3s ease-in-out infinite;
}

.finished-image {
    max-width: 180px;
    width: 60%;
    height: auto;
    max-height: 25vh;
    object-fit: contain;
    filter: drop-shadow(0 8px 24px rgba(234, 216, 93, 0.4));
    transition: transform 0.3s ease;
}

.finished-image:hover {
    transform: scale(1.05) rotate(3deg);
}

.finished-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2rem;
    width: 100%;
}

.finished-title {
    color: #EAD85D;
    font-size: clamp(1.8rem, 5vw, 2.8rem);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
    letter-spacing: 0.1em;
    margin: 0;
    font-weight: 700;
}

.finished-desc {
    font-size: clamp(0.95rem, 2.2vw, 1.25rem);
    color: #fff;
    font-weight: bold;
    max-width: 460px;
    line-height: 1.5;
    margin: 0;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.finished-subdesc {
    font-size: clamp(0.8rem, 1.8vw, 0.95rem);
    color: rgba(255, 255, 255, 0.7);
    max-width: 440px;
    line-height: 1.6;
    margin: 0 0 0.2rem 0;
}

.finished-actions {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 0.5rem;
}

/* Animations */
@keyframes floatCup {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .finished-page {
        padding: 1.5rem 1rem;
    }
    
    .finished-card {
        padding: 2.2rem 1.5rem;
        gap: 1.2rem;
    }
    
    .finished-image {
        max-width: 140px;
    }
}

/* Mobile Landscape optimizations to prevent scrolling/truncation */
@media (max-height: 520px) and (orientation: landscape) {
    .finished-page {
        padding: 1rem;
    }
    
    .finished-card {
        flex-direction: row;
        max-width: 780px;
        padding: 1.5rem 2rem;
        gap: 2rem;
        align-items: center;
        text-align: left;
    }
    
    .finished-icon-container {
        width: 35%;
        flex-shrink: 0;
        animation: floatCupHorizontal 3s ease-in-out infinite;
    }
    
    .finished-image {
        max-width: 130px;
        max-height: 45vh;
    }
    
    .finished-content {
        width: 65%;
        align-items: flex-start;
        gap: 0.8rem;
    }
    
    .finished-title, 
    .finished-desc,
    .finished-subdesc {
        text-align: left;
        margin: 0;
    }
    
    .finished-actions {
        justify-content: flex-start;
        margin-top: 0.2rem;
    }
}

@keyframes floatCupHorizontal {
    0% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-6px) rotate(1deg); }
    100% { transform: translateY(0px) rotate(0deg); }
}

/* ===== Menu dropdown ===== */
.game-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 50;
}

.game-menu {
    position: fixed;
    top: 0.5rem;
    right: 0.5rem;
    background: #222;
    border: 1px solid #555;
    border-radius: 8px;
    overflow: hidden;
    z-index: 51;
    animation: slideMenuDown 0.2s ease;
}

.game-menu-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7em 1.2em;
    color: #ddd;
    font-size: clamp(0.8rem, 2vw, 1rem);
    cursor: pointer;
    border-bottom: 1px solid #333;
    transition: background 0.15s;
}

.game-menu-item:last-child {
    border-bottom: none;
}

.game-menu-item:hover {
    background: #333;
}

/* ===== Pause overlay ===== */
.pause-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 40;
    cursor: pointer;
}

.pause-overlay .pause-text {
    font-size: clamp(2rem, 8vw, 4rem);
    color: #888;
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-40px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes popIn {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.3); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes slideMenuDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Sound button on main menu ===== */
.sound-toggle {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #888;
    transition: color 0.2s;
}

.sound-toggle:hover {
    color: #fff;
}

.button-o {
    display: flex;
    align-items: stretch;
    justify-content: center;
    cursor: pointer;
    font-size: 2rem;
    --btn-height: 1.925em;
}

.button-o.disabled {
    cursor: default;
}

.button-m {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background-image: url("../images/button-m.png");
    background-repeat: repeat-x;
    background-position: center;
    background-size: contain;
    padding: 0.4em;
    text-align: center;
    font-family: 'ParksFont';
    color: white;
    flex-grow: 1;
}

.button-corner-text {
    position: absolute;
    right: 0em;
    bottom: 0.6em;
    font-size: 0.55em;
    color: rgba(255, 255, 255, 0.9);
    pointer-events: none;
}

.button-l {
    background-image: url("../images/button-l.png");
    background-repeat: no-repeat;
    background-position: right;
    background-size: 100% 100%;
    box-sizing: border-box;
    width: calc(var(--btn-height) / 3);
    padding: 0;
    flex-shrink: 0;
}

.button-r {
    background-image: url("../images/button-r.png");
    background-repeat: no-repeat;
    background-position: left;
    background-size: 100% 100%;
    box-sizing: border-box;
    width: calc(var(--btn-height) / 3);
    padding: 0;
    flex-shrink: 0;
}

.button-m.disabled {
    background-image: url("../images/button-m-i.png");
}

.button-l.disabled {
    background-image: url("../images/button-l-i.png");
}

.button-r.disabled {
    background-image: url("../images/button-r-i.png");
}

.star-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-image: url("../vectors/button-sqr.svg");
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    padding: 0.4em;
    color: white;
    cursor: pointer;
}

.star-button.disabled {
    cursor: default;
}

.star-button.current {
    background-image: url("../vectors/button-sqr-org.svg");
}

.action-bar {
    padding-top: 0.8rem;
}

.action-button {
    align-items: center;
    justify-content: center;
    background-image: url("../vectors/button-sqr.svg");
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    padding: 0.4em;
    color: white;
    cursor: pointer;
}

.action-button.disabled {
    background-image: url("../vectors/button-sqr-gr.svg");
    cursor: default;
}

.action-button-image {
    width: 100%;
    height: 100%;
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.action-button-image img {
    width: 70% !important;
    height: 70% !important;
    object-fit: contain;
}

.number-container {
    margin-top: 8%;
}

.number-container.current {
    color: black;
}

.stars-container {
    display: flex;
    justify-content: center;
    margin-bottom: 10%;
}

.star-icon {
    margin: 1%;
    width: 25%
}

.padlock {
    width: 35%;
    height: auto;
}

/* ===== Settings Modal Popup ===== */
.settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 0;
    box-sizing: border-box;
    outline: none;
    animation: fadeIn 0.3s ease;
}

.settings-modal {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2rem;
    width: 96%;
    max-width: 520px;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
    padding: 1.5rem 2rem;
    border: 2px solid white;
    border-radius: 16px;
    background: rgba(28, 11, 43, 0.85);
    text-align: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.settings-close {
    position: absolute;
    top: 0.6rem;
    right: 0.8rem;
    background: none;
    border: none;
    color: #ccc;
    font-family: 'ParksFont';
    font-size: clamp(1.4rem, 4vw, 2rem);
    line-height: 1;
    cursor: pointer;
    transition: color 0.15s;
}

.settings-close:hover {
    color: #EAD85D;
}

.settings-title {
    color: #EAD85D;
    font-size: clamp(1.8rem, 4.5vw, 2.5rem);
    margin: 0;
}

.settings-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 1rem;
}

.settings-heading {
    color: #EAD85D;
    font-family: 'ParksFont';
    font-size: clamp(1.2rem, 3vw, 1.6rem);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.settings-section-icon {
    width: 24px;
    height: 16px;
    border-radius: 2px;
}

/* Language Selection Grid */
.language-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    justify-content: flex-start;
    margin-top: 0.2rem;
}

.language-card {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 0.4rem 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    color: white;
    font-family: inherit;
}

.language-card:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
}

.language-card.active {
    background: rgba(234, 216, 93, 0.15);
    border-color: #EAD85D;
    box-shadow: 0 0 8px rgba(234, 216, 93, 0.3);
}

.language-flag {
    width: 24px;
    height: 16px;
    border-radius: 2px;
    object-fit: cover;
}

.language-name {
    font-family: 'ParksFont';
    font-size: clamp(0.95rem, 2.4vw, 1.25rem);
    font-weight: 500;
}

/* Settings Options Rows */
.settings-row {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
}

.settings-row-label {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: white;
    font-family: 'ParksFont';
    font-size: clamp(1.1rem, 2.8vw, 1.45rem);
}

.settings-row-icon {
    width: 24px;
    height: 24px;
}

.settings-row-icon.dimmed {
    opacity: 0.5;
}

/* Custom CSS Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: rgba(255, 255, 255, 0.2);
    transition: .3s;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .slider {
    background-color: rgba(234, 216, 93, 0.8);
    border-color: #EAD85D;
}

input:checked + .slider:before {
    transform: translateX(22px);
}

.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

.settings-audio-group {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.settings-volume-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0 0 0.4rem 2.8rem;
}

.volume-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.2);
    outline: none;
    cursor: pointer;
}

.volume-slider:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #EAD85D;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    cursor: pointer;
}

.volume-slider:disabled::-webkit-slider-thumb {
    background: rgba(255, 255, 255, 0.5);
    cursor: not-allowed;
}

.volume-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border: none;
    border-radius: 50%;
    background: #EAD85D;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    cursor: pointer;
}

.volume-slider:disabled::-moz-range-thumb {
    background: rgba(255, 255, 255, 0.5);
    cursor: not-allowed;
}

.volume-value {
    min-width: 3rem;
    color: rgba(255, 255, 255, 0.75);
    font-family: 'ParksFont';
    font-size: clamp(0.9rem, 2.2vw, 1.1rem);
    text-align: right;
}

.settings-footer {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 0.8rem;
}

.navigation-row {
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1rem;
}

/* ===== Landing / Home Page Redesign ===== */
.home-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    box-sizing: border-box;
    padding: 2.5rem 1rem 1.5rem 1rem;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.home-copyright {
    margin-top: auto;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.45);
    text-align: center;
    letter-spacing: 0.05em;
    padding-top: 1.5rem;
    flex-shrink: 0;
}

.home-logo-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-bottom: 2rem;
    flex-shrink: 0;
}

.home-logo {
    max-width: 380px;
    width: 75%;
    height: auto;
    filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.4));
}

.main-logo {
    max-width: 580px;
    width: 75%;
    height: auto;
    filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.4));
}

.home-subtitle {
    font-size: clamp(0.9rem, 2vw, 1.25rem);
    color: rgba(255, 255, 255, 0.9);
    margin-top: 0;
    margin-bottom: 2rem;
    text-shadow: 1px 2px 4px rgba(0, 0, 0, 0.6);
    max-width: 600px;
    line-height: 1.4;
    text-align: center;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

.home-cards-container {
    display: flex;
    gap: 2rem;
    justify-content: center;
    align-items: stretch;
    width: 100%;
    max-width: 960px;
    margin-bottom: 1.5rem;
    flex-grow: 1;
    max-height: 520px; /* limit height on desktop to keep layout tight */
}

.home-card {
    flex: 1;
    min-width: 280px;
    max-width: 420px;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-sizing: border-box;
}

.home-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.6);
    border-color: rgba(234, 216, 93, 0.45);
}

.home-card-header {
    font-size: clamp(0.7rem, 1.5vw, 0.8rem);
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: #EAD85D;
    margin-bottom: 0.6rem;
    font-weight: 700;
}

.home-card-title {
    font-size: clamp(1.2rem, 2.5vw, 1.5rem);
    margin: 0 0 1rem 0;
    color: #fff;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
    font-weight: 700;
    letter-spacing: 0.05em;
}

.home-card-desc {
    font-size: clamp(0.8rem, 1.8vw, 0.95rem);
    color: rgba(255, 255, 255, 0.75);
    line-height: 1.5;
    margin-bottom: 1.5rem;
    flex-grow: 1;
    text-align: center;
}

.home-web-preview-container {
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    background: rgba(0, 0, 0, 0.3);
    position: relative;
    aspect-ratio: 16/9;
}

.home-web-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: block;
}

.home-web-preview-container:hover .home-web-preview {
    transform: scale(1.05);
}

.home-button {
    display: inline-block;
    background: linear-gradient(180deg, #2a7a2a, #1a5a1a);
    border: 2px solid #EAD85D;
    color: white;
    font-family: 'ParksFont';
    font-size: clamp(0.85rem, 2vw, 1rem);
    font-weight: 700;
    padding: 0.85em 2em;
    border-radius: 10px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    transition: all 0.2s ease;
    width: 100%;
    max-width: 250px;
    box-shadow: 0 4px 15px rgba(26, 90, 26, 0.4);
    text-decoration: none;
    text-align: center;
}

.home-button:hover {
    background: linear-gradient(180deg, #3a9a3a, #2a7a2a);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(42, 122, 42, 0.6);
}

.home-button:active {
    transform: translateY(1px);
}

.home-play-badge {
    max-width: 180px;
    width: 80%;
    height: auto;
    transition: transform 0.2s ease, filter 0.2s ease;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
    display: block;
    margin: 1.5rem auto 1.5rem auto;
}

.home-play-badge:hover {
    transform: scale(1.06);
    filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.5)) brightness(1.05);
}

.home-play-badge:active {
    transform: scale(0.98);
}

@media (max-width: 768px) {
    .home-page {
        padding: 1.5rem 1rem;
    }
    
    .home-cards-container {
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
        max-height: none; /* remove height limit so it stacks naturally */
        flex-grow: 0;
    }
    
    .home-card {
        width: 100%;
        max-width: 420px;
        padding: 1.5rem;
    }
    
    .home-logo {
        max-width: 280px;
    }
    
    .home-subtitle {
        margin-bottom: 1.5rem;
    }

    .home-copyright {
        margin-top: 2rem;
    }
}

/* Landscape mode adjustment on mobile to avoid vertical truncation */
@media (max-height: 600px) and (orientation: landscape) {
    .home-page {
        padding: 1rem;
    }
    .home-logo {
        max-width: 180px;
    }
    .home-subtitle {
        margin-bottom: 1rem;
    }
    .home-cards-container {
        max-height: none;
        gap: 1rem;
    }
    .home-card {
        padding: 1rem;
    }
    .home-web-preview-container {
        margin-bottom: 1rem;
    }
}

/* Mobile responsive selection pages & overlays */
@media (max-width: 768px) {
    .selection-content {
        justify-content: flex-start;
    }

    .button-o {
        font-size: clamp(1.1rem, 4.5vw, 1.6rem) !important;
    }

    .star-button {
        --button-size: clamp(45px, 13vw, 75px) !important;
    }

    .action-button {
        --action-size: clamp(35px, 10vw, 45px) !important;
    }

    .navigation-row {
        --action-size: clamp(35px, 10vw, 45px);
        gap: 0.8rem;
        margin-top: 0.8rem;
    }

    .navigation-row .button-o {
        --btn-height: calc(var(--action-size) + 12.8px);
        height: var(--btn-height);
    }
}