/* Game Area */
.target-area {
    flex: 1;
    overflow-y: auto;
    padding: 10px 5px;
    margin-bottom: 20px;
    scrollbar-width: thin;
    scrollbar-color: var(--surface-border) transparent;
}

.target-words-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    align-content: flex-start;
}

.word-slot {
    display: flex;
    gap: 4px;
    padding: 4px;
    transition: transform 0.2s;
    cursor: pointer;
}

.word-slot:hover { transform: scale(1.02); }
.word-slot.found { cursor: default; transform: none; }

.letter-box {
    width: 44px;
    height: 44px;
    background: var(--slot-bg);
    border-radius: 10px;
    border: 2px solid var(--surface-border);
    /* Deep socket look */
    box-shadow: 
        inset 0 6px 10px rgba(0, 0, 0, 0.6),
        0 1px 0 rgba(255,255,255,0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 800;
    font-size: 1.5rem;
    color: transparent;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.word-slot.found .letter-box {
    background: var(--accent-light);
    color: var(--accent-dark);
    border: 2px solid var(--accent-light);
    box-shadow: 
        0 4px 0 var(--accent-dark),
        0 6px 10px rgba(0,0,0,0.2);
    transform: translateY(-4px);
    text-shadow: none;
}

/* New Discovery Effect */
@keyframes shine {
    0% { background-position: -100% 0; }
    20% { background-position: 200% 0; } /* Fast pass */
    100% { background-position: 200% 0; } /* Long pause */
}

.word-slot.new-discovery .letter-box {
    background: linear-gradient(120deg, var(--accent-light) 30%, #fef08a 50%, var(--accent-light) 70%);
    background-size: 200% 100%;
    animation: shine 3s infinite;
    border-color: #fef08a;
    color: #713f12;
}

/* Hold to reveal feedback */
.word-slot.holding {
    transform: scale(0.98);
    filter: brightness(1.1);
}

.word-slot.holding .letter-box {
    border-color: var(--accent-light);
    box-shadow: 0 0 8px var(--accent-light);
    transition: all 1s linear; /* Match hold duration */
    background-color: rgba(255, 255, 255, 0.1);
}

/* Flash reveal effect */
@keyframes flashReveal {
    0% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.1); filter: brightness(2); background-color: var(--accent-light); }
    100% { transform: scale(1); filter: brightness(1); }
}

.word-slot.flash-reveal {
    animation: flashReveal 0.5s ease-out;
}

/* Play Area & Tiles */
.play-area {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-bottom: 10px;
    width: 100%;
}

.slots {
    display: flex;
    gap: 8px;
    min-height: 72px;
    width: 100%;
    overflow-x: auto;
    padding: 8px 4px;
    scrollbar-width: none;
}
.slots::-webkit-scrollbar { display: none; }
.slots .tile:first-child { margin-left: auto; }
.slots .tile:last-child { margin-right: auto; }

/* 3D Button/Tile Base Style */
.tile, .control-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.1s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s;
    flex-shrink: 0;
    user-select: none;
    position: relative;
}

