@import url('https://fonts.googleapis.com/css2?family=Rubik:wght@400;500;700&display=swap');

:root {
    /* Light Theme (Default for Wordlegame.org clone) */
    --bg-color: #ffffff;
    --text-color: #363e52;
    --tile-correct: #79b851;
    --tile-present: #f3c237;
    --tile-absent: #a4aec4;
    --tile-empty-bg: #fbfcff;
    --tile-empty-border: #c0c5d3;
    --tile-tbd-border: #6d7385;
    --key-bg: #dce1ed;
    --key-text: #414a5e;
    --key-hover: #c4cbdd;
    --key-active: #b1b9ce;
    --modal-bg: #ffffff;
    --overlay-bg: rgba(255, 255, 255, 0.7);
    --border-color: #e9edf7;
    --toast-bg: #363e52;
    --toast-text: #ffffff;
}

[data-theme="dark"] {
    --bg-color: #2b2d3c;
    --text-color: #6e7b98;
    --tile-correct: #79b851;
    --tile-present: #f3c237;
    --tile-absent: #3d4054;
    --tile-empty-bg: #191a24;
    --tile-empty-border: #666a85;
    --tile-tbd-border: #7b7f98;
    --key-bg: #656780;
    --key-text: #ffffff;
    --key-hover: #787a94;
    --key-active: #9496ae;
    --modal-bg: #2b2d3c;
    --overlay-bg: rgba(0, 0, 0, 0.7);
    --border-color: #40445c;
    --toast-bg: #ffffff;
    --toast-text: #000000;
}

[data-theme-hc="true"] {
    --tile-correct: #f17e2d;
    --tile-present: #3f94e9;
}

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

body {
    font-family: 'Rubik', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    outline: none;
}

/* ================= NAVBAR ================= */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    height: 65px;
    border-bottom: 1px solid var(--border-color);
}

.nav-left, .nav-right {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 80px;
}
.nav-right {
    justify-content: flex-end;
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: background-color 0.2s;
    color: var(--text-color);
}
.icon-btn:hover {
    background-color: var(--border-color);
}
.icon-btn svg {
    width: 24px;
    height: 24px;
}

.nav-brand {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    cursor: pointer;
    color: var(--text-color);
}

.logo-tile {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 24px;
    height: 24px;
    margin-right: 2px;
    font-size: 1.2rem;
    color: white;
    border-radius: 2px;
}
.logo-tile.correct { background-color: var(--tile-correct); }
.logo-tile.present { background-color: var(--tile-present); }

/* ================= MAIN CONTAINER ================= */
#app-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.view {
    display: none;
    flex-direction: column;
    flex-grow: 1;
    width: 100%;
}
.view.active {
    display: flex;
}

/* ================= HOMEPAGE ================= */
.hero {
    text-align: center;
    padding: 40px 20px;
}
.animated-wordle {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-bottom: 20px;
}
.animated-wordle .tile {
    width: 64px;
    height: 64px;
    font-size: 28px;
    border-radius: 0;
    animation: bounce 2s infinite ease-in-out;
}
.subtitle {
    font-size: 1.1rem;
    color: var(--text-color);
    opacity: 0.8;
}

.cta-cards {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 0 20px;
}
.card {
    display: flex;
    align-items: center;
    padding: 20px;
    border-radius: 8px;
    background-color: var(--border-color);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.card-icon {
    font-size: 2.5rem;
    margin-right: 16px;
}
.card-content h3 {
    font-size: 1.2rem;
    margin-bottom: 4px;
    font-weight: 700;
}
.card-content p {
    font-size: 0.9rem;
    opacity: 0.8;
}

footer {
    margin-top: auto;
    padding: 20px;
    text-align: center;
    display: flex;
    justify-content: center;
    gap: 16px;
}
footer a {
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.9rem;
    opacity: 0.6;
}
footer a:hover {
    opacity: 1;
}

/* ================= GAME VIEW ================= */
.game-mode-toggle {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}
.mode-btn {
    background-color: var(--border-color);
    color: var(--text-color);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 700;
    opacity: 0.7;
    transition: 0.2s;
}
.mode-btn.active {
    background-color: var(--tile-correct);
    color: white;
    opacity: 1;
}

.game-header {
    text-align: center;
    padding: 5px 0 10px;
}
.game-header h2 {
    display: none; /* Removed from view, handled by toggles now */
}
.game-subtitle {
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.8;
    margin-top: 4px;
    min-height: 20px;
}
.length-selector select {
    background-color: var(--border-color);
    color: var(--text-color);
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.9rem;
}

.board-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-grow: 1;
    overflow: hidden;
}
.board {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 10px;
    box-sizing: border-box;
}
.board-row {
    display: grid;
    grid-gap: 5px;
}

