:root {
  --bg-color: #fafaf8;

  --primary: #8968aa;
  --primary-dark: #5e4580;

  --flap-color: #f39200;
  --pocket-light: #e5ee91;
  --pocket-dark: #bccf00;

  --gold: #f39200;
  --gold-light: #ffb52e;

  --card-white: #ffffff;

  --text-dark: #1d1d1d;
  --text-muted: #77716c;

  --empty-gray: #c9c6c0;

  --radius: 18px;

  --font-title: "Colak Pro Soft", "Montserrat Alternates", "Vazirmatn", Tahoma, sans-serif;
  --font-body: "Ravagh", "Montserrat Alternates", "Vazirmatn", Tahoma, sans-serif;
}

/* =========================================================
   RESET
   ========================================================= */

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  min-height: 100dvh;

  font-family: var(--font-body);

  background:
    radial-gradient(
      circle at 15% 10%,
      rgba(137, 104, 170, 0.10),
      transparent 40%
    ),
    radial-gradient(
      circle at 85% 80%,
      rgba(243, 146, 0, 0.12),
      transparent 45%
    ),
    var(--bg-color);

  color: var(--text-dark);
  direction: rtl;
  overflow-x: hidden;
}

/* =========================================================
   PAGE
   ========================================================= */

.screen {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  padding: 20px 24px 40px;
}

.game-page .screen {
  justify-content: flex-start;
}

.login-page .screen {
  justify-content: center;
  align-items: center;
}

.login-page .panel {
  margin: auto;
}

/* =========================================================
   PANELS
   ========================================================= */

.panel {
  width: min(100%, 420px);

  background: rgba(255, 255, 255, 0.78);

  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);

  border-radius: 24px;

  padding: 36px 30px;

  box-shadow:
    0 20px 50px rgba(83, 56, 120, 0.12);

  border: 1px solid rgba(255, 255, 255, 0.8);
}

.panel h1,
.panel h2 {
  margin: 0 0 8px;
  text-align: center;
  color: var(--primary-dark);
}

.panel h1 {
  font-size: clamp(22px, 5vw, 28px);
  line-height: 1.4;
}

.panel h2 {
  font-size: 22px;
}

.panel .subtitle,
.subtitle {
  margin: 0 0 24px;

  text-align: center;

  color: var(--text-muted);

  font-size: 14px;
  line-height: 1.8;
}

/* =========================================================
   NAVBAR
   ========================================================= */

.navbar {
  width: 100%;
  max-width: 1100px;

  min-height: 68px;

  margin: 0 auto 28px;

  padding: 10px 20px;

  display: flex;
  align-items: center;

  direction: rtl;

  background: rgba(255, 255, 255, 0.88);

  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);

  border: 1px solid rgba(137, 104, 170, 0.10);

  border-radius: 20px;

  box-shadow:
    0 10px 35px rgba(83, 56, 120, 0.08);

  position: relative;
  z-index: 50;
}

/* =========================================================
   BRAND
   ========================================================= */

.brand {
  display: flex;
  align-items: center;

  flex: 0 0 auto;

  margin-right: auto;
}

.brand-logo {
  display: block;

  height: 30px;
  width: auto;

  object-fit: contain;
}

/* =========================================================
   NAV USER
   ========================================================= */

.nav-user {
  position: absolute;

  left: 50%;
  top: 50%;

  transform: translate(-50%, -50%);

  display: flex;
  align-items: center;
  justify-content: center;

  gap: 10px;

  direction: rtl;

  max-width: 50%;
  min-width: 0;
}

.guest-label {
  padding: 6px 11px;

  border-radius: 999px;

  background: var(--pocket-light);

  color: var(--primary-dark);

  font-size: 11px;
  font-weight: 700;

  white-space: nowrap;
}

