body {
    /* Prioritize standard Western fonts before defaulting to the locale system font */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
}

h2 { margin-top: 0; color: #1e293b; text-align: center; }

.panel {
    background: white;
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    width: 100%;
    max-width: 800px;
    box-sizing: border-box;
}

.controls {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.size-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f1f5f9;
    padding: 6px 12px;
    border-radius: 6px;
}

input[type="number"] {
    padding: 6px;
    font-size: 16px;
    width: 55px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    text-align: center;
}

button.action-btn {
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
    border: none;
    border-radius: 4px;
    transition: all 0.2s;
    font-weight: bold;
    color: white;
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-play { background: #3b82f6; }
.btn-play:hover:not(:disabled) { background: #2563eb; }
.btn-auto { background: #8b5cf6; }
.btn-auto:hover:not(:disabled) { background: #7c3aed; }
.btn-undo { background: #f59e0b; }
.btn-undo:hover:not(:disabled) { background: #d97706; }
button:disabled { background: #cbd5e1; cursor: not-allowed; }

.toggle-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 15px;
    color: #334155;
    cursor: pointer;
    user-select: none;
    background: #f1f5f9;
    padding: 8px 12px;
    border-radius: 4px;
    font-weight: 500;
    transition: background 0.2s;
}
.toggle-label:hover { background: #e2e8f0; }
.toggle-label input[type="checkbox"] { margin: 0; cursor: pointer; width: 16px; height: 16px; }

#status { font-weight: bold; font-size: 1.1rem; color: #334155; text-align: center; }
.success-text { color: #16a34a; }
.error-text { color: #dc2626; }

#board-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    /* Removed fixed height to let JS control the perfect bounds */
    margin-bottom: 40px; 
    padding: 10px 0;
}

#board-container {
    position: relative;
    border: 2px solid #0f172a;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    background: white;
    touch-action: manipulation;
    /* Dimensions explicitly set by JS to guarantee square cells */
}

.grid { 
    display: grid; 
    width: 100%; 
    height: 100%; 
}
.cell {
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}
.cell:active { transform: scale(0.95); }
.white { background-color: #ffffff; }
.black { background-color: #e2e8f0; }

.current-cell { background-color: #fef08a !important; box-shadow: inset 0 0 10px rgba(0,0,0,0.1); }
.hint-cell { background-color: #dcfce7 !important; box-shadow: inset 0 0 0 3px #4ade80; }
.hint-cell:hover { background-color: #bbf7d0 !important; }

.step-number {
    position: relative;
    z-index: 3;
    font-weight: bold;
    /* Explicitly define standard monospace fonts instead of generic 'monospace' */
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace !important;
    text-shadow: 0 0 4px white, 0 0 4px white, 0 0 4px white;
    pointer-events: none; 
}

.svg-layer {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 2;
    pointer-events: none;
}
polyline {
    fill: none;
    stroke: #ef4444; 
    stroke-opacity: 0.8;
    stroke-linejoin: round;
    stroke-linecap: round;
    transition: all 0.3s ease;
}

/* SEO Content Footer */
.seo-footer {
    width: 100%;
    max-width: 800px;
    color: #475569;
    font-size: 0.95rem;
    line-height: 1.6;
    padding: 20px;
    background: white;
    border-top: 3px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.seo-footer h3 { color: #1e293b; margin-top: 0; }
.seo-lang-block { display: none; }
.seo-lang-block.active { display: block; }