.tile {
    width: 56px;
    height: 56px;
    /* Smooth, cold ivory look */
    background: linear-gradient(135deg, #ffffff 0%, #f0f0e0 100%);
    color: #0d2e18; /* Dark Green text ink */
    font-size: 1.8rem;
    border-radius: 6px; /* Sharper corners than Scrabble */
    font-family: "Georgia", serif; /* Classier serif font */
    
    /* The 3D effect */
    box-shadow: 
        inset 0 1px 0 #fff, /* Top edge shine */
        0 1px 0 #ccc,       /* Subtle side depth */
        0 4px 0 #11331f,    /* The dark green plastic backing found on real tiles */
        0 6px 6px rgba(0,0,0,0.4); /* Shadow on the felt */
        
    /* Make it glossy */
    overflow: hidden;
    border: none;
}

/* Optional: The "Glossy sheen" reflection on top */
.tile::after {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; height: 40%;
    background: linear-gradient(to bottom, rgba(255,255,255,0.8), transparent);
    border-radius: 6px 6px 0 0;
    pointer-events: none;
}

[data-theme="night"] .tile {
    backdrop-filter: blur(4px);
    border-top: 1px solid rgba(255,255,255,0.3);
    border-bottom: 4px solid var(--tile-edge);
    box-shadow: 
        0 0 15px rgba(99, 102, 241, 0.2),
        0 4px 6px rgba(0,0,0,0.5);
    text-shadow: 0 0 5px rgba(255,255,255,0.5);
}

[data-theme="wood"] .tile {
    background-color: #d4a373; /* Lighter wood tone */
    color: #3e2723; /* Dark brown text */
    border: 1px solid #b08968;
    border-radius: 8px;
    
    /* A wood-grain texture on the tile itself using a gradient trick */
    background-image: repeating-linear-gradient(
        45deg,
        rgba(255,255,255,0.1) 0px,
        rgba(255,255,255,0.1) 2px,
        transparent 2px,
        transparent 5px
    );

    box-shadow: 
        inset 0 0 10px rgba(0,0,0,0.1), /* Inner depth */
        0 4px 0 #8d6e63, /* Darker wood side */
        0 6px 6px rgba(0,0,0,0.5);
        
    text-shadow: 0 1px 0 rgba(255,255,255,0.3); /* Letterpress effect */
}

[data-theme="night"] .word-slot .letter-box {
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: inset 0 0 10px rgba(0,0,0,0.8);
}

[data-theme="wood"] .word-slot .letter-box {
    background-color: rgba(0, 0, 0, 0.2); /* Darken the wood behind it */
    border-radius: 12px;
    border: none;
    
    /* Inner shadow makes it look like a hole */
    box-shadow: 
        inset 0 3px 6px rgba(0, 0, 0, 0.6), /* Top shadow = depth */
        inset 0 -1px 2px rgba(255, 255, 255, 0.1), /* Bottom highlight = edge */
        0 1px 0 rgba(255, 255, 255, 0.1); /* Bottom rim highlight */
}

[data-theme="retro"] .tile {
    /* Transparent center */
    background: rgba(0, 255, 65, 0.05); 
    
    /* The Phosphor Green */
    color: #00ff41;
    border: 1px solid #00ff41;
    font-family: "Courier New", monospace;
    
    /* The Glow */
    box-shadow: 0 0 8px rgba(0, 255, 65, 0.4), inset 0 0 8px rgba(0, 255, 65, 0.2);
    text-shadow: 0 0 5px rgba(0, 255, 65, 0.8);
    
    border-radius: 2px; /* Tech is angular */
    transition: all 0.1s;
}

[data-theme="retro"] .tile::after {
    display: none;
}

[data-theme="retro"] .tile:active, [data-theme="retro"] .tile:hover {
    background: #00ff41;
    color: #000;
    box-shadow: 0 0 20px rgba(0, 255, 65, 0.8);
    text-shadow: none;
    cursor: crosshair;
    transform: none;
}

[data-theme="retro"] .word-slot .letter-box {
    border: 2px solid #33ff33;
    box-shadow: 0 0 5px rgba(51, 255, 51, 0.3), inset 0 0 10px rgba(0, 20, 0, 0.8);
    color: #33ff33;
    text-shadow: 0 0 5px #33ff33;
    border-radius: 2px;
    background: #000;
}

[data-theme="retro"] .word-slot.found .letter-box {
    background: #33ff33;
    color: #000;
    box-shadow: 0 0 15px #33ff33;
    text-shadow: none;
}

.tile:active {
    transform: translateY(4px);
    border-bottom-width: 2px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.tile.used {
    opacity: 0.4;
    background: var(--surface-border);
    color: var(--text-secondary);
    border-color: var(--surface-color);
    box-shadow: none;
    transform: translateY(4px);
    cursor: default;
    pointer-events: none;
    border-bottom-width: 2px;
}

.control-btn {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    font-size: 1.4rem;
    color: #0f172a;
    font-family: 'Noto Emoji', var(--font-main);
    border: none;
    border-bottom: 4px solid rgba(0,0,0,0.2);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.control-btn:active {
    transform: translateY(3px);
    border-bottom-width: 1px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: translateY(3px);
    border-bottom-width: 0;
    box-shadow: none;
    background: var(--surface-border);
    color: var(--text-secondary);
    filter: grayscale(100%);
}

.control-btn.shuffle {
    background: var(--warning-color);
    border-bottom-color: #d97706;
    color: #78350f;
}

.control-btn.clear {
    background: var(--error-color);
    border-bottom-color: #b91c1c;
    color: #7f1d1d;
}

.control-btn.submit-btn {
    background: var(--success-color);
    border-bottom-color: #15803d;
    color: #14532d;
}

.candidate-row, .rack-row {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    min-height: 70px;
    gap: 16px;
    width: 100%;
}

.rack-row { justify-content: space-between; padding: 0 4px; }
.side-actions { display: flex; gap: 8px; flex-shrink: 0; margin-left: 8px; }

@media (max-width: 480px) {
    .tile { width: 40px; height: 40px; font-size: 1.4rem; border-radius: 8px; }
    .control-btn { width: 40px; height: 40px; font-size: 1.2rem; }
    .rack-row { gap: 6px; }
    .slots { gap: 4px; }
    .side-actions { gap: 4px; margin-left: 4px; }
}
