body {
    font-family: Candara, sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100dvh;
    overflow: hidden;
    animation: subtleBg 10s infinite ease-in-out;
}

body.light-mode {
    background: white;
    color: #333;
}

body.dark-mode {
    background: #1a1a1a;
    color: #f0f0f0;
}

body.dark-mode #container {
    background: #1a1a1a;
}

body.dark-mode h1 {
    color: #f0f0f0;
}

body.dark-mode .letter {
    background: #333;
    border: 2px solid #555;
    color: #f0f0f0;
}

body.dark-mode .found {
    background: #228b22;
    border-color: #006400;
}

body.dark-mode #wordList li.found {
    color: #228b22;
}

body.dark-mode button {
    background: linear-gradient(to bottom, #ffd700, #ff8c00);
    color: #333;
}

@keyframes subtleBg {
    0% { background-color: var(--bg-start); }
    50% { background-color: var(--bg-mid); }
    100% { background-color: var(--bg-start); }
}

body.light-mode {
    --bg-start: white;
    --bg-mid: #f8f8f8;
}

body.dark-mode {
    --bg-start: #1a1a1a;
    --bg-mid: #222;
}

#particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100dvh;
    z-index: -1;
    pointer-events: none;
}

#container {
    width: 100%;
    max-width: 400px;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: calc(20px + env(safe-area-inset-top)) 20px calc(20px + env(safe-area-inset-bottom)) 20px;
    box-sizing: border-box;
}

.screen, .overlay {
    width: 100%;
    text-align: center;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    height: 100dvh;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

body.dark-mode .overlay {
    background: rgba(26, 26, 26, 0.9);
}

h1 {
    font-size: 2em;
    margin-bottom: 20px;
}

button {
    background: linear-gradient(to bottom, #ffd700, #ff8c00);
    border: 2px solid #ff4500;
    border-radius: 20px;
    color: #333;
    padding: 10px 20px;
    margin: 10px 0;
    font-size: 1.2em;
    cursor: pointer;
    transition: transform 0.3s;
    animation: pulse 2s infinite;
    min-width: 120px;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

button:hover {
    transform: scale(1.1);
}

#topbar {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

#topbar span {
    font-size: 1em;
    margin: 5px;
}

.topbar-btn {
    padding: 8px 12px !important;
    font-size: 1em !important;
    min-width: 70px !important;
    margin: 5px;
}

#score, #lives, #timer {
    font-size: 1em;
}

#levelInfo {
    font-size: 1.2em;
    margin-bottom: 10px;
}

#wordList {
    margin-bottom: 20px;
}

#wordList ul {
    list-style: none;
    padding: 0;
}

#wordList li {
    font-size: 1.2em;
    margin: 5px;
}

#wordList li.found {
    text-decoration: line-through;
    color: green;
}

#grid {
    display: grid;
    grid-template-columns: repeat(11, 1fr);
    gap: 2px;
    width: 100%;
    margin: 0 auto;
}

.letter {
    background: #f0f0f0;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 1em;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    user-select: none;
    transition: background 0.3s;
    box-sizing: border-box;
}

.selected {
    background: yellow;
    animation: selectAnim 0.5s;
}

@keyframes selectAnim {
    0% { background: white; }
    100% { background: yellow; }
}

.found {
    background: greenyellow;
    border-color: green;
}

.glow {
    animation: glow 1s ease-in-out;
}

@keyframes glow {
    0% { box-shadow: 0 0 0 rgba(0, 255, 0, 0.5); }
    50% { box-shadow: 0 0 20px rgba(0, 255, 0, 1); }
    100% { box-shadow: 0 0 0 rgba(0, 255, 0, 0.5); }
}

.hint-glow {
    animation: hintGlow 3s ease-in-out;
}

@keyframes hintGlow {
    0% { box-shadow: 0 0 5px blue; }
    50% { box-shadow: 0 0 15px blue; }
    100% { box-shadow: 0 0 5px blue; }
}

#rotateMessage {
    display: none;
    font-size: 1.5em;
    text-align: center;
}
