/* ═══════════════════════════════════════════════════════════════
   Droob Areeka — Main Stylesheet
   Palette: bg #1a1208 | accent #c9943a | text #f0e6d3
   Font: Playpen Sans Arabic
   Easing: cubic-bezier(0.77,0,0.18,1)
═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Playpen+Sans+Arabic:wght@300;400;600;700&display=swap');

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

:root {
  --bg:       #1a1208;
  --accent:   #c9943a;
  --text:     #f0e6d3;
  --panel-w:  920px;
  --ease:     cubic-bezier(0.77, 0, 0.18, 1);
  --dur:      0.7s;
}

html, body {
  width: 100vw;
  height: 100vh;
  height: 100dvh; /* Chrome iOS: dvh = actual visible area, vh includes hidden browser chrome */
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Playpen Sans Arabic', 'Georgia', serif;
}

/* ── Loading overlay ─────────────────────────────────────────── */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  transition: opacity 0.6s var(--ease);
}
#loading-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}
#loading-overlay img {
  width: 80px;
  height: 80px;
}

/* ── Stage & Map ─────────────────────────────────────────────── */
#stage {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
}

#map-container {
  position: relative;
  z-index: 10;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#map-container svg {
  width: 100%;
  height: 125%;
  display: block;
  will-change: transform;   /* keep GPU layer alive; avoids re-promotion hitch on each zoom */
}

/* ── Clickable map regions ───────────────────────────────────── */
.region-clickable {
  cursor: pointer;
  transition: filter 0.3s ease;
}
.region-clickable:hover {
  /*filter: brightness(1.13) drop-shadow(0 0 12px rgba(201,148,58,0.6));*/
      filter: drop-shadow(2px 3px 10px #fff);
}
.region-clickable.active {
    filter: drop-shadow(2px 3px 10px #fff);
    animation: pulseShadowStrong 0.8s ease-in-out infinite;
}

@keyframes pulseShadowStrong {
    0% {
        filter: drop-shadow(2px 3px 5px rgba(255, 255, 255, 0.2));
    }
    50% {
        filter: drop-shadow(2px 3px 25px rgba(255, 255, 255, 1));
    }
    100% {
        filter: drop-shadow(2px 3px 5px rgba(255, 255, 255, 0.2));
    }
}
/* ── Waves layer ─────────────────────────────────────────────── */
#waves-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  overflow: hidden;
  transition: filter 0.7s var(--ease), opacity 0.7s var(--ease);
}

#stage.panel-open #waves-layer {
  filter: blur(8px);
  opacity: 0;
}

.wave {
  position: absolute;
  width: 40px;
  animation: drift 4s ease-in-out infinite alternate;
}

@keyframes drift {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

/* ── Back button ─────────────────────────────────────────────── */
#btn-back {
  position: fixed;
  top: 20px;
  right: calc(var(--panel-w) - 24px);
  left: auto;
  z-index: 200;
  background: rgba(26,18,8,0.85);
  border: 1px solid rgba(201,148,58,0.4);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease), background 0.2s;
}
#btn-back.visible {
  opacity: 1;
  pointer-events: all;
}
#btn-back:hover {
  background: rgba(201,148,58,0.2);
}
#btn-back img {
  width: 24px;
  height: 24px;
  transform: rotate(180deg);
  filter: invert(1);
}

/* ── Country Panel ───────────────────────────────────────────── */
#country-panel {
  position: fixed;
  top: 12vh;
  right: 2vh;
  width: var(--panel-w);
  height: 100vh;
  transform: translateX(105%);
  transition: transform var(--dur) var(--ease);
  z-index: 150;
  overflow-y: auto;
  overflow-x: hidden;
  direction: rtl;
  scrollbar-width: thin;
  scrollbar-color: rgba(201,148,58,0.3) transparent;
}
#country-panel::-webkit-scrollbar { width: 4px; }
#country-panel::-webkit-scrollbar-thumb { background: rgba(201,148,58,0.3); border-radius: 2px; }
#country-panel.open {
  transform: translateX(0);
}

#panel-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: url(../../assets/img/country-details/country-container.svg) no-repeat;
}
#panel-bg img,
#panel-bg svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#panel-inner {
  position: relative;
  padding: 0px 24px 60px;
  min-height: 100%;
}

/* Panel title */
#panel-country-title {
  text-align: center;
  margin-bottom: 28px;
}
#panel-country-title img,
#panel-country-title .svg-placeholder {
  max-width: 320px;
  height: auto;
  margin: 0 auto;
  display: block;
}

/* City row */
.city-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 28px;
}
.city-row.city-row-2 {
  flex-direction: row-reverse;
  margin-bottom: -45px;
}

.city-row.city-row-1 {
  margin-bottom: 85px;
}

.city-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 69%;
}
.city-info img.city-title,
.city-info .svg-placeholder.city-title {
  max-width: 280px;
  height: auto;
}
.city-info-1{
    margin-right: 20px;
}

