:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-bg: #eef2ff;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --radius: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 20px;
}

body.rtl {
    direction: rtl;
    font-family: 'Tajawal', sans-serif;
}

.app-container {
    width: 100%;
    max-width: 900px; /* Slightly wider for the sheet */
    background: var(--bg-color); /* App container blends with bg now, cards are separate */
    /* border-radius: var(--radius); */
    /* box-shadow: var(--shadow-lg); */
    /* padding: 2rem; */
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

header {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

h1 {
    font-size: 2.5rem;
    color: var(--primary-color);
    font-weight: 800;
}

.language-selector {
    background: white;
    padding: 4px;
    border-radius: 99px;
    display: flex;
    box-shadow: var(--shadow-sm);
}

.lang-btn {
    border: none;
    background: transparent;
    padding: 8px 24px;
    border-radius: 99px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.2s;
    font-family: inherit;
}

.lang-btn.active {
    background: var(--secondary-bg);
    color: var(--primary-color);
}

/* Controls Section */
.controls-section {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.input-group textarea {
    width: 100%;
    min-height: 80px;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1.1rem;
    font-family: inherit;
    resize: vertical;
}

.actions-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

/* Game Sheet (The part we screenshot) */
.game-sheet {
    background: white;
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.sheet-header {
    text-align: center;
    border-bottom: 2px solid var(--secondary-bg);
    padding-bottom: 1rem;
}

.sheet-header h3 {
    display: none; /* Removed in favor of input */
}

/* .sheet-title-input styles removed */

.instruction-input {
    width: 100%;
    text-align: center;
    border: none;
    font-size: 1.1rem;
    color: var(--text-muted);
    font-family: inherit;
    background: transparent;
}

.instruction-input:focus {
    outline: none;
    background: var(--secondary-bg);
}

.grid-container {
    display: grid;
    /* Default for mobile: adaptive */
    grid-template-columns: repeat(auto-fill, minmax(45px, 1fr));
    gap: 8px;
    justify-content: center;
}

@media (min-width: 600px) {
    .grid-container {
        /* Tablet/Desktop: Exactly 10 columns as requested */
        grid-template-columns: repeat(10, 1fr);
    }
}

.grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--secondary-bg);
    padding: 6px;
    border-radius: 6px;
    border: 1px solid rgba(0,0,0,0.05);
}

.char {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: bold;
}

.emoji {
    font-size: 1.4rem;
    line-height: normal;
}

.sheet-footer {
    border-top: 2px dashed var(--border-color);
    padding-top: 1.5rem;
}

.puzzle-box {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.label {
    display: none; /* Removed in favor of input */
}

.sheet-label-input {
    border: none;
    background: transparent;
    font-weight: bold;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.9rem;
    font-family: inherit;
    width: 100%;
}

.sheet-label-input:focus {
    outline: none;
    background: var(--secondary-bg);
    border-radius: 4px;
}

body.rtl .sheet-label-input {
    letter-spacing: 0;
    text-transform: none;
}

.encoded-display {
    min-height: 60px;
    padding: 1rem;
    background: var(--bg-color); /* Contrast against white sheet */
    border-radius: 8px;
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    line-height: 1.8;
}

.word-spacer {
    display: inline-block;
    width: 2rem;
}

/* Buttons */
button {
    font-family: inherit;
    cursor: pointer;
    font-size: 0.95rem;
    border: none;
    transition: all 0.2s;
    border-radius: 8px;
}

.primary-btn {
    background: var(--primary-color);
    color: white;
    padding: 10px 20px;
    font-weight: 600;
}

.primary-btn:hover {
    background: var(--primary-hover);
}

.secondary-btn {
    background: var(--secondary-bg);
    color: var(--primary-color);
    padding: 8px 16px;
    font-weight: 600;
}

.secondary-btn:hover {
    background: #e0e7ff;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: auto;
}