* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
}

body {
    background: #35654d;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;

    font-family: sans-serif;
    overflow: hidden;
}
/* =========================
   الشريط العلوي
   ========================= */
#topbar {
    position: fixed;
    z-index: 1000;
    height: 60px;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 60px;
    padding: 0 20px;
    border-radius: 6px;
    background: #222;
    color: white;
}

#topbar h1 {
    margin: 0;
    font-size: 20px;
}

.topbar-group,
.topbar-group-end {
    display: flex;
    align-items: center;
    gap: 10px;
}

#topbar button {
    margin: 0.1rem;
    padding: 0.4rem;
    border: 1px solid #fff;
    border-radius: 6px;
    outline: none;
    background: none;
    color: #fff;
    font: inherit;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

#move-deck.active {
    background: #4040e0;
}
/* =========================
   الطاولة والرزمة
   ========================= */

#table {
    position: relative;
    z-index: 1;
    width: 100%;
    height: calc(100% - 60px);
    overflow: hidden;
    background: transparent;
}

.deck {
    position: absolute;
    left: 50%;
    top: 50%;
    cursor: grab;
}

.deck-handle {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 10px;
    background: rgb(244, 237, 237);
    border-radius: 6px;
    font-size: 16px;
    cursor: grab;
    display: none;
    z-index: 10000;
}


/* =========================
   المناطق
   ========================= */

.zone {
    position: absolute;
    width: 140px;
    height: 190px;
    left: 80px;
    top: 100px;
    border: 2px dashed white;
    border-radius: 10px;
    user-select: none;
}

/* الاسم الصغير فوق المنطقة */

.zone-name {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 5px;
    color: white;
    font-size: 12px;
    white-space: nowrap;
}

/* الاسم الكبير داخل المنطقة */

.zone-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    text-align: center;
}

/* المنطقة في وضع التعديل */

.zone.selected {
    border-style: solid;
    cursor: move;
}

/* أزرار المنطقة */

.zone-actions {
    position: absolute;
    top: -38px;
    right: 0;
    display: flex;
    gap: 5px;
}

.zone-actions button {
    padding: 5px 8px;
    border: 0;
    border-radius: 5px;
    cursor: pointer;
}

/* =========================
   النوافذ المنبثقة
   ========================= */
.save-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
}

.save-modal.open {
    display: flex;
}

.save-modal-content {
    width: 550px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px;
    background: rgba(255, 255, 255, 0.885);
    border-radius: 12px;
    color: #222;
}

.save-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.save-modal-header h2 {
    margin: 0;
    font-size: 20px;
}

.close-modal {
    border: 0;
    background: none;
    font-size: 28px;
    cursor: pointer;
}
/* =========================
   خيارات الألعاب
   ========================= */

.game-option {
    display: flex;
    gap: 15px;
}

.game-info {
    width: 10%;
    padding: 10px;
    margin-bottom: 8px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #f5f5f5;
    text-align: right;
    font-size: 16px;
    cursor: pointer;
}

.game-info:hover {
    background: #e8eeee;
}


/* =========================
   الجداول المحفوظة
   ========================= */

.saved-table {
    width: 100%;
    padding: 12px;
    margin-bottom: 8px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #f5f5f5;
    text-align: right;
    font-size: 16px;
    cursor: pointer;
}

.saved-table:hover {
    background: #e8eeee;
}

.saved-table-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.saved-table-row .saved-table {
    flex: 1;
    margin: 0;
}

.delete-save {
    padding: 0 12px;
    border: 0;
    border-radius: 8px;
    background: #ddd;
    cursor: pointer;
}

.delete-save:hover {
    background: #ccc;
}
/* =========================
   أحجام البطاقات
   ========================= */
.card-size-option {
    width: 30%;
    padding: 10px;
    margin-bottom: 8px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #f5f5f5;
    text-align: center;
    font-size: 16px;
    cursor: pointer;
}

/* حجم صغير */

.deck.card-size-small .card {
    width: 4.84375rem;
    height: 6.875rem;
}

/* حجم متوسط */

.deck.card-size-medium .card {
    width: 5.625rem; 
    height: 7.875rem;
}

/* حجم كبير */

.deck.card-size-large .card {
    width: 7.875rem;
    height: 11.1875rem;
}

/* =========================
   ظهر البطاقات
   ========================= */

.deck.custom-card-back .card .back {
    background-image: var(--custom-card-back);
    background-size: cover;
    background-position: center;
    border-radius: 4px;
}

/* =========================
   خلفيات الطاولة
   ========================= */
#table-background-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

#table-background-options button {
    width: 100px;
    height: 70px;
    padding: 0;
    border: 2px solid #ccc;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    background: white;
}

#table-background-options button img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

#table-background-options .table-background-color {
    background: #35654d;
}

#table-background-options button.selected {
    border: 3px solid #222;
}

/* =========================
   خلفيات البطاقات
   ========================= */
#card-back-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

#card-back-options button {
    width: 70px;
    height: 100px;
    padding: 0;
    border: 2px solid #ccc;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    background: white;
}

#card-back-options button:hover {
    background: #e8eeee;
}

#card-back-options button img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

#card-back-options .card-back-default {
    background: #35654d;
}

#card-back-options #card-back-upload-button {
    font-size: 28px;
    background: #f5f5f5;
}

#card-back-options button.selected {
    border: 3px solid #222;
}

/* =========================
   التحذيرات
   ========================= */
.warning-popup {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 18px;
    background: #222;
    color: white;
    border-radius: 6px;
    font-size: 14px;
    z-index: 2000;
}