:root {
    /* Fonts */
    --font-main: 'Metal Mania', cursive;
    --font-gothic-1: 'Creepster', cursive;
    --font-gothic-2: 'UnifrakturMaguntia', serif;
    --font-gothic-3: 'Metal Mania', cursive;
    /* Dark Cruel Palette - Browns and Reds */
    --bg-dark: #0a0a0a;
    --bg-card: rgba(25, 20, 20, 0.92);
    --primary-brown: #5c3d2e;
    --medium-brown: #7d5a4f;
    --light-brown: #a67c6c;
    --cream: #e8d5c4;
    --dark-red: #bb5555;
    --medium-red: #a84848;
    --light-red: #c66b6b;
    --bg-color: #f5ebe0;
    --text-dark: #ccc;
    --text-light: #998877;
    --border-color: #6a3030;
    --shadow: rgba(120, 40, 40, 0.25);
}

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

body {
    font-family: var(--font-main);
    background: var(--bg-dark);
    color: var(--text-dark);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow-x: hidden;
    position: relative;
}

/* Embers */
.embers {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}
.ember {
    position: absolute;
    width: 3px;
    height: 3px;
    background: #ff5533;
    border-radius: 50%;
    box-shadow: 0 0 8px 3px rgba(255, 100, 50, 0.7), 0 0 16px 6px rgba(180, 50, 30, 0.35);
    opacity: 0;
    animation: rise 8s ease-out infinite;
}
.ember.small { width: 2px; height: 2px; }
.ember.large { width: 4px; height: 4px; }
.ember:nth-child(1) { left: 3%; animation-delay: 0s; animation-duration: 9s; }
.ember:nth-child(2) { left: 8%; animation-delay: 2s; animation-duration: 7s; }
.ember:nth-child(3) { left: 12%; animation-delay: 4s; animation-duration: 10s; }
.ember:nth-child(4) { left: 18%; animation-delay: 1s; animation-duration: 8s; }
.ember:nth-child(5) { left: 23%; animation-delay: 3s; animation-duration: 9s; }
.ember:nth-child(6) { left: 6%; animation-delay: 5s; animation-duration: 11s; }
.ember:nth-child(7) { left: 15%; animation-delay: 6s; animation-duration: 7s; }
.ember:nth-child(8) { left: 20%; animation-delay: 7s; animation-duration: 8s; }
.ember:nth-child(9) { left: 10%; animation-delay: 1.5s; animation-duration: 10s; }
.ember:nth-child(10) { left: 25%; animation-delay: 4.5s; animation-duration: 9s; }
.ember:nth-child(11) { left: 75%; animation-delay: 0.5s; animation-duration: 8s; }
.ember:nth-child(12) { left: 80%; animation-delay: 2.5s; animation-duration: 10s; }
.ember:nth-child(13) { left: 85%; animation-delay: 4.2s; animation-duration: 7s; }
.ember:nth-child(14) { left: 90%; animation-delay: 1.2s; animation-duration: 9s; }
.ember:nth-child(15) { left: 95%; animation-delay: 3.5s; animation-duration: 11s; }
.ember:nth-child(16) { left: 78%; animation-delay: 5.5s; animation-duration: 8s; }
.ember:nth-child(17) { left: 88%; animation-delay: 6.5s; animation-duration: 10s; }
.ember:nth-child(18) { left: 97%; animation-delay: 7.5s; animation-duration: 7s; }
.ember:nth-child(19) { left: 82%; animation-delay: 0.8s; animation-duration: 9s; }
.ember:nth-child(20) { left: 92%; animation-delay: 3.8s; animation-duration: 8s; }

@keyframes rise {
    0% {
        bottom: -10px;
        opacity: 0;
        transform: translateX(0) scale(1);
    }
    10% {
        opacity: 0.8;
    }
    50% {
        opacity: 0.6;
    }
    100% {
        bottom: 110%;
        opacity: 0;
        transform: translateX(20px) scale(0.3);
    }
}

.container {
    max-width: 600px;
    width: 100%;
    background: var(--bg-card);
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 0 40px var(--shadow), inset 0 0 80px rgba(100, 30, 30, 0.15);
    border: 1px solid var(--border-color);
    position: relative;
    z-index: 10;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #4a2525;
}

h1 {
    font-size: 2.2em;
    color: var(--dark-red);
    margin-bottom: 10px;
    text-shadow: 0 0 25px rgba(180, 60, 60, 0.4);
    letter-spacing: 3px;
    font-weight: 500;
}

