:root {
    --bg-color: #f6f4ec;
    --text-color: #3d3f43;
    --key-bg: #f6f4ec;
    --key-bg-active: #e3e1d9;
    --border-color: #d9d4c7;
    --correct: #a9dbb8;
    --present: #e3c574;
    --absent: #c1c5cc;
    --tile-text: #3d3f43;
    --shadow-light: #ffffff;
    --shadow-dark: #d9d4c7;
}

[data-theme="dark"] {
    --bg-color: #2c2f33;
    --text-color: #e0e0e0;
    --key-bg: #2c2f33;
    --key-bg-active: #23272a;
    --border-color: #23272a;
    --correct: #538d4e;
    --present: #b59f3b;
    --absent: #3a3a3c;
    --tile-text: #ffffff;
    --shadow-light: #3a3e43;
    --shadow-dark: #1e2023;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-bottom: 20px;
}

.game-container {
    width: 100%;
    max-width: 500px;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
}

header {
    width: 100%;
    position: relative;
}

.header-icons-container {
    padding-bottom: 20px;
}

.neumorphic-circle {
    position: static;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--bg-color);
    box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
    display: flex;
    justify-content: center;
    align-items: center;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.neumorphic-circle:active {
    box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
}

.separator {
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    height: 1px;
    background-color: var(--shadow-dark);
    opacity: 0.5;
    margin-bottom: 20px;
}

.elegant-title {
    font-weight: 300;
    font-size: 1.3rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    text-align: center;
    margin-bottom: 20px;
    color: var(--text-color);
}

.theme-toggle-icon {
    display: inline-block;
    vertical-align: text-bottom;
    cursor: pointer;
    transition: transform 0.2s ease, color 0.2s ease;
    padding: 0 2px;
}

.theme-toggle-icon:hover {
    transform: scale(1.2);
    color: var(--correct);
}

.theme-toggle-icon svg {
    width: 0.85em;
    height: 0.85em;
    margin-bottom: 0.1em;
}

#grid-container {
    display: grid;
    grid-template-rows: repeat(6, 1fr);
    grid-gap: 5px;
    margin-bottom: 20px;
    flex-grow: 1;
    justify-content: center;
}

.row {
    display: grid;
    grid-template-columns: repeat(var(--grid-cols, 5), 1fr);
    grid-gap: 5px;
}

.tile {
    width: 52px;
    height: 52px;
    border-radius: 10px;
    background-color: var(--bg-color);
    box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--tile-text);
    border: none;
    transition: all 0.2s ease;
}

.tile[data-state="active"] {
    /* Optional: active input styling */
}

.tile.selected {
    box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
}

.tile[data-state="correct"] {
    background-color: var(--correct);
    box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
    color: var(--text-color) !important;
}

.tile[data-state="present"] {
    background-color: var(--present);
    box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
    color: var(--text-color) !important;
}

.tile[data-state="absent"] {
    background-color: var(--absent);
    box-shadow: inset 4px 4px 8px rgba(0,0,0,0.1), inset -4px -4px 8px rgba(255,255,255,0.7);
    color: var(--text-color) !important;
}

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

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

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

.tile.pop {
    animation: pop 0.1s ease-in-out;
}

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

    50% {
        transform: scale(1.1);
    }

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

/* Keyboard */
#keyboard-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 20px;
}

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

.key {
    background-color: var(--key-bg);
    color: var(--text-color);
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    height: 58px;
    display: flex;
    justify-content: center;
    align-items: center;
    text-transform: uppercase;
    flex: 1;
    min-width: 0;
    padding: 0;
    font-size: 1.2rem;
    border: none;
    box-shadow: 3px 3px 6px var(--shadow-dark), -3px -3px 6px var(--shadow-light);
    transition: all 0.2s ease;
}

.key:active {
    box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light);
}

.key.wide {
    flex: 1.5;
}

.key[data-state="correct"] {
    background-color: var(--correct);
    box-shadow: 3px 3px 6px var(--shadow-dark), -3px -3px 6px var(--shadow-light);
    color: var(--text-color);
}

.key[data-state="present"] {
    background-color: var(--present);
    box-shadow: 3px 3px 6px var(--shadow-dark), -3px -3px 6px var(--shadow-light);
    color: var(--text-color);
}

.key[data-state="absent"] {
    background-color: var(--absent);
    box-shadow: inset 3px 3px 6px rgba(0,0,0,0.1), inset -3px -3px 6px rgba(255,255,255,0.7);
    color: var(--text-color);
}

.guess-stats-container {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-top: 15px;
    margin-bottom: 5px;
    font-size: 0.9rem;
    color: var(--text-color);
    text-transform: uppercase;
    padding: 0 5px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-y: auto;
    padding: 20px 0;
    z-index: 100;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-color);
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    border: none;
    box-shadow: 8px 8px 16px var(--shadow-dark), -8px -8px 16px var(--shadow-light);
    max-width: 90%;
    margin: auto;
    color: var(--text-color);
}

.player-rank {
    margin-top: 5px;
    margin-bottom: 20px;
    min-height: 24px;
}

.btn {
    margin-top: 20px;
    padding: 10px 20px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    border-radius: 4px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    transition: background-color 0.2s, transform 0.1s;
}

.btn:active {
    transform: scale(0.95);
}

.btn.primary {
    background-color: var(--correct);
    color: #111;
}

