* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 20px;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    color: #e8e8e8;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    transition: background 0.3s, color 0.3s;
}

body.light {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 50%, #a5d6a7 100%);
    color: #333;
}

.container {
    max-width: 500px;
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

body.light .container {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
}

h1 {
    margin: 0 0 5px 0;
    font-size: 2.5em;
    background: linear-gradient(135deg, #4ade80, #22d3ee);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
}

body.light h1 {
    background: linear-gradient(135deg, #2e7d32, #00796b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    text-align: center;
    color: #aaa;
    margin: 0 0 25px 0;
    font-size: 0.95em;
}

body.light .subtitle {
    color: #666;
}

.game-area {
    margin-bottom: 20px;
}

/* Word Ladder Display */
.word-ladder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.word-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.word-label {
    font-size: 0.75em;
    text-transform: uppercase;
    color: #888;
    letter-spacing: 1px;
}

.word-letters {
    display: flex;
    gap: 5px;
}

.letter-box {
    width: 45px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    font-weight: bold;
    border-radius: 8px;
    text-transform: uppercase;
    transition: all 0.3s;
}

.start-word .letter-box {
    background: linear-gradient(135deg, #4ade80, #22c55e);
    color: white;
    box-shadow: 0 4px 15px rgba(74, 222, 128, 0.3);
}

.target-word .letter-box {
    background: linear-gradient(135deg, #f472b6, #ec4899);
    color: white;
    box-shadow: 0 4px 15px rgba(236, 72, 153, 0.3);
}

/* Ladder Steps */
.ladder-steps {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-height: 50px;
    padding: 10px 0;
    position: relative;
}

.ladder-steps::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(180deg, rgba(74, 222, 128, 0.5), rgba(236, 72, 153, 0.5));
    z-index: 0;
}

.step-word {
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 12px;
    border-radius: 8px;
    position: relative;
    z-index: 1;
    animation: slideIn 0.3s ease-out;
}

body.light .step-word {
    background: rgba(0, 0, 0, 0.05);
}

.step-word .letter-box {
    width: 35px;
    height: 40px;
    font-size: 1.2em;
    background: rgba(34, 211, 238, 0.3);
    border: 2px solid rgba(34, 211, 238, 0.5);
    color: #22d3ee;
}

body.light .step-word .letter-box {
    background: rgba(0, 121, 107, 0.1);
    border-color: rgba(0, 121, 107, 0.3);
    color: #00796b;
}

.step-word .letter-box.changed {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    border-color: #f59e0b;
    color: white;
    animation: pop 0.3s ease-out;
}

.arrow {
    color: #666;
    font-size: 1.2em;
    padding: 5px 0;
}

/* Input Area */
.input-area {
    display: flex;
    gap: 10px;
    margin: 20px 0;
}

input {
    flex: 1;
    padding: 14px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    color: #fff;
    font-size: 1.1em;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-align: center;
}

body.light input {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.15);
    color: #333;
}

input::placeholder {
    color: #888;
    text-transform: none;
    letter-spacing: 0;
}

input:focus {
    outline: none;
    border-color: #4ade80;
    box-shadow: 0 0 15px rgba(74, 222, 128, 0.3);
}

button {
    padding: 14px 24px;
    background: linear-gradient(135deg, #4ade80, #22d3ee);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1em;
    transition: all 0.3s;
}

button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(74, 222, 128, 0.4);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Controls */
.controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 15px 0;
}

.controls button {
    padding: 10px 16px;
    font-size: 0.9em;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

body.light .controls button {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
    color: #333;
}

.controls button:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.2);
}

#hint-btn {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
}

#new-puzzle-btn {
    background: linear-gradient(135deg, #a78bfa, #8b5cf6);
}

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

.stat {
    background: rgba(0, 0, 0, 0.3);
    padding: 12px 8px;
    border-radius: 10px;
    text-align: center;
}

body.light .stat {
    background: rgba(0, 0, 0, 0.05);
}

.stat-label {
    font-size: 0.7em;
    color: #888;
    text-transform: uppercase;
    display: block;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.3em;
    font-weight: bold;
    color: #4ade80;
}

body.light .stat-value {
    color: #2e7d32;
}

/* Message */
.message {
    padding: 12px;
    border-radius: 10px;
    text-align: center;
    margin: 15px 0;
    min-height: 20px;
    font-weight: 500;
}

.message.success {
    background: rgba(74, 222, 128, 0.2);
    color: #4ade80;
    border: 1px solid rgba(74, 222, 128, 0.4);
}

.message.error {
    background: rgba(255, 100, 100, 0.2);
    color: #ff6464;
    border: 1px solid rgba(255, 100, 100, 0.4);
}

.message.info {
    background: rgba(34, 211, 238, 0.2);
    color: #22d3ee;
    border: 1px solid rgba(34, 211, 238, 0.4);
}

.message.victory {
    background: linear-gradient(135deg, rgba(74, 222, 128, 0.3), rgba(236, 72, 153, 0.3));
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.3);
    font-size: 1.2em;
    animation: celebrate 0.5s ease-out;
}