.city-desc {
  font-size: 1.50rem;
  line-height: 1.7;
  color: #9977bf;
  font-weight:bold;
}
.city-bullet {
  width: 16px;
  height: auto;
  margin-top: 4px;
}

/* Photo stack — frame SVG viewBox 110.83×137.85, ratio 1:1.244 (portrait) */
.photo-stack-wrap {
  width: 160px;
  flex-shrink: 0;
  position: relative;
  cursor: pointer;
}
.photo-stack {
  position: relative;
  width: 160px;
  height: 199px; /* 160 × 1.244 — matches frame SVG portrait ratio */
}
/* Each card = rotated wrapper */
.photo-stack .stack-item {
  position: absolute;
  inset: 0;
  transition: transform 0.4s var(--ease);
}
.photo-stack .stack-item:nth-child(1) { transform: rotate(-5deg);  z-index: 1; }
.photo-stack .stack-item:nth-child(2) { transform: rotate(2deg);   z-index: 2; }
.photo-stack .stack-item:nth-child(3) { transform: rotate(-1deg);  z-index: 3; }

/* Photo sits BEHIND the frame — percentages derived from SVG path coords */
.stack-item .stack-photo {
  position: absolute;
  top: 8%;
  left: 8%;
  width: 84%;
  height: 70%;
  object-fit: cover;
  z-index: 1;
}
/* Frame SVG sits on TOP, its transparent hole reveals the photo beneath */
.stack-item .stack-frame {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.photo-stack-wrap:hover .stack-item:nth-child(1) { transform: rotate(-12deg) translateX(-10px); }
.photo-stack-wrap:hover .stack-item:nth-child(2) { transform: rotate(0deg); }
.photo-stack-wrap:hover .stack-item:nth-child(3) { transform: rotate(10deg)  translateX(10px); }

/* Mailbox sprite animation — 17 frames, scaled to 100×103 px */
.mailbox-sprite {
  display: inline-block;
  background: url('../img/country-details/mailbox-seq/spritesheet.png') no-repeat;
  background-size: 400px 516px;   /* 2860×3690 scaled by 100/715 */
  width: 100px;
  height: 103px;
  flex-shrink: 0;
}
.mailbox-sprite.frame-0  { background-position:    0px    0px; }
.mailbox-sprite.frame-1  { background-position: -100px    0px; }
.mailbox-sprite.frame-2  { background-position: -200px    0px; }
.mailbox-sprite.frame-3  { background-position: -300px    0px; }
.mailbox-sprite.frame-4  { background-position:    0px -103px; }
.mailbox-sprite.frame-5  { background-position: -100px -103px; }
.mailbox-sprite.frame-6  { background-position: -200px -103px; }
.mailbox-sprite.frame-7  { background-position: -300px -103px; }
.mailbox-sprite.frame-8  { background-position:    0px -206px; }
.mailbox-sprite.frame-9  { background-position: -100px -206px; }
.mailbox-sprite.frame-10 { background-position: -200px -206px; }
.mailbox-sprite.frame-11 { background-position: -300px -206px; }
.mailbox-sprite.frame-12 { background-position:    0px -309px; }
.mailbox-sprite.frame-13 { background-position: -100px -309px; }
.mailbox-sprite.frame-14 { background-position: -200px -309px; }
.mailbox-sprite.frame-15 { background-position: -300px -309px; }
.mailbox-sprite.frame-16 { background-position:    0px -412px; }

/* Mailbox */
#panel-mailbox {
  margin-top: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 0 8px 13px;
  justify-content: flex-end;
  background: url(../../assets/img/love-letter/mailbox-bubble.svg) no-repeat;
  background-size: 103px;
}
#panel-mailbox-count {
  font-size: 1.0rem;
  font-weight: bold;
  color: #fff;
  direction: rtl;
  margin-bottom: 17px;
  animation: colorPulse 0.5s infinite alternate;
}

@keyframes colorPulse {
  0% {
    color: #000;
  }
  100% {
    color: #fff;
  }
}

.mailbox-home {
  float:left;
  width:190px;
  margin-left: 25px;
}

/* Panel loading state */
#panel-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 200px;
}
#panel-loading img {
  width: 60px;
  height: 60px;
}

