/* ==========================================================================
   Base Layout & Typography
   ========================================================================== */

.game-container {
    border-radius: 1.5rem;
    display: flex;
    flex-direction: column;
    max-width: 900px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    align-items: center;
}

.title {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
}

.subtitle {
    font-size: 1rem;
    text-align: center;
}

.hidden {
    display: none;
}


/* ==========================================================================
   Common Components
   ========================================================================== */

.buttons-container {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
}

.check-button {
    margin-top: 10px;
    padding: 0.75rem 2rem;
    border-radius: 0.5rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s;
    border: none;
}

.message-box {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 1.5rem;
    border-radius: 0.75rem;
    z-index: 1000;
    display: none;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.message-box.show {
    display: block;
    opacity: 1;
}

#clue-display {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    text-align: left;
    padding: 1.5rem;
    border-radius: 0.5rem;
    transition: opacity 0.5s ease-in-out;
}

#clue-display p {
    margin: 0;
    font-size: 1.125rem;
    line-height: 1.75;
}

#clue-display img {
    max-width: 100%;
    height: auto;
    border-radius: 0.5rem;
}

.input-group {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin: 10px 0px;
}

.btn-group {
    display: flex;
    justify-content: center;
    margin-top: 10px;
    margin-bottom: 10px;
}

.btn-group button {
    margin: 0 10px;
}

#guess-input {
    padding: 0.75rem;
    border-radius: 0.5rem;
    font-size: 1.25rem;
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
    width: 100%;
    max-width: 300px;
}

/* ==========================================================================
   Game-Specific Styles
   ========================================================================== */

/* --- Timeline / Drag & Drop Game --- */
.timeline {
    display: flex;
    flex-direction: column;
    align-self: center;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    border-radius: 0.75rem;
    min-height: 200px;
    width: 90%;
}

.timeline-slot {
    width: 100%;
    height: 50px;
}

#event-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 0.75rem;
    min-height: 100px;
}

.event-card {
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    cursor: grab;
    transition: transform 0.2s, background-color 0.2s;
    touch-action: none;
    user-select: none;
}

.event-card:active {
    cursor: grabbing;
}

.event-card.is-dragging {
    opacity: 0.5;
}

/* --- Verse Matching Game --- */
.game-grid {
    display: flex;
    justify-content: space-between;
    align-self: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.column {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex: 1;
    min-width: 250px;
}

.verse-card,
.reference-card {
    border-radius: 0.5rem;
    padding: 1rem;
    min-height: 120px;
    display: flex;
    align-items: center;
    text-align: center;
    justify-content: center;
    cursor: grab;
    transition: transform 0.2s, box-shadow 0.2s;
}

.drop-zone {
    border-radius: 0.5rem;
    min-height: 120px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-style: italic;
    transition: background-color 0.2s;
}

/* --- Puzzle Game --- */
#puzzle-grid {
    display: grid;
    width: 95%;
    border-radius: 0.5rem;
    overflow: hidden;
    touch-action: none;
    user-select: none;
}

.puzzle-piece {
    cursor: grab;
    display: flex;
    justify-content: center;
    align-items: center;
}

.puzzle-piece.dragging {
    opacity: 0.7;
}

.puzzle-piece canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* --- Crossword --- */
#ristsona {
    margin-left: auto;
    margin-right: auto;
}

#ristsona input {
    width: 25px;
    height: 25px;
    padding: 0;
    margin: 0;
    text-align: center;
    text-transform: uppercase;
}

#ristsona td {
    text-align: center;
}

/* --- Cipher Game --- */
#cipher-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 4px;
    padding: 5px;
}

.word-wrapper {
    display: inline-flex;
    flex-wrap: wrap;
    margin-right: 25px;
}

.cipher-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 3.5rem;
}

.cipher-cell.hyphen {
    font-weight: bold;
    user-select: none;
}

.cipher-symbol {
    width: 100%;
    height: 1.75rem;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 0.25rem 0.25rem 0 0;
    font-weight: 700;
}

.cipher-input {
    width: 100%;
    height: 1.75rem;
    border-radius: 0 0 0.25rem 0.25rem;
    text-align: center;
    text-transform: uppercase;
    font-weight: 700;
}

.key-table {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.5rem;
    padding: 1rem;
    border-radius: 0.5rem;
}

.key-cell {
    border-radius: 0.25rem;
    padding: 0.5rem;
    text-align: center;
    font-weight: bold;
}

/* --- Word Scramble & Word Search --- */
.verse-display-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-height: 100px;
    border-radius: 0.5rem;
    padding: 1rem;
}