.tile {
    width: 64px;
    height: 64px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    font-family: 'Rubik', sans-serif;
    font-size: 28px;
    font-weight: 700;
    text-transform: uppercase;
    border: 2px solid var(--tile-empty-border);
    background-color: var(--tile-empty-bg);
    color: var(--text-color);
    user-select: none;
}
.tile[data-state="tbd"] {
    border-color: var(--tile-tbd-border);
}
.tile[data-state="correct"] {
    background-color: var(--tile-correct);
    border-color: var(--tile-correct);
    color: white;
}
.tile[data-state="present"] {
    background-color: var(--tile-present);
    border-color: var(--tile-present);
    color: white;
}
.tile[data-state="absent"] {
    background-color: var(--tile-absent);
    border-color: transparent;
    color: white;
}

/* ================= KEYBOARD ================= */
.keyboard-container {
    padding: 0 8px 8px;
    user-select: none;
    margin: 32px 0 20px;
}
.keyboard-row {
    display: flex;
    width: 100%;
    margin: 0 auto 6px;
    touch-action: manipulation;
}
.key {
    font-family: inherit;
    font-weight: 700;
    border: 2px solid transparent;
    padding: 3px;
    margin: 3px;
    min-height: 54px;
    border-radius: 4px;
    cursor: pointer;
    background-color: var(--key-bg);
    color: var(--key-text) !important;
    flex: 1 1;
    display: flex;
    justify-content: center;
    align-items: center;
    text-transform: capitalize;
    font-size: 18px;
    transition: .2s;
    -webkit-tap-highlight-color: rgba(0,0,0,0.3);
}
.key-large {
    flex: 2 1;
    font-size: 16px;
}
.key:hover {
    background-color: var(--key-hover);
}
.key:active {
    background-color: var(--key-active);
}
.key[data-state="correct"] { background-color: var(--tile-correct); color: white !important; }
.key[data-state="present"] { background-color: var(--tile-present); color: white !important; }
.key[data-state="absent"] { background-color: var(--tile-absent); color: white !important; }

/* ================= HOW TO PLAY ================= */
.how-to-play-section {
    padding: 30px 16px;
    margin-top: 30px;
    border-top: 1px solid var(--border-color);
    font-size: 1rem;
    line-height: 1.6;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    color: var(--text-color);
}
.how-to-play-section h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 12px;
}
.how-to-play-section h3 {
    font-size: 1.1rem;
    font-weight: 400;
    margin-bottom: 16px;
}
.how-to-play-section ul {
    margin-left: 20px;
    margin-bottom: 24px;
}
.how-to-play-section li {
    margin-bottom: 8px;
}
.examples-title {
    font-size: 1.1rem;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}
.example-block {
    margin-bottom: 24px;
}
.example-block p {
    margin-top: 10px;
    font-size: 0.95rem;
}
.example-row {
    display: flex;
    gap: 6px;
}
.example-row .tile {
    width: 48px;
    height: 48px;
    font-size: 1.8rem;
}

