html {
    background: #1a0025;
    -webkit-print-color-adjust: exact;
    color-adjust: exact;
}

body {
    font-family: 'Creepster', 'Cairo', Arial, sans-serif;
    background: #1a0025;
    background: linear-gradient(135deg, #1a0025 0%, #3a1c3a 100%);
    min-height: 100vh;
    margin: 0;
    direction: ltr;
    overflow-x: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    -webkit-print-color-adjust: exact;
    color-adjust: exact;
}


.moon {
    position: fixed;
    top: 40px;
    right: 60px;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle at 60% 40%, #fffbe6 70%, #f7d774 100%, #fff0 100%);
    border-radius: 50%;
    box-shadow: 0 0 80px 20px #fffbe6;
    z-index: 1;
    opacity: 0.8;
}

.bats {
    position: fixed;
    top: 60px;
    left: 0;
    width: 100vw;
    height: 120px;
    pointer-events: none;
    z-index: 2;
}
.bats::before, .bats::after {
    content: '🦇 🦇 🦇';
    font-size: 2.2rem;
    position: absolute;
    left: 10vw;
    top: 0;
    animation: bats-fly 6s linear infinite alternate;
}
.bats::after {
    left: 60vw;
    top: 40px;
    font-size: 2.8rem;
    animation-delay: 2s;
}
@keyframes bats-fly {
    0% { transform: translateY(0) scaleX(1); }
    50% { transform: translateY(30px) scaleX(-1); }
    100% { transform: translateY(0) scaleX(1); }
}

.container {
    max-width: none;
    min-width: 450px;
    min-height: 450px;
    margin: 24px auto;
    background: #1e0a28;
    background: rgba(30, 10, 40, 0.92);
    border-radius: 20px;
    box-shadow: 0 10px 50px 0 #000a, 0 0 0 4px #ff6f00 inset;
    padding: 48px 36px 36px 36px;
    text-align: center;
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    -webkit-print-color-adjust: exact;
    color-adjust: exact;
}

h1, h2, .halloween-msg {
    color: #ff6f00;
    font-family: 'Creepster', 'Cairo', Arial, sans-serif;
    letter-spacing: 1.5px;
    text-shadow: 0 2px 8px #000, 0 0 16px #ff6f00aa;
}

h1 {
    font-size: 2.4rem;
    margin-bottom: 24px;
    line-height: 1.2;
}

h2 {
    font-size: 2rem;
    margin-bottom: 20px;
    line-height: 1.3;
}

.halloween-msg {
    font-size: 1.4rem;
    margin-bottom: 28px;
    color: #fffbe6;
    text-shadow: 0 2px 8px #000, 0 0 8px #ff6f00;
    line-height: 1.4;
}

label, .game-info, #congrats-message, #message {
    color: #fffbe6;
    font-family: 'Cairo', Arial, sans-serif;
}

input, select {
    width: 100%;
    padding: 16px;
    margin-bottom: 24px;
    border: 2px solid #ff6f00;
    border-radius: 12px;
    font-size: 1.1rem;
    background: #2d1436;
    color: #fffbe6;
    transition: border 0.2s, box-shadow 0.2s;
    box-shadow: 0 0 0 2px #ff6f0033;
}
input:focus, select:focus {
    border: 2.5px solid #ffb300;
    outline: none;
    box-shadow: 0 0 12px 3px #ffb30077;
}

