/* ========================================
   1. MAIN GAME STYLES (استایل‌های اصلی بازی)
   ======================================== */

/* کانتینر اصلی - طرح کاغذ قدیمی */
.kth-game-container {
    max-width: 800px;
    margin: 50px auto;
    background-color: #f4e4bc; /* رنگ کاغذ کاهی */
    background-image: url('https://www.transparenttextures.com/patterns/aged-paper.png');
    border: 1px solid #d4c4a8;
    box-shadow: 0 0 20px rgba(0,0,0,0.3), inset 0 0 50px rgba(160, 133, 90, 0.4);
    padding: 40px;
    border-radius: 10px;
    font-family: inherit; /* ارث‌بری فونت از قالب */
    direction: rtl;
    text-align: right;
    position: relative;
    overflow: hidden;
}

/* افکت حاشیه تزئینی */
.kth-game-container::before {
    content: ""; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    border: 2px dashed #8c7b5d; margin: 10px; pointer-events: none; border-radius: 8px;
}

/* تیترها */
.kth-game-container h3 {
    color: #5d4037; font-size: 24px; font-family: inherit;
    border-bottom: 2px solid #8c7b5d; padding-bottom: 15px; margin-bottom: 20px;
    text-align: center; font-weight: bold;
}

/* متون */
.kth-game-container p, .kth-game-container label, .kth-game-container li {
    color: #4e342e; line-height: 1.8; font-size: 16px; margin-bottom: 20px; font-family: inherit;
}

/* --- اصلاح شده: تصاویر مراحل --- */
.kth-stage-image {
    display: block; 
    max-width: 100%; 
    height: auto; 
    margin: 20px auto;
    border: 5px solid #fff; 
    box-shadow: 0 5px 15px rgba(0,0,0,0.2); 
    
    /* تنظیمات چرخش و انیمیشن */
    transform: rotate(-2deg); 
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); /* حرکت نرم و فنری */
    cursor: pointer;
}

.kth-stage-image:hover { 
    transform: rotate(0deg) scale(1.03); /* صاف شدن و کمی زوم */
    box-shadow: 0 10px 25px rgba(0,0,0,0.3); /* سایه عمیق‌تر */
    z-index: 10;
}