.subtitle {
    color: #776666;
    font-style: italic;
    font-size: 0.9em;
    letter-spacing: 1px;
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.target-word {
    background: rgba(80, 55, 45, 0.6);
    color: #cc8877;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 1.4em;
    font-weight: bold;
    letter-spacing: 3px;
    border: 1px solid #5a3a30;
}

.target-word .label {
    font-size: 0.7em;
    opacity: 0.8;
    margin-right: 10px;
}

.stats-bar {
    display: flex;
    gap: 15px;
    flex: 1;
    justify-content: flex-end;
}

.stat {
    text-align: center;
    background: rgba(40, 30, 30, 0.6);
    padding: 8px 15px;
    border-radius: 6px;
    border: 1px solid #4a2525;
}

.stat-label {
    display: block;
    font-size: 0.75em;
    color: #776666;
    margin-bottom: 2px;
}

.stat-value,
#timer,
#streak {
    font-weight: bold;
    color: #cc8877;
    font-size: 1.1em;
}

.cell {
    aspect-ratio: 1;
    background: rgba(50, 35, 30, 0.7);
    border: 1px solid #5a3a30;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1em;
    font-weight: bold;
    color: #cc9988;
    cursor: pointer;
    user-select: none;
    overflow: hidden;
    min-width: 0;
    min-height: 0;
    padding: 4px;
}

/* Responsive cell font sizes based on grid container */
.game-board {
    display: grid;
    gap: 3px;
    margin: 25px auto;
    max-width: 500px;
    background: rgba(30, 20, 20, 0.6);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #4a2525;
}

@media (max-width: 500px) {
    .cell {
        font-size: 0.85em;
    }
}

@media (max-width: 450px) {
    .cell {
        font-size: 0.75em;
    }
}

@media (max-width: 380px) {
    .cell {
        font-size: 0.65em;
    }
}

@media (max-width: 320px) {
    .cell {
        font-size: 0.55em;
    }
}

.cell:hover:not(.selected):not(.used) {
    background: rgba(140, 80, 60, 0.6);
    border-color: #bb5555;
}

.cell.selected {
    background: #8b3a3a;
    color: #e8d5c4;
    border-color: #bb5555;
    box-shadow: 0 0 10px rgba(180, 60, 60, 0.4);
}

.cell.used {
    opacity: 0.5;
    cursor: not-allowed;
}

.game-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin: 25px 0;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-family: var(--font-main);
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
}

.btn-primary {
    background: #8b3a3a;
    color: #e8d5c4;
    border: 1px solid #bb5555;
}

.btn-secondary {
    background: rgba(80, 55, 45, 0.6);
    color: #cc8877;
    border: 1px solid #5a3a30;
}

.btn-link {
    background: transparent;
    color: #776666;
    box-shadow: none;
    padding: 8px 16px;
    font-size: 0.9em;
}

.btn-link:hover {
    color: #bb5555;
    background: rgba(60, 40, 40, 0.5);
}

.message {
    text-align: center;
    min-height: 30px;
    font-weight: bold;
    font-size: 1.1em;
    margin: 15px 0;
    color: #998877;
}

.message.success {
    color: #bb5555;
}

.message.error {
    color: #c66b6b;
}

.actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #4a2525;
    flex-wrap: wrap;
}

/* 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.85);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: rgba(25, 20, 20, 0.98);
    margin: 10% auto;
    padding: 30px;
    border: 1px solid #6a3030;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 0 40px rgba(120, 40, 40, 0.25);
    animation: slideIn 0.3s ease;
}

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

.close {
    color: #776666;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
}

.close:hover {
    color: #bb5555;
}

.modal h2 {
    color: #bb5555;
    margin-bottom: 20px;
    text-align: center;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.stat-box {
    background: rgba(40, 30, 30, 0.6);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid #4a2525;
}

.stat-value {
    font-size: 2em;
    font-weight: bold;
    color: #cc8877;
    margin-bottom: 5px;
}

.stat-name {
    font-size: 0.9em;
    color: #776666;
}

.avg-time {
    text-align: center;
    margin-top: 20px;
    padding: 15px;
    background: rgba(80, 55, 45, 0.5);
    border-radius: 8px;
    color: #cc8877;
}

.help-content {
    color: #aaa;
    line-height: 1.6;
}

.help-content p {
    margin-bottom: 15px;
}

.help-content strong {
    color: #bb5555;
}

.help-content ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

.help-content li {
    margin-bottom: 8px;
}

/* Victory Modal Styles */
.victory-content {
    text-align: center;
    background: rgba(25, 20, 20, 0.98);
    border: 1px solid #bb5555;
}

.victory-title {
    color: #bb5555;
    font-size: 1.8em;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.victory-word {
    font-size: 2.5em;
    font-weight: bold;
    color: #bb5555;
    margin: 30px 0;
    text-shadow: 0 0 20px rgba(180, 60, 60, 0.4);
}

.victory-time {
    font-size: 1.3em;
    margin: 20px 0;
    color: #ccc;
}

.victory-label {
    color: #776666;
    margin-right: 10px;
}

.victory-puzzle {
    font-size: 1.1em;
    color: #998877;
    margin: 15px 0 30px 0;
    font-style: italic;
}

.victory-share-btn {
    margin: 10px;
    font-size: 1.1em;
    padding: 15px 30px;
}

.victory-content .btn {
    margin: 5px;
}

.victory-footer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #4a2525;
    font-size: 0.9em;
}

