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

:root {
    --bg-color: #181826;
    --card-bg: #34344F;
    --text-color: #FFFFFF;
    --text-secondary: #B8B8B8;
    --active-color: #F5C139;
    --active-text: #000000;
    --success-color: #50C878;
    --error-color: #E74C3C;
    --primary-color: #4A90E2;
    --border-color: #2D3561;
}

html {
    overflow-y: hidden;
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    min-height: 100dvh;
    max-height: 1000px;
    overflow-x: hidden;
    overflow-y: hidden;
}

.container {
    width: 100%;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    margin: 0 auto;
    padding-top: env(safe-area-inset-top);
}

/* Logo */
.logo-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0;
    background: var(--bg-color);
    gap: 12px;
}

.page-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-color);
    text-align: center;
    margin: 0;
}

.logo {
    max-width: 180px;
    height: auto;
    width: 100%;
}

.logo-link {
    display: inline-block;
    cursor: pointer;
    text-decoration: none;
}

.logo-link:hover {
    opacity: 0.8;
}

/* Header */
.game-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px 20px;
    background: var(--bg-color);
    border-bottom: none;
    border-image: none;
    width: 100%;
}

.game-header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 410px;
}

.btn-exit {
    background: transparent;
    border: none;
    color: var(--text-color);
    font-size: 16px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background 0.2s;
}

.btn-exit:hover {
    background: var(--card-bg);
}

.btn-reset {
    background: transparent;
    border: none;
    color: var(--text-color);
    font-size: 16px;
    cursor: pointer;
    padding: 0;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-reset .tries-counter {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 400;
}

.btn-reset .reset-icon {
    width: 18px;
    height: 18px;
    vertical-align: middle;
}

.coins-display, .hearts-display {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 16px;
    font-weight: 500;
}

/* Words Found Counter Button */
.words-found-wrapper {
    position: relative;
}

.words-found-counter {
    background: transparent;
    border: none;
    color: var(--text-color);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
    width: fit-content;
    white-space: nowrap;
}

.words-found-counter:hover {
    background: var(--card-bg);
}

.words-found-counter .accordion-icon {
    width: 16px;
    height: 16px;
    transition: transform 0.3s;
    flex-shrink: 0;
}

.words-found-counter.expanded .accordion-icon {
    transform: rotate(180deg);
}

/* Words Found Accordion */
.words-found-accordion {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--card-bg);
    border-radius: 12px;
    padding: 16px;
    min-width: 280px;
    max-width: 400px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 100;
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    transition: all 0.3s;
    max-height: 0;
    overflow: hidden;
}

.words-found-accordion.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
    max-height: 500px;
}

.accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

.accordion-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.accordion-close:hover {
    background: var(--bg-color);
    color: var(--text-color);
}

.accordion-close svg {
    width: 18px;
    height: 18px;
}

.accordion-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.words-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.words-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 4px;
}

.no-words-message {
    color: var(--text-color);
    font-size: 14px;
    font-style: italic;
}

.coins-icon {
    font-size: 20px;
}


/* Main Game Area */
.game-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 0 20px 0;
    width: 100%;
}

/* Letter Grid */
.letter-grid-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    margin: 0;
    padding: 24px 0;
    overflow-y: auto;
    overflow-x: hidden;
    max-width: none;
}

.letter-row-container {
    width: 100%;
    overflow: visible;
    position: relative;
    cursor: grab;
}

.letter-row-container:active {
    cursor: grabbing;
}

.letter-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    padding: 0;
    will-change: transform;
    transition: transform 0s ease-out;
}

.letter-button {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    color: var(--text-color);
    border-radius: 4px;
    font-size: 22px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    scroll-snap-align: center;
    margin: 0;
    padding: 0;
    border: none;
}


.letter-button.active {
    background: var(--active-color);
    color: var(--active-text);
    font-weight: 700;
    border-radius: 4px;
    margin: 0;
    padding: 0;
}

.empty-grid {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px;
}

/* Game Controls */
.game-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 0;
    padding: 0 20px;
    padding-bottom: 20px;
}

/* Found Words List (in accordion) */
.words-found-accordion .found-words-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
    align-items: center;
}

.words-found-accordion .found-word {
    color: var(--text-color);
    font-size: 14px;
    font-weight: 400;
}

/* Ensure all text in accordion is white */
.words-found-accordion {
    color: var(--text-color);
}

.result-banner {
    text-align: center;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
}

.result-banner.show {
    opacity: 1;
    transform: translateY(0);
}

.result-banner.success {
    background: transparent;
    color: var(--success-color);
}

.result-banner.error {
    background: transparent;
    color: var(--error-color);
}

.result-banner.info {
    background: var(--primary-color);
    color: white;
}

.btn-progress {
    width: 100%;
    padding: 14px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-progress:hover:not(:disabled) {
    background: #357ABD;
    transform: translateY(-2px);
}

.btn-progress:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* Submitted Words */
.submitted-words {
    margin-top: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
}

.submitted-words h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.words-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    min-height: 30px;
}

