/* =========================================================
   ⲧⲉⲛⲯⲩⲭⲏ — Coptic Letters App
   Design tokens
   -------------------------------------------------
   Palette (Coptic manuscript / icon inspired):
     --parchment      #EDE3CC   aged vellum background
     --parchment-2    #E4D5AE   deeper parchment (cards)
     --ink            #2B2118   near-black manuscript ink
     --maroon         #6B1E23   oxblood red (rubrication)
     --maroon-deep    #4A1216   shadow red
     --gold           #B8892B   gilding
     --gold-light     #D9B45C   gilding highlight
     --teal           #1F3B3A   icon-panel teal (tab 2 accent)

   Type:
     display  -> 'Amiri' (Arabic headers, manuscript character)
     body     -> 'Cairo' (clean reading face)
     utility  -> 'IBM Plex Sans Arabic' (labels, counters)
   ========================================================= */

@font-face {
  font-family: "coptic-abraam";
  src: url("../fonts/ABRAAM_0.ttf") format("truetype");
  font-display: swap;
}
@font-face {
  font-family: "coptic-shenouda";
  src: url("../fonts/Avva_Shenouda.ttf") format("truetype");
  font-display: swap;
}
@font-face {
  font-family: "coptic-copt";
  src: url("../fonts/copt.ttf") format("truetype");
  font-display: swap;
}

:root {
  --parchment: #EDE3CC;
  --parchment-2: #E4D5AE;
  --ink: #2B2118;
  --maroon: #6B1E23;
  --maroon-deep: #4A1216;
  --gold: #B8892B;
  --gold-light: #D9B45C;
  --teal: #1F3B3A;

  --font-display: "Amiri", serif;
  --font-body: "Cairo", sans-serif;
  --font-utility: "IBM Plex Sans Arabic", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--parchment);
  color: var(--ink);
  font-family: var(--font-body);
}

/* subtle vellum texture */
body {
  background-image:
    radial-gradient(circle at 20% 10%, rgba(184,137,43,0.08), transparent 40%),
    radial-gradient(circle at 85% 90%, rgba(107,30,35,0.06), transparent 45%);
}

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

button { font-family: inherit; cursor: pointer; }

/* ---------------------------------------------------------
   Header
--------------------------------------------------------- */
.app-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px 10px 26px;
  border-bottom: 2px solid var(--gold);
}

.header-text { text-align: center; }

.eyebrow {
  margin: 0 0 6px;
  font-family: var(--font-utility);
  font-size: 13px;
  letter-spacing: 0.14em;
  color: var(--maroon);
}

.app-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(30px, 5vw, 44px);
  color: var(--ink);
}

.header-ornament {
  width: 46px;
  height: 46px;
  opacity: 0.85;
  background:
    conic-gradient(from 45deg, var(--gold) 0 25%, transparent 0 50%, var(--gold) 0 75%, transparent 0);
  border-radius: 50%;
  flex: 0 0 auto;
}
.header-ornament.right { margin-left: 18px; }
.header-ornament.left  { margin-right: 18px; }

/* ---------------------------------------------------------
   Tabs — styled like manuscript bookmark tabs
--------------------------------------------------------- */
.tabs {
  display: flex;
  gap: 10px;
  margin: 24px 0 8px;
  border-bottom: 1px solid rgba(43,33,24,0.15);
}

.tab-btn {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 8px;
  background: transparent;
  border: none;
  padding: 12px 18px 14px;
  font-size: 16px;
  font-weight: 600;
  color: rgba(43,33,24,0.55);
  border-radius: 10px 10px 0 0;
  transition: color .2s ease, background .2s ease;
}

.tab-btn .tab-index {
  font-family: "coptic-abraam", var(--font-display);
  color: var(--gold);
  font-size: 15px;
}

.tab-btn:hover { color: var(--ink); }

.tab-btn.active {
  color: var(--maroon);
  background: var(--parchment-2);
}

.tab-btn.active::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 3px;
  background: var(--maroon);
  border-radius: 3px 3px 0 0;
}