.victory-footer p {
    margin: 8px 0;
    color: #776666;
}

.victory-footer a {
    color: #bb5555;
    text-decoration: none;
}

.victory-footer a:hover {
    color: #cc8877;
}

.coming-soon-victory {
    font-style: italic;
    opacity: 0.8;
}

/* Footer Styles */
.footer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #4a2525;
    text-align: center;
    font-size: 0.9em;
    color: #776666;
}

.footer p {
    margin: 5px 0;
}

.footer a {
    color: #bb5555;
    text-decoration: none;
}

.footer a:hover {
    color: #cc8877;
}

.footer .toms-link {
    margin-top: 12px;
    font-size: 0.85em;
}

.footer .toms-link a {
    color: #776060;
    font-weight: normal;
}

.coming-soon {
    font-style: italic;
    opacity: 0.7;
    font-size: 0.95em;
}

/* Historical Game Banner */
.historical-banner {
    background: rgba(80, 55, 45, 0.6);
    color: #cc8877;
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    border: 1px solid #5a3a30;
}

.historical-banner .btn-link {
    color: #e8d5c4;
    background: #8b3a3a;
    padding: 6px 12px;
    border-radius: 4px;
}

.historical-banner .btn-link:hover {
    background: rgba(140, 80, 60, 0.7);
}

/* Calendar Modal Styles */
.calendar-info {
    margin: 20px 0;
    color: #aaa;
}

.calendar-input {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
}

.calendar-input input[type="date"] {
    padding: 10px;
    border: 1px solid #5a3a30;
    border-radius: 6px;
    font-family: var(--font-main);
    font-size: 1em;
    color: #cc8877;
    background: rgba(40, 30, 30, 0.6);
}

.calendar-input input[type="date"]:focus {
    outline: none;
    border-color: #bb5555;
}

/* Responsive Design */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 15px;
        max-width: 100%;
    }

    h1 {
        font-size: 1.8em;
        letter-spacing: 1px;
    }

    .subtitle {
        font-size: 0.85em;
    }

    .game-info {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .target-word {
        font-size: 1.2em;
        padding: 10px 15px;
    }

    .stats-bar {
        justify-content: stretch;
        gap: 8px;
        width: 100%;
    }

    .stat {
        padding: 6px 12px;
        flex: 1;
    }

    .game-board {
        padding: 8px;
        gap: 4px;
        margin: 20px auto;
    }

    .cell {
        font-size: 0.9em;
        border-radius: 4px;
        border-width: 1px;
    }

    .game-controls {
        margin: 20px 0;
        gap: 10px;
    }

    .btn {
        padding: 10px 20px;
        font-size: 0.95em;
    }

    .message {
        font-size: 1em;
        margin: 12px 0;
    }

    .actions {
        gap: 12px;
        justify-content: space-evenly;
    }

    .btn-link {
        padding: 8px 12px;
        font-size: 0.85em;
    }

    .modal-content {
        margin: 20% auto;
        padding: 20px;
        width: 95%;
    }

    .stats-grid {
        gap: 10px;
    }

    .stat-box {
        padding: 15px;
    }

    .stat-value {
        font-size: 1.6em;
    }

    .victory-word {
        font-size: 2em;
        margin: 20px 0;
    }

    .victory-title {
        font-size: 1.4em;
    }

    .victory-time {
        font-size: 1.1em;
    }

    .victory-share-btn {
        padding: 12px 24px;
        font-size: 1em;
    }
}

/* Extra small screens */
@media (max-width: 380px) {
    h1 {
        font-size: 1.5em;
    }

    .target-word {
        font-size: 1em;
        padding: 8px 10px;
    }

    .game-board {
        gap: 3px;
        padding: 6px;
    }

    .cell {
        font-size: 0.75em;
        border-width: 1px;
    }

    .victory-word {
        font-size: 1.7em;
    }

    .victory-title {
        font-size: 1.2em;
    }

    .btn {
        padding: 8px 16px;
        font-size: 0.9em;
    }

    .btn-link {
        padding: 6px 10px;
        font-size: 0.8em;
    }
}

/* Victory Animation */
@keyframes celebrate {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.1) rotate(-5deg); }
    75% { transform: scale(1.1) rotate(5deg); }
}

.cell.victory {
    animation: celebrate 0.5s ease;
}

/* Flash Hint Animation (SOS cheat code) */
@keyframes flashHint {
    0%, 100% {
        background: rgba(50, 35, 30, 0.7);
        transform: scale(1);
    }
    50% {
        background: #bb5555;
        transform: scale(1.15);
        box-shadow: 0 0 20px rgba(180, 60, 60, 0.6);
    }
}

.cell.flash-hint {
    animation: flashHint 0.6s ease;
    z-index: 10;
}
