:root {
    font-family: system-ui, sans-serif;
    --primary: #f7931a;
}

body {
    margin: 0;
    padding: 1rem;
    background: #fafafa;
}

h1 {
    margin-top: 0;
    color: var(--primary);
}

.hidden {
    display: none;
}

label {
    display: block;
    margin: .5rem 0;
}

input,
button {
    font-size: 1rem;
    padding: .3rem .6rem;
    border: 1px solid #ccc;
    border-radius: 4px;
}

button {
    cursor: pointer;
    background: var(--primary);
    color: #fff;
    border: none;
}

button:hover {
    opacity: .9;
}

.bank {
    margin: 1rem 0;
    padding: 1rem;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.word {
    display: inline-block;
    margin: .25rem .5rem;
    padding: .25rem .5rem;
    background: #eee;
    border-radius: 4px;
    font-weight: 600;
}

/* Notepad status colors */
.word.present {
    background: #2ecc71;
    color: #fff;
}

.word.absent {
    background: #e74c3c;
    color: #fff;
}

.log {
    margin-top: 1rem;
}

.attempt {
    margin: .5rem 0;
    padding: .5rem;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
}

.success {
    border-color: var(--primary);
    background: #fff9f2;
}

#board {
    list-style: none;
    padding-left: 0;
}

#board li {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin: .25rem 0;
    padding: .25rem .5rem;
}

.winner {
    border-color: var(--primary);
    font-weight: 700;
}

/* Grace period countdown */
#graceCountdown {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary);
    margin: 0.5rem 0;
}

/* Cajas de una sola letra */
.letterBox {
    width: 2.4rem;
    text-align: center;
    margin: 0;
}

/* online/offline dots */
.dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
}

.online {
    background: #2ecc71;
}

.offline {
    background: #e74c3c;
    opacity: 0.6;
}

/* Modal styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: #fff;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    max-width: 600px;
    max-height: 80vh;
    overflow: auto;
    position: relative;
}

.closeBtn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    font-size: 2rem;
    color: #333;
    cursor: pointer;
    line-height: 1;
    padding: 0.2rem 0.4rem;
}

/* Guess form layout */
#guessForm {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
}
#letterInputs {
    display: flex;
    gap: .4rem;
    flex-wrap: wrap;
}
#letterInputs .letterBox {
    flex: 0 0 auto;
}
#guessForm button {
    margin: 0;
}

@media (max-width: 480px) {
    #guessForm {
        flex-direction: column;
        align-items: flex-start;
    }
    #guessForm button {
        margin-top: .5rem;
    }
}

.modal.hidden {
    display: none !important;
}

.chat-box {
    max-height: 200px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: .5rem;
    margin-bottom: .5rem;
}
.chat-box div {
    margin: .25rem 0;
}
.toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    margin-left: .4rem;
}
.collapsed .chat-box,
.collapsed form {
    display: none;
}

.chat-fab {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    width: 3.2rem;
    height: 3.2rem;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    font-size: 1.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    cursor: pointer;
    z-index: 1001;
}

.chat-fab.has-new {
    animation: chat-shake 0.6s linear infinite;
}

@keyframes chat-shake {
    0%, 100% { transform: rotate(0deg); }
    20% { transform: rotate(-10deg); }
    40% { transform: rotate(10deg); }
    60% { transform: rotate(-8deg); }
    80% { transform: rotate(8deg); }
}

.chat-fab.has-new::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 14px;
    height: 14px;
    background: #ff3860; /* brighter red */
    border: 2px solid #fff; /* white ring */
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(0,0,0,0.3);
}