/* ---------------------------------------------------------
   Panels
--------------------------------------------------------- */
.tab-panel { padding: 26px 4px 10px; }
.tab-panel[hidden] { display: none; }

.panel-intro h2 {
  font-family: var(--font-display);
  font-size: 26px;
  margin: 0 0 6px;
  color: var(--maroon);
}
.panel-intro p {
  margin: 0 0 20px;
  color: rgba(43,33,24,0.75);
}

/* ---------------------------------------------------------
   TAB 0 — Intro Video (المقدمة)
--------------------------------------------------------- */
.intro-video-wrapper {
  position: relative;
  width: 100%;
  max-width: 860px;
  margin: 0 auto 24px;
  background: var(--parchment-2);
  border: 4px solid var(--gold);
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(43, 33, 24, 0.25);
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

.intro-video {
  width: 100%;
  max-height: 520px;
  display: block;
  border-radius: 12px;
  background: #000;
  outline: none;
}

/* ---------------------------------------------------------
   TAB 1 — letters
--------------------------------------------------------- */
.font-switcher {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  font-family: var(--font-utility);
  font-size: 14px;
}
.font-options { display: flex; gap: 8px; flex-wrap: wrap; }
.font-opt {
  border: 1px solid rgba(184,137,43,0.5);
  background: transparent;
  color: var(--maroon-deep);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
}
.font-opt.active {
  background: var(--gold);
  border-color: var(--gold);
  color: #fff;
}

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

.letter-card {
  position: relative;
  background: var(--parchment-2);
  border: 1px solid rgba(184,137,43,0.4);
  border-radius: 14px;
  padding: 16px 8px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}

/* illuminated-manuscript corner flourishes — signature detail */
.letter-card::before,
.letter-card::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid var(--gold);
  opacity: 0.6;
}
.letter-card::before { top: 6px; right: 6px; border-bottom: none; border-left: none; }
.letter-card::after  { bottom: 6px; left: 6px; border-top: none; border-right: none; }

.letter-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 18px rgba(74,18,22,0.18);
  border-color: var(--gold);
}

.letter-card.playing {
  border-color: var(--maroon);
  box-shadow: 0 0 0 3px rgba(107,30,35,0.15);
}

/* the empty "letter shape" slot — fill with an <img> per letter, or it
   falls back to rendering the Unicode Coptic character in the chosen font */
.letter-shape {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(255,255,255,0.35);
  overflow: hidden;
}
.letter-shape img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.letter-shape .letter-glyph {
  font-family: "coptic-abraam", sans-serif;
  font-size: 34px;
  line-height: 1;
  color: var(--maroon-deep);
}

.letter-name {
  font-family: var(--font-utility);
  font-size: 12px;
  color: rgba(43,33,24,0.7);
  text-align: center;
}

/* sound-playing indicator, shown while audio is active */
.sound-indicator {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 22px;
  height: 22px;
  display: none;
  align-items: center;
  justify-content: center;
}
.letter-card.playing .sound-indicator { display: flex; }
.sound-indicator span {
  display: block;
  width: 4px;
  margin: 0 1.5px;
  background: var(--maroon);
  border-radius: 2px;
  animation: soundBar 0.9s ease-in-out infinite;
}
.sound-indicator span:nth-child(1) { height: 8px;  animation-delay: 0s; }
.sound-indicator span:nth-child(2) { height: 16px; animation-delay: 0.15s; }
.sound-indicator span:nth-child(3) { height: 10px; animation-delay: 0.3s; }

@keyframes soundBar {
  0%, 100% { transform: scaleY(0.4); }
  50%      { transform: scaleY(1); }
}

/* ---------------------------------------------------------
   TAB RULES — Progress & Stepper Pathway
--------------------------------------------------------- */
.rules-progress-card {
  max-width: 860px;
  margin: 0 auto 20px;
  background: var(--parchment-2);
  border: 2px solid var(--gold);
  border-radius: 14px;
  padding: 16px 20px;
  box-shadow: 0 4px 12px rgba(43, 33, 24, 0.1);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-utility);
  font-size: 14px;
  font-weight: 600;
}