.spooky-btn {
    background: linear-gradient(90deg, #ff6f00 60%, #a259ff 100%);
    border: none;
    border-radius: 12px;
    padding: 18px 44px;
    font-size: 1.3rem;
    font-family: 'Creepster', 'Cairo', Arial, sans-serif;
    color: #fffbe6;
    cursor: pointer;
    box-shadow: 0 0 20px 3px #ff6f00cc, 0 3px 10px #000a;
    text-shadow: 0 2px 8px #000, 0 0 8px #ff6f00;
    letter-spacing: 1.2px;
    transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
    animation: spooky-glow 1.2s infinite alternate;
}
.spooky-btn:hover {
    background: linear-gradient(90deg, #a259ff 40%, #ff6f00 100%);
    box-shadow: 0 0 32px 6px #a259ffcc, 0 2px 8px #000a;
    transform: scale(1.05);
}
@keyframes spooky-glow {
    0% { box-shadow: 0 0 16px 2px #ff6f00cc, 0 2px 8px #000a; }
    100% { box-shadow: 0 0 32px 8px #a259ffcc, 0 2px 8px #000a; }
}

.hidden {
    display: none !important;
}

.game-info {
    margin-bottom: 28px;
    font-size: 1.3rem;
    color: #fffbe6;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    text-shadow: 0 2px 8px #000, 0 0 8px #ff6f00;
    padding: 16px 20px;
    background: rgba(45, 20, 54, 0.7);
    border-radius: 12px;
    border: 2px solid #ff6f00;
    box-shadow: 0 4px 15px rgba(255, 111, 0, 0.2);
}

.game-board {
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    display: grid;
    gap: 14px;
    justify-content: center;
    align-items: center;
    grid-template-columns: repeat(auto-fit, minmax(85px, 1fr));
    grid-auto-rows: 115px;
    padding: 20px 0;
}
.game-board.easy {
    grid-template-columns: repeat(4, 85px);
    max-width: 380px;
}
.game-board.medium {
    grid-template-columns: repeat(4, 85px);
    max-width: 380px;
}
.game-board.hard {
    grid-template-columns: repeat(8, 75px);
    max-width: 640px;
}

.card {
    width: 85px;
    height: 115px;
    background: linear-gradient(135deg, #2d1436 0%, #3a1c3a 100%);
    border-radius: 14px;
    box-shadow: 0 3px 15px #000a, 0 0 0 2px #ff6f00 inset;
    cursor: pointer;
    perspective: 1000px;
    user-select: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.card-inner {
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.5s;
    position: relative;
}

.card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    border-radius: 12px;
}

.card-front {
    background: #a259ff;
    color: #fff;
    transform: rotateY(0deg);
}

.card-back {
    background: #2d1436;
    color: #ff6f00;
    transform: rotateY(180deg);
}

.card:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 6px 25px #000a, 0 0 0 2px #ffb300 inset, 0 0 25px #ff6f00cc;
}

.card.flipped, .card.matched {
    background: #a259ff;
    color: #fffbe6;
    cursor: default;
    box-shadow: 0 0 24px 6px #ff6f00cc, 0 2px 12px #a259ff99;
}

#end-screen h2 {
    color: #ff6f00;
    margin-bottom: 16px;
    font-family: 'Creepster', 'Cairo', Arial, sans-serif;
    text-shadow: 0 2px 8px #000, 0 0 16px #ff6f00aa;
}
#congrats-message {
    font-size: 1.2rem;
    margin-bottom: 24px;
    color: #fffbe6;
    text-shadow: 0 2px 8px #000, 0 0 8px #a259ff;
}
#message {
    font-size: 1.3rem;
    margin: 20px 0 0 0;
    color: #ffb300;
    min-height: 36px;
    font-family: 'Creepster', 'Cairo', Arial, sans-serif;
    text-shadow: 0 2px 8px #000, 0 0 8px #ff6f00;
    letter-spacing: 1.2px;
    animation: spooky-msg 1.2s;
    padding: 12px 20px;
    background: rgba(45, 20, 54, 0.5);
    border-radius: 10px;
    border: 2px solid #ffb300;
    box-shadow: 0 4px 15px rgba(255, 179, 0, 0.2);
}
@keyframes spooky-msg {
    0% { opacity: 0; transform: scale(0.8); }
    60% { opacity: 1; transform: scale(1.1); }
    100% { opacity: 1; transform: scale(1); }
}

@media (max-width: 600px) {
    .container {
        min-width: unset;
        min-height: unset;
        padding: 20px 16px;
        margin: 12px 8px;
        border-radius: 16px;
    }
    
    h1 {
        font-size: 2rem;
        margin-bottom: 20px;
    }
    
    h2 {
        font-size: 1.7rem;
        margin-bottom: 16px;
    }
    
    .halloween-msg {
        font-size: 1.2rem;
        margin-bottom: 24px;
    }
    
    .game-board {
        max-width: 98vw;
        gap: 10px;
        grid-template-columns: repeat(auto-fit, minmax(65px, 1fr));
        grid-auto-rows: 85px;
        padding: 16px 0;
    }
    
    .card {
        width: 65px;
        height: 85px;
        font-size: 1.5rem;
    }
    
    .game-info {
        font-size: 1.1rem;
        padding: 12px 16px;
        gap: 10px;
        flex-wrap: wrap;
        margin-bottom: 20px;
    }
    
    .spooky-btn, button {
        padding: 14px 28px;
        font-size: 1.2rem;
    }
    
    input, select {
        padding: 14px;
        font-size: 1rem;
        margin-bottom: 20px;
    }
    
    #play-music-btn, #stop-music-btn {
        top: 20px;
        padding: 12px 24px;
        font-size: 1.1rem;
    }
    
    #play-music-btn {
        left: 20px;
    }
    
    #stop-music-btn {
        left: 180px;
    }
    
    .exit-btn {
        top: 8px;
        right: 16px;
        padding: 6px 12px;
        font-size: 0.85rem;
    }
    
    #message {
        font-size: 1.1rem;
        padding: 10px 16px;
        margin: 16px 0 0 0;
    }
    
    .moon {
        width: 60px;
        height: 60px;
        top: 16px;
        right: 16px;
    }
}

.hidden-card {
    display: none !important;
}

.card-front.emoji-hidden {
    opacity: 0 !important;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

/* الوضع الطبيعي - ❗ ظاهر - قابل للنقر */
.card:not(.matched):not(.hidden-card) {
    cursor: pointer;
}

/* البطاقات اللي مش جاهزة للنقر (مثلاً: تطابقت أو اختفت) */
.card.matched,
.card.hidden-card {
    cursor: default;
}

/* أثناء بداية اللعبة لما تظهر الإيموجي: لا تعرض علامة يد */
.card:not(.flipped):not(.matched):not(.hidden-card) .card-inner {
    pointer-events: none;
}

/* Fade-in animation */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-30px);}
  to   { opacity: 1; transform: translateY(0);}
}

.fade-in {
  opacity: 0;
  animation: fadeIn 1s ease forwards;
}