/* ── Modal base ──────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s var(--ease);
}
.modal.open {
  opacity: 1;
  pointer-events: all;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
}

.modal-corner {
  position: fixed;
  width: 100%;
  z-index: 610;
  pointer-events: none;
}
.modal-corner.top-left     { top: 0;    left: 0; }
.modal-corner.top-right    { bottom: 0;    right: 0; transform: rotate(180deg); }
.modal-corner.bottom-left  { top: 50%; left: 0;  right: auto; bottom: auto; width: 100vh; transform-origin: top left;  transform: rotate(-90deg) translateX(-50%); }
.modal-corner.bottom-right { top: 50%; right: 0; left: auto;  bottom: auto; width: 100vh; transform-origin: top right; transform: rotate(90deg)  translateX(50%);  }

.modal-close {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 520;
  background: rgba(26,18,8,0.8);
  border: 1px solid rgba(201,148,58,0.4);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}
.modal-close:hover { background: rgba(201,148,58,0.2); }
.modal-close img { width: 20px; height: 20px; filter: invert(1); }

.modal-content {
  position: relative;
  z-index: 510;
  width: 90vw;
  max-width: 1000px;
  max-height: 90vh;
  overflow-y: auto;
  background: rgb(57 190 106);
  border: 1px solid rgba(201,148,58,0.25);
  border-radius: 12px;
  padding: 32px;
  direction: rtl;
  scrollbar-width: thin;
  scrollbar-color: rgb(38 141 76) transparent;
}
.modal-content::-webkit-scrollbar { width: 4px; }
.modal-content::-webkit-scrollbar-thumb { background: rgba(201,148,58,0.3); border-radius: 2px; }

/* ── Photo Gallery Modal ─────────────────────────────────────── */
#modal-gallery .modal-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

#gallery-main {
  position: relative;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 4/3;
  background: #0d0a0538;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
#gallery-main img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
#gallery-main .gallery-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgb(228 232 209);
}
#gallery-main .gallery-loading img { width: 48px; }

.gallery-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgb(0 0 0);
  border: 1px solid rgba(201,148,58,0.3);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  transition: background 0.2s;
}
.gallery-arrow:hover { background: rgba(201,148,58,0.2); }
.gallery-arrow img { width: 20px; filter: invert(1); }
#gallery-arrow-prev { left: 8px; }
#gallery-arrow-next { right: 8px; transform: translateY(-50%) scaleX(-1); }

#gallery-thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  width: 100%;
}
#gallery-thumbs::-webkit-scrollbar { height: 3px; }
#gallery-thumbs::-webkit-scrollbar-thumb { background: rgba(201,148,58,0.3); }

.gallery-thumb {
  width: 80px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid #257b45;
  flex-shrink: 0;
  transition: border-color 0.2s, opacity 0.2s;
  opacity: 0.7;
}
.gallery-thumb:hover { opacity: 1; }
.gallery-thumb.active { border-color: #9361cf; opacity: 1; }

/* ── Mailbox Modal ───────────────────────────────────────────── */
#modal-mailbox .modal-content {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 90vw;
  max-width: 1385px;
  max-height: 85vh;
  padding: 0;
  overflow: hidden;
  transition: background-color 0.3s ease;
}

#modal-mailbox .modal-content.composing {
  background-color: rgb(36, 37, 36);
}

#mailbox-preview {
  padding: 32px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

#mailbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#btn-write-letter {
  background: #ffd767;
  color: var(--bg);
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
#btn-write-letter:hover { opacity: 0.85; }

#mailbox-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: rgba(240,230,211,0.7);
  direction: rtl;
}
.mailbox-flag {
  width: 26px;
  height: 18px;
  object-fit: cover;
  border-radius: 2px;
  object-position: left;
}

#mailbox-letters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.letter-card {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.3s var(--ease), box-shadow 0.3s;
}
.letter-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.letter-card-bg {
  width: 100%;
  height: auto;
  display: block;
}
.letter-card-msg {
  position: absolute;
  top: 16%;
  left: 3%;
  right: 3%;
  bottom: 32%;
  width: auto;
  padding: 6px 15px;
  font-size: 0.65rem;
  line-height: 1.55;
  color: #3a2a10;
  direction: rtl;
  text-align: right;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 7;
  -webkit-box-orient: vertical;
}
.letter-card-stamp {
  position: absolute;
  pointer-events: none;
}

/* Sender badge overlaid on each letter card */
.letter-sender-badge {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 30%;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  padding: 2% 32% 4% 6%;
  direction: rtl;
  pointer-events: none;
}
.letter-sender-name {
    font-size: 0.6rem;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    direction: rtl;
    text-align: right;
    padding: 15px 16px;
}
.letter-sender-flag {
  width: 20px;
  height: 14px;
  object-fit: cover;
  border-radius: 2px;
  flex-shrink: 0;
  margin-right: 15px;
}

#mailbox-empty {
  text-align: center;
  padding: 40px;
  color: rgba(240,230,211,0.5);
  font-size: 0.9rem;
  direction: rtl;
}