.greeting {
  color: var(--text-dark);

  font-size: 14px;
  font-weight: 600;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =========================================================
   LOGOUT
   ========================================================= */

.logout-btn {
  flex: 0 0 auto;

  margin: 0;

  padding: 9px 17px;

  min-width: 64px;

  border: 1px solid rgba(137, 104, 170, 0.15);

  background: rgba(255, 255, 255, 0.75);

  color: var(--text-muted);

  border-radius: 12px;

  font-family: inherit;

  font-size: 12px;
  font-weight: 600;

  cursor: pointer;

  transition:
    background 0.2s ease,
    color 0.2s ease,
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.logout-btn:hover {
  background: var(--primary);
  color: #fff;

  transform: translateY(-1px);

  box-shadow:
    0 6px 16px rgba(83, 56, 120, 0.18);
}

.logout-btn:active {
  transform: scale(0.97);
}

/* =========================================================
   PROFILE TRIGGER (navbar)
   ========================================================= */

.nav-user-btn {
  background: none;
  border: none;

  font: inherit;
  color: inherit;

  cursor: pointer;

  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.nav-user-btn:hover {
  opacity: 0.82;
}

.nav-user-btn:active {
  transform:
    translate(-50%, -50%)
    scale(0.97);
}

.profile-chevron {
  color: var(--text-muted);
  font-size: 13px;
}

/* =========================================================
   PROFILE MODAL
   ========================================================= */

.profile-modal {
  position: relative;

  max-width: 360px;

  text-align: center;
}

.modal-close {
  position: absolute;

  top: 14px;
  left: 14px;

  width: 30px;
  height: 30px;

  border: none;
  border-radius: 50%;

  background: rgba(137, 104, 170, 0.08);

  color: var(--text-muted);

  font-size: 18px;
  line-height: 1;

  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;

  transition:
    background 0.2s ease,
    color 0.2s ease;
}

.modal-close:hover {
  background: var(--primary);
  color: #fff;
}

.profile-avatar {
  width: 56px;
  height: 56px;

  margin: 4px auto 14px;

  border-radius: 50%;

  background: var(--pocket-light);

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 26px;
}

.profile-phone {
  margin: 0 0 20px;

  color: var(--text-muted);

  font-size: 13px;

  direction: ltr;

  display: inline-block;
}

.profile-events {
  text-align: right;

  margin: 0 0 22px;

  padding: 14px 16px;

  border-radius: 16px;

  background: rgba(137, 104, 170, 0.06);
}

.profile-events h3 {
  margin: 0 0 10px;

  font-size: 13px;

  color: var(--primary-dark);
}

.profile-events ul {
  margin: 0;

  padding-right: 18px;

  font-size: 13px;
  line-height: 1.9;

  color: var(--text-dark);
}

.profile-events-empty {
  margin: 0;

  font-size: 13px;

  color: var(--text-muted);

  text-align: center;
}

.profile-logout {
  width: 100%;

  margin-top: 4px;
}

/* =========================================================
   GAME BOARD
   ========================================================= */

#boardWrap {
  width: 100%;
  max-width: 1100px;

  margin: 0 auto;

  display: flex;
  flex-direction: column;
  align-items: center;
}

.game-intro-panel {
  width: min(100%, 560px);
}

/* =========================================================
   PAGINATION
   ========================================================= */

.page-tabs {
  width: 100%;
  max-width: 560px;

  display: flex;

  gap: 8px;

  overflow-x: auto;

  padding-bottom: 10px;
  margin-bottom: 14px;

  -ms-overflow-style: none;
  scrollbar-width: none;
}

.page-tabs::-webkit-scrollbar {
  display: none;
}

.page-tab {
  flex: 0 0 auto;

  padding: 8px 16px;

  border-radius: 20px;

  background: rgba(255, 255, 255, 0.5);

  border: 1px solid var(--gold-light);

  color: var(--text-muted);

  font-family: inherit;

  font-size: 13px;

  cursor: pointer;

  white-space: nowrap;
}

.page-tab.active {
  background:
    linear-gradient(
      135deg,
      var(--gold),
      var(--gold-light)
    );

  color: var(--text-dark);

  font-weight: 700;

  border-color: transparent;
}

/* =========================================================
   ⭐ FIXED 3 × 3 GRID
   ========================================================= */

.pocket-grid {

  
  width: 100%;

  /*
   * IMPORTANT:
   * Never use fixed 130px / 110px / 90px columns here.
   * The grid itself determines the size.
   */
  max-width: 420px;

  margin: 0 auto;

  display: grid;

  grid-template-columns:
    repeat(3, minmax(0, 1fr));

  grid-template-rows:
    repeat(3, auto);

  column-gap: 24px;
  row-gap: 28px; 

  justify-content: center;
  align-items: center;


}

/*
 * Every cell has exactly the same width and height.
 */
.pocket-tile {
  position: relative;

  width: 100%;

  aspect-ratio: 1 / 1;

  min-width: 0;
  min-height: 0;

  display: flex;
  align-items: center;
  justify-content: center;
}

/*
 * Prevent opened cells from changing the grid geometry.
 */
.pocket-tile.opened {
  width: 100%;
  height: 100%;

  aspect-ratio: 1 / 1;

  min-width: 0;
  min-height: 0;

  border-radius: 14px;

  background: var(--card-white);

  border: 1.5px solid var(--gold-light);

  display: flex;

  flex-direction: column;

  align-items: center;
  justify-content: center;

  font-size: 20px;
}

/* =========================================================
   GIFT BOX
   ========================================================= */

.gift-box {
  position: relative;

  /*
   * The gift MUST fill the grid cell.
   */
  width: 100%;
  height: 100%;

  margin: 0;

  display: block;

  isolation: isolate;
}

.gift-box.clickable {
  cursor: pointer;
}

/* =========================================================
   BOX LID
   ========================================================= */

.gift-box .box-top {
  position: absolute;

  top: 0;
  left: 5%;

  width: 90%;
  height: 27%;

  background:
    linear-gradient(
      to right,
      var(--primary) 0%,
      var(--primary) 43%,
      var(--gold) 43%,
      var(--gold) 57%,
      var(--primary) 57%,
      var(--primary) 100%
    );

  border-radius:
    6px 6px 3px 3px;

  z-index: 3;

  transform-origin: center bottom;

  transition:
    transform 0.5s
    cubic-bezier(
      0.34,
      1.56,
      0.64,
      1
    );
}

/* =========================================================
   BOW
   ========================================================= */

.gift-box .box-top::before,
.gift-box .box-top::after {
  content: "";

  width: 15px;
  height: 15px;

  border: 8px solid var(--gold);

  border-radius:
    50% 50% 0 50%;

  position: absolute;

  top: 0;
  left: 50%;

  transform:
    translate3d(
      -100%,
      -55%,
      0
    )
    skew(10deg, 10deg);
}

.gift-box .box-top::after {
  border-radius:
    50% 50% 50% 0;

  transform:
    translate3d(
      0,
      -55%,
      0
    )
    skew(-10deg, -10deg);
}

/* =========================================================
   BOX BASE
   ========================================================= */

.gift-box .box-base {
  position: absolute;

  left: 8%;
  bottom: 0;

  width: 84%;
  height: 76%;

  background:
    linear-gradient(
      to right,
      var(--primary-dark) 0%,
      var(--primary-dark) 43%,
      var(--gold) 43%,
      var(--gold) 57%,
      var(--primary-dark) 57%,
      var(--primary-dark) 100%
    );

  border-radius:
    3px 3px 8px 8px;

  z-index: 2;

  box-shadow:
    0 10px 18px
    rgba(83, 56, 120, 0.18);
}

/* =========================================================
   AMOUNT
   ========================================================= */

.gift-box .box-amount {
  position: absolute;

  left: 50%;
  top: 50%;

  transform:
    translate(-50%, -50%);

  width: 90%;

  text-align: center;

  font-weight: 900;

  font-size: clamp(
    11px,
    3vw,
    17px
  );

  line-height: 1.5;

  color: var(--gold);

  opacity: 0;

  z-index: 100;

  transition:
    opacity 0.4s ease 0.5s;
}

/* =========================================================
   JIGGLE
   ========================================================= */

@keyframes giftJiggle {
  0%,
  100% {
    transform:
      translate3d(
        -5%,
        0,
        0
      )
      rotate(0deg);
  }

  20% {
    transform:
      translate3d(
        -5%,
        -10%,
        0
      )
      rotate(-8deg);
  }

  50% {
    transform:
      translate3d(
        -5%,
        -4%,
        0
      )
      rotate(6deg);
  }

  80% {
    transform:
      translate3d(
        -5%,
        -6%,
        0
      )
      rotate(-3deg);
  }
}

.gift-box.jiggle .box-top,
.gift-box:hover .box-top {
  animation:
    giftJiggle
    0.5s
    ease;
}

/* =========================================================
   TOOLTIP
   ========================================================= */

.gift-box .box-tooltip {
  position: absolute;

  bottom: 108%;
  left: 50%;

  transform:
    translateX(-50%);

  background:
    var(--card-white);

  color:
    var(--text-dark);

  padding:
    6px 10px;

  border-radius:
    12px;

  font-size:
    11px;

  line-height:
    1.4;

  white-space:
    nowrap;

  box-shadow:
    0 4px 10px
    rgba(0, 0, 0, 0.15);

  opacity: 0;

  pointer-events:
    none;

  transition:
    opacity 0.2s;

  z-index: 20;
}

.gift-box.jiggle .box-tooltip,
.gift-box:hover .box-tooltip {
  opacity: 1;
}

/* =========================================================
   ARMED
   ========================================================= */

.gift-box.armed .box-base {
  box-shadow:
    0 0 0 3px var(--gold),
    0 8px 16px
    rgba(0, 0, 0, 0.15);
}

/* =========================================================
   OPEN
   ========================================================= */

.gift-box.open .box-top {
  transform:
    translate3d(
      -5%,
      -230%,
      0
    )
    rotate(-25deg);

  transition:
    transform 0.6s ease-in;
}

.gift-box.open .box-base {
  opacity: 0.2;

  transition:
    opacity 0.5s ease 0.1s;
}

.gift-box.open .box-amount {
  opacity: 1;
}

/* =========================================================
   MINI BOX
   ========================================================= */

.gift-box--mini {
  width: 100%;
  height: 100%;
}

/* =========================================================
   OPENED POCKET
   ========================================================= */

.pocket-tile.opened.won {
  background:
    linear-gradient(
      160deg,
      #fff8e6,
      #ffe9b0
    );

  border-color:
    var(--gold);
}

.pocket-tile.opened .amount-tag {
  font-size: 10px;

  font-weight: 700;

  color: var(--gold);

  margin-top: 2px;

  text-align: center;
}

.pocket-tile.opened.empty .amount-tag {
  color: var(--empty-gray);
}

/* =========================================================
   MODAL
   ========================================================= */

.modal-backdrop {
  position: fixed;

  inset: 0;

  background:
    rgba(74, 42, 43, 0.55);

  display: flex;

  align-items: center;
  justify-content: center;

  z-index: 100000;

  padding: 20px;
}

.modal {
  width: 100%;
  max-width: 340px;

  background: #fff;

  border-radius: 20px;

  padding: 26px 22px;

  text-align: center;

  box-shadow:
    0 20px 50px
    rgba(0, 0, 0, 0.25);
}

.modal p {
  margin: 0 0 18px;

  font-size: 15px;
}

/* =========================================================
   REVEAL MODAL
   ========================================================= */

.reveal-modal {
  width: min(92vw, 430px);

  max-width: 430px;

  padding:
    30px 22px 24px;

  border-radius: 28px;

  background:
    rgba(255, 255, 255, 0.94);

  box-shadow:
    0 30px 80px
    rgba(0, 0, 0, 0.22);
}

.reveal-modal .box-wrap {
  --box-w: min(58vw, 220px);

  width: var(--box-w);
  height: var(--box-w);

  margin:
    24px auto 28px;
}

/* =========================================================
   LOTTIE
   ========================================================= */

.effect-overlay {
  position: absolute;

  width: 240%;
  height: 240%;

  left: 50%;
  top: 50%;

  transform:
    translate(-50%, -50%);

  pointer-events: none;

  z-index: 10;

  display: block;
}

/* =========================================================
   REVEAL BUTTON
   ========================================================= */

.reveal-close {
  margin-top: 18px;

  width: 100%;

  padding: 12px 0;

  background:
    linear-gradient(
      135deg,
      var(--primary),
      var(--primary-dark)
    );

  color: #fff;

  border: none;

  border-radius: 26px;

  font-family: inherit;

  font-weight: 700;

  cursor: pointer;

  opacity: 0;

  pointer-events: none;

  transition:
    opacity 0.3s;
}

.reveal-close.show {
  opacity: 1;

  pointer-events: auto;
}

/* =========================================================
   RESULT
   ========================================================= */

.result-panel {
  width: min(100%, 420px);
}

.result-icon {
  width: 84px;
  height: 84px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  box-shadow: 0 12px 26px rgba(243, 146, 0, 0.32);
}

.result-icon.empty {
  background: var(--empty-gray);
  box-shadow: none;
  opacity: 0.85;
}

.result-amount {
  display: inline-block;
  font-size: clamp(19px, 5vw, 26px);
  font-weight: 800;
  color: var(--primary-dark);
  background: linear-gradient(135deg, rgba(243, 146, 0, 0.14), rgba(137, 104, 170, 0.10));
  border-radius: 18px;
  padding: 14px 22px;
  margin: 4px 0;
}

.result-amount.empty {
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 700;
  background: rgba(119, 113, 108, 0.08);
}

.result-subtitle {
  margin: 12px 0 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.8;
}
/* =========================================================
   LOGIN
   ========================================================= */

#loginForm {
  width: 100%;
}

.field {
  display: flex;

  flex-direction: column;

  gap: 7px;

  width: 100%;

  margin-bottom: 17px;
}

label {
  font-size: 13px;

  font-weight: 600;

  color: var(--text-muted);
}

input {
  width: 100%;

  height: 50px;

  padding:
    0 16px;

  border-radius: 14px;

  border:
    1.5px solid
    rgba(137, 104, 170, 0.18);

  background: #fff;

  color: var(--text-dark);

  font-family: inherit;

  font-size: 15px;

  outline: none;

  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

input::placeholder {
  color: #aaa;
}

input:focus {
  border-color:
    var(--primary);

  box-shadow:
    0 0 0 4px
    rgba(137, 104, 170, 0.1);
}

input.error {
  border-color:
    var(--primary-dark);

  animation:
    shake 0.4s ease;
}

input.valid {
  border-color:
    var(--pocket-dark);
}

input.invalid {
  border-color:
    #d34b50;
}

/* =========================================================
   FIELD ERROR
   ========================================================= */

.field-error {
  display: none;

  margin: 0;

  padding-right: 4px;

  font-size: 12px;

  line-height: 1.6;

  color:
    #d34b50;
}

.field-error.visible {
  display: block;
}

/* =========================================================
   PRIMARY BUTTON
   ========================================================= */

button.primary {
  width: 100%;

  min-height: 50px;

  margin-top: 8px;

  padding:
    13px 20px;

  border: none;

  border-radius: 28px;

  background:
    linear-gradient(
      135deg,
      var(--primary),
      var(--primary-dark)
    );

  color: #fff;

  font-family: inherit;

  font-size: 15px;

  font-weight: 700;

  cursor: pointer;

  box-shadow:
    0 10px 24px
    rgba(83, 56, 120, 0.25);

  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
}

button.primary:hover {
  transform:
    translateY(-2px);

  box-shadow:
    0 14px 28px
    rgba(83, 56, 120, 0.3);
}

button.primary:active {
  transform:
    translateY(0)
    scale(0.98);
}

button.primary:disabled {
  opacity: 0.6;

  cursor: default;

  transform: none;
}

/* =========================================================
   ERROR MESSAGE
   ========================================================= */

.error-msg {
  min-height: 18px;

  margin:
    8px 0 2px;

  font-size: 13px;

  line-height: 1.6;

  color:
    var(--primary-dark);

  text-align: center;

  opacity: 0;

  transition:
    opacity 0.2s ease;
}

.error-msg.visible {
  opacity: 1;
}

/* =========================================================
   SHAKE
   ========================================================= */

@keyframes shake {
  0%,
  100% {
    transform:
      translateX(0);
  }

  20% {
    transform:
      translateX(-7px);
  }

  40% {
    transform:
      translateX(7px);
  }

  60% {
    transform:
      translateX(-5px);
  }

  80% {
    transform:
      translateX(5px);
  }
}

/* =========================================================
   HIDDEN
   ========================================================= */

.hidden {
  display: none !important;
}

/* =========================================================
   RAVIYA INTRO
   ========================================================= */

.heart-group {
  position: fixed;

  inset: 0;

  z-index: 1;

  pointer-events: none;
}

.hover-heart {
  position: absolute;

  font-size: 22px;

  opacity: 0.55;
}

.intro-container {
  width: 100%;

  max-width: 460px;

  flex: 1;

  align-self: stretch;

  text-align: center;

  position: relative;

  z-index: 2;

  margin: 0 auto;
}

/* =========================================================
   ENVELOPE
   ========================================================= */

.envelope {
  position: absolute;

  top: 50%;
  left: 50%;

  transform:
    translate(-50%, -50%);

  width: var(--env-w, 300px);

  height: var(--env-h, 180px);

  margin: 0;
}

.envelope.clickable {
  cursor: pointer;
}

/* =========================================================
   INTRO HINT
   ========================================================= */

.intro-container .reveal-hint {
  position: absolute;

  top:
    calc(
      50% +
      min(31vw, 150px) +
      18px
    );

  left: 50%;

  transform:
    translateX(-50%);

  width: 100%;

  margin: 0;
}

.intro-container #continueBtn {
  position: absolute;

  top:
    calc(
      50% +
      min(31vw, 150px) +
      54px
    );

  left: 50%;

  transform:
    translateX(-50%);

  width: min(100%, 440px);
}

/* =========================================================
   ENVELOPE FLAP
   ========================================================= */

.envelope .flap {
  position: absolute;

  top: 0;

  width: 100%;
  height: 100%;

  background-color:
    var(--flap-color);

  clip-path:
    polygon(
      0 0,
      100% 0,
      50% 50%
    );

  z-index: 5;

  transform-origin: top;

  transition:
    transform 0.5s ease;
}

.envelope .heart-seal {
  position: absolute;

  top: 45%;
  left: 50%;

  transform:
    translate(-50%, -50%);

  z-index: 6;

  font-size:
    calc(
      var(--env-h, 180px) * 0.16
    );

  transition:
    opacity 0.3s;
}

.envelope .pocket-left {
  position: absolute;

  width: 100%;
  height: 100%;

  background:
    var(--pocket-light);

  clip-path:
    polygon(
      0 0,
      50% 50%,
      0 100%
    );

  z-index: 4;
}

.envelope .pocket-right {
  position: absolute;

  width: 100%;
  height: 100%;

  background:
    var(--pocket-light);

  clip-path:
    polygon(
      100% 0,
      100% 100%,
      50% 50%
    );

  z-index: 4;
}

.envelope .pocket-bottom {
  position: absolute;

  width: 100%;
  height: 100%;

  background:
    var(--pocket-dark);

  clip-path:
    polygon(
      0 100%,
      50% 50%,
      100% 100%
    );

  z-index: 4;
}

/* =========================================================
   ENVELOPE CARD
   ========================================================= */

.envelope .env-card {
  position: absolute;

  bottom: 3%;
  left: 2%;

  width: 96%;
  height: 93%;

  background: transparent;

  border-radius: 4px;

  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;

  transform-origin: center center;

  transition:
    transform 0.8s cubic-bezier(
      0.175,
      0.885,
      0.32,
      1.275
    );

  z-index: 2;

  box-shadow: none;
}

.envelope .env-card-front,
.envelope .env-card-back {
  position: absolute;

  inset: 0;

  width: 100%;
  height: 100%;

  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;

  box-sizing: border-box;

  overflow: hidden;

  border-radius: 4px;

  background: var(--card-white);

  /* Prevent the reverse face from showing through */
  -webkit-transform-style: preserve-3d;
  transform-style: preserve-3d;
}

.envelope .env-card-front {
  transform: rotateY(0deg);
  -webkit-transform: rotateY(0deg);

  z-index: 2;
}

.envelope .env-card-back {
  transform: rotateY(180deg);
  -webkit-transform: rotateY(180deg);

  z-index: 1;
}

.envelope.flipped .env-card {
  transform:
    translateY(
      calc(
        var(--env-h, 180px) * -0.75
      )
    )
    rotateY(180deg);

  -webkit-transform:
    translateY(
      calc(
        var(--env-h, 180px) * -0.75
      )
    )
    rotateY(180deg);
}

.envelope .env-card-front {
  display: flex;

  flex-direction: column;
}

.envelope .env-card-back {
  transform:
    rotateY(180deg);
}

.envelope.open .flap {
  transform:
    rotateX(180deg);

  z-index: 1;
}

.envelope.open .heart-seal {
  opacity: 0;
}

.envelope.open .env-card {
  transform:
    translateY(
      calc(
        var(--env-h, 180px) * -0.75
      )
    );
}

.envelope.flipped .env-card {
  transform:
    translateY(
      calc(
        var(--env-h, 180px) * -0.75
      )
    )
    rotateY(180deg);
}

/* =========================================================
   FORMAL LETTER
   ========================================================= */

.env-text-box {
  width: 100%;
  height: 100%;
  padding: 4%;
  box-sizing: border-box;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}


/* ---------------------------------------------------------
   LETTER PAPER
   --------------------------------------------------------- */

.letter-paper {
  position: relative;

  width: 100%;
  height: 100%;

  padding: 8% 8% 7%;

  box-sizing: border-box;

  background:
    linear-gradient(
      135deg,
      #fffefa 0%,
      #faf7f0 100%
    );

  border: 1px solid rgba(83, 56, 120, 0.28);

  color: #4f4a45;

  overflow: hidden;
}


/* Elegant inner outline */

.letter-paper::before {
  content: "";

  position: absolute;

  inset: 7px;

  border: 1px solid rgba(137, 104, 170, 0.20);

  pointer-events: none;
}


/* Small corner details */

.letter-paper::after {
  content: "";

  position: absolute;

  inset: 11px;

  border: 1px solid rgba(243, 146, 0, 0.10);

  pointer-events: none;
}


/* ---------------------------------------------------------
   HEADER
   --------------------------------------------------------- */

.letter-header {
  position: relative;
  z-index: 2;

  display: flex;

  justify-content: space-between;

  align-items: flex-start;

  direction: rtl;

  margin-bottom: 5%;
}

.letter-date {
  font-size: clamp(
    8px,
    2vw,
    10px
  );

  color: #888078;

  direction: rtl;
}

.letter-to {
  font-size: clamp(
    8px,
    2vw,
    10px
  );

  color: #888078;

  text-align: right;
}

.letter-to strong {
  color: #533878;

  font-weight: 700;
}


/* ---------------------------------------------------------
   TITLE
   --------------------------------------------------------- */

.letter-title {
  position: relative;
  z-index: 2;

  text-align: center;

  color: var(--primary-dark);

  font-family:
    Georgia,
    "Times New Roman",
    serif;

  font-size: clamp(
    17px,
    4.5vw,
    23px
  );

  font-weight: 600;

  line-height: 1.4;

  margin-bottom: 5px;
}


/* ---------------------------------------------------------
   DIVIDER
   --------------------------------------------------------- */

.letter-divider {
  position: relative;
  z-index: 2;

  width: 45%;

  height: 1px;

  margin: 0 auto 6%;

  background:
    linear-gradient(
      to right,
      transparent,
      rgba(137, 104, 170, 0.45),
      transparent
    );
}


/* ---------------------------------------------------------
   BODY
   --------------------------------------------------------- */

.letter-body {
  position: relative;
  z-index: 2;

  text-align: right;

  direction: rtl;

  font-family:
    "Vazirmatn",
    Tahoma,
    "Segoe UI",
    sans-serif;

  font-size: clamp(
    9px,
    2.35vw,
    12px
  );

  line-height: 2;

  color: #625c56;

  height: 58%;

  overflow-y: auto;

  padding-left: 2px;

  scrollbar-width: thin;

  scrollbar-color:
    rgba(137, 104, 170, 0.25)
    transparent;
}

.letter-body p {
  margin: 0 0 5%;

  text-align: justify;

  text-justify: inter-word;
}

.letter-body p:first-child {
  color: var(--primary-dark);

  font-weight: 700;

  margin-bottom: 4%;
}


/* ---------------------------------------------------------
   SIGNATURE
   --------------------------------------------------------- */

.letter-signature {
  position: absolute;

  z-index: 3;

  left: 8%;

  bottom: 7%;

  display: flex;

  flex-direction: column;

  align-items: flex-start;

  gap: 1px;

  font-family:
    "Vazirmatn",
    Tahoma,
    sans-serif;

  font-size: clamp(
    8px,
    2vw,
    11px
  );

  color: #888078;
}

.letter-signature strong {
  color: var(--primary-dark);

  font-family:
    Georgia,
    serif;

  font-size: clamp(
    11px,
    2.8vw,
    15px
  );

  font-style: italic;
}

.letter-signature a {
  color: #7654a8;

  text-decoration: none;

  font-size: clamp(
    7px,
    1.8vw,
    10px
  );
}


/* ---------------------------------------------------------
   STAMP
   --------------------------------------------------------- */

.letter-stamp {
  position: absolute;

  left: 8%;

  bottom: 7%;

  width: clamp(
    38px,
    10vw,
    52px
  );

  height: clamp(
    38px,
    10vw,
    52px
  );

  border:
    1px solid
    rgba(137, 104, 170, 0.35);

  border-radius: 50%;

  display: flex;

  flex-direction: column;

  align-items: center;

  justify-content: center;

  color:
    rgba(137, 104, 170, 0.55);

  font-family:
    Georgia,
    serif;

  font-size: clamp(
    7px,
    1.8vw,
    10px
  );

  letter-spacing: 1px;

  transform: rotate(-12deg);

  opacity: 0.75;
}

.letter-stamp span {
  font-family:
    "Segoe UI",
    sans-serif;

  font-size: 7px;

  margin-top: 2px;

  letter-spacing: 0;
}


/* ---------------------------------------------------------
   MOBILE
   --------------------------------------------------------- */

@media (max-width: 450px) {

  .letter-paper {
    padding:
      8% 7% 7%;
  }

  .letter-body {
    font-size: 9px;

    line-height: 1.85;
  }

  .letter-body p {
    margin-bottom: 4%;
  }

}

/* =========================================================
   PHOTO GALLERY
   ========================================================= */

.photo-gallery {
  display: flex;

  width: 100%;
  height: 100%;

  gap: 8px;

  padding: 4%;

  box-sizing: border-box;
}

.photo-gallery img {
  flex:
    1 1 50%;

  width: 50%;
  height: 100%;

  min-width: 0;

  border:
    3px solid white;

  box-shadow:
    0 3px 8px
    rgba(0, 0, 0, 0.15);

  border-radius: 6px;

  object-fit: cover;
}

.reveal-hint {
  margin-top: 14px;

  font-size: 14px;

  color:
    var(--text-muted);

  text-align: center;
}

/* =========================================================
   📱 TABLET
   ========================================================= */

@media (max-width: 900px) {
  .pocket-grid {
    width: min(100%, 400px);

    grid-template-columns:
      repeat(3, minmax(0, 1fr));

    gap: 14px;
  }
}

/* =========================================================
   📱 MOBILE
   ========================================================= */

@media (max-width: 650px) {
  .screen {
    padding:
      12px 14px 30px;
  }

  .navbar {
    min-height: 60px;

    margin-bottom: 20px;

    padding:
      8px 10px;

    border-radius: 17px;
  }

  /*
   * Still exactly 3 columns.
   */
  .pocket-grid {
    width: min(100%, 360px);

    grid-template-columns:
      repeat(3, minmax(0, 1fr));

    gap: 12px;
  }

  .nav-user {
    max-width: 55%;

    gap: 6px;
  }

  .guest-label {
    font-size: 10px;

    padding:
      5px 8px;
  }

  .greeting {
    font-size: 12px;
  }

  .logout-btn {
    padding:
      8px 11px;

    font-size: 11px;
  }

  .brand-logo {
    height: 26px;
  }

  .panel {
    padding:
      30px 22px;
  }
}

/* =========================================================
   📱 SMALL PHONE
   ========================================================= */

@media (max-width: 450px) {
  .screen {
    padding:
      10px 10px 28px;
  }

  .navbar {
    min-height: 56px;

    padding:
      7px 8px;

    border-radius: 15px;
  }

  .nav-user {
    max-width: 50%;
  }

  .guest-label {
    display: none;
  }

  .greeting {
    font-size: 11px;
  }

  .logout-btn {
    padding:
      7px 9px;

    border-radius: 10px;

    font-size: 10px;
  }

  /*
   * 3 × 3 remains locked.
   */
  .pocket-grid {
    width: min(100%, 300px);

    grid-template-columns:
      repeat(3, minmax(0, 1fr));

    gap: 9px;
  }

  .panel {
    padding:
      26px 18px;

    border-radius: 20px;
  }

  .panel h1 {
    font-size: 22px;
  }

  .panel .subtitle {
    font-size: 13px;
  }

  input {
    height: 48px;

    font-size: 15px;
  }

  button.primary {
    min-height: 48px;
  }
}

/* =========================================================
   📱 VERY SMALL PHONE
   ========================================================= */

@media (max-width: 350px) {
  .nav-user {
    max-width: 48%;
  }

  .greeting {
    font-size: 10px;
  }

  .navbar {
    padding: 7px;
  }

  /*
   * Never allow 2-column wrapping.
   */
  .pocket-grid {
    width: min(100%, 270px);

    grid-template-columns:
      repeat(3, minmax(0, 1fr));

    gap: 7px;
  }

  .brand-logo {
    height: 22px;
  }
}

/* =========================================================
   ADMIN PANEL
   ========================================================= */

.admin-error {
  width: min(100%, 560px);

  margin: 0 auto 16px;

  padding: 14px 18px;

  border-radius: 14px;

  background: rgba(211, 75, 80, 0.1);

  color: #b3383d;

  font-size: 14px;
  text-align: center;
}

.admin-wrap {
  width: 100%;
  max-width: 1100px;

  margin: 0 auto;

  display: flex;
  flex-direction: column;
  align-items: center;

  gap: 20px;
}

.admin-stats {
  width: 100%;

  display: grid;

  grid-template-columns:
    repeat(auto-fit, minmax(130px, 1fr));

  gap: 12px;
}

.admin-stat-card {
  padding: 16px 14px;

  border-radius: 18px;

  background: rgba(255, 255, 255, 0.78);

  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);

  border: 1px solid rgba(255, 255, 255, 0.8);

  box-shadow:
    0 10px 26px rgba(83, 56, 120, 0.08);

  text-align: center;
}