/* فرم‌ها و ورودی‌ها (استایل مشخص و کادردار) */
.kth-input-group { margin-bottom: 20px; }
.kth-input-group label { display: block; margin-bottom: 8px; font-weight: bold; color: #3e2723; }

.kth-form-control {
    width: 100%; padding: 12px 15px;
    border: 2px solid #5d4037; /* کادر ضخیم و تیره */
    background: #ffffff; /* پس‌زمینه کاملاً سفید */
    border-radius: 8px; font-size: 16px; font-family: inherit; outline: none;
    transition: all 0.3s; box-shadow: inset 0 2px 4px rgba(0,0,0,0.1); color: #333;
}
.kth-form-control:focus {
    border-color: #d684b3; box-shadow: 0 0 0 3px rgba(214, 132, 179, 0.3); background: #fff;
}
.kth-form-control::placeholder { color: #999; font-size: 14px; }

/* دکمه‌ها */
.kth-btn {
    display: inline-block; padding: 12px 30px; font-size: 16px; font-weight: bold; color: #fff;
    background: #5d4037; border: none; border-radius: 5px; cursor: pointer;
    transition: background 0.3s; margin-left: 10px; font-family: inherit; text-decoration: none;
}
.kth-btn:hover { background: #3e2723; }
.kth-btn:disabled { background: #a1887f; cursor: not-allowed; }
.kth-btn-secondary { background: #795548; }
.kth-btn-secondary:hover { background: #5d4037; }
.kth-btn-danger { background: #d32f2f; }
.kth-btn-danger:hover { background: #b71c1c; }

/* نوار پیشرفت و عدد درصد */
.kth-progress-bar-container {
    background: #d7ccc8; border-radius: 10px; height: 24px; /* ارتفاع بیشتر */
    margin-bottom: 20px; overflow: hidden; border: 1px solid #a1887f; position: relative;
}
.kth-progress-bar {
    height: 100%; background: #5d4037; width: 0%; transition: width 0.5s ease;
}
#kth-progress-text {
    position: absolute; left: 0; top: 0; width: 100%; height: 100%;
    text-align: center; 
    color: #fff; /* متن سفید */
    font-size: 13px; 
    line-height: 24px; /* تراز عمودی */
    font-weight: bold; 
    text-shadow: 0 1px 2px rgba(0,0,0,0.8); /* سایه متن برای خوانایی روی هر رنگی */
    z-index: 2;
}

/* پیام‌ها */
.kth-message { padding: 15px; margin-top: 20px; border-radius: 5px; display: none; font-weight: bold; }
.kth-message.error { background: #ffebee; color: #c62828; border: 1px solid #ef9a9a; }
.kth-message.success { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }

/* باکس لینک ذخیره */
.kth-save-box {
    background: #fff; border: 2px dashed #5d4037; padding: 20px; border-radius: 8px;
    margin-top: 20px; text-align: center; display: none; animation: fadeIn 0.5s;
}
.kth-save-box h4 { margin-top: 0; color: #5d4037; }
.kth-copy-wrapper { display: flex; gap: 10px; direction: ltr; margin-top: 15px; }
.kth-copy-input { flex-grow: 1; padding: 10px; border: 1px solid #ccc; border-radius: 5px; background: #f9f9f9; font-family: monospace; }
.kth-copy-btn { padding: 10px 20px; background: #2e7d32; color: #fff; border: none; border-radius: 5px; cursor: pointer; font-weight: bold; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* ========================================
   2. GATEWAY STYLES (دروازه ورودی)
   ======================================== */
body.gate-open { overflow: hidden !important; }
#gate-container {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 999999;
    display: flex; justify-content: center; align-items: center; background-color: #a88beb;
}
#gate-container::before {
    content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
    background: conic-gradient(from 0deg at 50% 50%, #a88beb 0deg, #de95ba 60deg, #f2d5e3 120deg, #92a6e0 180deg, #de95ba 240deg, #f2d5e3 300deg, #a88beb 360deg);
    filter: blur(80px); animation: fluidRotate 20s linear infinite; z-index: -1;
}
@keyframes fluidRotate { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.noise-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHdpZHRoPScxMDAlJyBoZWlnaHQ9JzEwMCUnPjxmaWx0ZXIgaWQ9J24nPjxmZVR1cmJ1bGVuY2UgdHlwZT0nZnJhY3RhbE5vaXNlJyBiYXNlRnJlcXVlbmN5PScwLjYnIHN0aXRjaFRpbGVzPSdzdGl0Y2gnLz48L2ZpbHRlcj48cmVjdCB3aWR0aD0nMTAwJScgaGVpZ2h0PScxMDAlJyBmaWx0ZXI9J3VybCgjbiknIG9wYWNpdHk9JzAuMDUnLz48L3N2Zz4=');
    opacity: 0.4; pointer-events: none; z-index: 0; mix-blend-mode: overlay;
}
.gate-content {
    position: relative; z-index: 10; text-align: center; width: 420px; max-width: 90%;
    padding: 50px 40px; background: rgba(20, 10, 30, 0.45); backdrop-filter: blur(30px) saturate(180%);
    border-radius: 40px; border: 1px solid rgba(255, 255, 255, 0.15); box-shadow: 0 40px 80px rgba(0, 0, 0, 0.2);
}
.brand-logo { width: 150px; height: auto; margin-bottom: 40px; filter: drop-shadow(0 0 10px rgba(255,255,255,0.3)); }
.countdown-container { display: flex; justify-content: center; gap: 25px; margin-bottom: 45px; direction: ltr; }
.time-value { font-size: 2.5rem; font-weight: 500; color: #fff; line-height: 1; margin-bottom: 8px; text-shadow: 0 2px 10px rgba(0,0,0,0.2); }
.time-label { font-size: 0.75rem; color: #e0d4f5; text-transform: uppercase; }
.instruction-text { color: #f0f0f0; margin-bottom: 25px; font-size: 0.95rem; font-weight: 300; }
.input-wrapper { position: relative; margin-bottom: 30px; width: 100%; }
#access-code { width: 100%; background: rgba(0, 0, 0, 0.3); border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 50px; padding: 18px; font-size: 1.5rem; color: #fff; text-align: center; letter-spacing: 5px; outline: none; transition: all 0.3s ease; }
#enter-btn { width: 100%; padding: 18px; border-radius: 50px; border: none; font-size: 1.1rem; font-weight: bold; color: #fff; cursor: pointer; background: linear-gradient(135deg, #8e7cc3 0%, #d684b3 100%); box-shadow: 0 10px 30px rgba(142, 124, 195, 0.4); position: relative; overflow: hidden; }
.white-flash { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: #fff; opacity: 0; pointer-events: none; z-index: 100; transition: opacity 1s ease-in; }
.launch-sequence .gate-content { animation: propelForward 2s cubic-bezier(0.7, 0, 0.2, 1) forwards; }
@keyframes propelForward { 0% { transform: scale(1); opacity: 1; filter: blur(0); } 20% { transform: scale(0.9); opacity: 0.9; } 100% { transform: scale(20); opacity: 0; filter: blur(20px); } }
.launch-sequence .white-flash { animation: flashBang 2.5s ease-in forwards; }
@keyframes flashBang { 0%, 60% { opacity: 0; } 100% { opacity: 1; } }
.gate-message { margin-top: 20px; color: #ff8fa3; height: 20px; opacity: 0; font-size: 0.9rem; transition: opacity 0.3s; font-weight: bold; }
.shake { animation: shake 0.4s ease-in-out; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.spinner { display: none; width: 24px; height: 24px; border: 3px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin 1s infinite linear; margin: auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading .btn-text { display:none; } .loading .spinner { display: block; }

/* ========================================
   3. WHEEL OF FORTUNE (گردونه شانس)
   ======================================== */
.kth-wheel-wrapper { text-align: center; padding: 20px; animation: fadeIn 1s; }
.kth-wheel-container {
    position: relative; width: 320px; height: 320px; margin: 30px auto;
    border-radius: 50%; border: 12px solid #5d4037; background: #fff;
    box-shadow: 0 15px 40px rgba(0,0,0,0.4); overflow: hidden;
}
/* عنصر چرخان - ترنزیشن بسیار مهم است */
#kth-wheel-element {
    width: 100%; height: 100%; position: absolute; top: 0; left: 0;
    border-radius: 50%; 
    /* تغییر: زمان ۵ ثانیه و منحنی بزیر برای ایستادن نرم */
    transition: transform 5s cubic-bezier(0.25, 0.1, 0.25, 1);
    transform: rotate(0deg); /* شروع از صفر */
}
.kth-wheel-segment {
    position: absolute; width: 50%; height: 50%; background: var(--clr);
    transform-origin: bottom right; top: 0; left: 0;
    display: flex; justify-content: center; align-items: center;
    clip-path: polygon(0 0, 100% 0, 100% 100%);
    transform: rotate(calc(45deg * (var(--i) - 1)));
}
/* متن داخل گردونه */
.kth-wheel-segment .kth-text {
    position: absolute; width: 150px; text-align: center; top: 100%; left: 100%; transform-origin: 0 0; 
    /* زاویه -112.5 برای تراز متن در وسط تکه پیتزایی */
    transform: rotate(-112.5deg) translate(20px, -10px); 
    color: #fff; font-size: 13px; font-weight: bold; text-shadow: 1px 1px 2px rgba(0,0,0,0.5); white-space: nowrap;
}
.kth-pointer {
    position: absolute; top: -15px; left: 50%; transform: translateX(-50%);
    width: 40px; height: 40px; background: #d32f2f;
    clip-path: polygon(50% 100%, 0 0, 100% 0); z-index: 20;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}
.kth-spin-btn {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 70px; height: 70px; border-radius: 50%; background: #fff;
    border: 5px solid #5d4037; color: #5d4037; font-weight: 900;
    cursor: pointer; z-index: 30; box-shadow: 0 0 15px rgba(0,0,0,0.3);
    font-size: 14px; font-family: inherit; transition: all 0.2s;
}
.kth-spin-btn:active { transform: translate(-50%, -50%) scale(0.9); }
.kth-spin-btn:disabled { background: #ddd; border-color: #999; color: #777; cursor: not-allowed; }

/* باکس نمایش کد جایزه */
.kth-code-display {
    display: block; background: #333; color: #f1f1f1; padding: 15px;
    margin: 15px auto; font-family: monospace; font-size: 20px; letter-spacing: 2px;
    border-radius: 8px; width: fit-content; border: 2px dashed #ffeb3b; direction: ltr;
}
.kth-result-copy-btn {
    display: inline-block; margin-top: 10px; padding: 10px 25px;
    background: #388e3c; color: white; border: none; border-radius: 5px;
    cursor: pointer; font-size: 14px; font-weight: bold; box-shadow: 0 3px 0 #2e7d32;
}
.kth-result-copy-btn:hover { background: #4caf50; }
.kth-result-copy-btn:active { transform: translateY(3px); box-shadow: none; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }