/* kalimle - Minimalist Wordle-style CSS */

:root {
    /* Colors */
    --bg-color: #121213;
    --tile-bg: #3a3a3c;
    --tile-border: #565758;
    --tile-correct: #538d4e;
    --tile-present: #b59f3b;
    --tile-absent: #3a3a3c;
    --text-color: #ffffff;
    --text-secondary: #818384;
    --card-bg: #1a1a1b;
    --error-color: #e74c3c;
    --success-color: #538d4e;

    /* Sizing */
    --tile-size: 62px;
    --tile-gap: 5px;
    --tile-font-size: 2rem;
    --container-max-width: 540px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Clear Sans', 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    width: 100%;
    max-width: var(--container-max-width);
    padding: 0;
    padding-top: 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

/* Navbar - Wordle Style */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0 16px;
    height: 52px;
    border-bottom: 1px solid var(--tile-border);
    background: var(--bg-color);
    z-index: 100;
}

.nav-left,
.nav-right {
    display: flex;
    gap: 8px;
    flex: 1;
}

.nav-right {
    justify-content: flex-end;
}

.nav-center {
    flex: 0 0 auto;
    text-align: center;
}

.navbar h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.05rem;
    margin: 0;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.15s ease;
}

.icon-btn:hover {
    background: var(--tile-bg);
}

/* Main Content */
main {
    width: 100%;
    max-width: var(--container-max-width);
    padding: 0 16px;
    padding-top: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

/* Sentence Card */
.sentence-card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 16px 20px;
    text-align: center;
    width: 100%;
    border: 1px solid var(--tile-border);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.sentence-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

.sentence {
    font-size: 1.1rem;
    line-height: 1.5;
    margin-bottom: 8px;
    font-weight: 500;
}

.hint {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.hint strong {
    color: var(--tile-correct);
    font-weight: 700;
}

/* Error Message */
.error-message {
    background: rgba(231, 76, 60, 0.15);
    border: 2px solid var(--error-color);
    color: var(--error-color);
    padding: 14px 20px;
    border-radius: 10px;
    text-align: center;
    width: 100%;
    font-weight: 500;
    animation: shake 0.4s ease;
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.3);
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-10px);
    }

    75% {
        transform: translateX(10px);
    }
}

/* Guesses Container */
.guesses-container {
    display: flex;
    flex-direction: column;
    gap: var(--tile-gap);
    padding: 4px 0;
}

.guess-row {
    display: flex;
    gap: var(--tile-gap);
    justify-content: center;
    direction: rtl;
}

/* Tiles */
.tile {
    width: var(--tile-size);
    height: var(--tile-size);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: var(--tile-font-size);
    font-weight: 700;
    border-radius: 6px;
    text-transform: uppercase;
    transition: transform 0.1s ease, background-color 0.3s ease;
    user-select: none;
}

.tile.empty {
    border: 2px solid var(--tile-border);
    background-color: transparent;
    transition: border-color 0.2s ease;
}

.tile.empty:hover {
    border-color: var(--text-secondary);
}

.tile.correct {
    background-color: var(--tile-correct);
    border: none;
    animation: flip 0.5s ease;
    box-shadow: 0 2px 4px rgba(83, 141, 78, 0.4);
}

.tile.present {
    background-color: var(--tile-present);
    border: none;
    animation: flip 0.5s ease;
    box-shadow: 0 2px 4px rgba(181, 159, 59, 0.4);
}

.tile.absent {
    background-color: var(--tile-absent);
    border: none;
    animation: flip 0.5s ease;
}

@keyframes flip {
    0% {
        transform: rotateX(0);
    }

    50% {
        transform: rotateX(90deg);
    }

    100% {
        transform: rotateX(0);
    }
}

@keyframes pop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

/* Game Result */
.game-result {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 28px;
    text-align: center;
    width: 100%;
    border: 2px solid var(--tile-border);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
    animation: slideIn 0.5s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.game-result.win {
    border-color: var(--success-color);
    box-shadow: 0 8px 20px rgba(83, 141, 78, 0.3);
}

.game-result.lose {
    border-color: var(--error-color);
    box-shadow: 0 8px 20px rgba(231, 76, 60, 0.3);
}

.game-result h2 {
    font-size: 2rem;
    margin-bottom: var(--spacing-md);
    animation: bounce 0.6s ease;
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-20px);
    }

    60% {
        transform: translateY(-10px);
    }
}