.chat-panel {
    position: fixed;
    bottom: 4.5rem;
    right: 1rem;
    width: 320px;
    max-height: 65vh;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    padding: .5rem .75rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.chat-panel.collapsed {
    display: none;
}

/* Hide old arrow toggle button if still present */
.toggle { display: none; }

.empty-chat {
    color: #999;
    font-style: italic;
    text-align: center;
    margin: .5rem 0;
}

.online-count {
    font-size: 0.85rem;
    color: #666;
    margin-left: .25rem;
}

.container {
    max-width: 500px;
    margin: 0 auto;
    width: 100%;
}

/* Button alignment in game header */
#game h2 {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .4rem;
    margin-bottom: .6rem;
}
#rulesBtn,
#probsBtn {
    display: inline-block;
    margin: 0 .4rem .6rem 0;
}

/* --- Toggle switch --- */
.create-actions {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-top: .5rem;
}
.switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ccc;
    transition: .2s;
    border-radius: 24px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    transition: .2s;
    border-radius: 50%;
}
.switch input:checked + .slider {
    background: var(--primary);
}
.switch input:checked + .slider:before {
    transform: translateX(18px);
}
.switch-label {
    font-size: 0.9rem;
    user-select: none;
}

/* When screen small, ensure actions wrap */
@media (max-width: 480px) {
    .create-actions {
        flex-wrap: wrap;
        justify-content: flex-start;
    }
}

/* --- Public games list --- */
.public-games {
    display: flex;
    flex-direction: column;
    gap: .6rem;
}
.public-game {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: .6rem 1rem;
    gap: .8rem;
}
.public-game .details {
    flex: 1 1 auto;
}
.public-game .details small {
    color: #666;
}
.public-game button {
    flex: 0 0 auto;
    margin: 0;
}
.public-game .fire {
    font-size: 1.2rem;
    margin-right: .25rem;
    color: #e74c3c;
}
@media (max-width: 480px) {
    .public-game {
        flex-direction: column;
        align-items: stretch;
    }
    .public-game button {
        align-self: flex-start;
        margin-top: .4rem;
    }
}

.empty-public {
    padding: 1rem;
    text-align: center;
    color: #555;
    background: #fff;
    border: 1px dashed #ccc;
    border-radius: 8px;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    margin: 0 0.2rem;
}

/* Table styling */
#games table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}
#games th,
#games td {
    padding: .4rem .6rem;
    border: 1px solid #ddd;
}
#games th {
    background: #f5f5f5;
    text-align: left;
}
#games tbody tr:nth-child(even) {
    background: #fafafa;
}

/* Stats card grid */
.statsGrid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 1rem 0;
}

.statCard {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1rem;
    min-width: 140px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.statCard .label {
    display: block;
    color: #555;
    font-size: .9rem;
    margin-bottom: .2rem;
}

.statCard .value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
}

/* Leaderboard styles */
#board {
    list-style: none;
    padding-left: 0;
}
#board li {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    margin: .25rem 0;
    padding: .4rem .6rem;
    display: flex;
    align-items: center;
    gap: .4rem;
}

#board li.section {
    background: #f5f5f5;
    font-weight: 600;
    border-style: dashed;
    justify-content: flex-start;
}

#board li.winner {
    border-color: var(--primary);
    background: #fff9f2;
}

#board .dot {
    flex: 0 0 auto;
}

.site-footer {
    margin-top: 2rem;
    padding: 1.5rem 0;
    text-align: center;
    background: #fafafa;
    border-top: 1px solid #ddd;
    font-size: .9rem;
    color: #666;
}
.site-footer .logo {
    width: 140px;
    height: auto;
    margin-bottom: .5rem;
}
.site-footer .tagline {
    margin: .3rem 0 1rem;
    font-weight: 500;
    color: #333;
}
.site-footer .credits {
    margin: 0;
}
.site-footer .credits a {
    color: var(--primary);
    text-decoration: none;
}
.site-footer .credits a:hover {
    text-decoration: underline;
}

.site-footer .hosted-logo {
    max-height: 25px;
    height: auto;
    vertical-align: middle;
    margin-left: .3rem;
}

.site-footer .hosted {
    margin: .5rem 0 0;
}