/* AŞAĞISI — arayüz stilleri (v2) */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  /* accent köprüsü — karakedidub.com'dan gelir (theme.js); UI vurgusu buna bağlı */
  --glow: #ff6fa5; --glow-2: #9db8ff;
  --bg: #0a0814; --ink: #e8e2f0; --dim: #8a82a0;
  --koz: #ffae5e; --kul: #9db8ff; --accent: var(--glow); --teal: #58e6d9;
  --gold: #ffd24d; --panel: rgba(16, 12, 30, 0.82);
  --heart-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 21s-9-5.5-9-12a5 5 0 0 1 9-3 5 5 0 0 1 9 3c0 6.5-9 12-9 12z'/%3E%3C/svg%3E") center/contain no-repeat;
}
html, body { height: 100%; background: var(--bg); overflow: hidden; font-family: 'Inter', system-ui, -apple-system, sans-serif; color: var(--ink); }
/* storybook dokunuşu: başlık ve anlatı serif kalsın (oyunun ruhu) */
.gameTitle, .subtitle, .endTitle, .endQuote, .charDesc, .endChapter, .lobbyStatus, .menuHint, .codeHint, .pauseHint, .dcSub, .helpHint, .lobbyHint { font-family: Georgia, 'Times New Roman', serif; }
#stage { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 120%, #141027 0%, #0a0814 70%); }
#game { background: #0a0814; box-shadow: 0 0 80px rgba(90, 60, 160, 0.25); max-width: 100vw; max-height: 100vh; }
button { font-family: inherit; cursor: pointer; }

/* erişilebilirlik: klavye odak görünürlüğü */
:focus-visible { outline: 2px solid var(--glow); outline-offset: 3px; border-radius: 4px; }
button:focus-visible, .charCard:focus-visible { box-shadow: 0 0 0 3px var(--glow); }

/* erişilebilirlik: hareketi azalt (prefers-reduced-motion) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important; scroll-behavior: auto !important;
  }
}
/* glassmorphism — site estetiğiyle uyumlu frosted paneller */
.charCard, .helpBox, .shopPanel, .codeBox, .boxWidget, .hostInfo, .pauseBox, .endBox {
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}

/* ---------- overlay genel ---------- */
.overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px; padding: 18px; overflow-y: auto;
  background: radial-gradient(ellipse at 50% 30%, rgba(60, 40, 110, 0.35) 0%, transparent 60%), rgba(8, 6, 16, 0.94);
  z-index: 10; transition: opacity 0.6s ease;
}
.overlay.hidden { opacity: 0; pointer-events: none; }

/* ---------- başlık ---------- */
.titleWrap { text-align: center; }
.gameTitle {
  font-size: clamp(34px, 8vw, 60px); letter-spacing: clamp(8px, 4vw, 24px);
  margin-left: clamp(8px, 4vw, 24px); font-weight: normal; color: #f3edff; white-space: nowrap;
  text-shadow: 0 0 18px rgba(157,184,255,.55), 0 0 60px rgba(255,111,165,.35);
  animation: titleGlow 4s ease-in-out infinite alternate;
}
@keyframes titleGlow { from { text-shadow: 0 0 18px rgba(157,184,255,.55), 0 0 60px rgba(255,111,165,.3); } to { text-shadow: 0 0 26px rgba(157,184,255,.8), 0 0 90px rgba(255,111,165,.5); } }
.subtitle { color: var(--dim); font-style: italic; margin-top: 8px; letter-spacing: 4px; }

.menuChars { display: flex; align-items: center; gap: 20px; }
.heartDivider { color: var(--accent); font-size: 28px; animation: beat 1.6s ease-in-out infinite; }
@keyframes beat { 0%,100% { transform: scale(1); opacity: .7; } 12% { transform: scale(1.25); opacity: 1; } 24% { transform: scale(1); } 36% { transform: scale(1.18); } }