.answer-reveal {
    margin-top: 24px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.answer-reveal h3 {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.answer-word {
    font-size: 3rem;
    font-weight: 700;
    color: var(--tile-correct);
    margin-bottom: 12px;
}

.pronunciation {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 8px;
}

.example {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-style: italic;
}

.share-section {
    margin-top: 24px;
}

.next-puzzle-info {
    margin-top: 16px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Form */
.guess-form {
    width: 100%;
    max-width: 380px;
}

.input-group {
    display: flex;
    gap: 10px;
    align-items: stretch;
    margin-bottom: 2px;
}

.guess-input {
    flex: 1;
    padding: 16px 18px;
    font-size: 1.25rem;
    border: 2px solid var(--tile-border);
    border-radius: 10px;
    background: var(--card-bg);
    color: var(--text-color);
    outline: none;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.guess-input:focus {
    border-color: var(--tile-correct);
    box-shadow: 0 0 0 3px rgba(83, 141, 78, 0.2);
    transform: translateY(-1px);
}

.guess-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.remaining {
    text-align: center;
    margin-top: var(--spacing-md);
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
}

/* Buttons */
.btn {
    padding: 16px 28px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    font-family: inherit;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-submit {
    background-color: var(--tile-correct);
    color: white;
    padding: 16px 24px;
}

.btn-submit:hover {
    background-color: #4a7d45;
}

.btn-share {
    background-color: var(--tile-correct);
    color: white;
    padding: 18px 36px;
    font-size: 1.1rem;
}

.btn-share:hover {
    background-color: #4a7d45;
}

.btn-reset {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--tile-border);
    padding: 10px 20px;
    font-size: 0.9rem;
}

.btn-reset:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-color);
    color: var(--text-color);
}

/* Legend */
.legend {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    width: 100%;
    margin-top: var(--spacing-md);
    border: 1px solid var(--tile-border);
}

.legend h4 {
    text-align: center;
    margin-bottom: var(--spacing-md);
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.legend-items {
    display: flex;
    justify-content: center;
    gap: 28px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    transition: transform 0.2s ease;
}

.legend-item:hover {
    transform: scale(1.05);
}

.tile-example {
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.3rem;
    font-weight: 700;
    border-radius: 6px;
}

.tile-example.correct {
    background-color: var(--tile-correct);
    box-shadow: 0 2px 4px rgba(83, 141, 78, 0.4);
}

.tile-example.present {
    background-color: var(--tile-present);
    box-shadow: 0 2px 4px rgba(181, 159, 59, 0.4);
}

.tile-example.absent {
    background-color: var(--tile-absent);
}

.legend-item span {
    font-size: 0.9rem;
    color: var(--text-color);
    font-weight: 500;
}

/* Footer */
footer {
    margin-top: auto;
    padding-top: 40px;
    padding-bottom: 24px;
    text-align: center;
    width: 100%;
}

footer p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 0;
    font-weight: 400;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    animation: fadeIn 0.2s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--card-bg);
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    animation: slideIn 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--tile-border);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.15s ease;
    line-height: 1;
}

.close-btn:hover {
    background: var(--tile-bg);
}

.modal-body {
    padding: 24px;
}

.modal-description {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.5;
}

.modal-section {
    margin-bottom: 24px;
}

.modal-section:last-child {
    margin-bottom: 0;
}

.modal-section h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-color);
}

.modal-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.modal-section li {
    padding: 8px 0;
    color: var(--text-color);
    line-height: 1.5;
    position: relative;
    padding-left: 20px;
}

.modal-section li:before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--tile-correct);
    font-weight: bold;
}

.modal-section p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 8px 0;
}

.note-small {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 8px;
}

.example-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--tile-border);
}

.example-row:last-child {
    border-bottom: none;
}

.example-text {
    flex: 1;
}

.example-text strong {
    display: block;
    margin-bottom: 4px;
    color: var(--text-color);
}

.example-text p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Animation delays for tiles */
.guess-row.submitted .tile:nth-child(1) {
    animation-delay: 0s;
}

.guess-row.submitted .tile:nth-child(2) {
    animation-delay: 0.1s;
}

.guess-row.submitted .tile:nth-child(3) {
    animation-delay: 0.2s;
}

.guess-row.submitted .tile:nth-child(4) {
    animation-delay: 0.3s;
}

.guess-row.submitted .tile:nth-child(5) {
    animation-delay: 0.4s;
}

.guess-row.submitted .tile:nth-child(6) {
    animation-delay: 0.5s;
}

.guess-row.submitted .tile:nth-child(7) {
    animation-delay: 0.6s;
}

.guess-row.submitted .tile:nth-child(8) {
    animation-delay: 0.7s;
}

/* On-Screen Keyboard */
.keyboard {
    width: 100%;
    max-width: 540px;
    margin: 0 auto;
    margin-top: 8px;
    padding: 0 8px;
    user-select: none;
    touch-action: manipulation;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-bottom: 6px;
    direction: rtl;
}

.keyboard-row-bottom {
    width: 100%;
    padding: 0;
    direction: ltr;
    gap: 0;
    justify-content: space-between;
}

.key {
    font-family: inherit;
    font-weight: 600;
    border: none;
    padding: 0;
    min-width: 40px;
    height: 56px;
    border-radius: 6px;
    cursor: pointer;
    background-color: var(--tile-border);
    color: var(--text-color);
    font-size: 1.15rem;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.15s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.key:hover {
    background-color: #6a6a6c;
    transform: scale(1.05);
}

.key:active {
    transform: scale(0.95);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.key-wide {
    min-width: 68px;
    width: 68px;
    font-size: 0.85rem;
    padding: 0 12px;
    font-weight: 700;
}

.key.correct {
    background-color: var(--tile-correct);
    box-shadow: 0 2px 4px rgba(83, 141, 78, 0.4);
}

.key.correct:hover {
    background-color: #4a7d45;
}

.key.present {
    background-color: var(--tile-present);
    box-shadow: 0 2px 4px rgba(181, 159, 59, 0.4);
}

.key.present:hover {
    background-color: #a08d34;
}

.key.absent {
    background-color: #3a3a3c;
    color: var(--text-secondary);
}

/* Responsive Design */
@media (max-width: 500px) {
    :root {
        --tile-size: 56px;
        --tile-font-size: 1.8rem;
        --spacing-sm: 6px;
        --spacing-md: 12px;
        --spacing-lg: 18px;
    }

    .container {
        padding: var(--spacing-sm);
    }

    header h1 {
        font-size: 1.9rem;
        letter-spacing: 0.05rem;
    }

    .subtitle {
        font-size: 0.85rem;
    }

    .sentence-card {
        padding: 18px;
    }

    .sentence {
        font-size: 1.15rem;
        line-height: 1.6;
    }

    .guess-input {
        padding: 14px 16px;
        font-size: 1.1rem;
    }

    .btn-submit {
        padding: 14px 20px;
        font-size: 0.95rem;
    }

    .game-result {
        padding: 20px;
    }

    .game-result h2 {
        font-size: 1.6rem;
    }

    .answer-word {
        font-size: 2.5rem;
    }

    .legend-items {
        gap: 16px;
    }

    .keyboard {
        max-width: 100%;
        padding: 0 4px;
        margin-top: 6px;
    }

    .key {
        min-width: 30px;
        height: 48px;
        font-size: 1.1rem;
        flex: 1;
    }

    .key-wide {
        width: calc((30px * 2) + 4px);
        min-width: 64px;
        flex: none;
        font-size: 0.75rem;
        padding: 0 10px;
    }

    .keyboard-row {
        gap: 4px;
        margin-bottom: 5px;
    }
}

@media (max-width: 380px) {
    :root {
        --tile-size: 50px;
        --tile-font-size: 1.6rem;
    }

    header h1 {
        font-size: 1.7rem;
    }

    .sentence {
        font-size: 1rem;
    }

    .legend-items {
        flex-direction: column;
        align-items: flex-start;
    }

    .guess-input {
        font-size: 1rem;
    }

    .key {
        min-width: 26px;
        height: 44px;
        font-size: 0.95rem;
        flex: 1;
    }

    .key-wide {
        width: calc((26px * 2) + 3px);
        min-width: 55px;
        flex: none;
        font-size: 0.68rem;
        padding: 0 8px;
    }

    .keyboard-row {
        gap: 3px;
        margin-bottom: 4px;
    }
}

/* Tablet and Desktop */
@media (min-width: 768px) {
    :root {
        --tile-size: 68px;
        --tile-font-size: 2.2rem;
        --container-max-width: 600px;
    }

    main {
        padding-top: 16px;
    }

    header h1 {
        font-size: 2.5rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .sentence-card {
        padding: 28px 32px;
    }

    .sentence {
        font-size: 1.5rem;
    }

    .guess-input {
        font-size: 1.35rem;
        padding: 18px 20px;
    }

    .game-result {
        padding: 32px;
    }

    .answer-word {
        font-size: 3.5rem;
    }

    .keyboard {
        max-width: 580px;
    }

    .key {
        min-width: 46px;
        height: 60px;
        font-size: 1.25rem;
    }

    .key-wide {
        min-width: 75px;
        font-size: 0.9rem;
    }
}

/* Touch device improvements */
@media (hover: none) and (pointer: coarse) {
    .btn {
        padding: 18px 30px;
        min-height: 48px;
    }

    .key {
        min-height: 48px;
    }

    .guess-input {
        min-height: 52px;
    }
}