/* Letter zoom overlay — fixed so it always covers the full viewport */
#letter-zoom {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 550;
  background: rgba(26,18,8,0.92);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  padding: 40px 24px 24px;
}
#letter-zoom.open { display: flex; }
#letter-zoom-card {
  position: relative;
  width: min(780px, 90vw);
}
#letter-zoom-card img.letter-zoom-bg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
}
#letter-zoom-country-name {
  position: absolute;
  top: 5%;
  left: 4%;
  width: 48%;
  z-index: 3;
  pointer-events: none;
}
#letter-zoom-msg {
  position: absolute;
  top: 54%;
  left: 8%;
  width: 40%;
  bottom: 24%;
  padding: 16px 12px;
  font-size: 1.0rem;
  line-height: 1.9;
  color: #3a2a10;
  direction: rtl;
  text-align: right;
  overflow: hidden;
  font-weight: bold;
}

#letter-zoom-sender {
  position: absolute;
  bottom: 99px;
  left: 184px;
  width: 100%;
  height: 22%;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 5px;
  padding: 6% 33% 2% 6%;
  direction: rtl;
  pointer-events: none;
}
.letter-zoom-sender-name {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  direction: rtl;
  text-align: right;
}
.letter-zoom-sender-flag {
  width: 28px;
  height: 20px;
  border-radius: 2px;
  flex-shrink: 0;
}
#btn-letter-zoom-close {
  background: rgba(201,148,58,0.2);
  border: 1px solid rgba(201,148,58,0.4);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 20px;
  font-family: inherit;
  cursor: pointer;
}

/* ── Mailbox Write Mode ───────────────────────────────────────── */
#mailbox-write {
  display: none;
  flex-direction: column;
  direction: rtl;
  position: relative;
  height: 100%;
}
#mailbox-write.open {
  display: flex;
}

/* 3-column grid: RIGHT=postcards, CENTER=card, LEFT=stamps */
.write-layout {
  display: grid;
  grid-template-columns: 330px 1fr 200px;
  grid-template-rows: auto 1fr;
  gap: 6px 16px;
  align-items: stretch;
  flex: 1;
  overflow: hidden;
  padding: 20px 24px 12px;
}

.write-col-header {
  font-size: 1.52rem;
  font-weight: bold;
  color: var(--accent);
  text-align: center;
  direction: rtl;
  padding-bottom: 2px;
}

/* ── RIGHT column: postcard selector ── */
.postcard-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-content: start;
  overflow-y: auto;
  padding: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(201,148,58,0.3) transparent;
}
.postcard-thumb {
  width: 150px;
  height: 150px;
  border-radius: 10px;
  cursor: pointer;
  border: 2px solid transparent;
  background-size: 207%;
  background-position: -153px -10px;
  background-repeat: no-repeat;
  transition: border-color 0.2s, transform 0.2s;
  flex-shrink: 0;
}
.postcard-thumb:hover { transform: scale(1.04); }
.postcard-thumb.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(201,148,58,0.4); }

/* ── CENTER: postcard canvas ── */
#write-card-wrap {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  align-self: center;
}
#write-card-bg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

/* Country name SVG — adjust position freely here */
.write-country-name {
  position: absolute;
  top: 43.5%;
  left: 7.5%;
  width: 29%;
  z-index: 3;
  pointer-events: none;
}

#write-card-textarea {
  position: absolute;
  top: 57%;
  left: 10%;
  width: 39%;
  height: 28%;
  background: transparent;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 1.1rem;
  line-height: 1.7;
  color: #3a2a10;
  resize: none;
  direction: rtl;
  z-index: 3;
  font-weight: bold;
}
#write-card-textarea::placeholder { color: rgba(58,42,16,0.5); }

#write-char-count {
  position: absolute;
  bottom: 61px;
  left: 26%;
  font-size: 0.65rem;
  color: rgba(58,42,16,0.6);
  z-index: 3;
  font-weight: bold;
}

/* Right side of card: labeled inputs */
#write-card-meta {
  position: absolute;
  top: 58%;
  right: 6%;
  width: 39%;
  display: flex;
  flex-direction: column;
  gap: 3px;
  z-index: 3;
  direction: rtl;
}
.meta-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
}
.write-meta-label {
  font-size: 0.7rem;
  font-weight: bold;
  color: #8f5acf;
  flex-shrink: 0;
  white-space: nowrap;
}
.meta-row input,
.meta-row select {
  flex: 1;
  min-width: 0;
}
#write-to-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #3a2a10;
}
#write-name-input {
  background: rgba(255,255,255,0.35);
  border: 1px solid rgba(58,42,16,0.3);
  border-radius: 4px;
  padding: 4px 6px;
  font-family: inherit;
  font-size: 0.75rem;
  color: #3a2a10;
  width: 100%;
  direction: rtl;
}
#write-name-input::placeholder { color: rgba(58,42,16,0.4); }

