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

body {
    background-color: #fffef0;
    color: #111;
    font-family: 'Georgia', serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ==================== START SCREEN ==================== */
.start-screen {
    text-align: center;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.start-title {
    font-size: 5rem;
    font-weight: bold;
    color: #111;
    letter-spacing: 15px;
    margin-bottom: 40px;
    text-shadow: 4px 4px 0 #daa520;
    animation: titlePulse 2s ease-in-out infinite;
}

@keyframes titlePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.start-grid-container {
    margin: 30px 0 50px 0;
    position: relative;
}

.start-grid {
    display: grid;
    grid-template-columns: repeat(3, 80px);
    grid-template-rows: repeat(3, 80px);
    gap: 5px;
    position: relative;
}

.start-tile {
    width: 80px;
    height: 80px;
    background-color: #fff;
    border: 3px solid #111;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.5rem;
    font-weight: bold;
    text-transform: uppercase;
    position: absolute;
    transition: all 0.5s ease-out;
}

.start-tile.center {
    position: relative;
    background-color: #ffd700;
    z-index: 10;
}

.start-tile.orbiting {
    animation: float 3s ease-in-out infinite;
}

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

.start-button {
    background-color: #111;
    color: #fffef0;
    border: none;
    padding: 20px 60px;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Georgia', serif;
    letter-spacing: 3px;
}

.start-button:hover {
    background-color: #333;
    transform: scale(1.05);
}

.ghost-kitchen {
    margin-top: 60px;
    font-size: 1rem;
    color: #888;
    letter-spacing: 3px;
    text-transform: uppercase;
}

/* ==================== GAME MODE SELECTION ==================== */
.mode-select-box {
    padding: 40px 50px;
}

.mode-buttons {
    display: flex;
    gap: 20px;
    margin-top: 25px;
    justify-content: center;
    flex-wrap: wrap;
}

.mode-select-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 25px 35px;
    border: 3px solid #111;
    background-color: #fff;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 150px;
}

.mode-select-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.mode-select-btn .mode-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.mode-select-btn .mode-name {
    font-size: 1.3rem;
    font-weight: bold;
    color: #111;
    margin-bottom: 5px;
}

.mode-select-btn .mode-desc {
    font-size: 0.9rem;
    color: #666;
}

.words-btn:hover {
    background-color: #e6f3ff;
    border-color: #2a5298;
}

.numbers-btn:hover {
    background-color: #fff3e6;
    border-color: #daa520;
}

/* ==================== GAME CONTAINER ==================== */
.game-container {
    text-align: center;
    padding: 20px;
}

h1 {
    font-size: 2rem;
    margin-bottom: 10px;
    color: #111;
}

/* High Score Display */
.high-score-display {
    font-size: 1.1rem;
    margin-bottom: 5px;
    color: #b8860b;
    font-weight: bold;
}

/* Lives Display */
.lives-display {
    font-size: 1.2rem;
    margin-bottom: 15px;
    font-weight: bold;
}

#lives {
    letter-spacing: 3px;
}

.stats-row {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.stats-row.secondary {
    margin-bottom: 10px;
}

.stat-item {
    font-size: 1.1rem;
    font-weight: bold;
    padding: 5px 12px;
    background: #f5f5dc;
    border-radius: 8px;
    border: 2px solid #111;
}

.stat-item.small {
    font-size: 0.95rem;
    padding: 4px 10px;
}

.stat-item.points {
    background: #e6f7e6;
    border-color: #228b22;
}

.stat-item #hp {
    color: #c00;
}

.stat-item #score {
    color: #228b22;
}

.stat-item #rotations {
    color: #4169e1;
}

.stat-item #points-available {
    color: #228b22;
    font-weight: bold;
}

.hp-display, .score-display, .level-display {
    font-size: 1.5rem;
    margin-bottom: 10px;
    font-weight: bold;
}

#hp {
    color: #c00;
}

#grid-container {
    display: flex;
    justify-content: center;
    margin: 20px 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

#grid-wrapper {
    position: relative;
    padding: 10px;
    touch-action: none;
}

#grid {
    display: grid;
    grid-template-columns: repeat(3, 80px);
    grid-template-rows: repeat(3, 80px);
    gap: 5px;
    position: relative;
    overflow: visible;
    touch-action: none;
}