.fog-bg {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  pointer-events: none;
  z-index: 1;
  background: radial-gradient(ellipse at 50% 60%, #fff8 0%, #fff0 70%);
  opacity: 0.18;
  mix-blend-mode: lighten;
}

.card-explosion {
  position: absolute;
  top: 50%; left: 50%;
  width: 0; height: 0;
  pointer-events: none;
  z-index: 10;
}

.spark {
  position: absolute;
  width: 8px; height: 24px;
  left: -4px; top: -12px;
  background: linear-gradient(180deg, #fffbe6 0%, #ff6f00 60%, #a259ff 100%);
  border-radius: 4px 4px 16px 16px;
  opacity: 0.85;
  transform: scaleY(0.2);
  animation: spark-explode 0.5s cubic-bezier(.5,1.8,.5,1) forwards;
  box-shadow: 0 0 8px 2px #ff6f00cc;
}

@keyframes spark-explode {
  0%   { opacity: 0.9; transform: scaleY(0.2) translateY(0);}
  60%  { opacity: 1;   transform: scaleY(1.2) translateY(-30px);}
  100% { opacity: 0;   transform: scaleY(1.2) translateY(-50px);}
}

@keyframes card-drop {
  0% {
    opacity: 0;
    transform: translateY(-120px) scale(0.8) rotate(-10deg);
  }
  60% {
    opacity: 1;
    transform: translateY(12px) scale(1.05) rotate(3deg);
  }
  80% {
    transform: translateY(-6px) scale(0.98) rotate(-2deg);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0deg);
  }
}

/* تم حذف جميع تأثيرات الظهور */

/* حذف جميع تأثيرات الظهور - البطاقات تظهر مباشرة */
.card.card-animate-in {
  /* لا توجد تأثيرات */
}

#lightning-flash {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  pointer-events: none;
  z-index: 2;
  background: rgba(255,255,255,0.0);
  transition: background 0.2s;
}
.eye-pair {
  position: absolute;
  width: 32px; height: 16px;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.4s;
}
.eye {
  display: inline-block;
  width: 12px; height: 12px;
  margin: 0 2px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 8px 2px #ff6f00cc;
}

#play-music-btn, #stop-music-btn {
  position: fixed;
  bottom: 1.2rem;
  right: 1.2rem;
  left: auto !important;
  top: auto !important;
  z-index: 10000;
  font-size: 1.1rem;
  padding: 0.9em 2em;
  min-width: 7.5em;
  min-height: 2.8em;
  border-radius: 1.2em;
  box-shadow: 0 2px 12px #0005;
  transition: background 0.2s, box-shadow 0.2s;
}
#stop-music-btn {
  right: 1.2rem;
  bottom: 4.2rem;
}
@media (max-width: 600px) {
  #play-music-btn, #stop-music-btn {
    font-size: 1em;
    padding: 0.7em 1.2em;
    min-width: 6em;
    min-height: 2.3em;
    bottom: 0.7rem;
    right: 0.7rem;
    border-radius: 1em;
  }
  #stop-music-btn {
    right: 0.7rem;
    bottom: 3.2rem;
  }
}

.exit-btn {
  position: fixed;
  bottom: 1.2rem;
  left: 1.2rem;
  right: auto !important;
  top: auto !important;
  z-index: 10000;
  font-size: 1.1rem;
  padding: 0.9em 2em;
  min-width: 7.5em;
  min-height: 2.8em;
  border-radius: 1.2em;
  box-shadow: 0 2px 12px #0005;
  transition: background 0.2s, box-shadow 0.2s;
}

.exit-btn:hover {
  background: #cc3333 !important;
  box-shadow: 0 4px 12px rgba(255, 68, 68, 0.5);
  transform: translateY(-1px);
}

#lang-switcher {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin: 24px 0;
}

#lang-switcher .spooky-btn {
    padding: 14px 28px;
    font-size: 1.2rem;
    margin: 0;
    min-width: 140px;
    font-weight: bold;
}

@keyframes ghost-dance {
  0% { transform: translateY(0) scale(1) rotate(-8deg); }
  30% { transform: translateY(-18px) scale(1.1) rotate(8deg); }
  60% { transform: translateY(-8px) scale(1.05) rotate(-8deg); }
  100% { transform: translateY(0) scale(1) rotate(8deg); }
}

/* --- Halloween Win Animation --- */
#win-animation {
  position: relative;
  width: 100%;
  height: 320px;
  background: linear-gradient(135deg, #1a0025 60%, #3a1c3a 100%);
  overflow: hidden;
  border-radius: 18px;
  box-shadow: 0 0 60px 10px #000a, 0 0 0 4px #ff6f00 inset;
  margin: 0 auto 18px auto;
}