.gender-toggle {
  display: flex;
  gap: 6px;
}
.gender-btn {
  background: transparent;
  border: 1px solid rgba(58,42,16,0.3);
  border-radius: 4px;
  padding: 2px 5px;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s, border-color 0.2s;
}
.gender-btn.active { opacity: 1; border-color: #3a2a10; }
.gender-btn img { width: 22px; height: 22px; }

#write-country-select {
  background: rgba(255,255,255,0.35);
  border: 1px solid rgba(58,42,16,0.3);
  border-radius: 4px;
  padding: 4px 6px;
  font-family: inherit;
  font-size: 0.7rem;
  color: #3a2a10;
  width: 100%;
  direction: rtl;
}

/* Dropped stamps on card */
.dropped-stamp {
  position: absolute;
  width: 48px;
  height: 48px;
  cursor: grab;
  z-index: 4;
  pointer-events: all;
  user-select: none;
}
.dropped-stamp:active { cursor: grabbing; }
.dropped-stamp img { width: 100%; height: 100%; pointer-events: none; }

/* ── LEFT column: stamp palette with sticker-bg ── */
.stamp-palette {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  justify-content: center;
  padding: 16px 12px;
  background-image: url('../img/love-letter/sticker-bg.svg');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  border-radius: 8px;
  overflow-y: auto;
  scrollbar-width: none;
}
.stamp-item {
  width: 60px;
  height: 60px;
  cursor: grab;
  user-select: none;
  transition: transform 0.2s;
  flex-shrink: 0;
}
.stamp-item:hover { transform: scale(1.12); }
.stamp-item img { width: 100%; height: 100%; pointer-events: none; }

/* Write footer */
#write-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 10px 0 14px;
  flex-shrink: 0;
}
.write-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: transform 0.2s, opacity 0.2s;
}
.write-btn:hover { transform: scale(1.05); opacity: 0.85; }
.write-btn img { height: 44px; width: auto; display: block; }

/* Message overlay (success + validation) */
#write-msgbox {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 20;
  align-items: center;
  justify-content: center;
  background: rgba(26,18,8,0.88);
  border-radius: 12px;
  direction: rtl;
}
#write-msgbox.open { display: flex; }

.msgbox-inner {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.msgbox-bg {
  display: block;
  width: 360px;
  max-width: 80vw;
  height: auto;
}
.msgbox-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px 40px 48px;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.9;
  color: #3a2a10;
  direction: rtl;
  white-space: pre-line;
}

/* Countdown timer ring inside msgbox */
.msgbox-timer {
  position: absolute;
  bottom: 10%;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 30px;
}
.msgbox-timer-track {
  fill: none;
  stroke: rgba(58,42,16,0.18);
  stroke-width: 3.5;
}
.msgbox-timer-ring {
  fill: none;
  stroke: #8f5acf;
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 0;
  transform-origin: 18px 18px;
  transform: rotate(-90deg);
}

/* ── Music Player ────────────────────────────────────────────── */
#music-player {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 9999;
  width: 500px;
  height: 148px;
  direction: ltr;
}

#music-player-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
#music-player-bg img,
#music-player-bg .svg-placeholder {
  width: 100%;
  height: 100%;
}

/* Single horizontal row: [play] [progress] [mute] [volume] */
#music-player-inner {
  position: relative;
  height: 100%;
  padding: 0 28px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

#btn-play-pause,
#btn-mute {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
#btn-play-pause img { width: 46px; height: 46px; }
#btn-mute img       { width: 26px; height: 26px; }

/* Progress — time-line.svg is the track, time-ind.svg (car) slides along it */
#progress-track {
  flex: 1;
  position: relative;
  height: 44px;
  cursor: pointer;
  display: flex;
  align-items: center;
  margin-left: 11px;
}
#progress-track img.time-line {
  width: 100%;
  height: auto;
  display: block;
}
#progress-indicator {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translate(-50%, -50%);
  cursor: grab;
}
#progress-indicator img { width: 38px; height: auto; }
#progress-indicator:active { cursor: grabbing; }

/* Volume — vol-control-slider.svg is the track, vol-lvl.svg (oval) slides along it */
#volume-track {
  flex: 0 0 90px;
  position: relative;
  height: 44px;
  cursor: pointer;
  display: flex;
  align-items: center;
  margin-left: 17px;
}
#volume-track img.vol-line {
  width: 100%;
  height: auto;
  display: block;
  margin-bottom: 17px;
}
#volume-fill {
  position: absolute;
  left: 0;
  top: 79%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
#volume-fill img { width: 20px; height: auto; }

/* ── Asset pending placeholders ──────────────────────────────── */
.svg-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1.5px dashed rgba(201,148,58,0.5);
  border-radius: 4px;
  color: rgba(201,148,58,0.7);
  font-size: 0.65rem;
  padding: 4px 6px;
  min-width: 40px;
  min-height: 20px;
  text-align: center;
  background: rgba(201,148,58,0.05);
}

/* ── Scrollbar hiding on IE/Edge ─────────────────────────────── */
body { -ms-overflow-style: none; }

