* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-image: url(images/ornamented.png);
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    font-family: 'Segoe UI', Tahoma, 'Cairo', 'Noto Sans Arabic', sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    background: #a79f72fa;
    border: 2px solid #3e3668;
    border-radius: 12px;
    box-shadow: 15px 15px 10px rgba(0, 0, 0, 0.7);
    padding: 30px;
    max-width: 900px;
    width: 100%;
}

h1 {
    color: #2e284b;
    text-align: center;
    margin-bottom: 10px;
    font-size: 2.2rem;
    padding: 11px 18px;
    text-shadow:
        2px 2px 4px rgba(0, 0, 0, 0.5),
        4px 4px 10px rgba(0, 0, 0, 0.3),
        -1px -1px 0 #f39d12cb;

    font-weight: bold;
    letter-spacing: 0.05em;
    font-family: 'Segoe UI', Tahoma, 'Cairo', 'Noto Sans Arabic', sans-serif;
    line-height: 1.15;
    display: flex;
    align-items: center;
}


h1 span.arabic {
    margin-inline-start: auto;
}

.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 15px;
    font-size: 1rem;
}

.text-area-wrapper {
    margin-bottom: 30px;
    position: relative;
}

.text-output {
    background: #e2e1d8fa;
    width: 100%;
    min-height: 150px;
    padding: 10px;
    font-size: 1.2rem;
    border: 3px inset #928080;
    border-radius: 8px;
    font-family: Arial, sans-serif;
    resize: vertical;
    direction: rtl;
    text-align: right;
    transition: border-color 0.3s;
}

.text-output:focus {
    outline: none;
}

.text-output::placeholder {
    color: #bbb;
}

.tool-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-top: 5px;
}

.copy-btn {
    flex-shrink: 0;
    padding: 10px 25px;
    background: #2e284b;
    color: white;
    border: 2px outset #4a4175;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.3s, transform 0.1s;
    font-weight: 600;
}

.copy-btn:hover {
    background: #FFD700;
    border-color: #fdd808;
    transform: translateY(-2px);
}

.copy-btn:active {
    border-style: inset;
    transform: translateY(0);
}

.copy-btn.copied {
    background: #207068;
    border-color: #2b887f;
}

.clear-btn {
    flex-shrink: 0;
    padding: 10px 25px;
    background: #928080;
    color: white;
    border: 2px outset #a09090;
    border-radius: 6px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.3s, transform 0.1s;
    font-weight: 600;
}

.clear-btn:hover {
    background: #ee5a5a;
    transform: translateY(-2px);
}

.clear-btn:active {
    transform: translateY(0);
}

.keyboard-info {
    flex-grow: 1;
    margin: 0 5px;
    border: 2px solid #928080;
    text-align: center;
    padding: 3px;
    background: #e2e1d8fa;
    border-radius: 8px;
    border-left: 4px solid #2e284b;
}

.keyboard-info p {
    color: #333;
    font-size: 1rem;
    font-weight: 500;
}

.keyboard-layout {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 2px solid #4a4175;
}

.keyboard-layout h2 {
    color: #2e284b;
    margin-bottom: 5px;
    font-size: 1.3rem;
}

.key-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    direction: rtl;
    gap: 4px;
    padding: 5px;
    background: linear-gradient(-150deg, #101010, #24221b);
    border-radius: 8px;
    margin-bottom: 10px;
}

.compact-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    width: auto;
    flex: 0 1 auto;
    margin-inline-start: auto;
}

.grid-row {
    display: flex;
    flex-direction: row-reverse;
    gap: 10px;
    width: 100%;
}

.grid-row .compact-grid {
    margin-inline-start: 0;
}

.compact-grid .key-item {
    flex: 1 1 50px;
}

.key-item {
    cursor: pointer;
    background: linear-gradient(-45deg, #050505, #333026);
    border: 3px outset #222;
    border-radius: 6px;
    padding: 5px;
    text-align: center;
    display: flex;
    flex-direction: column;
    box-shadow:
        inset 0 2px 5px rgba(255, 255, 255, 0.1),
        0 2px 5px rgba(0, 0, 0, 0.7);
    transition: all 0.2s;
    user-select: none;
}

.key-item:hover {
    background: linear-gradient(-45deg, #101010, #444033);
    border: 3px outset #363636;
}

.key-item.key-clicked {
    background: linear-gradient(-45deg, #000000, #29261e);
    border: 3px outset #222;
}

.key-item .ar-key {
    font-weight: bold;
    font-size: 1.2rem;
    color: #ccac4d;
}

.key-item .eng-key {
    padding-left: 4px;
    align-self: flex-end;
    font-weight: bold;
    font-size: 0.85rem;
    color: RGB(170, 175, 180);
    font-family: 'Fira Mono', 'JetBrains Mono', 'Cascadia Mono'
}

.highlight {
    text-shadow:
        0 0 8px #d4c7a1,
        0 0 16px #ffc40099;
}

@media (max-width: 600px) {
    .container {
        padding: 20px;
    }

    h1 {
        font-size: 1.8rem;
    }

    .text-output {
        min-height: 120px;
        font-size: 1rem;
        padding: 15px;
    }

    .key-grid {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    }
}