:root {
    --case-color: #1a1b1d;
    --bezel-color: #000;
    --screen-bg: #8ba989;
    /* Retro green */
    --screen-text: #fff;
    --key-color: #0f0f10;
    --key-text: #ddd;
    --key-text-secondary: #777;
    --accent-green: #4caf50;
    --accent-red: #f44336;
    --brand-color: #eeeeee;
}

* {
    box-sizing: border-box;
    user-select: none;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

body {
    margin: 0;
    padding: 0;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #f0f2f5;
    font-family: 'Inter', sans-serif;
}

/* Arabic Font Support */
body[lang="ar"] {
    font-family: 'Tajawal', 'Cairo', sans-serif !important;
}

body[lang="ar"] *:not(i) {
    font-family: 'Tajawal', 'Cairo', sans-serif !important;
}

body[lang="ar"] .screen,
body[lang="ar"] .screen * {
    font-family: 'VT323', 'Tajawal', monospace !important;
}

body[lang="ar"] .header-brand {
    font-family: 'Tajawal', sans-serif !important;
    font-weight: 700;
}

body[lang="ar"] .menu-item span,
body[lang="ar"] .soft-keys-labels span,
body[lang="ar"] .app-list-item,
body[lang="ar"] .app-title-display,
body[lang="ar"] .system-dialog-text {
    font-family: 'Tajawal', sans-serif !important;
    font-weight: 500;
}

body[lang="ar"] .app-content p {
    font-family: 'Tajawal', sans-serif !important;
}

.phone-container {
    width: 320px;
    /* Tall feature phone */
    background: linear-gradient(135deg, #2a2a2c, #111);
    border-radius: 40px;
    padding: 20px 15px;
    box-shadow:
        -5px -5px 15px rgba(255, 255, 255, 0.1),
        10px 10px 30px rgba(0, 0, 0, 0.5),
        inset 0 0 0 2px #333;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.phone-case {
    width: 100%;
}

/* --- Branding --- */
.header-brand {
    font-family: 'Exo 2', sans-serif;
    color: var(--brand-color);
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 25px;
    /* Increased margin to separate from keys */
    margin-top: 5px;
    letter-spacing: 1px;
    text-transform: uppercase;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.speaker-grill {
    display: flex;
    gap: 3px;
    justify-content: center;
    margin-bottom: 15px;
    margin-top: 5px;
}

.speaker-grill span {
    width: 4px;
    height: 4px;
    background-color: #000;
    border-radius: 50%;
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.2);
}

/* --- Screen --- */
.screen-bezel {
    width: 100%;
    background-color: var(--bezel-color);
    padding: 10px 12px;
    border-radius: 15px 15px 15px 15px;
    /* Slightly curved bottom like some models */
    box-shadow: inset 0 0 5px rgba(255, 255, 255, 0.1);
    pointer-events: none;
}

.startup-screen {
    position: absolute;
    top: -6px;
    left: -6px;
    width: calc(100% + 12px);
    height: calc(100% + 12px);
    background-color: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    z-index: 100;
}

.startup-screen img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
    /* Retro feel */
}

.screen {
    background-color: var(--screen-bg);
    background-image: url("https://file.garden/aU1YMB49_1Ga6wPg/filip/image%20(9).png");
    background-size: cover;
    background-position: center;
    height: 220px;
    border-radius: 4px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-family: 'VT323', monospace;
    font-size: 22px;
    color: var(--screen-text);
    box-shadow: inset 2px 2px 5px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px;
    color: var(--screen-text);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    position: relative;
    z-index: 20;
}

/* Menu Grid Styles */
.menu-screen {
    flex-grow: 1;
    padding: 5px;
    overflow: hidden;
    color: #fff;
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    height: 100%;
}

.menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 4px 2px;
    padding: 2px 1px;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
}

.menu-item i {
    font-size: 20px;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.5));
}

.menu-item img {
    width: 40px;
    height: 30px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
    margin-bottom: 2px;
}

.menu-item span {
    font-size: 10px;
    font-family: 'Exo 2', sans-serif;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* Highlighted item style (simulated for now) */
.menu-item.active {
    background-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}

/* Red Background when Menu is active */
.screen.menu-active {
    background-image: none !important;
    /* Override the default wallpaper */
    background: radial-gradient(circle at center, #ff5252, #b71c1c);
}

.screen.settings-active {
    background-image: none !important;
    background: #000;
}

/* Fade Effect for Status Bar and Soft Keys */
.status-bar.fade-bg {
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.6), transparent);
    margin: -6px -6px 0 -6px;
    padding: 8px 8px 2px 8px;
    /* Compensate for negative margin + original padding */
}