body.light .message.victory {
    color: #333;
}

/* Settings */
.settings {
    display: flex;
    gap: 10px;
    margin: 20px 0;
    flex-wrap: wrap;
    align-items: center;
}

.settings label {
    color: #888;
}

select {
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    font-size: 0.95em;
}

body.light select {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
    color: #333;
}

#theme-toggle {
    margin-left: auto;
    padding: 10px 16px;
    font-size: 0.9em;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

body.light #theme-toggle {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
    color: #333;
}

/* Instructions */
.instructions {
    background: rgba(0, 0, 0, 0.2);
    padding: 20px;
    border-radius: 12px;
    margin-top: 20px;
    font-size: 0.9em;
}

body.light .instructions {
    background: rgba(0, 0, 0, 0.05);
}

.instructions h3 {
    margin: 0 0 15px 0;
    color: #4ade80;
    font-size: 1.1em;
}

body.light .instructions h3 {
    color: #2e7d32;
}

.instructions ul {
    padding-left: 20px;
    line-height: 1.8;
    margin: 0;
}

.instructions li {
    margin-bottom: 5px;
}

.example {
    margin: 15px 0 0 0;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    text-align: center;
    font-family: monospace;
    font-size: 1.1em;
    color: #22d3ee;
}

body.light .example {
    background: rgba(0, 0, 0, 0.05);
    color: #00796b;
}

/* Music Controls */
.music-controls {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    background: rgba(0, 0, 0, 0.5);
    padding: 12px;
    border-radius: 12px;
    backdrop-filter: blur(10px);
}

body.light .music-controls {
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.music-controls button {
    padding: 8px 16px;
    font-size: 0.85em;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

body.light .music-controls button {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
    color: #333;
}

.song-name {
    position: fixed;
    bottom: 80px;
    right: 20px;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.8em;
    white-space: nowrap;
    display: none;
}

body.light .song-name {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    color: #333;
}

.song-name:not(:empty) {
    display: block;
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pop {
    0% {
        transform: scale(0.8);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes celebrate {
    0% {
        transform: scale(1) rotate(0deg);
    }
    25% {
        transform: scale(1.05) rotate(-2deg);
    }
    75% {
        transform: scale(1.05) rotate(2deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-5px);
    }
    75% {
        transform: translateX(5px);
    }
}

.shake {
    animation: shake 0.3s ease-out;
}

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

    .container {
        padding: 20px;
    }

    h1 {
        font-size: 2em;
    }

    .letter-box {
        width: 38px;
        height: 42px;
        font-size: 1.3em;
    }

    .step-word .letter-box {
        width: 30px;
        height: 35px;
        font-size: 1em;
    }

    .stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .controls {
        flex-direction: column;
    }

    .controls button {
        width: 100%;
    }

    .settings {
        flex-direction: column;
        align-items: stretch;
    }

    #theme-toggle {
        margin-left: 0;
    }

    .music-controls {
        bottom: 10px;
        right: 10px;
        left: 10px;
        justify-content: center;
    }

    .song-name {
        bottom: 70px;
        right: 10px;
        left: 10px;
        text-align: center;
    }
}
