/* Main game container */
.main-game-container {
    min-width: 300px;
    width: fit-content;
    max-width: 100vw; /* Never exceed viewport width */
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.crossword-container {
    background: white;
    padding: var(--container-padding);
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
    margin-bottom: 0;
    position: relative;
    display: inline-block;
    width: fit-content;
    max-width: 100vw; /* Never exceed viewport width */
}

.main-crossword-content {
    display: flex;
    justify-content: center;
    position: relative;
}

.crossword-grid {
    display: inline-block;
    position: relative;
    margin: 0 auto;
}

.grid-row {
    display: flex;
}

.grid-cell {
    width: var(--cell-size);
    height: var(--cell-size);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--cell-size) * var(--font-scale));
    font-weight: 700;
    text-transform: uppercase;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    border-radius: calc(var(--cell-size) * var(--border-radius-scale));
    margin: 1px;
    -webkit-text-stroke: calc(var(--cell-size) * var(--text-stroke-scale)) currentColor;
    paint-order: stroke fill;
}

.grid-cell.empty {
    background: transparent;
    cursor: default;
    box-shadow: none;
}

.grid-cell.filled {
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
}

.grid-cell.filled:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

/* Color coding for letters */
.grid-cell.correct {
    background-color: #4CAF50;
    color: white;
    box-shadow: 0 2px 4px rgba(76, 175, 80, 0.3), 0 1px 2px rgba(0, 0, 0, 0.1);
}

.grid-cell.wrong-position {
    background-color: #FF9800;
    color: white;
    box-shadow: 0 2px 4px rgba(255, 152, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.1);
}

.grid-cell.connected-word {
    background-color: #9C27B0;
    color: white;
    box-shadow: 0 2px 4px rgba(156, 39, 176, 0.3), 0 1px 2px rgba(0, 0, 0, 0.1);
}

.grid-cell.wrong-word {
    background-color: #9E9E9E;
    color: white;
    box-shadow: 0 2px 4px rgba(158, 158, 158, 0.3), 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Selection states */
.grid-cell.selected {
    border: 3px solid #2196F3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.3);
    transform: scale(1.1);
    z-index: 20;
}

.grid-cell.swapping {
    animation: swapSpinFirst 0.25s ease forwards;
}

@keyframes swapSpinFirst {
    0% { transform: scale(1) rotate(0deg); }
    100% { transform: scale(1.2) rotate(180deg); }
}

@keyframes swapSpinSecond {
    0% { transform: scale(1.2) rotate(180deg); }
    100% { transform: scale(1) rotate(360deg); }
}

/* Top Toolbar */
.top-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

/* Toolbar buttons - shared styling */
.toolbar-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 10px;
    background: #f8fafc;
    color: #1f2937;
    cursor: pointer;
    transition: background 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
}

.toolbar-btn:hover {
    background: #e2e8f0;
}

.toolbar-btn:active {
    background: #cbd5e1;
}

.toolbar-btn svg {
    display: block;
}

/* Help button text icon */
.help-icon-text {
    font-family: 'Comfortaa', sans-serif;
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
}

/* Left buttons container */
.toolbar-left-buttons {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* Right buttons container */
.toolbar-right-buttons {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* Crossword Footer - invisible container for legend */
.crossword-footer {
    display: flex;
    justify-content: center;
    margin-top: 16px;
}

/* Color Legend - now in footer */
.color-legend {
    flex: 1;
    min-width: 0;
    display: flex;
    justify-content: center;
}

.legend-list {
    list-style: none;
    padding: 8px 12px;
    margin: 0;
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    background: #f8fafc;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    width: fit-content;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--font-size-sm);
    color: #4b5563;
    margin: 0;
    padding: 0;
    border: none;
    white-space: nowrap;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.legend-text {
    font-weight: 500;
}