.soft-keys-labels.fade-bg {
    background: linear-gradient(to top, rgba(0, 0, 0, 0.6), transparent);
    margin: 0 -6px -6px -6px;
    padding: 2px 8px 8px 8px;
    /* Compensate */
}

/* App Screen Styles */
.app-screen {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    background: rgba(0, 0, 0, 0.4);
    /* Backdrop for apps */
    /* Backdrop for apps */
    margin: 10px;
    border-radius: 4px;
    /* position: relative; Removed to allow children to position relative to .screen */
}

.app-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.wallpaper-preview {
    position: absolute;
    inset: -6px;
    border: none;
    border-radius: 4px;
    z-index: 1;
    background-size: cover;
    background-position: center;
}

.app-icon-display {
    font-size: 40px;
    margin-bottom: 15px;
}

.app-title-display {
    margin: 0;
    font-size: 20px;
    font-family: 'Exo 2', sans-serif;
}

/* App List Styles */
.app-list {
    list-style: none;
    padding: 0;
    margin: 0;
    width: 100%;
    margin-top: 10px;
    /* ensure it scrolls if too long */
    overflow-y: auto;
    max-height: 140px;
}

.app-list-item {
    font-size: 16px;
    font-family: 'Exo 2', sans-serif;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    text-align: left;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background-color 0.2s;
}

.app-list-item i {
    font-size: 18px;
    min-width: 20px;
    text-align: center;
    opacity: 0.9;
}

.app-list-item span {
    flex: 1;
}

.app-list-item.active {
    background-color: rgba(255, 255, 255, 0.3);
}

/* RTL Support for Arabic */
body[lang="ar"] .app-list-item {
    text-align: right;
    flex-direction: row-reverse;
}

/* Wallpaper Slider Styles */
.wallpaper-slider {
    /* No layout needed, just a container for the absolute preview */
    width: 0;
    height: 0;
}

.wallpaper-preview {
    position: absolute;
    border: none;
    border-radius: 4px;
    /* Matches .screen radius */
    z-index: 1;
}

.slider-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.7);
    font-size: 24px;
    z-index: 10;
    animation: blinkArrow 2s infinite;
}

.slider-arrow.left {
    left: 10px;
}

.slider-arrow.right {
    right: 10px;
}

@keyframes blinkArrow {

    0%,
    100% {
        opacity: 0.4;
    }

    50% {
        opacity: 0.9;
    }
}


.signal-icon {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 16px;
}

