/* Anagramatorex Specific Styles */

.game-container {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    padding: var(--space-md);
}

/* Setup Card */
.setup-card {
    max-width: 500px;
    margin: 0 auto;
    text-align: center;
}

.mode-selector {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
    margin-bottom: var(--space-lg);
}

.mode-selector .btn {
    flex: 1;
    padding: var(--space-md);
}

.mode-selector .btn.active {
    background-color: var(--color-accent);
    color: white;
    border-color: var(--color-accent);
}

.options-section {
    background: var(--color-bg-primary);
    padding: var(--space-lg);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    border: 1px solid var(--color-border);
    animation: fadeIn 0.3s ease;
}

.range-container {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) 0;
}

.slider {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--color-border);
    border-radius: var(--radius-full);
    outline: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--color-accent);
    cursor: pointer;
    box-shadow: 0 0 0 4px var(--color-bg-secondary);
    transition: transform 0.1s;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.full-width {
    width: 100%;
}

.btn-lg {
    padding: var(--space-md) var(--space-xl);
    font-size: var(--font-size-lg);
}

/* Game Screen */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-xl);
    position: relative;
}

.score-wrapper {
    position: relative;
}

.score-display {
    font-weight: 700;
    font-size: var(--font-size-lg);
    background: var(--color-bg-secondary);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-full);
    border: 1px solid var(--color-border);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}

.score-display:hover {
    border-color: var(--color-accent);
}

.dropdown-arrow {
    font-size: 0.8em;
    opacity: 0.7;
}

.score-details-popover {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    width: 300px;
    max-width: 90vw;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    animation: fadeIn 0.2s ease;
}

.score-detail-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.score-detail-row:last-child {
    margin-bottom: 0;
}

.score-len {
    width: 60px;
    color: var(--color-text-secondary);
}

.score-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--color-bg-primary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.score-progress-fill {
    height: 100%;
    background: var(--color-accent);
    transition: width 0.3s ease;
}

.score-detail-row.done .score-progress-fill {
    background: var(--color-success);
}

.score-val {
    width: 40px;
    text-align: right;
    font-weight: 600;
}


/* Rack & Tiles */
.rack-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-xl);
    min-height: 80px;
    padding: var(--space-lg);
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-lg);
    border: 1px dashed var(--color-border);
}

/* Tile Styles */
.tile {
    width: 50px;
    height: 50px;
    background: var(--bg-card-gradient);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--color-text-primary);
    cursor: pointer;
    user-select: none;
    box-shadow: var(--shadow-md);
    transition: transform 0.1s, box-shadow 0.1s, opacity 0.2s;
    position: relative;
}

.tile:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--color-accent);
}

.tile:active {
    transform: translateY(1px);
}

.tile.used {
    opacity: 0.3;
    pointer-events: none;
    transform: scale(0.9);
}

.tile.selected {
    border-color: var(--color-accent);
    background: var(--color-accent-light);
}

/* Placeholder Slot (Ghost Tile) */
.tile.placeholder-slot {
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed var(--color-border);
    box-shadow: none;
    cursor: default;
    pointer-events: none;
}

.tile.placeholder-slot:hover {
    transform: none;
    border-color: var(--color-border);
}

/* Controls */
.controls {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
    justify-content: center;
}

.input-display {
    flex: 1;
    max-width: 500px;
    height: 70px;
    background: var(--color-bg-secondary);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 var(--space-md);
    font-size: 2rem;
    letter-spacing: 0.2em;
    font-weight: 700;
    font-family: monospace;
    color: var(--color-accent);
    position: relative;
    overflow: hidden;
}

.input-display.invalid {
    border-color: var(--color-error);
    animation: shake 0.4s;
}

.input-display.valid {
    border-color: var(--color-success);
}

.input-display .placeholder {
    font-size: 1rem;
    color: var(--color-text-muted);
    letter-spacing: normal;
    font-family: var(--font-family);
    font-weight: 400;
    opacity: 0.6;
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
    flex-wrap: wrap;
}

/* Make Check Button Full Width on its own line */
.btn-check-wrapper {
    width: 100%;
    margin-bottom: var(--space-md);
    text-align: center;
}

.btn-check {
    width: 100%;
    max-width: 400px;
    padding: var(--space-md);
    font-size: 1.2rem;
}

/* Feedback & Results */
.feedback-area {
    height: 0;
    margin: 0;
    padding: 0;
    overflow: visible;
    position: relative;
    z-index: 200;
}

.feedback-popup {
    position: absolute;
    top: -100px;
    /* Appear above the feedback-area's vertical center in the game flow */
    left: 50%;
    transform: translateX(-50%);
    font-size: 5rem;
    filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.5));
    pointer-events: none;
    z-index: 1000;
    animation: feedbackPop 0.6s ease-out forwards;
}

.feedback-popup.ruler-popup {
    /* Most ruler emojis are tilted at 45 degrees. Rotate by -45deg to level it. */
    display: inline-block;
    transform-origin: center;
    rotate: -45deg;
}

@keyframes feedbackPop {
    0% {
        transform: translate(-50%, 20px) scale(0);
        opacity: 0;
    }

    20% {
        transform: translate(-50%, -20px) scale(1.2);
        opacity: 1;
    }

    80% {
        transform: translate(-50%, -40px) scale(1);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -60px) scale(0.8);
        opacity: 0;
    }
}

/* Give Up Button White */
#btn-give-up {
    color: white !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
}

#btn-give-up:hover {
    border-color: white !important;
    background: rgba(255, 255, 255, 0.1);
}

.found-words {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    justify-content: center;
    padding: var(--space-md);
    background: var(--color-bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
}

.found-word {
    padding: 8px 16px;
    background: transparent;
    border-radius: var(--radius-full);
    font-size: 1rem;
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
}

.found-word.new {
    /* Previously animated via popIn but requested "green simply" without animation transition from green to black if meant that way. 
       Actually user said: "dobre słowo po prostu wyświetla się na zielono później, a nie animacja z zielonego na czarny"
       This likely means: If it's correct, keep it green permanently? Or just don't do the complex animation?
       Let's make Found Words GREEN permanently if they are valid.
    */
    border-color: var(--color-success);
    color: var(--color-success);
    /* Remove temporary animation class usage or make it permanent style */
}

/* Override previous "new" animation if it was temporary */
.found-word.valid-found {
    border-color: var(--color-success);
    color: var(--color-success);
}

.found-word.missed {
    /* Reverted to warning color as requested */
    border-color: var(--color-warning);
    color: var(--color-warning);
    opacity: 0.9;
}

.found-word.invalid {
    border-color: var(--color-error);
    color: var(--color-error);
    background: rgba(239, 68, 68, 0.1);
    opacity: 0.8;
}

.found-word.too-short {
    border-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.6);
    background: rgba(0, 0, 0, 0.3);
}

/* Animations */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

@keyframes popIn {
    from {
        transform: scale(0);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Loading */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    color: white;
}

.loading-overlay .spinner {
    width: 50px;
    height: 50px;
    border-width: 4px;
    border-top-color: white;
    margin-bottom: var(--space-md);
}

/* Mobile Adjustments */
@media (max-width: 600px) {
    .tile {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }

    .controls {
        flex-wrap: wrap;
    }

    .input-display {
        order: -1;
        width: 100%;
        max-width: 100%;
    }

    .action-buttons {
        gap: var(--space-sm);
    }

    .btn {
        padding: var(--space-sm) var(--space-md);
        font-size: 0.9rem;
    }
}