.word-badge {
    padding: 6px 12px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 16px;
    font-weight: 600;
    font-size: 0.85rem;
    color: white;
    animation: slideIn 0.3s ease;
}

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

.btn-action {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px;
    background: var(--card-bg);
    color: var(--text-color);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.btn-action:hover:not(:disabled) {
    background: #3D3D5F;
    /* transform: translateY(-2px); */
}

.btn-action:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-action.btn-confirm {
    background: white;
    color: var(--bg-color);
    max-width: 410px;
    padding: 0 48px;
    height: 42px;
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-action.btn-confirm:hover:not(:disabled) {
    background: #f0f0f0;
}

.btn-icon {
    font-size: 20px;
}

.btn-label {
    font-weight: 600;
    font-size: 18px;
    text-transform: uppercase;
}

.btn-cost {
    font-size: 10px;
    opacity: 0.8;
}

/* Game Over Modal */
.game-over-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s;
    /* Safe area insets for iPhone */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

.game-over-modal.show {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.3s;
}

.game-over-modal.show .modal-content {
    transform: scale(1);
}

.modal-content h2 {
    margin-bottom: 16px;
    font-size: 24px;
}

.modal-content p {
    margin-bottom: 24px;
    color: var(--text-secondary);
    white-space: pre-line;
}

.modal-buttons {
    display: flex;
    gap: 12px;
}

.btn-modal {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-modal:first-child {
    background: var(--primary-color);
    color: white;
}

.btn-modal:first-child:hover {
    background: #357ABD;
}

.btn-modal:last-child {
    background: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-modal:last-child:hover {
    background: #3D3D5F;
}

/* Update Modal */
.update-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s;
    /* Safe area insets for iPhone */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

.update-modal.show {
    opacity: 1;
    pointer-events: all;
}

.update-modal.show .modal-content {
    transform: scale(1);
}

/* Completion Modal */
.completion-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    /* Safe area insets for iPhone */
    padding-top: 16px;
    padding-bottom: 16px;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s;
}

.completion-modal.show {
    opacity: 1;
    pointer-events: all;
}


/* Completion Page Styles */
.completion-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    min-height: calc(100dvh - 57px);
}

.completion-title {
    font-size: 32px;
    font-weight: 700;
    color: var(--active-color);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.completion-title.completion-title-spaced {
    margin-top: 40px;
}

.completion-title .confetti-icon {
    width: 32px;
    height: 32px;
    vertical-align: middle;
}

.completion-message {
    font-size: 18px;
    color: var(--text-color);
    margin-bottom: 40px;
    opacity: 0.9;
}

.words-section {
    width: 100%;
    max-width: 400px;
    margin-bottom: 0px;
}

.words-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 20px;
}

.completion-content .words-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    align-items: center;
}

.completion-content .word-badge {
    padding: 8px 16px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 20px;
    font-weight: 600;
    font-size: 16px;
    color: white;
}

.completion-actions {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.completion-actions-divider {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin: 4px 0;
}

.btn-share,
.btn-back,
.btn-reset {
    width: 100%;
    padding: 14px;
}

/* Responsive logo */
@media (max-width: 450px) {
    .logo {
        width: 100%;
        height: auto;
    }
}

/* Landing Page */
.landing-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    gap: 40px;
}

.how-to-play {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.how-to-play-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 20px;
    text-align: center;
}

.instructions {
    color: var(--text-secondary);
    font-size: 16px;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.instructions p {
    margin-bottom: 16px;
    text-align: center;
}

.instructions-list {
    list-style: none;
    padding: 0;
    margin: 0 auto;
    max-width: 340px;
    width: 100%;
}

.instructions-list li {
    padding: 4px 0;
    padding-left: 24px;
    position: relative;
    color: var(--text-color);
}

.instructions-list li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    background-image: url('img/arrow-right.svg');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.play-button-container {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.btn-play {
    display: inline-block;
    padding: 16px 48px;
    background: var(--active-color);
    color: var(--active-text);
    font-size: 20px;
    font-weight: 700;
    text-decoration: none;
    border-radius: 8px;
    text-align: center;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
}

.btn-play:hover {
    background: #E5B132;
}

.offline-message {
    color: var(--text-secondary);
    font-size: 14px;
    text-align: center;
    margin: 0;
    padding: 0;
}

/* Footer */
.page-footer {
    text-align: center;
    padding: 20px;
    padding-bottom: 20px;
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: auto;
}

.page-footer a {
    color: var(--active-color);
    text-decoration: none;
    transition: opacity 0.2s;
}

.page-footer a:hover {
    opacity: 0.8;
}

/* Touch device optimizations */
@media (hover: none) {
    .letter-button:hover {
        transform: none;
    }

    .letter-button.active {
        transform: none;
    }
}