.bar {
    width: 4px;
    background-color: var(--screen-text);
    border-radius: 1px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.b1 {
    height: 4px;
}

.b2 {
    height: 8px;
}

.b3 {
    height: 12px;
}

.b4 {
    height: 16px;
}

.battery-icon {
    display: flex;
    align-items: center;
    gap: 1px;
}

.battery-body {
    width: 22px;
    height: 12px;
    border: 2px solid var(--screen-text);
    padding: 1px;
    border-radius: 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.battery-level {
    width: 80%;
    height: 100%;
    background-color: var(--screen-text);
}

.battery-tip {
    width: 2px;
    height: 6px;
    background-color: var(--screen-text);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.main-display {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.home-clock {
    text-align: center;
    color: var(--screen-text);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.clock-time {
    font-family: 'VT323', monospace;
    font-size: 48px;
    font-weight: 400;
    line-height: 1;
    margin-bottom: 8px;
    letter-spacing: 2px;
}

.clock-date {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 400;
    opacity: 0.9;
}

.soft-keys-labels {
    display: flex;
    justify-content: space-between;
    font-weight: bold;
    font-size: 20px;
    padding: 0 2px;
    color: var(--screen-text);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    position: relative;
    z-index: 20;
}

/* --- Controls --- */
.control-pad {
    width: 100%;
    position: relative;
    margin-bottom: 10px;
}

.d-pad-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
}

/* D-Pad Restructuring */
.d-pad {
    width: 78px;
    height: 74px;
    background: linear-gradient(145deg, #222, #000);
    border: 2px solid #555;
    border-radius: 20px;
    box-shadow:
        0 4px 6px rgba(0, 0, 0, 0.5),
        inset 0 1px 2px rgba(255, 255, 255, 0.1);
    position: relative;
    /* Remove default button styles if any remained */
    display: block;
}

.d-key {
    position: absolute;
    background: transparent;
    border: none;
    outline: none;
    cursor: pointer;
    padding: 0;
    z-index: 5;
}

/* Touch areas for directional keys */
.d-up {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 25px;
    border-radius: 10px 10px 0 0;
}

.d-down {
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 25px;
    border-radius: 0 0 10px 10px;
}

.d-left {
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    width: 25px;
    height: 40px;
    border-radius: 10px 0 0 10px;
}

.d-right {
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    width: 25px;
    height: 40px;
    border-radius: 0 10px 10px 0;
}

.d-center {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: transparent;
    display: flex;
    /* To center the inner div */
    justify-content: center;
    align-items: center;
    z-index: 6;
}

.d-pad-center-inner {
    width: 25px;
    height: 25px;
    background: #111;
    border-radius: 5px;
    box-shadow: inset 0 0 2px #000;
}

/* Visual feedback on press */
.d-key:active {
    background: rgba(255, 255, 255, 0.05);
}

.d-center:active .d-pad-center-inner {
    transform: scale(0.95);
}

.function-keys-row,
.call-keys-row {
    display: flex;
    justify-content: space-between;
    padding: 0 5px;
}

.function-keys-row {
    margin-bottom: 11px;
}

.btn {
    border: none;
    outline: none;
    background: linear-gradient(180deg, #2b2b2b, #1a1a1a);
    color: #fff;
    cursor: pointer;
    box-shadow:
        0 3px 0 #000,
        0 4px 4px rgba(0, 0, 0, 0.4),
        inset 0 1px 1px rgba(255, 255, 255, 0.1);
    transition: transform 0.1s, box-shadow 0.1s;
}

.btn:active {
    transform: translateY(2px);
    box-shadow:
        0 1px 0 #000,
        0 2px 2px rgba(0, 0, 0, 0.4);
}

.soft-key {
    width: 84px;
    height: 35px;
    border-radius: 8px 8px 20px 20px;
    /* Tapered bottom */
    display: flex;
    justify-content: center;
    align-items: center;
}

.dash-mark {
    width: 20px;
    height: 3px;
    background-color: #fff;
    border-radius: 2px;
}

.call-btn,
.end-btn {
    width: 70px;
    height: 35px;
    border-radius: 20px 20px 8px 8px;
    /* Tapered top */
    display: flex;
    justify-content: center;
    align-items: center;
}

.call-key,
.end-key {
    width: 84px;
    height: 35px;
    border-radius: 20px 20px 8px 8px;
    /* Tapered top */
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    /* Icon size */
}


.call-key {
    color: var(--accent-green);
    border-top: 2px solid #2e7d32;
}

/* Revert svg specific styles if any, using standard font styling now */

.end-key {
    color: var(--accent-red);
    border-top: 2px solid #c62828;
}

/* --- Keypad --- */
.keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    width: 100%;
    padding: 0 5px;
}

.num-key {
    height: 45px;
    border-radius: 12px;
    font-family: 'Exo 2', sans-serif;
    font-size: 20px;
    font-weight: 700;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    line-height: 1;
    background: linear-gradient(180deg, #222, #0d0d0d);
}

.num-key span {
    font-size: 10px;
    font-weight: 400;
    color: var(--key-text-secondary);
    margin-top: 2px;
    text-transform: lowercase;
}

.space-icon {
    font-family: monospace;
}

/* Clock Styles */

/* Default Style (Centered) - Already covered by base .home-clock */
/* Default Style (Centered) - Already covered by base .home-clock */
/* .home-clock.clock-default {} */

/* Top Right Style */
.home-clock.clock-top-right {
    position: absolute;
    top: 30px;
    right: 15px;
    text-align: right;
    width: auto;
    z-index: 10;
}

.home-clock.clock-top-right .clock-time {
    font-size: 36px;
    margin-bottom: 2px;
}

.home-clock.clock-top-right .clock-date {
    font-size: 12px;
    opacity: 0.8;
}

/* Large Style */
.home-clock.clock-large .clock-time {
    font-size: 68px;
    font-weight: 700;
    letter-spacing: -2px;
    text-shadow: 4px 4px 0px rgba(0, 0, 0, 0.2);
}

.home-clock.clock-large .clock-date {
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-size: 12px;
}

/* Bottom Left Style */
.home-clock.clock-bottom-left {
    position: absolute;
    bottom: 30px;
    left: 15px;
    text-align: left;
    width: auto;
    z-index: 10;
}

.home-clock.clock-bottom-left .clock-time {
    font-size: 42px;
    margin-bottom: 0;
}

.home-clock.clock-bottom-left .clock-date {
    font-size: 14px;
    opacity: 0.9;
}