/* ---------- form alanları ---------- */
.textField {
  font-family: inherit; font-size: 16px; color: var(--ink); text-align: center;
  background: rgba(20, 16, 36, 0.8); border: 1px solid rgba(140, 120, 200, 0.3);
  border-radius: 9px; padding: 11px 18px; outline: none; transition: border-color .2s;
}
.textField:focus { border-color: rgba(180, 160, 255, 0.65); }
.textField.code { letter-spacing: 4px; text-transform: uppercase; font-family: Consolas, monospace; }
.textField::placeholder { color: #5e5678; letter-spacing: 1px; }

.menuActions { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; max-width: 380px; }
.orSep { color: #5e5678; font-size: 12px; font-style: italic; }
.joinRow { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; width: 100%; }
.joinRow .textField { flex: 1 1 140px; min-width: 0; }

.bigBtn {
  font-size: 17px; letter-spacing: 5px; padding: 12px 36px; color: var(--ink);
  background: linear-gradient(180deg, rgba(70, 48, 120, 0.5), rgba(40, 24, 70, 0.5));
  border: 1px solid rgba(180, 160, 255, 0.35); border-radius: 10px; transition: all .2s ease;
}
.bigBtn:hover:not(:disabled) { box-shadow: 0 0 24px rgba(157, 184, 255, 0.4); transform: translateY(-2px); }
.bigBtn:disabled { opacity: .35; cursor: default; }
.bigBtn.primary { border-color: var(--accent); background: linear-gradient(180deg, rgba(120, 50, 90, 0.5), rgba(70, 28, 60, 0.5)); }
.bigBtn.ghost { background: transparent; border-color: rgba(140,120,200,0.25); font-size: 14px; letter-spacing: 3px; padding: 9px 28px; }
.ghostBtn {
  background: transparent; border: 1px solid rgba(120,180,170,0.3); color: var(--teal);
  border-radius: 20px; padding: 7px 20px; font-size: 13px; letter-spacing: 2px; transition: all .2s;
}
.ghostBtn:hover { border-color: var(--teal); box-shadow: 0 0 18px rgba(88,230,217,0.3); }

.joinError { color: #ff8f9e; font-size: 13px; font-style: italic; min-height: 16px; }
.menuStatus { color: var(--teal); font-size: 13px; letter-spacing: 1px; min-height: 16px; }
.menuHint { color: #5e5678; font-size: 12.5px; font-style: italic; max-width: 540px; text-align: center; }

/* ---------- lobi ---------- */
.lobbyTop { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.codeBox {
  background: rgba(20, 40, 38, 0.5); border: 1px solid rgba(88, 230, 217, 0.35);
  border-radius: 12px; padding: 12px 28px; text-align: center;
}
.codeLabel { color: var(--teal); font-size: 12px; letter-spacing: 2px; }
.hostBadge { color: var(--gold); font-style: italic; }
.codeRow { display: flex; align-items: center; gap: 10px; justify-content: center; margin: 4px 0; }
.codeValue { font-family: Consolas, monospace; font-size: 30px; letter-spacing: 4px; color: #c8fff8; }
.copyBtn { background: transparent; border: none; font-size: 18px; opacity: .7; }
.copyBtn:hover { opacity: 1; }
.codeHint { color: var(--dim); font-size: 11.5px; font-style: italic; }
.lobbyPeers { color: var(--teal); font-size: 13px; letter-spacing: 1px; }

.charRow { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; justify-content: center; }
.charCard {
  width: 196px; padding: 14px 14px 12px; border: 1px solid rgba(140, 120, 200, 0.25);
  border-radius: 14px; background: var(--panel); text-align: center; user-select: none;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
/* sabit roller — seçim yok; "sen" olan kart vurgulanır, "hazır" olunca yeşil ışık */
.charCard.fixed { cursor: default; position: relative; }
.charCard.me { transform: translateY(-3px); }
#card-koz.me { border-color: var(--koz); box-shadow: 0 0 22px rgba(255, 174, 94, 0.30); }
#card-kul.me { border-color: var(--kul); box-shadow: 0 0 22px rgba(157, 184, 255, 0.30); }
.charCard.ready { box-shadow: 0 0 26px rgba(90, 230, 200, 0.35); border-color: var(--teal); }
.roleTag {
  font-size: 10px; letter-spacing: 2px; padding: 3px 8px; border-radius: 999px; margin-bottom: 8px;
  display: inline-block; background: rgba(20,14,36,0.8); border: 1px solid rgba(140,120,200,0.3);
}
.roleTag.koz { color: var(--koz); } .roleTag.kul { color: var(--kul); }
.charPreview { display: block; margin: 0 auto 6px; }
.charName { font-size: 22px; letter-spacing: 8px; margin-left: 8px; }
.charName.koz { color: var(--koz); } .charName.kul { color: var(--kul); }
.charDesc { color: var(--dim); font-size: 12.5px; font-style: italic; margin-top: 6px; line-height: 1.5; }
.pickedBy { min-height: 18px; font-size: 12px; color: var(--teal); margin-top: 8px; letter-spacing: 1px; }

#readyBtn {
  font-size: 18px; letter-spacing: 6px; padding: 12px 44px; color: var(--ink);
  background: linear-gradient(180deg, rgba(90, 60, 150, 0.5), rgba(50, 30, 90, 0.5));
  border: 1px solid rgba(180, 160, 255, 0.4); border-radius: 10px; transition: all .2s ease;
}
#readyBtn:hover:not(:disabled) { box-shadow: 0 0 24px rgba(157, 184, 255, 0.4); transform: translateY(-2px); }
#readyBtn:disabled { opacity: .35; cursor: default; }
#readyBtn.isReady { border-color: var(--accent); color: var(--accent); }
.lobbyStatus { color: var(--dim); font-size: 14px; min-height: 18px; font-style: italic; }

/* ---------- bölüm seçici ---------- */
.chapterPick { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 6px 0 4px; }
.chapterPickLabel { color: var(--dim); letter-spacing: 4px; font-size: 11px; }
.chapterPicker { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.chapterBtn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 116px; padding: 8px 14px; border-radius: 12px; cursor: pointer;
  background: rgba(22,16,38,0.7); border: 1px solid rgba(140,120,200,0.22);
  color: var(--ink); transition: transform .15s, border-color .15s, box-shadow .15s;
}
.chapterBtn:hover { transform: translateY(-2px); border-color: var(--teal); }
.chapterBtn.on { border-color: var(--accent); box-shadow: 0 0 16px rgba(157,184,255,0.22); }
.chapterBtn .chTitle { font-size: 13.5px; letter-spacing: 1px; }
.chapterBtn .chSub { font-size: 10.5px; color: var(--dim); font-style: italic; }

/* ---------- oyun içi ---------- */
.stuckHint {
  position: absolute; bottom: 64px; left: 50%; transform: translateX(-50%);
  background: rgba(20, 14, 36, 0.9); border: 1px solid rgba(255,111,165,0.4);
  color: var(--ink); padding: 9px 22px; border-radius: 20px; font-size: 14px; z-index: 15;
  animation: fadeIn .4s ease;
}
.stuckHint.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- pause ---------- */
.pauseBox { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.pauseTitle { font-size: 28px; letter-spacing: 6px; color: #e8e2f0; margin-bottom: 8px; }
.pauseHint { color: var(--dim); font-size: 12px; font-style: italic; max-width: 360px; text-align: center; margin-top: 6px; }

/* ---------- kopma / dolu ---------- */
.dcBox { text-align: center; }
.dcTitle { font-size: 28px; color: var(--ink); margin-bottom: 10px; }
.dcSub { color: var(--dim); font-style: italic; }
.dcPulse { color: var(--accent); font-size: 34px; margin-top: 22px; animation: beat 1.6s infinite; }

/* ---------- yardım ---------- */
.helpBox { background: var(--panel); border: 1px solid rgba(140, 120, 200, 0.3); border-radius: 14px; padding: 26px 36px; }
.helpTitle { text-align: center; letter-spacing: 6px; color: var(--accent); margin-bottom: 16px; }
.helpTable { border-collapse: collapse; }
.helpTable td { padding: 5px 14px; font-size: 14.5px; color: var(--ink); }
.helpTable .key { font-family: Consolas, monospace; color: var(--teal); text-align: right; font-size: 13px; }
.helpScheme { text-align: center; color: var(--dim); font-size: 12.5px; line-height: 1.7; margin: -4px 0 16px; }
.helpScheme b { color: var(--ink); font-family: Consolas, monospace; letter-spacing: 1px; }
.helpScheme .schemeRow { display: block; }
.helpHint { text-align: center; color: var(--dim); font-size: 12px; margin-top: 14px; font-style: italic; }

/* ---------- bölüm sonu ---------- */
.endBox { text-align: center; animation: endFade 3s ease; }
@keyframes endFade { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; } }
.endChapter { letter-spacing: 8px; color: var(--dim); font-size: 15px; }
.endTitle { font-size: 70px; letter-spacing: 28px; margin: 12px 0 6px 28px; color: #f3edff; text-shadow: 0 0 30px rgba(255, 111, 165, 0.45); }
.endQuote { color: var(--accent); font-style: italic; font-size: 20px; margin: 16px 0 22px; }
.endStats { color: var(--dim); font-size: 14.5px; line-height: 1.9; }
.endStats b { color: var(--ink); font-weight: normal; }
.endNext { margin: 24px 0 16px; color: #5e5678; letter-spacing: 4px; font-style: italic; animation: beat 3s infinite; }

/* ---------- toast ---------- */
.toast {
  position: absolute; top: 7%; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid rgba(255, 111, 165, 0.5); color: var(--ink);
  padding: 10px 26px; border-radius: 24px; font-size: 15.5px; z-index: 20;
  transition: opacity .5s ease, transform .5s ease; white-space: nowrap;
}
.toast.hidden { opacity: 0; transform: translateX(-50%) translateY(-12px); pointer-events: none; }

/* ============== MOBİL DOKUNMATİK KONTROLLER ============== */
.touchControls { position: fixed; inset: 0; z-index: 16; pointer-events: none; }
.touchControls.hidden { display: none; }
.touchLeft {
  position: absolute; left: 0; bottom: 0;
  padding: 0 0 calc(18px + env(safe-area-inset-bottom)) calc(18px + env(safe-area-inset-left));
  display: flex; gap: 14px;
}
.touchRight {
  position: absolute; right: 0; bottom: 0;
  padding: 0 calc(18px + env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) 0;
  display: flex; flex-direction: column; align-items: flex-end; gap: 12px;
}
.actCluster { display: grid; grid-template-columns: repeat(3, 52px); gap: 9px; justify-items: center; }
.moveCluster { display: flex; align-items: flex-end; gap: 14px; }

.tbtn {
  pointer-events: auto; -webkit-user-select: none; user-select: none; touch-action: none;
  font-family: inherit; color: var(--ink);
  background: rgba(20, 16, 36, 0.5); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border: 1.5px solid rgba(180, 160, 255, 0.35); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: transform .08s ease, background .08s ease, box-shadow .08s ease;
}
.tbtn.pressed { background: rgba(120, 90, 180, 0.6); box-shadow: 0 0 22px rgba(157,184,255,0.5); transform: scale(0.92); }
.tbtn.move { width: 66px; height: 66px; font-size: 26px; }
.tbtn.jump { width: 88px; height: 88px; font-size: 34px; border-color: var(--accent); color: var(--accent); }
.tbtn.small { width: 56px; height: 56px; font-size: 20px; }
.tbtn.act { width: 52px; height: 52px; font-size: 21px; border-color: rgba(120,180,170,0.4); color: var(--teal); }
.touchPause {
  pointer-events: auto; position: absolute; top: calc(10px + env(safe-area-inset-top)); right: calc(12px + env(safe-area-inset-right));
  width: 44px; height: 44px; border-radius: 10px; font-size: 17px;
  background: rgba(20,16,36,0.5); border: 1px solid rgba(180,160,255,0.3); color: var(--ink);
  backdrop-filter: blur(6px);
}

/* portrait çevir ipucu */
.rotateHint {
  position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; text-align: center;
  background: rgba(8,6,16,0.92); color: var(--ink); font-size: 17px; padding: 30px;
}
.rotateHint.hidden { display: none; }
.rotateIcon { font-size: 54px; animation: rotateWiggle 2s ease-in-out infinite; }
@keyframes rotateWiggle { 0%,100% { transform: rotate(-12deg); } 50% { transform: rotate(12deg); } }
.rotateSub { color: var(--dim); font-size: 13px; font-style: italic; }

/* dokunmatik cihazda metin seçimini/uzun-bas menüsünü kıs */
body.touch { -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }

/* ============== MAĞAZA ============== */
.shop { background: rgba(6, 4, 14, 0.97); }
.shopPanel {
  width: min(920px, 94vw); height: min(620px, 90vh); background: var(--panel);
  border: 1px solid rgba(140, 120, 200, 0.3); border-radius: 16px; display: flex; flex-direction: column;
  box-shadow: 0 0 60px rgba(90,60,160,0.3);
}
.shopHeader { display: flex; align-items: center; gap: 16px; padding: 16px 22px; border-bottom: 1px solid rgba(140,120,200,0.2); }
.shopTitle { font-size: 20px; letter-spacing: 3px; color: #f3edff; }
.shopCoins { margin-left: auto; color: var(--gold); font-size: 16px; font-family: Consolas, monospace; }
.shopCoins.shake { animation: shake .4s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-5px)} 75%{transform:translateX(5px)} }
.shopClose { background: transparent; border: none; color: var(--dim); font-size: 20px; }
.shopClose:hover { color: var(--ink); }

.shopBody { flex: 1; display: flex; gap: 16px; padding: 18px 22px; overflow: hidden; }
.shopLeft { width: 220px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.shopPreview { background: radial-gradient(ellipse at 50% 60%, rgba(60,40,110,0.3), transparent 70%); border-radius: 12px; }
.shopLoadoutInfo { color: var(--dim); font-size: 11.5px; text-align: center; line-height: 1.6; }
.shopLoadoutInfo b { color: var(--teal); font-weight: normal; }

.boxWidget { width: 100%; background: rgba(20,16,36,0.6); border: 1px solid rgba(140,120,200,0.25); border-radius: 12px; padding: 14px; text-align: center; margin-top: auto; }
.boxLabel { color: var(--ink); font-size: 14px; letter-spacing: 2px; margin-bottom: 8px; }
.pityWrap { height: 6px; background: rgba(0,0,0,0.4); border-radius: 4px; overflow: hidden; margin-bottom: 5px; }
.pityBar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--teal), var(--accent)); transition: width .4s ease; }
.pityLabel { color: var(--dim); font-size: 10.5px; margin-bottom: 10px; }
.boxWidget .bigBtn { font-size: 14px; padding: 10px 20px; letter-spacing: 2px; width: 100%; }

.shopGrid { flex: 1; overflow-y: auto; padding-right: 6px; }
.shopGrid::-webkit-scrollbar { width: 8px; }
.shopGrid::-webkit-scrollbar-thumb { background: rgba(140,120,200,0.3); border-radius: 4px; }
.shopCatHeader { color: var(--accent); letter-spacing: 3px; font-size: 13px; margin: 12px 0 8px; }
.shopRow { display: grid; grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)); gap: 10px; }
.shopCard {
  background: rgba(22,16,38,0.7); border: 1px solid rgba(140,120,200,0.18); border-radius: 10px;
  padding: 10px 6px 8px; text-align: center; transition: transform .15s, border-color .15s;
}
.shopCard:hover { transform: translateY(-3px); }
.shopCard.rar-rare { border-color: rgba(95,176,255,0.4); }
.shopCard.rar-epic { border-color: rgba(176,123,255,0.45); box-shadow: 0 0 12px rgba(176,123,255,0.14); }
.shopCard.rar-legendary { border-color: rgba(255,207,77,0.5); box-shadow: 0 0 14px rgba(255,207,77,0.15); }
.shopCard.locked { opacity: 0.78; }
.shopCard.equipped { box-shadow: 0 0 0 2px var(--teal) inset; }
.shopSwatch { height: 44px; display: flex; align-items: center; justify-content: center; margin-bottom: 6px; }
.sw-skin { width: 34px; height: 34px; border-radius: 50%; display: inline-block; }
.sw-line { width: 44px; height: 6px; border-radius: 3px; display: inline-block; }
.sw-heart { width: 30px; height: 30px; display: inline-block; }
.sw-dot { width: 18px; height: 18px; border-radius: 50%; display: inline-block; }
.shopName { font-size: 12px; color: var(--ink); }
.shopRar { font-size: 10px; letter-spacing: 1px; margin: 2px 0 6px; }
.shopMini { font-size: 11px; padding: 4px 10px; border-radius: 14px; background: rgba(40,30,60,0.7); border: 1px solid rgba(140,120,200,0.3); color: var(--ink); }
.shopMini.on { border-color: var(--teal); color: var(--teal); }
.shopMini.buy { border-color: rgba(255,210,77,0.4); color: var(--gold); }
.shopMini:hover { transform: scale(1.05); }

/* kutu açma sahnesi */
.boxStage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(4,2,12,0.85); z-index: 30; cursor: pointer; overflow: hidden; }
.boxStage.hidden { display: none; }
.boxReveal { text-align: center; animation: boxPop .5s cubic-bezier(.2,1.4,.4,1); position: relative; }
@keyframes boxPop { from { transform: scale(0.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.boxGlow { position: absolute; inset: -60px; border-radius: 50%; background: radial-gradient(circle, rgba(var(--rg),0.5), transparent 65%); animation: boxGlowPulse 1.5s ease-in-out infinite; }
@keyframes boxGlowPulse { 0%,100% { transform: scale(1); opacity: .7; } 50% { transform: scale(1.15); opacity: 1; } }
.boxItem { position: relative; background: rgba(16,12,30,0.95); border: 1px solid rgba(180,160,255,0.4); border-radius: 16px; padding: 28px 40px; }
.boxSwatch { transform: scale(2.2); height: 70px; display: flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.boxItemName { font-size: 22px; color: #f3edff; letter-spacing: 2px; }
.boxItemRar { font-size: 14px; letter-spacing: 2px; margin-top: 4px; }
.boxNew { color: var(--teal); font-size: 16px; letter-spacing: 3px; margin-top: 10px; animation: beat 1.2s infinite; }
.boxDup { color: var(--gold); font-size: 13px; margin-top: 10px; }

/* --- destansı + efsane: sinematik açılış --- */
.boxStage.cinematic { background: rgba(2,1,7,0.94); }
.boxStage.cinematic .boxItem { padding: 34px 52px; }
/* dönen ışın yelpazesi */
.boxRays {
  position: absolute; width: 200vmax; height: 200vmax; left: 50%; top: 50%;
  transform: translate(-50%,-50%); pointer-events: none; opacity: 0;
  background: repeating-conic-gradient(from 0deg, rgba(var(--rg),0.16) 0deg 6deg, transparent 6deg 14deg);
  animation: rayspin 14s linear infinite, rayfade 1.1s ease-out forwards;
}
@keyframes rayspin { to { transform: translate(-50%,-50%) rotate(360deg); } }
@keyframes rayfade { from { opacity: 0; } to { opacity: 1; } }
/* açılış parlaması */
.boxFlash {
  position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle at 50% 50%, #fff, transparent 40%);
  opacity: 0; animation: boxFlashAnim 0.7s ease-out forwards;
}
@keyframes boxFlashAnim { 0% { opacity: 0; transform: scale(0.2); } 30% { opacity: 0.9; } 100% { opacity: 0; transform: scale(1.6); } }
/* kademe damgası */
.boxStamp {
  position: absolute; top: -46px; left: 50%; transform: translateX(-50%);
  font-size: 30px; letter-spacing: 8px; font-weight: 700; white-space: nowrap;
  text-shadow: 0 0 18px currentColor; animation: stampIn 0.6s cubic-bezier(.2,1.5,.4,1) 0.25s both;
}
.boxStamp.epic { font-size: 22px; letter-spacing: 6px; }
@keyframes stampIn { from { opacity: 0; transform: translateX(-50%) scale(2.4); } to { opacity: 1; transform: translateX(-50%) scale(1); } }
/* efsane: ekstra ihtişam — daha güçlü glow + sahne sarsıntısı + yavaş büyüyen reveal */
.boxStage.legendary .boxReveal { animation: legendaryReveal 1s cubic-bezier(.2,1.2,.3,1) both; }
@keyframes legendaryReveal { 0% { transform: scale(0.1) rotate(-8deg); opacity: 0; } 60% { transform: scale(1.12) rotate(2deg); } 100% { transform: scale(1) rotate(0); opacity: 1; } }
.boxStage.legendary .boxGlow { inset: -110px; animation: boxGlowPulse 1s ease-in-out infinite; }
.boxStage.legendary .boxItem {
  border-color: rgba(255,210,90,0.85);
  box-shadow: 0 0 50px rgba(255,200,80,0.55), inset 0 0 28px rgba(255,210,90,0.18);
  animation: legendaryShake 0.5s ease-in-out 0.9s 2;
}
@keyframes legendaryShake { 0%,100% { transform: translate(0,0); } 25% { transform: translate(-4px,2px); } 75% { transform: translate(4px,-2px); } }
.boxStage.legendary .boxItemName { color: #fff; text-shadow: 0 0 16px rgba(255,210,90,0.8); }
@media (prefers-reduced-motion: reduce) {
  .boxRays, .boxFlash { animation: rayfade 0.4s ease-out forwards; }
  .boxStage.legendary .boxItem { animation: none; }
  .boxStage.legendary .boxReveal { animation: boxPop .4s ease both; }
}

/* ---------- FAZ 1: sandık açılışı (her kademede) ---------- */
.boxChest {
  position: relative; width: 150px; height: 132px;
  animation: chestShake var(--shake, 800ms) ease-in-out forwards;
}
.chestGlow {
  position: absolute; inset: -50px; border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--rg),0.45), transparent 68%);
  animation: chestGlowBuild var(--shake, 800ms) ease-in forwards;
}
.chestBody {
  position: absolute; left: 15px; bottom: 0; width: 120px; height: 86px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #2a2142, #181028);
  border: 2px solid rgba(var(--rg),0.6); border-radius: 6px 6px 9px 9px;
  box-shadow: inset 0 0 18px rgba(var(--rg),0.25);
}
.chestSeal { font-size: 30px; color: var(--rc); text-shadow: 0 0 14px var(--rc); animation: sealPulse 0.7s ease-in-out infinite; }
.chestLid {
  position: absolute; left: 8px; top: 0; width: 134px; height: 40px;
  background: linear-gradient(180deg, #352a52, #221739);
  border: 2px solid rgba(var(--rg),0.7); border-radius: 10px 10px 4px 4px;
  transform-origin: 50% 100%; animation: lidRattle 0.18s ease-in-out infinite;
}
.chestHint {
  position: absolute; left: 50%; bottom: -34px; transform: translateX(-50%);
  white-space: nowrap; font-family: Georgia, serif; font-style: italic;
  font-size: 13px; color: var(--dim); opacity: 0; animation: fadeIn 0.6s ease 0.2s forwards;
}
@keyframes chestShake {
  0% { transform: translateX(0) scale(1); }
  88% { transform: translateX(0) scale(1.04); }
  92% { transform: translateX(-4px) scale(1.06); }
  100% { transform: translateX(0) scale(1.12); }
}
@keyframes chestGlowBuild { from { opacity: .35; transform: scale(.8); } to { opacity: 1; transform: scale(1.25); } }
@keyframes lidRattle { 0%,100% { transform: rotate(-1.5deg) translateY(0); } 50% { transform: rotate(1.5deg) translateY(-1px); } }
@keyframes sealPulse { 0%,100% { transform: scale(1); opacity: .85; } 50% { transform: scale(1.18); opacity: 1; } }
/* daha yüksek kademe → daha sert titreme + daha hızlı tıkırtı */
.boxChest.shake-2 .chestLid, .boxChest.shake-3 .chestLid { animation-duration: 0.12s; }
.boxChest.shake-3 { animation-name: chestShakeHard; }
@keyframes chestShakeHard {
  0% { transform: translateX(0) scale(1); }
  10%,30%,50%,70% { transform: translateX(-5px) rotate(-1deg) scale(1.03); }
  20%,40%,60%,80% { transform: translateX(5px) rotate(1deg) scale(1.05); }
  100% { transform: translateX(0) scale(1.18); }
}

/* ---------- FAZ 2: patlama dalgası ---------- */
.boxBurst {
  position: absolute; left: 50%; top: 50%; width: 60px; height: 60px;
  transform: translate(-50%,-50%); pointer-events: none; border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, rgba(var(--rg),0.85) 30%, transparent 70%);
  animation: burstWave 0.6s cubic-bezier(.1,.7,.3,1) forwards;
}
@keyframes burstWave {
  0% { opacity: 1; transform: translate(-50%,-50%) scale(0.3); }
  100% { opacity: 0; transform: translate(-50%,-50%) scale(16); }
}
@media (prefers-reduced-motion: reduce) {
  .boxChest, .chestLid, .chestGlow { animation-duration: 0.3s !important; animation-iteration-count: 1 !important; }
  .boxBurst { animation-duration: 0.3s; }
}