.admin-stat-value {
  font-size: 20px;
  font-weight: 800;

  color: var(--primary-dark);

  margin-bottom: 4px;

  white-space: nowrap;
}

.admin-stat-label {
  font-size: 12px;

  color: var(--text-muted);
}

.admin-table-panel {
  width: 100%;
  max-width: 1100px;

  padding: 24px 20px;
}

.admin-table-panel h2 {
  text-align: right;

  margin-bottom: 16px;
}

.admin-table-scroll {
  width: 100%;

  overflow-x: auto;
}

.admin-table {
  width: 100%;

  border-collapse: collapse;

  font-size: 13px;
}

.admin-table th,
.admin-table td {
  padding: 10px 12px;

  text-align: right;

  white-space: nowrap;

  border-bottom:
    1px solid rgba(137, 104, 170, 0.1);
}

.admin-table th {
  color: var(--text-muted);

  font-weight: 700;

  font-size: 12px;
}

.admin-table tbody tr:hover {
  background: rgba(137, 104, 170, 0.04);
}

.admin-table td.ltr {
  direction: ltr;
  text-align: right;
}

.admin-badge {
  display: inline-block;

  padding: 4px 10px;

  border-radius: 999px;

  font-size: 11px;
  font-weight: 700;
}

.admin-badge--won {
  background: rgba(199, 217, 0, 0.25);
  color: #5a6900;
}