/* ================= SOCIAL SHARE ================= */
.social-share-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 16px 0;
    margin-top: 10px;
    border-top: 1px solid var(--border-color);
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
}
.share-text {
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-color);
}
.share-buttons {
    display: flex;
    gap: 12px;
}
.share-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    color: white;
    text-decoration: none;
    transition: transform 0.2s, opacity 0.2s;
}
.share-btn:hover {
    transform: scale(1.05);
    opacity: 0.9;
}
.share-btn.facebook { background-color: #1877F2; }
.share-btn.twitter { background-color: #000000; }
.share-btn.whatsapp { background-color: #25D366; }

/* ================= LANGUAGE SELECTION ================= */
.language-section {
    padding: 30px 16px;
    max-width: 800px;
    margin: 40px auto 20px;
    text-align: center;
}
.language-section h2 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--text-color);
}
.language-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}
.lang-btn {
    display: flex;
    align-items: center;
    background-color: #dce5f7;
    color: #363e52;
    padding: 12px 16px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: background-color 0.2s, transform 0.2s;
    justify-content: flex-start;
}
.lang-btn:hover {
    background-color: #c4d4f2;
    transform: translateY(-2px);
}
[data-theme="dark"] .lang-btn {
    background-color: #3d4054;
    color: #e9edf7;
}
[data-theme="dark"] .lang-btn:hover {
    background-color: #4a4e69;
}
.lang-btn .flag {
    font-size: 1.2rem;
    margin-right: 12px;
}

/* ================= SEO CONTENT ================= */
.seo-content {
    padding: 30px 16px;
    font-size: 0.95rem;
    line-height: 1.6;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    color: var(--text-color);
    border-top: 1px solid var(--border-color);
}
.seo-content h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 15px;
}
.seo-content h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-top: 25px;
    margin-bottom: 12px;
}
.seo-content h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-top: 20px;
    margin-bottom: 8px;
}
.seo-content p {
    margin-bottom: 15px;
}
.seo-content ul {
    margin-left: 20px;
    margin-bottom: 15px;
}
.seo-content li {
    margin-bottom: 8px;
}
.faq {
    margin-top: 10px;
}

/* ================= MODALS ================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--overlay-bg);
    display: none;
    z-index: 100;
}
.modal-overlay.active { display: block; }

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    background-color: var(--modal-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 23px 0 rgba(0,0,0,0.2);
    display: none;
    z-index: 101;
    flex-direction: column;
}
.modal.active { display: flex; }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}
.modal-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
    text-transform: uppercase;
}
.modal-content {
    padding: 16px;
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Settings List specific */
.settings-list .setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
}
.settings-list .setting-item:last-child {
    border-bottom: none;
}
.setting-text {
    display: flex;
    flex-direction: column;
}
.setting-text span {
    font-size: 0.8rem;
    color: var(--text-color);
    opacity: 0.6;
}

/* Custom Switch for wordlegame.org look */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #dbe0ed;
    transition: .2s;
    border-radius: 24px;
}
[data-theme="dark"] .slider {
    background-color: #40445c;
}
.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .2s;
    border-radius: 50%;
}
[data-theme="dark"] .slider:before {
    background-color: #c0c3d6;
}
input:checked + .slider {
    background-color: #6bba6b;
}
[data-theme="dark"] input:checked + .slider {
    background-color: #6bba6b;
}
input:checked + .slider:before {
    transform: translateX(22px);
    background-color: white;
}

/* Modals Specifics */
.modal .examples .example-row .tile {
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
}

.stats-overview {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
}
.stat-box {
    text-align: center;
    width: 60px;
}
.stat-num {
    font-size: 2rem;
    font-weight: 700;
}
.stat-label {
    font-size: 0.75rem;
}

.guess-distribution {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 10px;
}
.graph-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.graph-num {
    width: 10px;
}
.graph-bar {
    background-color: var(--tile-absent);
    color: white;
    padding: 2px 8px;
    text-align: right;
    font-size: 0.8rem;
    font-weight: bold;
    min-width: 20px;
}
.graph-bar.highlight {
    background-color: var(--tile-correct);
}