/* ── Map hover tooltip (country + city titles, top-left) ────────── */
#map-hover-tooltip {
  position: fixed;
  top: 24px;
  left: 24px;
  z-index: 190;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#map-hover-tooltip img {
  max-width: 210px;
  height: auto;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.5));
}
#hover-country-title {
  transform: scale(0);
  transform-origin: left top;
  transition: transform 0.35s var(--ease);
}
#hover-country-title.vis { transform: scale(1); }

#hover-city-1-title {
  opacity: 0;
  transform: translateY(-14px);
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
  transition-delay: 0s;
}
#hover-city-2-title {
  opacity: 0;
  transform: translateY(-14px);
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
  transition-delay: 0s;
}
#hover-city-1-title.vis {
  opacity: 1; transform: translateY(0);
  transition-delay: 0.12s;
}
#hover-city-2-title.vis {
  opacity: 1; transform: translateY(0);
  transition-delay: 0.2s;
}

/* ── Utility ─────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Site Logo ───────────────────────────────────────────────── */
#site-logo {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  pointer-events: none;
  white-space: nowrap;
  transition: transform var(--dur) var(--ease), opacity 0.4s var(--ease);
}
/* Shift logo to center of the visible map area (left of open panel) */
#site-logo.panel-open {
  transform: translateX(calc(-50% - var(--panel-w) / 2));
}
#site-logo img.site-logo-img,
#site-logo .svg-placeholder {
  height: 180px;
  width: auto;
  display: block;
}