.admin-badge--empty {
  background: rgba(119, 113, 108, 0.14);
  color: var(--text-muted);
}

.admin-badge--pending {
  background: rgba(137, 104, 170, 0.1);
  color: var(--primary-dark);
}

/* =========================================================
   REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration:
      0.01ms !important;

    animation-iteration-count:
      1 !important;

    transition-duration:
      0.01ms !important;
  }
}

/* =========================================================
   LOCKED BOXES AFTER PLAY
   ========================================================= */

.pocket-tile.locked .gift-box.disabled {
  cursor: default;
  opacity: 0.42;
  filter: grayscale(0.15);
  transform: scale(0.96);

  transition:
    opacity 0.25s ease,
    transform 0.25s ease,
    filter 0.25s ease;
}

.pocket-tile.locked .gift-box.disabled .box-tooltip {
  display: none;
}

.pocket-tile.locked .gift-box.disabled:hover .box-top,
.pocket-tile.locked .gift-box.disabled.jiggle .box-top {
  animation: none;
}

.pocket-tile.locked .gift-box.disabled:hover {
  transform: scale(0.96);
}

/* ===== Typography: titles = Colak Pro Soft, body = Ravagh ===== */
h1, h2, h3, h4, .guest-label, .page-tab, .reveal-close, .logout-btn { font-family: var(--font-title); }
button, input, select, textarea { font-family: inherit; }