.word-item {
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-weight: 600;
    user-select: none;
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s, text-decoration 0.2s;
}

.word-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.word-item.placeholder {
    opacity: 0.5;
    height: 2.5rem;
    min-width: 3rem;
}

.grid-container {
    display: grid;
    gap: 0.125rem;
    padding: 0.5rem;
    border-radius: 0.75rem;
}

.grid-cell {
    width: 1.75rem;
    height: 1.75rem;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    border-radius: 0.25rem;
    user-select: none;
}

.word-list {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.word-list .word-item {
    font-size: 0.875rem;
    cursor: default;
}

.word-found {
    text-decoration: line-through;
}

/* --- Fill in the Blanks --- */
#sentence-display {
    font-size: 1.25rem;
    line-height: 1.75;
    padding: 1rem;
    border-radius: 0.5rem;
}

#sentence-display input {
    border: none;
    outline: none;
    padding: 0 0.25rem;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 700;
    width: auto;
    min-width: 50px;
}

/* --- Coloring Game --- */
#coloring-canvas {
    border-radius: 0.5rem;
    touch-action: none;
    cursor: pointer;
    width: 100%;
    height: auto;
}

.palette {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
}

.color-swatch {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.color-swatch.active {
    transform: scale(1.2);
}

.color-mixer-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    border-radius: 0.5rem;
}

#color-picker-input {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 100%;
    height: 50px;
    border: none;
    cursor: pointer;
    border-radius: 0.5rem;
}

#color-picker-input::-webkit-color-swatch-wrapper {
    padding: 0;
}

.mixer-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.hex-input-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.hex-input-group input {
    padding: 0.5rem;
    border-radius: 0.5rem;
    text-transform: uppercase;
}

.save-button {
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.2s;
}


/* ==========================================================================
   Animations
   ========================================================================== */

@keyframes shake {
    0% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    50% {
        transform: translateX(5px);
    }

    75% {
        transform: translateX(-5px);
    }

    100% {
        transform: translateX(0);
    }
}

@keyframes found-animation {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

#hint-tooltip {
    display: none;
    opacity: 0;
}

#hint-tooltip.visible {
    display: block;
    opacity: 1;
    position: absolute;
    padding: 5px;
    border-radius: 20px;
}

.word-number {
    cursor: pointer;
    font-weight: bold;
    font-size: x-small;
    padding: 0 2px;
}

.draggable {
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    transition: opacity 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.draggable.dragging {
    cursor: grabbing;
    opacity: 0.6;
}

.drag-over {
    transform: scale(0.98);
}

.selected {
    transform: scale(1.03);
}

#options-container {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 1rem;
    width: 100%;
}

@media (min-width: 640px) {
    #options-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

.option-btn {
    border-width: 2px;
    border-style: solid;
    border-radius: 0.75rem;
    padding: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    width: 100%;
    text-align: center;
    user-select: none;
}

.option-btn:hover:not(:disabled) {
    transform: translateY(-2px);
}

.option-btn:disabled {
    cursor: not-allowed;
    opacity: 0.8;
}

#options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    width: 100%;
}

.option-btn img {
    max-width: 100px;
    height: auto;
    border-radius: 0.5rem;
}

#feedback-text {
    font-size: 1.125rem;
    font-weight: 600;
    min-height: 2rem;
    text-align: center;
    margin-top: 1rem;
}

#feedback-area {
    margin-top: 2rem;
    padding: 1.5rem;
    border-radius: 0.75rem;
    text-align: center;
    border: 1px solid;
}

.feedback-explanation {
    font-size: 1rem;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

#next-btn {
    font-weight: 700;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s;
    width: 100%;
    border: none;
    margin-top: 1rem;
}

/* --- Langevad tähed --- */

#source-grid {
    margin-bottom: 8px;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
}

#target-grid {
    margin-top: 0;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
}

.grid-cell.block {
    cursor: default;
}

.grid-cell.empty {
    opacity: 0;
    cursor: default;
    pointer-events: none;
}

.invisible-cell {
    visibility: hidden;
    pointer-events: none;
}

/* --- Labürint --- */
.empty-slot {
    visibility: hidden;
}

.control-btn {
    border-radius: 0.75rem;
    padding: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    user-select: none;
    border: none;
}

.control-btn:active {
    transform: scale(0.95);
}

#maze-wrapper {
    position: relative;
    border: 4px solid;
    border-radius: 0.5rem;
    overflow: hidden;
    line-height: 0;
    touch-action: none;
}

canvas {
    display: block;
    max-width: 100%;
    height: auto;
    cursor: pointer;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 1.5rem;
    width: 180px;
}