.halloween-fog {
  position: absolute;
  left: 0; top: 0; width: 100%; height: 100%;
  background: radial-gradient(ellipse at 50% 70%, #fff8 0%, #fff0 70%);
  opacity: 0.22;
  mix-blend-mode: lighten;
  pointer-events: none;
  animation: fog-move 8s linear infinite alternate;
  z-index: 1;
}
@keyframes fog-move {
  0% { background-position: 50% 70%; opacity: 0.18; }
  100% { background-position: 60% 80%; opacity: 0.28; }
}

.flicker-light {
  position: absolute;
  left: 50%; top: 30px;
  width: 180px; height: 80px;
  background: radial-gradient(circle, #fffbe6 0%, #ffb30033 80%, #fff0 100%);
  opacity: 0.18;
  transform: translateX(-50%);
  pointer-events: none;
  animation: flicker 1.2s infinite alternate;
  z-index: 2;
}
@keyframes flicker {
  0% { opacity: 0.12; }
  50% { opacity: 0.22; }
  100% { opacity: 0.16; }
}

.win-title {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Creepster', 'Cairo', Arial, sans-serif;
  font-size: 3.2rem;
  background: linear-gradient(90deg, #ffb300, #a259ff, #ff6f00, #fffbe6, #a259ff);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 32px #ffb300, 0 0 60px #a259ff, 0 2px 8px #000, 0 0 16px #ff6f00aa;
  letter-spacing: 2px;
  filter: drop-shadow(0 0 16px #ffb300);
  animation: win-glow 2s infinite alternate, win-gradient 4s linear infinite, win-bounce 2.5s infinite;
  z-index: 10;
}
@keyframes win-glow {
  0% { text-shadow: 0 0 24px #ff6f00, 0 0 60px #a259ff, 0 2px 8px #000; }
  100% { text-shadow: 0 0 48px #ffb300, 0 0 80px #a259ff, 0 2px 12px #000; }
}
@keyframes win-gradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes win-bounce {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  20% { transform: translate(-50%, -54%) scale(1.08); }
  40% { transform: translate(-50%, -48%) scale(0.97); }
  60% { transform: translate(-50%, -52%) scale(1.04); }
  80% { transform: translate(-50%, -50%) scale(0.99); }
}

.ghost, .skeleton {
  position: absolute;
  bottom: 30px;
  font-size: 2.8rem;
  z-index: 5;
  filter: drop-shadow(0 0 8px #fffbe6);
  animation: dance-ghost 2.2s infinite alternate ease-in-out;
}
.skeleton {
  font-size: 2.6rem;
  left: auto;
  filter: drop-shadow(0 0 8px #fffbe6) drop-shadow(0 0 12px #a259ff);
  animation: dance-skeleton 2.2s infinite alternate-reverse ease-in-out;
}
@keyframes dance-ghost {
  0% { transform: translateY(0) scale(1) rotate(-8deg); }
  30% { transform: translateY(-22px) scale(1.1) rotate(8deg); }
  60% { transform: translateY(-8px) scale(1.05) rotate(-8deg); }
  100% { transform: translateY(0) scale(1) rotate(8deg); }
}
@keyframes dance-skeleton {
  0% { transform: translateY(0) scale(1) rotate(8deg); }
  30% { transform: translateY(-18px) scale(1.1) rotate(-8deg); }
  60% { transform: translateY(-6px) scale(1.05) rotate(8deg); }
  100% { transform: translateY(0) scale(1) rotate(-8deg); }
}

.pumpkin {
  position: absolute;
  font-size: 2.2rem;
  z-index: 4;
  animation: float-pumpkin 3.5s infinite ease-in-out;
}
@keyframes float-pumpkin {
  0% { transform: translateY(0) rotate(-8deg); }
  50% { transform: translateY(-24px) rotate(8deg); }
  100% { transform: translateY(0) rotate(-8deg); }
}

.bat {
  position: absolute;
  font-size: 2.2rem;
  z-index: 3;
  animation: bat-flap 2.2s infinite linear;
}
@keyframes bat-flap {
  0% { transform: translateY(0) scaleX(1); }
  50% { transform: translateY(12px) scaleX(-1.1); }
  100% { transform: translateY(0) scaleX(1); }
}

.firework, .sparkle {
  position: absolute;
  z-index: 20;
  pointer-events: none;
  font-size: 2.2rem;
  opacity: 0;
  animation: firework-burst 1.2s linear forwards;
}
@keyframes firework-burst {
  0% { opacity: 0; transform: scale(0.5) translateY(0); }
  30% { opacity: 1; transform: scale(1.2) translateY(-30px); }
  80% { opacity: 1; transform: scale(1.1) translateY(-60px); }
  100% { opacity: 0; transform: scale(0.7) translateY(-80px); }
}

.sparkle {
  font-size: 1.4rem;
  color: #fffbe6;
  animation: sparkle-float 1.8s linear infinite;
  opacity: 0.7;
}
@keyframes sparkle-float {
  0% { opacity: 0.7; transform: scale(1) translateY(0); }
  50% { opacity: 1; transform: scale(1.2) translateY(-18px); }
  100% { opacity: 0.7; transform: scale(1) translateY(0); }
}

/* Responsive for win animation */
@media (max-width: 600px) {
  #win-animation {
    height: 180px;
  }
  .win-title {
    font-size: 2rem;
  }
  .ghost, .skeleton {
    font-size: 1.5rem;
    bottom: 10px;
  }
  .pumpkin {
    font-size: 1.2rem;
  }
  .bat {
    font-size: 1.2rem;
  }
}

/* --- SVG/CSS Halloween Characters --- */
.win-ghost {
  position: absolute;
  bottom: 30px;
  width: 54px;
  height: 70px;
  z-index: 5;
  animation: dance-ghost 2.2s infinite alternate ease-in-out;
}
.win-skeleton {
  position: absolute;
  bottom: 30px;
  width: 54px;
  height: 70px;
  z-index: 5;
  animation: dance-skeleton 2.2s infinite alternate-reverse ease-in-out;
}
.win-bat {
  position: absolute;
  width: 48px;
  height: 28px;
  z-index: 3;
  animation: bat-flap 2.2s infinite linear;
}

/* Canvas overlay for fireworks/sparkles */
#win-canvas {
  position: absolute;
  left: 0; top: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
}

/* --- Halloween Parallax Background for Win Animation --- */
#win-animation-bg {
  position: absolute;
  left: 0; top: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.bg-moon {
  position: absolute;
  left: 60%;
  top: 8%;
  width: 120px;
  height: 120px;
  background: radial-gradient(circle at 60% 40%, #fffbe6 70%, #f7d774 100%, #fff0 100%);
  border-radius: 50%;
  box-shadow: 0 0 80px 20px #fffbe6;
  opacity: 0.85;
  animation: moon-glow 3s infinite alternate;
}
@keyframes moon-glow {
  0% { opacity: 0.7; }
  100% { opacity: 1; }
}

.bg-cloud {
  position: absolute;
  width: 180px;
  height: 60px;
  background: linear-gradient(90deg, #fff8 60%, #fff0 100%);
  border-radius: 50px;
  opacity: 0.18;
  filter: blur(2px);
  animation: cloud-move 18s linear infinite;
}
.bg-cloud.c1 { left: 10%; top: 18%; animation-delay: 0s; }
.bg-cloud.c2 { left: 50%; top: 22%; animation-delay: 6s; }
.bg-cloud.c3 { left: 30%; top: 12%; animation-delay: 12s; }
@keyframes cloud-move {
  0% { transform: translateX(0); }
  100% { transform: translateX(80px); }
}

.bg-trees {
  position: absolute;
  left: 0; bottom: 0;
  width: 100%;
  height: 60px;
  z-index: 1;
  background: url('data:image/svg+xml;utf8,<svg width="100%25" height="100%25" viewBox="0 0 400 60" xmlns="http://www.w3.org/2000/svg"><path d="M0,60 Q20,40 40,60 Q60,50 80,60 Q100,45 120,60 Q140,50 160,60 Q180,40 200,60 Q220,50 240,60 Q260,45 280,60 Q300,50 320,60 Q340,40 360,60 Q380,50 400,60 L400,60 L0,60 Z" fill="%231a0025" stroke="%233a1c3a" stroke-width="2"/><rect x="30" y="30" width="6" height="30" fill="%233a1c3a"/><rect x="60" y="40" width="5" height="20" fill="%233a1c3a"/><rect x="120" y="35" width="7" height="25" fill="%233a1c3a"/><rect x="200" y="30" width="8" height="30" fill="%233a1c3a"/><rect x="300" y="38" width="6" height="22" fill="%233a1c3a"/></svg>');
  background-size: cover;
  opacity: 0.7;
}

.bg-fog2 {
  position: absolute;
  left: 0; top: 0; width: 100%; height: 100%;
  background: radial-gradient(ellipse at 40% 80%, #fff8 0%, #fff0 70%);
  opacity: 0.13;
  mix-blend-mode: lighten;
  pointer-events: none;
  animation: fog2-move 12s linear infinite alternate;
  z-index: 2;
}
@keyframes fog2-move {
  0% { background-position: 40% 80%; opacity: 0.10; }
  100% { background-position: 60% 90%; opacity: 0.18; }
}

.bg-stars {
  position: absolute;
  left: 0; top: 0; width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
}
.bg-star {
  position: absolute;
  width: 2px; height: 2px;
  background: #fffbe6;
  border-radius: 50%;
  opacity: 0.7;
  animation: star-twinkle 2.5s infinite alternate;
}
@keyframes star-twinkle {
  0% { opacity: 0.4; }
  100% { opacity: 1; }
}

/* --- Advanced Halloween Characters & Effects --- */
/* Ghost face blink */
.win-ghost .ghost-eye {
  animation: ghost-blink 3.2s infinite;
  transform-origin: center;
}
@keyframes ghost-blink {
  0%, 92%, 100% { r: 3; }
  95% { r: 0.5; }
}
/* Ghost waving hand */
.win-ghost .ghost-hand {
  transform-box: fill-box;
  transform-origin: 80% 80%;
  animation: ghost-wave 2.5s infinite alternate;
}
@keyframes ghost-wave {
  0% { transform: rotate(0deg); }
  60% { transform: rotate(-18deg); }
  100% { transform: rotate(0deg); }
}
/* Skeleton arm/leg dance */
.win-skeleton .skel-arm {
  transform-box: fill-box;
  transform-origin: 90% 20%;
  animation: skel-arm-dance 2.2s infinite alternate;
}
@keyframes skel-arm-dance {
  0% { transform: rotate(0deg); }
  60% { transform: rotate(24deg); }
  100% { transform: rotate(0deg); }
}
.win-skeleton .skel-leg {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: skel-leg-dance 2.2s infinite alternate-reverse;
}
@keyframes skel-leg-dance {
  0% { transform: rotate(0deg); }
  60% { transform: rotate(-18deg); }
  100% { transform: rotate(0deg); }
}
/* Bat wing flap */
.win-bat .bat-wing {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: bat-wing-flap 1.1s infinite alternate;
}
@keyframes bat-wing-flap {
  0% { transform: rotate(0deg); }
  50% { transform: rotate(18deg); }
  100% { transform: rotate(0deg); }
}
/* Floating pumpkin */
.floating-pumpkin {
  position: absolute;
  font-size: 2.2rem;
  z-index: 4;
  animation: float-pumpkin 3.5s infinite ease-in-out;
}
@keyframes float-pumpkin {
  0% { transform: translateY(0) rotate(-8deg); }
  50% { transform: translateY(-24px) rotate(8deg); }
  100% { transform: translateY(0) rotate(-8deg); }
}
/* Blinking eyes */
.bg-eye {
  position: absolute;
  width: 22px; height: 12px;
  z-index: 2;
  left: 10%;
  top: 60%;
  opacity: 0.7;
  animation: eye-blink 4s infinite;
}
@keyframes eye-blink {
  0%, 92%, 100% { opacity: 0.7; }
  95% { opacity: 0.1; }
}

/* --- Professional Animated Win Screen --- */
#end-screen {
  position: relative;
  overflow: visible;
  background: transparent;
  box-shadow: none;
}
#win-bg {
  position: absolute;
  left: 0; top: 0; width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
}
#win-stars {
  position: absolute;
  left: 0; top: 0; width: 100%; height: 100%;
  z-index: 2;
  pointer-events: none;
}
#win-characters {
  position: absolute;
  left: 0; top: 0; width: 100%; height: 100%;
  z-index: 3;
  pointer-events: none;
}
#win-title {
  position: relative;
  z-index: 10;
  font-family: 'Creepster', 'Cairo', Arial, sans-serif;
  font-size: 3.2rem;
  color: #fffbe6;
  text-align: center;
  margin: 60px 0 24px 0;
  letter-spacing: 2px;
  text-shadow: 0 0 32px #ffb300, 0 0 60px #a259ff, 0 2px 8px #000, 0 0 16px #ff6f00aa;
  filter: drop-shadow(0 0 16px #ffb300);
  animation: win-title-glow 2s infinite alternate, win-title-pulse 2.5s infinite;
}
@keyframes win-title-glow {
  0% { text-shadow: 0 0 24px #ff6f00, 0 0 60px #a259ff, 0 2px 8px #000; }
  100% { text-shadow: 0 0 48px #ffb300, 0 0 80px #a259ff, 0 2px 12px #000; }
}
@keyframes win-title-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}
#play-again-btn {
  animation: play-again-glow 1.5s infinite alternate, play-again-pulse 2.2s infinite;
  box-shadow: 0 0 24px 6px #a259ffcc, 0 2px 8px #ff6f00cc;
  background: linear-gradient(90deg, #a259ff 40%, #ff6f00 100%);
  font-size: 1.4rem;
  font-weight: bold;
  margin-top: 32px;
}
@keyframes play-again-glow {
  0% { box-shadow: 0 0 16px 2px #ff6f00cc, 0 2px 8px #a259ffcc; }
  100% { box-shadow: 0 0 32px 8px #a259ffcc, 0 2px 8px #ff6f00cc; }
}
@keyframes play-again-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
#congrats-message {
  position: relative;
  z-index: 10;
  font-size: 1.2rem;
  color: #fffbe6;
  text-align: center;
  margin-bottom: 12px;
}

#about-section {
  background: #2d1436;
  padding: 28px 18px 18px 18px;
  border-radius: 18px;
  box-shadow: 0 8px 32px #000a, 0 0 0 3px #a259ff44 inset;
  max-width: 420px;
  width: 98vw;
  text-align: center;
  margin: 18px auto 32px auto;
  border: 2.5px solid #ff6f00;
  transition: box-shadow 0.3s, border 0.3s, opacity 0.3s;
  opacity: 1;
  animation: about-fade-in 0.7s cubic-bezier(.4,1.6,.4,1) both;
  position: relative;
  z-index: 30;
}
@keyframes about-fade-in {
  0% { opacity: 0; transform: translateY(-30px) scale(0.95); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
#about-section.hidden {
  display: none;
}
@media (max-width: 600px) {
  #about-section {
    max-width: 98vw;
    padding: 18px 4vw 12px 4vw;
    font-size: 0.98em;
  }
}

#lang-switcher {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin: 24px 0;
}

#lang-switcher .spooky-btn {
    padding: 14px 28px;
    font-size: 1.2rem;
    margin: 0;
    min-width: 140px;
    font-weight: bold;
}

@keyframes ghost-dance {
  0% { transform: translateY(0) scale(1) rotate(-8deg); }
  30% { transform: translateY(-18px) scale(1.1) rotate(8deg); }
  60% { transform: translateY(-8px) scale(1.05) rotate(-8deg); }
  100% { transform: translateY(0) scale(1) rotate(8deg); }
}

/* ===== COMPREHENSIVE MOBILE RESPONSIVE IMPROVEMENTS ===== */

/* Base mobile improvements */
@media (max-width: 768px) {
  html {
    font-size: 14px;
  }
  
  body {
    padding: 0.5rem;
    min-height: 100vh;
    overflow-x: hidden;
  }
  
  .container {
    min-width: auto;
    width: 100%;
    max-width: 100%;
    margin: 0.5rem auto;
    padding: 1.5rem 1rem;
    border-radius: 1rem;
  }
  
  h1 {
    font-size: 1.8rem;
    margin-bottom: 1rem;
    line-height: 1.3;
  }
  
  h2 {
    font-size: 1.5rem;
    margin-bottom: 0.8rem;
  }
  
  .halloween-msg {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    line-height: 1.4;
  }
  
  .spooky-btn, button {
    padding: 0.8rem 1.5rem;
    font-size: 1.1rem;
    margin-top: 0.8rem;
    min-height: 3rem;
    min-width: 8rem;
    touch-action: manipulation;
  }
  
  input, select {
    padding: 0.8rem;
    margin-bottom: 1rem;
    font-size: 1rem;
    min-height: 3rem;
  }
  
  .game-info {
    margin-bottom: 1rem;
    font-size: 1rem;
    padding: 0.8rem;
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
  }
  
  .game-board {
    max-width: 100%;
    gap: 0.5rem;
    padding: 0.5rem 0;
  }
  
  .game-board.easy,
  .game-board.medium {
    grid-template-columns: repeat(4, 1fr);
    max-width: 100%;
  }
  
  .game-board.hard {
    grid-template-columns: repeat(4, 1fr);
    max-width: 100%;
  }
  
  .card {
    width: 100%;
    height: 4rem;
    min-height: 4rem;
    border-radius: 0.5rem;
  }
  
  .card-front, .card-back {
    font-size: 1.5rem;
    border-radius: 0.5rem;
  }
  
  #play-music-btn, #stop-music-btn {
    position: fixed;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 10000;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    min-height: 2.5rem;
    min-width: 6rem;
  }
  
  #stop-music-btn {
    left: 7rem;
  }
  
  .exit-btn {
    position: fixed;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 10000;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    min-height: 2.5rem;
    min-width: 6rem;
  }
  
  #message {
    font-size: 1rem;
    margin: 0.5rem 0;
    padding: 0.5rem;
  }
  
  .moon {
    width: 3rem;
    height: 3rem;
    top: 1rem;
    right: 1rem;
  }
  
  .bats::before, .bats::after {
    font-size: 1.5rem;
  }
}

/* Small mobile devices */
@media (max-width: 480px) {
  html {
    font-size: 13px;
  }
  
  .container {
    padding: 1rem 0.5rem;
    margin: 0.25rem auto;
  }
  
  h1 {
    font-size: 1.5rem;
    margin-bottom: 0.8rem;
  }
  
  h2 {
    font-size: 1.3rem;
    margin-bottom: 0.6rem;
  }
  
  .halloween-msg {
    font-size: 1rem;
    margin-bottom: 1rem;
  }
  
  .spooky-btn, button {
    padding: 0.7rem 1.2rem;
    font-size: 1rem;
    min-height: 2.8rem;
    min-width: 7rem;
  }
  
  input, select {
    padding: 0.7rem;
    font-size: 0.9rem;
    min-height: 2.8rem;
  }
  
  .game-info {
    font-size: 0.9rem;
    padding: 0.6rem;
  }
  
  .game-board {
    gap: 0.4rem;
  }
  
  .card {
    height: 3.5rem;
    min-height: 3.5rem;
  }
  
  .card-front, .card-back {
    font-size: 1.3rem;
  }
  
  #play-music-btn, #stop-music-btn, .exit-btn {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
    min-height: 2.2rem;
    min-width: 5rem;
  }
  
  #stop-music-btn {
    left: 5.5rem;
  }
  
  #message {
    font-size: 0.9rem;
  }
  
  .moon {
    width: 2.5rem;
    height: 2.5rem;
  }
  
  .bats::before, .bats::after {
    font-size: 1.2rem;
  }
}