.btn.primary:hover {
    background-color: #8cdabf;
}

.btn.secondary {
    background-color: var(--border-color);
    color: var(--text-color);
    margin-left: 10px;
}

.btn.secondary:hover {
    background-color: #b0bfd4;
}

.btn.hidden {
    display: none;
}

/* Statistics */
#stats-container {
    margin-bottom: 20px;
}

#stats-container.hidden {
    display: none;
}

.stats-overview {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.stat-num {
    font-size: 22px;
    font-weight: bold;
}

.stat-label {
    font-size: 12px;
    text-align: center;
    margin-top: 5px;
}

.guess-distribution {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 15px;
    width: 100%;
}

.guess-row {
    display: flex;
    align-items: center;
    font-size: 14px;
    font-weight: bold;
    justify-content: flex-start;
}

.guess-label {
    width: 15px;
    text-align: right;
    margin-right: 8px;
}

.guess-bar-container {
    flex-grow: 1;
    display: flex;
}

.guess-bar {
    background-color: var(--border-color);
    color: var(--text-color);
    padding: 2px 8px;
    text-align: right;
    min-width: 8%;
}

.guess-bar.highlight {
    background-color: var(--correct);
}

/* Fireworks Container */
#fireworks-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 99;
    overflow: hidden;
}

.firework {
    position: absolute;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    animation: explode 1s ease-out forwards;
}

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

    100% {
        transform: scale(10) translate(var(--tx), var(--ty));
        opacity: 0;
    }
}

/* Message Toast */
#message-container {
    position: absolute;
    top: 10%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 50;
}

.hidden {
    display: none !important;
}

.message {
    background-color: white;
    color: black;
    padding: 10px 20px;
    border-radius: 4px;
    font-weight: 700;
    opacity: 1;
    transition: opacity 0.3s;
}

.message.fade-out {
    opacity: 0;
}

/* Auth Inputs */
.auth-input {
    width: 80%;
    padding: 12px;
    margin: 8px 0;
    border-radius: 8px;
    border: none;
    background-color: var(--bg-color);
    box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);
    color: var(--text-color);
    font-size: 1rem;
    font-family: inherit;
    text-align: center;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    transition: all 0.2s;
}

.auth-input:focus {
    outline: none;
    border-color: var(--present);
}

.error-msg {
    color: #e25822; /* Warning orange/red */
    font-size: 0.9rem;
    margin-bottom: 10px;
    min-height: 1.2rem;
    font-weight: bold;
}
@media (max-width: 480px) {
    h1 {
        font-size: 1.2rem;
        letter-spacing: 1px;
    }
    .keyboard-row {
        gap: 4px;
        width: 100%;
    }
    .key {
        font-size: 14px;
        height: 48px;
        border-radius: 4px;
    }
    .game-container {
        padding: 5px;
    }
    .modal-content {
        padding: 15px;
    }
}

/* Notifications */
.header-btn.hidden,
.notification-badge.hidden,
.notification-dropdown.hidden {
    display: none !important;
}

.notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background-color: #e25822;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 10px;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
}

.notification-dropdown {
    position: absolute;
    top: 50px;
    right: 70px;
    background: var(--bg-color);
    border: none;
    border-radius: 12px;
    width: 260px;
    padding: 15px;
    box-shadow: 8px 8px 16px var(--shadow-dark), -8px -8px 16px var(--shadow-light);
    z-index: 1000;
    text-align: left;
    color: var(--text-color);
}

/* Neumorphic Extended Components */
.neumorphic-tab {
    padding: 8px 15px;
    border: none;
    background: var(--bg-color);
    color: var(--text-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
    transition: all 0.2s ease;
    margin: 5px;
}

.neumorphic-tab.active {
    background: var(--correct);
    color: var(--text-color);
    font-weight: bold;
    box-shadow: inset 4px 4px 8px rgba(0,0,0,0.05), inset -4px -4px 8px rgba(255,255,255,0.6);
}

.neumorphic-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    margin-bottom: 10px;
    background: var(--bg-color);
    border-radius: 8px;
    box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light);
    color: var(--text-color);
    transition: all 0.2s ease;
}

.active-chat-friend {
    background: var(--correct) !important;
    color: var(--text-color) !important;
    box-shadow: inset 4px 4px 8px rgba(0,0,0,0.05), inset -4px -4px 8px rgba(255,255,255,0.6) !important;
}

.neumorphic-list-item-text {
    flex-grow: 1;
    text-align: left;
}

.neumorphic-btn {
    padding: 5px 10px;
    background: var(--bg-color);
    color: var(--text-color);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 3px 3px 6px var(--shadow-dark), -3px -3px 6px var(--shadow-light);
    transition: all 0.2s ease;
    font-size: 0.8rem;
    font-weight: bold;
}

.neumorphic-btn:active {
    box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light);
}

.neumorphic-btn.primary {
    background: var(--correct);
}

.neumorphic-btn.danger {
    background: #e25822;
    color: white;
}

@keyframes blink {
    0% { box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light); }
    50% { box-shadow: inset 2px 2px 5px rgba(226,88,34,0.3), 0 0 15px rgba(226,88,34,0.6); border: 1px solid rgba(226,88,34,0.5); }
    100% { box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light); }
}

.icon-blink {
    animation: blink 1.5s infinite;
}

.icon-blink svg {
    stroke: #e25822 !important;
}