.progress-title {
  color: var(--ink);
}

.progress-status {
  color: var(--maroon);
  font-weight: 700;
}

.progress-track {
  width: 100%;
  height: 12px;
  background: rgba(43, 33, 24, 0.12);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--gold);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold) 0%, var(--maroon) 100%);
  border-radius: 10px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------------------------------------------------------
   Radial Wheel Selector (المستوحى من تصميم العجلة الدائرية)
--------------------------------------------------------- */
.radial-wheel-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 10px auto 30px;
  max-width: 500px;
  padding: 10px 0;
}

/* اللافتة المضيئة العلوية */
.wheel-title-banner {
  position: relative;
  z-index: 10;
  background: linear-gradient(135deg, rgba(43, 33, 24, 0.92) 0%, rgba(74, 18, 22, 0.95) 100%);
  border: 2px solid var(--gold);
  border-radius: 30px;
  padding: 12px 28px;
  text-align: center;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.35), 0 0 15px rgba(184, 137, 43, 0.4);
  margin-bottom: 24px;
  min-width: 260px;
  max-width: 90%;
  animation: bannerGlow 3s infinite ease-in-out alternate;
}

@keyframes bannerGlow {
  0%   { box-shadow: 0 8px 25px rgba(0, 0, 0, 0.35), 0 0 15px rgba(184, 137, 43, 0.3); }
  100% { box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 0 25px rgba(217, 180, 92, 0.6); }
}

.banner-text {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: #FFF4B8;
  letter-spacing: 0.02em;
}

/* الأشعة الضوئية الصاعدة من المركز إلى اللافتة */
.wheel-light-rays {
  position: absolute;
  top: 40px;
  left: 50%;
  transform: translateX(-50%);
  width: 240px;
  height: 140px;
  background: conic-gradient(from 150deg at 50% 100%, transparent 0deg, rgba(184, 137, 43, 0.18) 25deg, rgba(217, 180, 92, 0.35) 30deg, transparent 60deg);
  pointer-events: none;
  z-index: 1;
  filter: blur(2px);
}

/* حاوية العجلة الدائرية الدوارة بالسحب واللمس */
.wheel-container {
  position: relative;
  width: 320px;
  height: 320px;
  margin: 0 auto;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, rgba(31, 59, 58, 0.15) 0%, transparent 70%);
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.wheel-container.is-dragging {
  cursor: grabbing;
}