/* Extra small mobile devices */
@media (max-width: 360px) {
  html {
    font-size: 12px;
  }
  
  .container {
    padding: 0.8rem 0.3rem;
  }
  
  h1 {
    font-size: 1.3rem;
  }
  
  h2 {
    font-size: 1.1rem;
  }
  
  .halloween-msg {
    font-size: 0.9rem;
  }
  
  .spooky-btn, button {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    min-height: 2.5rem;
    min-width: 6rem;
  }
  
  input, select {
    padding: 0.6rem;
    font-size: 0.8rem;
    min-height: 2.5rem;
  }
  
  .game-info {
    font-size: 0.8rem;
    padding: 0.5rem;
  }
  
  .card {
    height: 3rem;
    min-height: 3rem;
  }
  
  .card-front, .card-back {
    font-size: 1.1rem;
  }
  
  #play-music-btn, #stop-music-btn, .exit-btn {
    font-size: 0.7rem;
    padding: 0.3rem 0.6rem;
    min-height: 2rem;
    min-width: 4rem;
  }
  
  #stop-music-btn {
    left: 4.5rem;
  }
  
  #message {
    font-size: 0.8rem;
  }
}

/* Landscape orientation improvements */
@media (max-height: 500px) and (orientation: landscape) {
  .container {
    margin: 0.25rem auto;
    padding: 0.8rem 1rem;
  }
  
  h1 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
  }
  
  h2 {
    font-size: 1.1rem;
    margin-bottom: 0.4rem;
  }
  
  .halloween-msg {
    font-size: 0.9rem;
    margin-bottom: 0.8rem;
  }
  
  .spooky-btn, button {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    margin-top: 0.5rem;
    min-height: 2.2rem;
  }
  
  input, select {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    min-height: 2.2rem;
  }
  
  .game-info {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    padding: 0.5rem;
  }
  
  .game-board {
    padding: 0.3rem 0;
  }
  
  .card {
    height: 2.8rem;
    min-height: 2.8rem;
  }
  
  .card-front, .card-back {
    font-size: 1.2rem;
  }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
  .spooky-btn:hover, button:hover {
    transform: none;
  }
  
  .card:hover {
    transform: none;
  }
  
  .spooky-btn:active, button:active {
    transform: scale(0.95);
  }
  
  .card:active {
    transform: scale(0.95);
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .card-front, .card-back {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  /* Already dark theme, no changes needed */
}

/* Print styles */
@media print {
  .container {
    box-shadow: none;
    border: 1px solid #000;
  }
  
  .spooky-btn, button {
    display: none;
  }
  
  .game-board {
    display: none;
  }
}

/* --- Match Animation: Bounce + Glossy Shine + Glow --- */
@keyframes card-match-bounce {
  0%   { transform: scale(1) rotateY(0deg); }
  30%  { transform: scale(1.18) rotateY(8deg); }
  55%  { transform: scale(0.98) rotateY(-6deg); }
  70%  { transform: scale(1.08) rotateY(3deg); }
  85%  { transform: scale(1.03) rotateY(-2deg);}
  100% { transform: scale(1.05) rotateY(0deg);}
}
@keyframes card-match-glow {
  0%   { box-shadow: 0 0 0 0 #ffe06688; }
  40%  { box-shadow: 0 0 24px 8px #ffe066cc; }
  100% { box-shadow: 0 0 12px 2px #ffe06688; }
}
@keyframes card-match-shine {
  0% { opacity: 0; left: -70%; }
  50% { opacity: 0.85; left: 110%; }
  100% { opacity: 0; left: 110%; }
}
.card.matched .card-inner {
  animation: card-match-bounce 0.7s cubic-bezier(.23,1.12,.62,1.01), card-match-glow 0.7s cubic-bezier(.23,1.12,.62,1.01);
  box-shadow: 0 0 12px 2px #ffe06688;
  position: relative;
  z-index: 2;
  transition: box-shadow 0.3s;
  border-radius: 12px;
}
.card.matched .card-inner::after {
  content: "";
  position: absolute;
  top: 0; left: -70%;
  width: 60%;
  height: 100%;
  background: linear-gradient(120deg, rgba(255,255,255,0.0) 0%, rgba(255,255,255,0.85) 60%, rgba(255,255,255,0.0) 100%);
  opacity: 0;
  pointer-events: none;
  animation: card-match-shine 0.7s 0.1s linear;
  border-radius: 12px;
  filter: blur(0.5px);
}
.card.matched {
  background: #fffbe6;
  transition: background 0.3s;
}

/* --- Mismatch Animation: Shake + Border Color --- */
@keyframes card-shake {
  0% { transform: translateX(0); }
  15% { transform: translateX(-10px); }
  30% { transform: translateX(10px); }
  45% { transform: translateX(-7px); }
  60% { transform: translateX(7px); }
  75% { transform: translateX(-3px); }
  90% { transform: translateX(3px); }
  100% { transform: translateX(0); }
}
@keyframes card-mismatch-border {
  0%   { box-shadow: 0 0 0 0 #ff767500, 0 0 0 0 #fff0; }
  30%  { box-shadow: 0 0 0 4px #ff7675cc, 0 0 8px 2px #ff767588; }
  100% { box-shadow: 0 0 0 0 #ff767500, 0 0 0 0 #fff0; }
}
.card.mismatch .card-inner {
  animation: card-shake 0.45s cubic-bezier(.36,.07,.19,.97), card-mismatch-border 0.45s cubic-bezier(.36,.07,.19,.97);
  box-shadow: 0 0 0 0 #ff767500;
  border-radius: 12px;
}

/* Add or update styles for the player mode selection */
#players-choice {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin: 18px 0 14px 0;
  background: #2d1436cc;
  border-radius: 16px;
  padding: 10px 0 10px 0;
  box-shadow: 0 2px 12px #0002;
  border: 1.5px solid #ffb30055;
}
#players-choice label {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1a0025;
  border-radius: 12px;
  padding: 10px 22px;
  cursor: pointer;
  font-weight: bold;
  color: #ffb300;
  font-size: 1.08em;
  box-shadow: 0 1px 6px #0001;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
  border: 2px solid transparent;
}
#players-choice input[type="radio"] {
  accent-color: #ffb300;
  width: 1.1em;
  height: 1.1em;
  margin: 0 6px 0 0;
}
#players-choice label.selected, #players-choice input[type="radio"]:checked + span {
  background: #ffb300;
  color: #2d1436;
  border: 2px solid #ffb300;
  box-shadow: 0 2px 12px #ffb30044;
}
#players-choice label span {
  transition: color 0.2s, background 0.2s;
}
@media (max-width: 600px) {
  #players-choice label {
    padding: 8px 10px;
    font-size: 0.98em;
  }
}

/* RTL support for Arabic */
body[dir='rtl'] #players-choice {
  flex-direction: row-reverse;
}
body[dir='rtl'] #players-choice label {
  flex-direction: row-reverse;
  text-align: right;
}
body[dir='rtl'] #players-choice input[type="radio"] {
  margin: 0 0 0 6px;
}
body[dir='rtl'] input,
body[dir='rtl'] select,
body[dir='rtl'] label {
  text-align: right;
}

/* Remove all custom styles for #game-screen #player-name and reset it */
#game-screen #player-name {
  color: #fff;
  text-shadow: 0 0 12px #ff6f00, 0 0 24px #ffb300, 0 2px 8px #ff6f00;
  font-weight: bold;
  display: inline;
}