.tile {
    width: 80px;
    height: 80px;
    background-color: #fff;
    border: 3px solid #111;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.15s ease-out, opacity 0.3s;
    text-transform: uppercase;
    position: relative;
    will-change: transform;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.tile:hover {
    background-color: #f0f0e0;
}

.tile.selected {
    background-color: #ffd700;
    transform: scale(1.05);
}

.tile.dragging {
    transition: none !important;
}

.tile.snapping {
    transition: transform 0.15s ease-out;
}

.tile.empty {
    background-color: #ddd;
    border-color: #999;
}

/* Wild Card Tile */
.tile.wild {
    background: linear-gradient(135deg, #ff6b6b, #ffd700, #4ecdc4, #a855f7);
    background-size: 400% 400%;
    animation: wildGradient 2s ease infinite;
    border-color: #daa520;
    border-width: 4px;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.tile.wild.selected {
    animation: wildGradient 0.5s ease infinite;
    transform: scale(1.1);
}

@keyframes wildGradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Clearing animation */
.tile.clearing {
    animation: clearTile 0.4s ease-out forwards;
}

@keyframes clearTile {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.7;
        background-color: #90ee90;
    }
    100% {
        transform: scale(0);
        opacity: 0;
    }
}

/* Floating points animation */
.floating-points {
    position: fixed;
    font-size: 1.5rem;
    font-weight: bold;
    color: #228b22;
    pointer-events: none;
    z-index: 1001;
    animation: floatUp 1s ease-out forwards;
    text-shadow: 2px 2px 0 #fff, -2px -2px 0 #fff, 2px -2px 0 #fff, -2px 2px 0 #fff;
}

@keyframes floatUp {
    0% {
        transform: translateY(0);
        opacity: 1;
    }
    100% {
        transform: translateY(-60px);
        opacity: 0;
    }
}

.selected-word {
    font-size: 1.3rem;
    margin: 15px 0;
    min-height: 35px;
}

#selected-letters {
    font-weight: bold;
    letter-spacing: 3px;
}

.button-row {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

button {
    background-color: #111;
    color: #fffef0;
    border: none;
    padding: 12px 24px;
    font-size: 1.1rem;
    cursor: pointer;
    margin: 5px;
    transition: background-color 0.2s;
}

button:hover {
    background-color: #333;
}

.hint-button {
    background-color: #daa520;
}

.hint-button:hover {
    background-color: #cd950c;
}

#message {
    font-size: 1.1rem;
    margin-top: 15px;
    min-height: 25px;
    font-style: italic;
}

.message-success {
    color: #090;
}

.message-error {
    color: #c00;
}

.rotating {
    opacity: 0.7;
}

.game-over {
    font-size: 1.8rem;
    color: #c00;
    font-weight: bold;
}

/* Dialog Overlays */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.dialog-box {
    background-color: #fffef0;
    border: 4px solid #111;
    padding: 35px 50px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 90vw;
}

.dialog-box h2 {
    font-size: 2.2rem;
    margin-bottom: 15px;
    color: #111;
}

.dialog-box p {
    font-size: 1.2rem;
    margin-bottom: 12px;
    color: #333;
}

.dialog-box .bonus-text {
    color: #090;
    font-weight: bold;
    font-size: 1.3rem;
}

.dialog-box .extra-life-text {
    color: #c71585;
    font-weight: bold;
    font-size: 1.2rem;
}

.dialog-box .lives-warning {
    color: #c00;
    font-weight: bold;
}

.dialog-box button {
    margin-top: 15px;
    font-size: 1.2rem;
    padding: 12px 35px;
}

/* Rules Dialog */
.rules-dialog-box {
    max-width: 450px;
}

.rules-list {
    text-align: left;
    list-style: none;
    padding: 0;
    margin: 0;
}

.rules-list li {
    font-size: 1rem;
    margin-bottom: 12px;
    padding-left: 20px;
    position: relative;
    color: #333;
}

.rules-list li::before {
    content: '•';
    position: absolute;
    left: 5px;
    color: #111;
    font-weight: bold;
}

.level-display {
    font-size: 1.5rem;
    margin-bottom: 10px;
    font-weight: bold;
}

/* Game Mode Section */
.game-mode-section {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 2px solid #ddd;
}

.mode-button {
    background-color: #2a5298;
}

.mode-button:hover {
    background-color: #3a62a8;
}

.mode-button.approved-mode {
    background-color: #28a745;
}

.mode-button.approved-mode:hover {
    background-color: #38b755;
}

.approved-count {
    display: block;
    margin-top: 8px;
    font-size: 0.85rem;
    color: #666;
}

/* Developer Controls */
.dev-controls {
    margin-top: 25px;
    padding-top: 15px;
    border-top: 2px dashed #ccc;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.dev-button {
    background-color: #666;
    font-size: 0.9rem;
    padding: 8px 15px;
}

.dev-button:hover {
    background-color: #888;
}

.dev-button.danger {
    background-color: #c00;
}

.dev-button.danger:hover {
    background-color: #e00;
}

/* Responsive adjustments */
@media (max-width: 400px) {
    .start-title {
        font-size: 3rem;
        letter-spacing: 8px;
    }
    
    h1 {
        font-size: 1.6rem;
    }
    
    .tile, .start-tile {
        width: 70px;
        height: 70px;
        font-size: 2rem;
    }
    
    #grid, .start-grid {
        grid-template-columns: repeat(3, 70px);
        grid-template-rows: repeat(3, 70px);
    }
    
    .stat-item {
        font-size: 1rem;
        padding: 4px 10px;
    }
    
    button {
        padding: 10px 18px;
        font-size: 1rem;
    }
    
    .mode-select-btn {
        padding: 20px 25px;
        min-width: 130px;
    }
    
    .mode-select-btn .mode-icon {
        font-size: 2.5rem;
    }
}