/* ════════════════════════════════════════════════════════════════
   MOBILE  ≤ 768 px
   All rules below override ONLY layout/size for small screens.
   PC styles above are untouched.
════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* ── Logo ─────────────────────────────────────────────────── */
  #site-logo img.site-logo-img,
  #site-logo .svg-placeholder { height: 46px; }

  /* On mobile, logo fades out when panel covers it (no shift) */
  #site-logo.panel-open {
    transform: translateX(-50%);
    opacity: 0;
    pointer-events: none;
  }

  /* ── Back button: top-left corner on mobile ─────────────── */
  #btn-back {
    top: 12px;
    left: 12px;
    right: auto;
  }

  /* ── Hover tooltip: meaningless on touch, hide it ─────────── */
  #map-hover-tooltip { display: none !important; }

  /* ── Country panel: bottom sheet ─────────────────────────── */
  #country-panel {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100vw;
    height: calc(100vh - 80px);
    height: calc(100dvh - 80px);
    transform: translateY(110%);
    border-radius: 20px 20px 0 0;
    border-top: 1px solid rgba(201,148,58,0.3);
    overflow-y: auto;
    overflow-x: hidden;
    background: rgb(224 226 199);
    margin-bottom: 50px;
  }
  #country-panel.open { transform: translateY(0); }

  /* Drag handle indicator */
  #country-panel::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: rgba(201,148,58,0.4);
    border-radius: 2px;
    margin: 10px auto 0;
    flex-shrink: 0;
  }

  #panel-bg {
    background-size: 100% 100%;
    background: #e0e2c7;
    border-radius: 20px 20px 0 0;
  }

  /* Extra bottom padding so content clears the fixed music player footer */
  #panel-inner { padding: 8px 14px 88px; }

  /* ── City rows: stack vertically ─────────────────────────── */
  .city-row,
  .city-row.city-row-2 {
    flex-direction: column !important;
    margin-bottom: 20px !important;
  }
  .city-row.city-row-1 { margin-bottom: 20px !important; }
  .city-info { max-width: 100%; }
  .city-info-1 { margin-right: 0; }
  .city-desc { font-size: 1.1rem; }

  /* ── Photo stack: smaller, always fanned (no hover) ───────── */
  .photo-stack-wrap { width: 120px; align-self: center; }
  .photo-stack { width: 120px; height: 149px; }
  .photo-stack-wrap .stack-item:nth-child(1) { transform: rotate(-8deg) translateX(-6px); }
  .photo-stack-wrap .stack-item:nth-child(3) { transform: rotate( 8deg) translateX( 6px); }

  /* ── Music player: full-width footer ─────────────────────── */
  #music-player {
    width: 100vw;
    height: 64px;
    bottom: 0;
    left: 0;
    border-radius: 16px 16px 0 0;
  }
  #progress-track  { display: flex; }          /* re-enable on the wide footer */
  #volume-track    { display: none; }
  #music-player-inner { padding: 0 20px; gap: 14px; }
  #btn-play-pause img { width: 32px; height: 32px; }
  #btn-mute img       { width: 22px; height: 22px; }

  /* Keep modal flex-box away from the fixed player at bottom */
  .modal { padding-bottom: 64px; }

  /* ── Generic modal content ─────────────────────────────────── */
  .modal-content {
    width: 96vw;
    /* dvh = actual visible area; vh can overshoot on Chrome iOS */
    max-height: calc(100dvh - 64px - 40px);
    padding: 14px 14px 80px;
  }

  /* ── Mailbox preview modal ─────────────────────────────────── */
  #modal-mailbox .modal-content {
    width: 96vw;
    max-height: calc(100dvh - 64px - 40px);
    padding: 0; /* inner sections (#mailbox-preview, #wizard-wrap) carry their own pb clearance */
  }

  /* Write mode: must be a scrollable flex child */
  #mailbox-write {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }
  #mailbox-preview { padding: 14px; gap: 12px; padding-bottom: 80px; }
  #mailbox-header  { flex-wrap: wrap; gap: 8px; }
  #mailbox-stats   { flex-wrap: wrap; }
  #mailbox-letters-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  /* ── Write mode background (compose only) ─────────────────── */
  #mailbox-write {
    background-color: rgb(36, 37, 36);
    overflow-y: auto;
  }

  /* ── Mobile postcard wizard ────────────────────────────────── */
  #wizard-wrap {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 12px 14px 80px;
    min-height: 100%;
  }

  #wizard-dots {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding-top: 4px;
  }

  .step-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(201,148,58,0.25);
    transition: background 0.3s;
  }

  .step-dot.active { background: #c9943a; }

  .wizard-step-label {
    font-family: var(--font);
    color: #f0e6d3;
    text-align: center;
    font-size: 0.95rem;
    margin: 0;
  }

  /* Step 1: postcard grid */
  #mobile-postcard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .mobile-postcard-thumb {
    width: 100%;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
  }

  .mobile-postcard-thumb.selected {
    border-color: #c9943a;
    box-shadow: 0 0 0 2px rgba(201,148,58,0.35);
  }

  /* Step 2 & 3: card preview */
  #wizard-card-preview-2,
  #wizard-card-preview-3 {
    position: relative;
    width: 100%;
    max-width: 340px;
    margin: 0 auto;
  }

  .wizard-card-img {
    width: 100%;
    border-radius: 8px;
    display: block;
  }

  #wizard-card-preview-2 textarea {
      position: absolute;
      top: 46%;
      left: 6%;
      width: 86%;
      height: 32%;
      background: transparent;
      border: none;
      resize: none;
      font-family: var(--font);
      font-size: 16px; /* prevents iOS auto-zoom on focus */
      color: #1a1208;
      text-align: right;
      direction: rtl;
      outline: none;
      padding: 4px;
  }

  /* Char count overlaid inside card, below the textarea */
  #wizard-card-preview-2 .write-char-count {
    position: absolute;
    top: 79%;
    left: 6%;
    width: 86%;
    font-size: 0.68rem;
    color: rgba(26,18,8,0.65);
    text-align: center;
  }

  /* "إلى" inside card at top-left */
  #wizard-card-preview-2 .wizard-to-row {
    position: absolute;
    top: 24.5%;
    left: 6.5%;
    direction: rtl;
    display: flex;
    align-items: center;
    gap: 4px;
  }

  #wizard-card-preview-2 .wizard-to-label {
    color: rgba(26,18,8,0.8);
    font-size: 0.85rem;
    display:none;
  }

  #wizard-card-preview-2 .wizard-country-name-img {
    height: 15px;
  }

  /* Step 2 form fields */
  .wizard-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #e3e4cc24;
    padding: 5px;
    border-radius: 8px;
  }

  .wizard-to-row {
    display: flex;
    align-items: center;
    gap: 8px;
    direction: rtl;
  }

  .wizard-to-label {
    color: #f0e6d3;
    font-family: var(--font);
    font-size: 0.95rem;
  }

  .wizard-country-name-img {
    height: 24px;
    width: auto;
  }

  .wizard-input {
    width: 100%;
    padding: 8px 12px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(201,148,58,0.4);
    border-radius: 8px;
    color: #f0e6d3;
    font-size: 16px; /* prevents iOS auto-zoom on focus */
    font-family: var(--font);
    font-size: 1rem;
    box-sizing: border-box;
  }

  .wizard-input::placeholder { color: rgba(240,230,211,0.45); }

  .wizard-select {
    width: 100%;
    padding: 8px 12px;
    background: rgba(26,18,8,0.92);
    border: 1px solid rgba(201,148,58,0.4);
    border-radius: 8px;
    color: #f0e6d3;
    font-family: var(--font);
    font-size: 16px; /* prevents iOS auto-zoom on focus */
    box-sizing: border-box;
  }

  .wizard-gender-row {
    display: flex;
    gap: 12px;
    justify-content: center;
  }

  .gender-btn-mobile {
    background: rgba(255,255,255,0.06);
    border: 2px solid rgba(201,148,58,0.3);
    border-radius: 50%;
    width: 56px;
    height: 56px;
    cursor: pointer;
    padding: 6px;
    transition: border-color 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .gender-btn-mobile.active {
    border-color: #c9943a;
    background: rgba(201,148,58,0.15);
  }

  .gender-btn-mobile img {
    width: 36px;
    height: 36px;
    object-fit: contain;
  }

  /* Step 3: placed stamps */
  #wizard-placed-stamps {
    position: absolute;
    inset: 0;
    pointer-events: none;
  }

  .wizard-placed-stamp {
    position: absolute;
    width: 44px;
    height: 44px;
    transform: translate(-50%, -50%);
    cursor: pointer;
    pointer-events: all;
    transition: transform 0.15s;
  }

  .wizard-placed-stamp:active { transform: translate(-50%, -50%) scale(0.82); }

  /* Step 3: stamp strip */
  #mobile-stamp-row {
    display: flex;
    flex-direction: row;
    gap: 12px;
    overflow-x: auto;
    padding: 8px 6px;
    scrollbar-width: none;
    background: rgb(153 109 207);
    border-radius: 12px;
  }

  #mobile-stamp-row::-webkit-scrollbar { display: none; }

  .mobile-stamp-item {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    cursor: pointer;
    border-radius: 8px;
    padding: 4px;
    border: 2px solid transparent;
    transition: border-color 0.2s, opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-stamp-item.used {
    opacity: 0.45;
    border-color: rgba(201,148,58,0.3);
  }

  .mobile-stamp-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }

  /* Wizard nav buttons */
  .wizard-nav {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    direction: rtl;
    margin-top: 4px;
    margin-bottom:25px;
    background: #e3e4cc24;
    padding: 5px;
    border-radius: 8px;
  }

  .write-btn-mobile {
    padding: 10px 22px;
    background: #c9943a;
    color: #1a1208;
    border: none;
    border-radius: 10px;
    font-family: var(--font);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s;
  }

  .write-btn-mobile:disabled { opacity: 0.45; cursor: not-allowed; }

  .write-btn-mobile-ghost {
    background: transparent;
    color: #f0e6d3;
    border: 1px solid rgba(201,148,58,0.4);
  }

  .write-btn-mobile-send { background: #4cba50; color: #fff; }

  .write-char-count {
    font-family: var(--font);
    font-size: 0.8rem;
    color: rgba(240,230,211,0.55);
    text-align: left;
  }

  /* Letter zoom card: full-width centered on mobile */
  #letter-zoom-card { width: 100%; max-width: 400px; margin: 0 auto; }

  /* ── Mailbox write mode: single-column ─────────────────────── */
  .write-layout {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    padding: 10px 12px 4px;
    height: auto;
    /* override the 3-col desktop grid */
    grid-template-columns: unset;
    grid-template-rows: unset;
  }
  .write-col-header { font-size: 1rem; padding-bottom: 0; }

  /* Postcard selector → horizontal scrollable strip */
  #write-postcard-selector {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 8px;
    align-content: unset;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  #write-postcard-selector::-webkit-scrollbar { display: none; }
  .postcard-thumb {flex-shrink: 0; }

  /* Card canvas: full width */
  #write-card-wrap { width: 100%; }

  /* Stamp palette → horizontal strip */
  .stamp-palette {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    height: 80px;
    justify-content: flex-start;
    padding: 8px 12px;
    gap: 16px;
    border-radius: 8px;
  }
  .stamp-palette::-webkit-scrollbar { display: none; }
  .stamp-item { width: 50px; height: 50px; flex-shrink: 0; }

  #write-footer { padding: 8px 0 10px; }

  /* ── Gallery: bigger arrow tap targets ─────────────────────── */
  .gallery-arrow { width: 50px; height: 50px; top:32px;}

  /* ── Letter zoom: less side padding ───────────────────────── */
  #letter-zoom { padding: 60px 10px 80px; }
  #letter-zoom-card { width: 96vw; max-width: none; }

  /* Adjust letter text + sender badge for mobile card proportions */
  #letter-zoom-msg {
    top: 41%;
    left: 6%;
    width: 86%;
    height: 32%;
  }
  #letter-zoom-sender {
    bottom: 10%;
    left: 29%;
    transform: scale(0.7);
    transform-origin: bottom left;
  }

  /* Letter preview cards: show flag only, hide sender name */
  .letter-sender-name { display: none; }

  /* ── Wizard step 3: message text overlay ───────────────────── */
  #wizard-step3-msg {
    position: absolute;
    top: 46%;
    left: 6%;
    width: 86%;
    height: 32%;
    font-family: var(--font);
    font-size: 0.78rem;
    color: #1a1208;
    text-align: right;
    direction: rtl;
    overflow: hidden;
    pointer-events: none;
    white-space: pre-wrap;
    word-break: break-word;
  }

  /* ── Map SVG: fill available screen (JS sets initial scale) ── */
  #map-container svg { width: 100%; height: 100%; }

  /* ── Stamp palette: purple background on mobile ────────────── */
  .stamp-palette {
    background-image: none !important;
    background-color: #8f5acf;
  }

}