/* كرة المركز المضيئة */
.wheel-center-orb {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #2b5688 0%, var(--teal) 60%, var(--maroon-deep) 100%);
  border: 4px solid var(--gold);
  box-shadow: 0 0 25px rgba(31, 59, 58, 0.7), inset 0 0 15px rgba(255, 255, 255, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.orb-icon {
  display: inline-block;
  font-size: 32px;
  color: var(--gold-light);
  filter: drop-shadow(0 0 8px rgba(255, 244, 184, 0.8));
  pointer-events: none;
  transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

/* أزرار العجلة الدائرية (Nodes) */
.wheel-node {
  position: absolute;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FFF9EA 0%, var(--parchment-2) 100%);
  border: 3px solid var(--gold);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25), inset 0 0 6px rgba(255, 255, 255, 0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease, border-color 0.3s ease;
  transform: translate(-50%, -50%);
}

.wheel-node:hover {
  transform: translate(-50%, -50%) scale(1.12);
  border-color: var(--maroon);
  box-shadow: 0 8px 24px rgba(107, 30, 35, 0.4);
}

.wheel-node.active {
  transform: translate(-50%, -50%) scale(1.24);
  border-color: var(--maroon);
  background: linear-gradient(135deg, #FFF 0%, #F5E8C7 100%);
  box-shadow: 0 0 25px rgba(107, 30, 35, 0.6), 0 0 15px var(--gold-light);
  z-index: 10;
}

.node-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.node-icon {
  font-size: 22px;
  color: var(--maroon-deep);
  transition: color 0.3s ease, transform 0.3s ease;
}

.wheel-node.active .node-icon {
  color: var(--maroon);
  transform: scale(1.15);
}

.node-badge {
  position: absolute;
  bottom: -10px;
  right: -10px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--maroon);
  color: #FFF4B8;
  border: 1.5px solid var(--gold);
  font-family: "coptic-abraam", var(--font-utility);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wheel-node.completed .node-badge {
  background: #4A7C38;
  border-color: #A2D68C;
  color: #fff;
}

.node-label {
  display: none;
}

@media (max-width: 480px) {
  .wheel-container { width: 280px; height: 280px; }
  .wheel-node {
    width: 62px;
    height: 62px;
    transform: translate(-50%, -50%);
  }
  .wheel-node:hover {
    transform: translate(-50%, -50%) scale(1.1);
  }
  .wheel-node.active {
    transform: translate(-50%, -50%) scale(1.18);
  }
}

/* Active Step Video Container & Actions */
.rules-active-container {
  max-width: 860px;
  margin: 0 auto;
}

.rule-video-card {
  background: var(--parchment-2);
  border: 3px solid var(--gold);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 8px 24px rgba(43, 33, 24, 0.15);
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.rule-video-card:hover {
  box-shadow: 0 12px 30px rgba(43, 33, 24, 0.22);
}

.rule-video-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.rule-num-badge {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--maroon);
  color: #FFF4B8;
  border: 2px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-utility);
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 3px 8px rgba(107, 30, 35, 0.3);
}

.rule-num-badge.completed-badge {
  background: #4A7C38;
}

.rule-title-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rule-step-tag {
  font-family: var(--font-utility);
  font-size: 12px;
  font-weight: 700;
  color: var(--teal);
  letter-spacing: 0.05em;
}

.rule-video-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--maroon-deep);
}

.rule-video-desc {
  margin: 0;
  font-family: var(--font-body);
  font-size: 14px;
  color: rgba(43, 33, 24, 0.8);
  line-height: 1.5;
}

.rule-video-wrapper {
  position: relative;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  border: 2px solid var(--gold);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.rule-video {
  width: 100%;
  max-height: 480px;
  display: block;
  outline: none;
}

.rule-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding-top: 16px;
  border-top: 1px solid rgba(184, 137, 43, 0.3);
  flex-wrap: wrap;
}

.btn-step-nav {
  background: var(--parchment-2);
  border: 1px solid var(--gold);
  color: var(--ink);
  padding: 10px 18px;
  border-radius: 8px;
  font-family: var(--font-utility);
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.btn-step-nav:hover:not(:disabled) {
  background: var(--gold-light);
}

.btn-step-nav.primary {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}

.btn-step-nav.primary:hover:not(:disabled) {
  background: #2b4f4e;
}

.btn-step-nav:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-toggle-complete {
  background: var(--maroon);
  color: #fff;
  border: 1px solid var(--maroon-deep);
  padding: 10px 20px;
  border-radius: 25px;
  font-family: var(--font-utility);
  font-size: 14px;
  font-weight: 700;
  transition: all 0.2s ease;
  box-shadow: 0 3px 10px rgba(107, 30, 35, 0.25);
}

.btn-toggle-complete:hover {
  transform: translateY(-1px);
  background: var(--maroon-deep);
}

.btn-toggle-complete.is-complete {
  background: #4A7C38;
  border-color: #385E2A;
}

.btn-toggle-complete.is-complete:hover {
  background: #385E2A;
}

/* ---------------------------------------------------------
   TAB 2 — memory game
--------------------------------------------------------- */
.game-toolbar {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.game-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: var(--font-utility);
}
.stat-label { font-size: 12px; color: rgba(43,33,24,0.6); }
.stat-value { font-size: 18px; font-weight: 700; color: var(--teal); }

.btn-restart {
  margin-inline-start: auto;
  background: var(--maroon);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
}
.btn-restart:hover { background: var(--maroon-deep); }

.memory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 14px;
  perspective: 1000px;
}

