:root {
    --bg-color: #121213;
    --tile-bg: #3a3a3c;
    --tile-border: #3a3a3c;
    --tile-border-filled: #565758;
    --text-color: #ffffff;
    --correct: #538d4e;
    --present: #b59f3b;
    --absent: #3a3a3c;
    --modal-bg: #1a1a1b;
}

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

body {
    font-family: 'Clear Sans', 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
}

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

/* Header */
header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--tile-border);
    margin-bottom: 24px;
}

header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: 0.15rem;
}

header h1 a {
    color: inherit;
    text-decoration: none;
}

header h1 .domain {
    opacity: 0.6;
    font-weight: 400;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    font-size: 1.5rem;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: opacity 0.2s, transform 0.2s;
}

.icon-btn:hover {
    opacity: 1;
}

#helpBtn {
    background: var(--correct);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-weight: bold;
    opacity: 1;
}

#helpBtn:hover {
    transform: scale(1.1);
}

#helpBtn.pulse {
    animation: helpPulse 2s ease-in-out infinite;
}

@keyframes helpPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(83, 141, 78, 0.7); }
    50% { box-shadow: 0 0 0 10px rgba(83, 141, 78, 0); }
}

/* Confetti Canvas */
#confetti {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

/* Difficulty Selector */
.difficulty-selector {
    display: flex;
    gap: 16px;
    margin: 1px 0 32px 0;
    justify-content: center;
}

.diff-btn {
    position: relative;
    width: 60px;
    height: 32px;
    border: none;
    border-radius: 16px;
    font-size: 0.7rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.diff-btn:hover {
    transform: scale(1.05);
}

.diff-btn.active {
    outline: 3px solid white;
    outline-offset: 2px;
}

.diff-btn.completed {
    opacity: 0.5;
}

.diff-btn.completed::after {
    content: '✓';
    position: absolute;
    top: -6px;
    right: -4px;
    font-size: 0.7rem;
    font-weight: bold;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.diff-btn.failed {
    opacity: 0.5;
}

.diff-btn.failed::after {
    content: '✗';
    position: absolute;
    top: -6px;
    right: -4px;
    font-size: 0.7rem;
    font-weight: bold;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.diff-btn.easy {
    background: linear-gradient(135deg, #4ade80, #22c55e);
}

.diff-btn.medium {
    background: linear-gradient(135deg, #facc15, #eab308);
}

.diff-btn.hard {
    background: linear-gradient(135deg, #f97316, #ea580c);
}

.diff-btn.extra {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

/* Scrambled Letters */
.scrambled-letters {
    display: flex;
    gap: 6px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    justify-content: center;
}

.letter-tile {
    width: 50px;
    height: 50px;
    border: 2px solid var(--tile-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    font-weight: bold;
    text-transform: uppercase;
    background-color: var(--bg-color);
    transition: transform 0.1s, border-color 0.1s;
}

.letter-tile.scrambled {
    background-color: var(--tile-bg);
    border-color: var(--tile-bg);
    cursor: pointer;
    user-select: none;
}

.letter-tile.scrambled:hover {
    transform: scale(1.05);
}

.letter-tile.scrambled.used {
    opacity: 0.3;
    cursor: default;
    transform: none;
}

.letter-tile.filled {
    border-color: var(--tile-border-filled);
    animation: pop 0.1s ease;
}

@keyframes pop {
    50% {
        transform: scale(1.1);
    }
}

/* Game Board */
.game-board {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 24px;
}

.guess-row {
    display: flex;
    gap: 6px;
}

/* Tile States */
.letter-tile.correct {
    background-color: var(--correct);
    border-color: var(--correct);
}

.letter-tile.present {
    background-color: var(--present);
    border-color: var(--present);
}

.letter-tile.absent {
    background-color: var(--absent);
    border-color: var(--absent);
}

/* Flip Animation */
.letter-tile.flip {
    animation: flip 0.5s ease forwards;
}

@keyframes flip {
    0% {
        transform: rotateX(0);
    }
    50% {
        transform: rotateX(90deg);
    }
    100% {
        transform: rotateX(0);
    }
}

/* Shake Animation for invalid guess */
.guess-row.shake {
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-10px); }
    40% { transform: translateX(10px); }
    60% { transform: translateX(-10px); }
    80% { transform: translateX(10px); }
}

/* Win Animation */
.letter-tile.bounce {
    animation: bounce 0.5s ease;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

/* Input Area */
.input-area {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.action-btn {
    padding: 10px 16px;
    font-size: 0.85rem;
    font-weight: bold;
    background-color: var(--tile-bg);
    color: var(--text-color);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.action-btn:hover {
    background-color: #4a4a4c;
}

/* Message */
.message {
    min-height: 24px;
    font-size: 1rem;
    font-weight: bold;
    text-align: center;
    padding: 8px 16px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.3s;
}

.message.show {
    opacity: 1;
    background-color: var(--text-color);
    color: var(--bg-color);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal.show {
    display: flex;
}

.modal-content {
    background-color: var(--modal-bg);
    padding: 32px;
    border-radius: 8px;
    max-width: 400px;
    width: 90%;
    position: relative;
}

.close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.7;
}

.close-btn:hover {
    opacity: 1;
}

.modal-content h2 {
    margin-bottom: 16px;
    text-align: center;
}

.modal-content p,
.modal-content ul {
    margin-bottom: 16px;
    line-height: 1.6;
}

.modal-content ul {
    padding-left: 24px;
}

.modal-content h3 {
    margin: 16px 0 12px;
}

.example-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.letter-tile.example {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 24px;
}

.stat {
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
}

.stat-label {
    font-size: 0.75rem;
    color: #818384;
}

/* Difficulty Stats */
.difficulty-stats {
    margin: 20px 0;
}

.difficulty-stats h3 {
    margin-bottom: 12px;
    font-size: 0.9rem;
    opacity: 0.8;
}

.diff-stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.diff-stats-table th {
    text-align: center;
    padding: 6px 8px;
    opacity: 0.6;
    font-weight: normal;
    font-size: 0.75rem;
}

.diff-stats-table th:first-child {
    text-align: left;
}

.diff-stats-table td {
    padding: 8px;
    text-align: center;
}

.diff-stats-table td:first-child {
    text-align: left;
}

.diff-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
}

.diff-dot.easy { background: linear-gradient(135deg, #4ade80, #22c55e); }
.diff-dot.medium { background: linear-gradient(135deg, #facc15, #eab308); }
.diff-dot.hard { background: linear-gradient(135deg, #f97316, #ea580c); }
.diff-dot.extra { background: linear-gradient(135deg, #ef4444, #dc2626); }

/* Share */
.share-section {
    text-align: center;
}

.share-btn {
    padding: 16px 48px;
    font-size: 1.2rem;
    font-weight: bold;
    background-color: var(--correct);
    color: var(--text-color);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.share-btn:hover {
    background-color: #4a7c41;
}

.share-result {
    margin-top: 16px;
    font-family: monospace;
    white-space: pre-line;
    font-size: 1.2rem;
}

/* Footer */
footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px;
    font-size: 0.7rem;
    color: #555;
    text-align: center;
}

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

footer a:hover {
    color: #888;
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 400px) {
    .letter-tile {
        width: 42px;
        height: 42px;
        font-size: 1.4rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .action-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    .scrambled-letters,
    .guess-row {
        gap: 4px;
    }
}