/* ===== Prize list / odds ===== */
.prize-info { width: min(100%, 560px); margin: 0 auto 16px; padding: 14px 18px; }
.prize-info summary { cursor: pointer; font-family: var(--font-title); font-weight: 700;
  color: var(--primary-dark); list-style: none; text-align: center; }
.prize-info summary::-webkit-details-marker { display: none; }
.prize-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 0.95rem; }
.prize-table th { color: var(--text-muted); font-weight: 400; padding: 4px 6px; text-align: right;
  border-bottom: 2px solid var(--pocket-dark); }
.prize-table td { padding: 7px 6px; border-bottom: 1px solid rgba(0,0,0,0.06); }
.prize-table tbody tr:nth-child(odd) td { background: rgba(243,146,0,0.06); }
.prize-note { margin: 12px 0 0; padding: 8px 12px; border-radius: 12px; font-size: 0.9rem;
  background: rgba(188,207,0,0.18); color: var(--primary-dark); text-align: center; }
.plays-banner { width: min(100%, 560px); margin: 0 auto 14px; padding: 10px 16px; border-radius: 14px;
  text-align: center; background: var(--primary); color: #fff; }
.plays-banner small { opacity: 0.9; }
.result-chance{margin-top:10px;font-size:.9rem;color:var(--text-muted);}