/* CSS Reset & Global Mobile/WebView Constraints */
@font-face {
    font-family: 'Press Start 2P';
    src: url('./PressStart2P-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}
* {
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    font-family: 'Press Start 2P', monospace;
    color: var(--text-color, #FAFAFA);
    background-color: var(--bg-color, #111111);
    /* Reduced base font-size for better mobile fit */
    font-size: 13px;
}

body {
    overscroll-behavior-y: none;
}

/* Responsive Container */
#game-container {
    width: 100vw;
    height: calc(100vh - 40px);
    max-width: 450px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 8px;
    gap: 8px;
}

/* Header UI */
#header-ui {
    width: 100%;
    display: flex;
    /* make each top-level child take equal available space so spacing between items is uniform */
    align-items: center;
    padding: 4px 0;
    font-size: 0.85em; /* increased for better readability */
    line-height: 1;
    border-bottom: 2px solid var(--border-color, #333);
    gap: 8px;
}

/* Ensure each direct child of the header shares space equally */
#header-ui > * {
    flex: 1 1 0;
    display: flex;
    align-items: center;
}

/* Make the three top info boxes (score, level, lives) share available space while menu button remains fixed */
#header-ui > .ui-label,
#header-ui > .level-label {
    flex: 1 1 0;
}

/* Force the menu button's flex to be fixed (square) so other boxes expand equally */
#header-ui > #menu-button {
    flex: 0 0 44px;
}

/* UPDATED: unify label and value text sizes */
.ui-label {
    padding: 6px 8px;
    background: var(--ui-bg-color, rgba(0, 0, 0, 0.4));
    border: 2px solid var(--ui-border-color, #888);
    min-width: 80px;
    text-align: center;

    /* uniform box height and vertical centering for mobile touch targets */
    min-height: 44px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    /* unified text size for label and value */
    font-size: 0.95em;
}



.level-label {
    padding: 6px 10px;
    background: var(--ui-bg-color, rgba(0,0,0,0.4));
    border: 2px solid var(--ui-border-color, #888);
    min-width: 88px;
    text-align: center;
    font-size: 0.95em; /* increased to match .ui-label */

    /* match .ui-label box sizing and vertical centering */
    min-height: 44px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* NEW: force numeric values onto a second line and set same text size as labels */
.ui-label span,
.level-label span {
    display: block;
    margin-top: 6px;
    font-size: 0.95em;
    line-height: 1;
}

/* Burger Menu Button (fixed square) */
#menu-button {
    cursor: pointer;
    font-size: 1.1em;
    width: 44px;           /* fixed square width */
    height: 44px;          /* fixed square height */
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    border: 2px solid var(--ui-border-color, #888);
    background: var(--ui-bg-color, rgba(0, 0, 0, 0.4));
    color: var(--ui-border-color, #888);
    transition: background 0.1s;
    border-radius: 2px;
    justify-self: end;
    flex: 0 0 44px;        /* ensure it stays a fixed square in flex layout */
}

/* center the middle (lives) UI box content within its column */
#header-ui > .ui-label {
    justify-content: center;
}

#menu-button:active {
    background: var(--primary-color, #4CAF50);
}

/* Canvas */
#game-canvas {
    width: 100%;
    flex-grow: 1;
    image-rendering: pixelated;
    border: 4px solid var(--border-color, #666);
    background-color: var(--game-bg-color, #000000);
}

/* Footer */
footer {
    width: 100%;
    text-align: center;
    padding: 5px;
    font-size: 0.55em; /* reduced from 0.6em */
    color: #777;
}

footer a {
    color: #A0A0FF;
    text-decoration: none;
}

/* --- Modals and Menu --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    place-items: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-color, #111);
    border: 4px ridge var(--primary-color, #4CAF50);
    padding: 18px; /* slightly less padding */
    text-align: center;
    width: 90%;
    max-width: 350px;
    font-size: 0.95em; /* slightly reduced from 1em */
}

.modal-content h2 {
    margin-top: 0;
    color: var(--primary-color, #4CAF50);
    font-size: 1.05em; /* reduced from 1.2em */
}

.modal-button, .menu-item button {
    display: block;
    width: 100%;
    padding: 9px; /* slightly reduced */
    margin-top: 8px;
    font-family: inherit;
    font-size: 0.85em; /* reduced from 0.9em */
    cursor: pointer;
    border: 2px outset var(--primary-color, #4CAF50);
    background: var(--ui-bg-color, #222);
    color: var(--text-color, #FAFAFA);
    transition: background 0.1s;
}

.modal-button:active, .menu-item button:active {
    background: var(--primary-color, #4CAF50);
    border-style: inset;
}

/* Menu Specific */
#settings-menu .modal-content {
    text-align: left;
}

.menu-item {
    margin-bottom: 10px;
}

/* visual grouping blocks inside settings menu */
.menu-block {
    padding: 8px 0;
    border-bottom: 1px dashed rgba(255,255,255,0.06);
    margin-bottom: 10px;
}

/* remove divider for last block for cleaner look */
.menu-block--bottom {
    border-bottom: none;
    margin-bottom: 0;
    padding-top: 6px;
}

/* give grouped buttons a little vertical separation */
.menu-block .menu-item + .menu-item {
    margin-top: 6px;
}

/* add extra spacing between the two bottom buttons */
.menu-block--bottom .modal-button:first-child {
    margin-bottom: 10px;
}

/* style the main-menu button to match active theme and ensure readable contrast */
#return-menu-btn {
    background: var(--primary-color, #4CAF50);
    color: var(--bg-color, #111111);
    border: 2px outset var(--primary-color, #4CAF50);
}

/* keep active/pressed visual consistent */
#return-menu-btn:active {
    background: var(--bg-color, #111111);
    color: var(--primary-color, #4CAF50);
    border-style: inset;
}

.menu-item label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.85em; /* reduced */
}

.menu-item select {
    width: 100%;
    padding: 7px; /* reduced */
    font-family: inherit;
    background: var(--ui-bg-color, #333);
    color: var(--text-color, #FAFAFA);
    border: 2px solid var(--ui-border-color, #888);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    cursor: pointer;
}

/* Start modal frog preview */
#start-frog-wrap {
    pointer-events: none;
}
#start-frog-canvas {
    image-rendering: pixelated;
    border: 2px solid var(--ui-border-color, #888);
    background: transparent;
    display: block;
    width: 120px; /* slightly smaller to match reduced UI scale */
    height: 60px;
}