.memory-card {
  position: relative;
  aspect-ratio: 3 / 4;
  cursor: pointer;
}
.memory-card .card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform .5s cubic-bezier(.2,.8,.2,1);
  transform-style: preserve-3d;
}
.memory-card.flipped .card-inner,
.memory-card.matched .card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  text-align: center;
}

/* back of card = outward-facing side, shows Mar Afram image */
.card-back {
  background: var(--teal) center / cover no-repeat;
  border: 2px solid var(--gold);
}
.card-back img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
}

/* front of card = revealed side, question or answer text */
.card-front {
  transform: rotateY(180deg);
  background: var(--parchment-2);
  border: 2px solid var(--gold);
  font-family: var(--font-utility);
  font-size: 13px;
  line-height: 1.4;
  color: var(--ink);
}
.card-front.is-question { background: #F1E4C6; }
.card-front.is-answer   { background: #E7DAB6; }

.memory-card.matched .card-front {
  border-color: var(--maroon);
  box-shadow: 0 0 0 3px rgba(107,30,35,0.15);
}

.win-banner {
  margin-top: 22px;
  background: var(--maroon);
  color: #fff;
  padding: 14px 18px;
  border-radius: 10px;
  text-align: center;
  font-family: var(--font-utility);
}

/* ---------------------------------------------------------
   TAB 3 — Puzzle Game (لعبة البازل)
--------------------------------------------------------- */
.puzzle-toolbar {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.puzzle-select {
  background: var(--parchment-2);
  color: var(--ink);
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 6px 12px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}
.puzzle-select:focus {
  border-color: var(--maroon);
}

.puzzle-actions {
  display: flex;
  gap: 10px;
  margin-inline-start: auto;
}

.btn-action {
  background: var(--teal);
  color: var(--parchment);
  border: 1px solid var(--gold);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  transition: background .2s ease, transform .1s ease;
}
.btn-action:hover {
  background: #2b4f4e;
  transform: translateY(-1px);
}

.timer-val {
  font-family: var(--font-utility);
  font-weight: 700;
  color: var(--teal);

}

.timer-val.warning {
  color: var(--maroon);
  animation: pulseTimer 0.8s ease infinite alternate;
}

@keyframes pulseTimer {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0.6; transform: scale(1.1); }
}

.lose-banner {
  background: var(--maroon-deep);
  border: 1px solid var(--gold);
}

.puzzle-board {
  position: relative;
  display: grid;
  direction: ltr;
  width: 100%;
  max-width: 580px;
  margin: 0 auto 24px;
  padding: 8px;
  background-color: var(--parchment-2);
  border: 4px solid var(--gold);
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(43, 33, 24, 0.25);
  touch-action: none;
  overflow: visible;
}

.puzzle-tile-slot {
  position: relative;
  width: 100%;
  height: 100%;
  cursor: pointer;
  user-select: none;
  overflow: visible;
}

.jigsaw-piece-canvas {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: transform .18s ease, filter .18s ease;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
}

.puzzle-tile-slot:hover .jigsaw-piece-canvas {
  transform: translate(-50%, -52%) scale(1.04);
  z-index: 15;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.4));
}

.puzzle-tile-slot.selected .jigsaw-piece-canvas {
  transform: translate(-50%, -54%) scale(1.08);
  z-index: 30;
  filter: drop-shadow(0 0 8px var(--gold)) drop-shadow(0 8px 16px rgba(107, 30, 35, 0.6));
}

.puzzle-tile-slot.in-place::after {
  content: "✓";
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  background: rgba(31, 59, 58, 0.9);
  color: var(--gold-light);
  font-size: 10px;
  font-weight: bold;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--gold);
  z-index: 20;
  pointer-events: none;
}

.puzzle-board-wrapper {
  position: relative;
  width: 100%;
  max-width: 580px;
  margin: 0 auto 24px;
}