/* Game Over specific */
.text-center { text-align: center; }
.gameover-msg { font-size: 1.5rem; font-weight: bold; margin-bottom: 10px; }
.correct-word { font-size: 2rem; font-weight: bold; letter-spacing: 2px; margin-bottom: 5px; color: var(--text-color); }
.word-definition { font-size: 0.9rem; margin-bottom: 20px; color: var(--text-color); opacity:0.8; min-height: 40px;}
.primary-btn {
    background-color: var(--tile-correct);
    color: white;
    font-size: 1.1rem;
    font-weight: bold;
    padding: 12px 24px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 10px auto;
    transition: transform 0.1s;
}
.primary-btn:active { transform: scale(0.95); }
.primary-btn.outline {
    background-color: transparent;
    border: 2px solid var(--tile-correct);
    color: var(--tile-correct);
}
.timer { font-size: 2rem; font-weight: bold; }

/* ================= TOASTS ================= */
.toast-container {
    position: fixed;
    top: 10%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 200;
    pointer-events: none;
}
.toast {
    background-color: var(--toast-bg);
    color: var(--toast-text);
    padding: 12px 16px;
    border-radius: 8px;
    font-weight: bold;
    opacity: 1;
    transition: opacity 0.3s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.toast.fade-out { opacity: 0; }

/* ================= ANIMATIONS ================= */
@keyframes flipIn {
    0% { transform: rotateX(0deg); }
    50% { transform: rotateX(-90deg); }
    100% { transform: rotateX(0deg); }
}

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

@keyframes shake {
    10%, 90% { transform: translateX(-1px); }
    20%, 80% { transform: translateX(2px); }
    30%, 50%, 70% { transform: translateX(-4px); }
    40%, 60% { transform: translateX(4px); }
}

@keyframes bounce {
    0%, 20% { transform: translateY(0); }
    40% { transform: translateY(-15px); }
    50% { transform: translateY(0); }
    60% { transform: translateY(-7px); }
    80% { transform: translateY(0); }
}

.tile.flip { animation: flipIn 0.5s ease-in; }
.tile.pop { animation: popIn 0.1s; }
.row.shake { animation: shake 0.6s; }
.tile.bounce { animation: bounce 1s; }

/* Mobile Responsiveness specifically for wordlegame.org match */
@media (max-width: 767px) {
    .tile { width: 48px; height: 48px; font-size: 22px; }
    .keyboard-container { margin-top: 34px !important; margin-right: 2px; margin-left: 2px; }
    .language-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 479px) {
    .tile { width: 44px; height: 44px; font-size: 22px; }
    .key { font-size: 16px; }
    .language-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 375px) {
    .tile { width: 44px; height: 44px; font-size: 20px; }
    .key { font-size: 14px; min-height: 42px; }
}

@media (max-width: 320px) {
    .tile { width: 40px; height: 40px; font-size: 20px; }
}

/* ================= PLAY OTHER GAMES SECTION ================= */
.other-games-section {
    padding: 40px 15px;
    max-width: 1000px;
    margin: 0 auto;
    text-align: center;
}
.other-games-section h2 {
    font-size: 26px;
    margin-bottom: 25px;
    color: var(--text-color);
}
.games-grid-layout {
    display: grid;
    grid-template-columns: repeat(2, 160px);
    justify-content: center;
    gap: 15px;
}
@media (min-width: 600px) {
    .games-grid-layout {
        grid-template-columns: repeat(3, 160px);
    }
}
.game-card {
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 15px 10px;
    border-radius: 12px;
    text-decoration: none;
    color: #333;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.game-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.game-icon {
    font-size: 32px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.game-info {
    display: flex;
    flex-direction: column;
    text-align: center;
}
.game-title {
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 4px;
    color: #1a1a1a;
}
.game-sub {
    font-size: 13px;
    color: #555;
}

/* Pastel Background Colors for Game Cards */
.bg-green { background-color: #e6fbe1; }
.bg-light-green { background-color: #dffde0; }
.bg-yellow { background-color: #fdf1d6; }
.bg-light-blue { background-color: #d8f1fc; }
.bg-purple { background-color: #e9d8fd; }
.bg-blue { background-color: #cbe0fd; }

[data-theme="dark"] .game-title { color: #111; } 
[data-theme="dark"] .game-sub { color: #333; }
[data-theme="dark"] .game-card { box-shadow: none; }
