:root {
    --bg-color: #121213;
    --text-color: #ffffff;
    --tile-bg: #121213;
    --tile-border: #3a3a3c;
    --tile-active: #565758;
    --key-bg: #818384;
    --dist-bg: #3a3a3c;
    --valid-color: #538d4e;
    --invalid-color: #e25822;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Clear Sans', 'Helvetica Neue', Arial, sans-serif;
    user-select: none;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    height: 100dvh; 
    overflow: hidden;
    max-width: 500px;
    margin: 0 auto;
    position: relative;
}

#landing-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.menu-section {
    margin: 15px 0;
    text-align: center;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.menu-section p {
    color: #aaa;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.btn {
    background-color: var(--valid-color);
    color: white;
    border: none;
    padding: 15px 20px;
    margin: 5px;
    font-size: 1.1rem;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    width: 200px;
    flex-grow: 1; 
}

.btn-secondary {
    background-color: var(--key-bg);
}

.btn:active {
    opacity: 0.8;
}

#game-page {
    display: none;
    flex-direction: column;
    height: 100%;
    justify-content: space-between;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid var(--tile-border);
    min-height: 60px;
}

.header-btn {
    background: none;
    color: var(--text-color);
    border: 1px solid var(--key-bg);
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.play-btn {
    background-color: var(--valid-color);
    border-color: var(--valid-color);
    font-weight: bold;
}

.stats {
    font-size: 0.75rem;
    color: #aaa;
    text-align: center;
    margin-top: 3px;
    white-space: nowrap;
}

#category-container {
    display: flex;
    justify-content: center;
    margin-top: 15px;
    min-height: 25px;
}

/* NEW: Simulated Category Input Box */
#category-box {
    padding: 8px 15px;
    border-radius: 4px;
    border: 1px solid var(--tile-border);
    background: #1e1e1f;
    color: #aaa;
    text-align: center;
    font-size: 1rem;
    width: 60%;
    display: none;
    cursor: pointer;
    min-height: 38px;
    letter-spacing: 1px;
}

#category-box.active {
    border-color: var(--key-bg);
    color: white;
    box-shadow: inset 0 0 5px rgba(255,255,255,0.2);
}

#category-display {
    color: var(--valid-color);
    font-weight: bold;
    font-size: 1.1rem;
    text-transform: uppercase;
    display: none;
}

#board-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.board-row {
    display: flex;
    gap: 6px;
}

.tile {
    width: 55px;
    height: 55px;
    border: 2px solid var(--tile-border);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-weight: bold;
    text-transform: uppercase;
}

.tile.active {
    border-color: var(--key-bg);
    background-color: #2a2a2c;
    box-shadow: inset 0 0 5px rgba(255,255,255,0.2);
}

.tile.dist {
    background-color: var(--dist-bg);
    border: none;
    font-size: 1.5rem;
    border-radius: 4px;
}

.tile.valid {
    background-color: var(--valid-color);
    border-color: var(--valid-color);
}

.tile.invalid {
    background-color: var(--invalid-color);
    border-color: var(--invalid-color);
}

#helper-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    min-height: 60px;
    margin-bottom: 10px;
}

.helper-key {
    background-color: var(--valid-color);
    color: white;
    border: none;
    border-radius: 8px;
    width: 60px;
    height: 60px;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    animation: popIn 0.15s ease-out;
}

.helper-key:active {
    opacity: 0.8;
}

@keyframes popIn {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

#keyboard-container {
    padding: 10px 5px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 8px;
}

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

.kb-key {
    background-color: var(--key-bg);
    color: var(--text-color);
    border: none;
    border-radius: 4px;
    height: 58px;
    flex: 1;
    min-width: 0;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    -webkit-tap-highlight-color: transparent;
    padding: 6px 0 2px 0;
}

.kb-key.action {
    flex: 1.5;
    font-size: 0.9rem;
    font-weight: bold;
    justify-content: center; 
}

.kb-key:active {
    opacity: 0.7;
}

.kb-top {
    font-size: 1.2rem;
    font-weight: bold;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
}

.kb-bot {
    font-size: 0.75rem;
    color: #eee;
    border-top: 1px solid #999;
    width: 95%;
    min-height: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: normal;
    letter-spacing: 1px;
    margin-top: 2px;
    white-space: nowrap;
}

.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: #2a2a2c;
    padding: 25px 20px;
    border-radius: 8px;
    text-align: center;
    max-width: 90%;
    min-width: 300px;
    border: 1px solid var(--tile-border);
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    max-height: 80vh;
}

.modal-content h3 {
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.modal-content p {
    margin-bottom: 20px;
    line-height: 1.4;
    white-space: pre-wrap;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: space-between;
    margin-top: 10px;
}

.scrollable-list {
    display: none;
    max-height: 40vh;
    overflow-y: auto;
    background: #1e1e1f;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    text-align: center;
    border: 1px solid #444;
}

.answer-pair {
    padding: 8px 0;
    font-family: monospace;
    font-size: 1.2rem;
    letter-spacing: 2px;
}

.target-pair {
    color: var(--valid-color);
    font-weight: bold;
}

.scrollable-list hr {
    border: 0;
    height: 1px;
    background: #444;
    margin: 10px 0;
}
