* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    background-color: #121213;
    color: #ffffff;
    font-family: 'Roboto', sans-serif;
}

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 16px;
}

header {
    width: 100%;
    max-width: 800px;
    padding: 16px 0 12px;
    text-align: center;
    border-bottom: 1px solid #3a3a3c;
    margin-bottom: 24px;
}

header {
    position: relative;
}

header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

#help-btn {
    position: absolute;
    top: 50%;
    right: 16px;
    transform: translateY(-50%);
    background: transparent;
    border: 2px solid #818384;
    border-radius: 50%;
    color: #ffffff;
    font-size: 1rem;
    font-weight: 700;
    width: 32px;
    height: 32px;
    cursor: pointer;
    line-height: 1;
    transition: border-color 0.1s ease, background-color 0.1s ease;
}

#help-btn:hover {
    border-color: #ffffff;
    background-color: #1a1a1b;
}

#tutorial-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 100;
    justify-content: center;
    align-items: center;
}

#tutorial-overlay.open {
    display: flex;
}

#tutorial-dialog {
    position: relative;
    background-color: #1a1a1b;
    border: 1px solid #3a3a3c;
    border-radius: 12px;
    padding: 32px 28px 28px;
    max-width: 380px;
    width: 90%;
    color: #ffffff;
}

#tutorial-dialog h2 {
    font-size: 1.1rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 20px;
    text-align: center;
}

#tutorial-dialog ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0;
}

#tutorial-dialog ul li {
    font-size: 0.9rem;
    line-height: 1.5;
    color: #d7dadb;
    padding-left: 16px;
    position: relative;
}

#tutorial-dialog ul li::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: #538d4e;
}

#tutorial-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: transparent;
    border: none;
    color: #818384;
    font-size: 1rem;
    cursor: pointer;
    line-height: 1;
}

#tutorial-close:hover {
    color: #ffffff;
}

#word-input {
    background: #121213;
    border: 2px solid #3a3a3c;
    border-radius: 6px;
    color: #ffffff;
    font-family: 'Roboto', sans-serif;
    font-size: 1rem;
    padding: 8px 14px;
    outline: none;
    width: 100%;
    text-align: center;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

#word-input:focus {
    border-color: #818384;
}

#input-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: min(400px, 100%);
    gap: 6px;
    margin-bottom: 24px;
}

#combo-wrapper {
    position: relative;
    width: 100%;
}

#combo-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background-color: #1a1a1b;
    border: 1px solid #3a3a3c;
    border-radius: 6px;
    max-height: 240px;
    overflow-y: auto;
    z-index: 50;
}

.combo-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    color: #d7dadb;
    text-transform: uppercase;
}

.combo-option:hover {
    background-color: #2a2a2b;
}

.combo-option .opt-emoji {
    font-size: 1.4rem;
    line-height: 1;
}

#emoji-selected {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 6px 14px;
    border: 2px solid #538d4e;
    border-radius: 6px;
    background: #121213;
    width: 100%;
}

#selected-emoji-display {
    font-size: 2rem;
    line-height: 1;
}

#selected-name-display {
    font-size: 0.8rem;
    color: #d7dadb;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    flex: 1;
    text-align: center;
}

#clear-selection {
    background: transparent;
    border: none;
    color: #818384;
    font-size: 0.9rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

#clear-selection:hover {
    color: #ffffff;
}

label[for="word-input"] {
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: #818384;
    text-transform: uppercase;
}

#table-show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.cell-score {
    position: absolute;
    top: 4px;
    left: 5px;
    font-size: 0.55rem;
    font-weight: 700;
    color: #818384;
    line-height: 1;
    transition: color 0.3s ease;
    pointer-events: none;
}

table {
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 5px;
    width: min(400px, 100%);
    height: min(400px, calc(100vw - 32px));
}

table td {
    position: relative;
}

.cell-input {
    position: absolute;
    inset: 0;
    border: 2px solid #3a3a3c;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    cursor: pointer;
    touch-action: manipulation;
    transition: background-color 0.1s ease, border-color 0.1s ease;
}

.cell-input:hover {
    border-color: #818384;
    background-color: #1a1a1b;
}

.cell-input.aoe-highlight {
    background-color: #1a1a1b;
}

.cell-input .emoji {
    margin: 0;
    font-size: 2em;
    line-height: 1;
}

@keyframes emoji-pop {
    0%   { transform: scale(0.5); opacity: 0; }
    70%  { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1);   opacity: 1; }
}

.cell-input .emoji.pop {
    animation: emoji-pop 0.3s ease-out forwards;
}

.cell-input .emoji-label {
    margin: 0;
    font-size: 0.55em;
    text-align: center;
    color: #d7dadb;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

#toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #ffffff;
    color: #121213;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 10px 20px;
    border-radius: 6px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 200;
}

#toast.show {
    opacity: 1;
}

#similarity-label {
    margin-top: 16px;
    font-size: 1rem;
    letter-spacing: 0.08em;
    color: #818384;
}

#similarity-label #similarity-value {
    color: #ffffff;
    font-weight: 700;
}

#endgame-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.75);
    z-index: 100;
    justify-content: center;
    align-items: center;
}

#endgame-overlay.open {
    display: flex;
}

#endgame-dialog {
    background-color: #1a1a1b;
    border: 1px solid #3a3a3c;
    border-radius: 12px;
    padding: 36px 32px 28px;
    max-width: 340px;
    width: 90%;
    color: #ffffff;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

#endgame-title {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

#endgame-reason {
    font-size: 0.95rem;
    color: #d7dadb;
    line-height: 1.5;
}

#endgame-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    width: 136px;
}

#endgame-grid span {
    font-size: 1.4rem;
    line-height: 1;
    text-align: center;
}

#endgame-score {
    font-size: 0.85rem;
    color: #818384;
    letter-spacing: 0.08em;
}

#share-btn {
    margin-top: 8px;
    background-color: #538d4e;
    border: none;
    border-radius: 6px;
    color: #ffffff;
    font-family: 'Roboto', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 10px 24px;
    cursor: pointer;
    touch-action: manipulation;
    text-transform: uppercase;
    transition: background-color 0.15s ease;
}

#share-btn:hover {
    background-color: #6aaf65;
}

#copy-confirm {
    display: none;
    font-size: 0.8rem;
    color: #538d4e;
    font-weight: 700;
    letter-spacing: 0.08em;
}

/* Wordle state colors */
.cell-input.correct {
    /* background-color: #538d4e; */
    border-color: #538d4e;
}

.cell-input.present {
    /* background-color: #b59f3b; */
    border-color: #b59f3b;
}

.cell-input.absent {
    /* background-color: #3a3a3c; */
    border-color: #3a3a3c;
}