/* ---------------------------------------------------------
   Interactive Start Overlay & Button
--------------------------------------------------------- */
.puzzle-start-overlay {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(28, 20, 14, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 16px;
  padding: 20px;
  opacity: 1;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.puzzle-start-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.start-card {
  background: var(--parchment);
  border: 3px solid var(--gold);
  border-radius: 16px;
  padding: 28px 24px;
  text-align: center;
  max-width: 440px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4), inset 0 0 0 2px rgba(255, 245, 220, 0.5);
  animation: startCardPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

@keyframes startCardPop {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.start-badge {
  font-family: "coptic-abraam", var(--font-display);
  color: var(--gold);
  font-size: 16px;
  letter-spacing: 0.15em;
}

.start-icon {
  font-size: 48px;
  line-height: 1;
  animation: pulseIcon 2s infinite ease-in-out;
}

@keyframes pulseIcon {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.1) rotate(5deg); }
}

.start-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px;
  color: var(--maroon);
  font-weight: 700;
}

.start-desc {
  margin: 0;
  font-size: 14px;
  color: rgba(43, 33, 24, 0.85);
  line-height: 1.5;
}

.start-features {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 4px 0 8px;
}

.feature-badge {
  background: var(--parchment-2);
  border: 1px solid var(--gold);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--teal);
  font-family: var(--font-utility);
}

/* التنسيق المميز والبارز لزر البدء */
.btn-start-game {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 280px;
  padding: 14px 28px;
  background: linear-gradient(135deg, var(--maroon) 0%, var(--maroon-deep) 100%);
  color: #FFF4B8;
  border: 2px solid var(--gold);
  border-radius: 30px;
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(107, 30, 35, 0.5), 0 0 15px rgba(184, 137, 43, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  position: relative;
  overflow: hidden;
  animation: startGlow 2s infinite ease-in-out;
}

@keyframes startGlow {
  0%, 100% { box-shadow: 0 6px 20px rgba(107, 30, 35, 0.5), 0 0 15px rgba(184, 137, 43, 0.3); }
  50%      { box-shadow: 0 8px 26px rgba(107, 30, 35, 0.7), 0 0 25px rgba(217, 180, 92, 0.6); }
}

.btn-start-game:hover {
  transform: translateY(-3px) scale(1.03);
  background: linear-gradient(135deg, #7c242a 0%, var(--maroon) 100%);
  color: #ffffff;
  cursor: pointer;
}

.btn-start-game:active {
  transform: translateY(1px) scale(0.98);
}

.btn-start-game .btn-icon {
  font-size: 16px;
  transition: transform 0.2s ease;
}

.btn-start-game:hover .btn-icon {
  transform: translateX(-4px);
}

/* Touch Dragging Support for Mobile View */
.puzzle-tile-slot {
  touch-action: none;
  -webkit-touch-callout: none;
}

.puzzle-tile-slot.touch-dragging {
  opacity: 0.5;
  z-index: 40;
}

.touch-drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
  transform: translate(-50%, -50%) scale(1.1);
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.5)) drop-shadow(0 0 10px var(--gold));
  transition: none;
}

/* Sparkle & particle animation effects */
.sparkle-particle {
  position: absolute;
  pointer-events: none;
  width: 8px;
  height: 8px;
  background: var(--gold-light);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--gold);
  z-index: 40;
  animation: sparkleFade 0.6s ease-out forwards;
}

@keyframes sparkleFade {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; }
}

/* ---------------------------------------------------------
   Accessibility & responsiveness
--------------------------------------------------------- */





/* ---------------------------------------------------------
   Accessibility & responsiveness
--------------------------------------------------------- */
button:focus-visible,
.letter-card:focus-visible,
.memory-card:focus-visible,
.puzzle-tile:focus-visible {
  outline: 3px solid var(--maroon);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .memory-card .card-inner { transition: none; }
  .sound-indicator span { animation: none; }
  .puzzle-tile { transition: none; }
}

@media (max-width: 480px) {
  .app-header { flex-direction: column; gap: 10px; }
  .header-ornament { display: none; }
  .tabs { gap: 4px; }
  .tab-btn { padding: 10px 12px; font-size: 14px; }
  .puzzle-toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .puzzle-actions { margin-inline-start: 0; justify-content: space-between; }
}

