:root {
    --bg-color: #e0e5ec;
    --text-color: #333;
    --accent: #2c3e50;
    --success: #27ae60;
    --error: #e74c3c;
    --ladder-bg: #fff;
    --tile-bg: #ecf0f1;
    --tile-border: #bdc3c7;
    --key-bg: #d3d6da;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; 
}

#app {
    background: var(--ladder-bg);
    width: 100%;
    max-width: 450px;
    height: 100vh;
    height: 100dvh;
    max-height: 850px;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.screen { display: none; height: 100%; flex-direction: column; }
.screen.active { display: flex; }

/* --- Menu Screen --- */
#menu-screen {
    justify-content: center;
    align-items: center;
    padding: 2rem;
    text-align: center;
}

h1 { color: var(--accent); letter-spacing: 2px; }

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 20px auto 0 auto;
    width: 100%;
    max-width: 250px;
}

.menu-buttons .primary-btn {
    height: 70px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    line-height: 1.4;
    margin: 0;
}

.btn-subtext {
    font-size: 0.8em;
    font-weight: normal;
}

/* --- Mobile Layout Structure --- */
.game-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
    background: var(--ladder-bg);
    border-bottom: 2px solid #f0f0f0;
    position: relative;
    z-index: 10;
    min-height: 40px;
}

.header-left {
    position: absolute;
    left: 15px;
}

.header-right {
    position: absolute;
    right: 15px;
    display: flex;
    gap: 10px;
}

.header-btn {
    font-size: 1.5rem;
    border: none;
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    font-weight: bold;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-board {
    flex: 1;
    overflow-y: auto;
    padding: 25px 20px 240px 20px; 
    display: flex;
    flex-direction: column;
}

.game-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--ladder-bg);
    padding: 10px 10px 25px 10px; 
    box-sizing: border-box;
    box-shadow: 0 -4px 10px rgba(0,0,0,0.05);
    z-index: 10;
}

.footer-top {
    display: flex;
    justify-content: space-between; /* Space out Share and Hint buttons */
    align-items: center;
    margin-bottom: 10px;
    min-height: 40px;
    position: relative;
}

.error {
    position: absolute;
    left: 0; right: 0;
    color: var(--error);
    font-size: 0.9rem;
    margin: 0;
    font-weight: bold;
    text-align: center;
    pointer-events: none; 
}

/* --- Keyboard System --- */
#keyboard {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    margin: 0 auto;
}

.key-row {
    display: flex;
    justify-content: center;
    gap: 6px;
}

.key {
    flex: 1;
    height: 55px;
    background-color: var(--key-bg);
    border: none;
    border-radius: 4px;
    font-weight: bold;
    font-size: 1.2rem;
    color: var(--text-color);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    text-transform: uppercase;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.key:active { background-color: #bdc3c7; }
.key.large { flex: 1.5; font-size: 0.95rem; }
.spacer { flex: 0.5; }

/* --- Tile UI System --- */
.tile-row { display: flex; justify-content: center; gap: 6px; margin: 6px 0; }

.tile {
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: bold;
    text-transform: uppercase;
    background-color: var(--tile-bg);
    border-radius: 4px;
    color: var(--text-color);
}

.tile.peak { background-color: var(--success); color: white; }
.tile.base { background-color: var(--accent); color: white; }

.tile.input-tile {
    border: 2px solid var(--tile-border);
    background-color: white;
    cursor: pointer;
}

.tile.input-tile.selected {
    border-color: var(--accent);
    border-bottom-width: 6px; 
    background-color: #e8f4f8;
}

/* --- Buttons & Controls --- */
.primary-btn {
    padding: 12px 15px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1rem;
    width: 100%;
}
.primary-btn:hover { background: #1a252f; }

.secondary-btn {
    padding: 12px 15px;
    background: transparent;
    color: var(--accent);
    border: 2px solid var(--accent);
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1rem;
    width: 100%;
}
.secondary-btn:hover { background: #ecf0f1; }

.icon-btn {
    width: 40px;
    height: 40px;
    background: white;
    color: var(--accent);
    border: 2px solid var(--accent);
    border-radius: 6px;
    font-weight: bold;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2; 
}

/* --- Modal System --- */
.modal {
    display: none;
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 100;
    justify-content: center;
    align-items: center;
}
.modal.active { display: flex; }
.modal-content {
    background: white;
    padding: 25px;
    border-radius: 12px;
    width: 80%;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}
.hint-box { font-size: 1rem; color: var(--text-color); line-height: 1.5; }

.share-box {
    font-size: 1.2rem; 
    line-height: 1.2;
    margin: 15px 0;
    white-space: pre-wrap; 
    letter-spacing: 2px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}
.modal-buttons .primary-btn, .modal-buttons .secondary-btn {
    margin: 0;
    flex: 1;
}
