/* ===== v1 추가 스타일: 상단 버튼 · 설정 · 재료 가방 · 드롭 연출 · 내기 · 광고 자리 ===== */
:root { --top-btn: 40px; }

/* 글자 크기 (설정) */
html[data-fontsize="small"] .app-scroll,
html[data-fontsize="small"] .settings-sheet { zoom: 0.92; }
html[data-fontsize="large"] .app-scroll,
html[data-fontsize="large"] .settings-sheet { zoom: 1.14; }

/* 상단 우측 버튼 (언어 / 설정) */
.topbar {
  position: fixed;
  top: calc(var(--safe-top) + 6px);
  right: calc(var(--safe-right) + 8px);
  z-index: 36;
  display: flex;
  gap: 6px;
}
.top-btn {
  min-width: var(--top-btn);
  height: var(--top-btn);
  padding: 0 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(14, 18, 27, 0.82);
  color: var(--gold);
  font-weight: 700;
  font-size: 15px;
  backdrop-filter: blur(6px);
}
.top-btn:active { transform: scale(0.95); }

/* 광고 자리 (표준 320x50, 고정, 설정으로 끌 수 없음) */
.ad-slot { position: relative; }
.ad-slot::before {
  content: "";
  position: absolute;
  inset: 3px 0;
  margin: auto;
  width: min(320px, calc(100% - 16px));
  border: 1px dashed rgba(232, 204, 140, 0.28);
  border-radius: 6px;
}
.ad-slot { --ad-height: 50px; }

/* 설정 */
.settings-modal { z-index: 50; }
.settings-sheet { overflow: hidden; }
.settings-body { overflow-y: auto; max-height: 100%; padding-bottom: 24px; }
.settings-body h2 { margin: 0 0 8px; font-family: "Jua", sans-serif; }
.set-section { margin-top: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,0.03); }
.set-section h3 { margin: 0 0 8px; font-size: 14px; color: var(--gold); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 40px; font-size: 14px; }
.set-row-wrap { flex-wrap: wrap; }
.set-chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.set-chip, .set-toggle {
  min-height: 36px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(255,255,255,0.05); color: var(--ink); font-size: 13px;
}
.set-chip.is-on, .set-toggle.is-on { background: linear-gradient(180deg, #f3d37f, #c79a3b); color: #1a1405; border-color: transparent; font-weight: 700; }
.set-range { display: inline-flex; align-items: center; gap: 8px; }
.set-range input { width: 130px; accent-color: #e8c56a; }
.set-range output { min-width: 28px; text-align: right; font-variant-numeric: tabular-nums; }
.set-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.set-actions .seed-btn { min-height: 38px; }
.set-danger { color: #ffb4a8 !important; border-color: rgba(255, 120, 100, 0.5) !important; }
.set-text { width: 100%; margin-top: 8px; padding: 8px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0,0,0,0.35); color: var(--ink); font: 12px/1.4 ui-monospace, Consolas, monospace; resize: vertical; }
.set-file { display: inline-flex; align-items: center; cursor: pointer; }
.set-msg { min-height: 18px; margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.set-note { margin: 10px 2px 0; font-size: 12px; color: var(--muted); }
.set-about p { margin: 4px 0; font-size: 13px; color: var(--muted); }
.set-confirm { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; background: rgba(4, 6, 10, 0.78); padding: 20px; }
.set-confirm[hidden] { display: none; }
.set-confirm-card { max-width: 340px; padding: 18px; border-radius: 16px; background: #141a26; border: 1px solid var(--line); font-size: 14px; line-height: 1.5; }

/* 재료 가방 */
.inv-panel { margin: 14px 0; padding: 10px 12px; border-radius: 16px; border: 1px solid var(--line); background: var(--glass); }
.inv-panel > summary { cursor: pointer; font-weight: 700; color: var(--gold); list-style: none; display: flex; justify-content: space-between; align-items: center; min-height: 32px; }
.inv-panel > summary::-webkit-details-marker { display: none; }
.inv-total { padding: 2px 10px; border-radius: 999px; background: rgba(232,197,106,0.16); font-size: 13px; }
.inv-grid { display: grid; gap: 6px; margin-top: 8px; }
.inv-row { display: grid; grid-template-columns: 22px repeat(6, minmax(0, 1fr)); gap: 4px; align-items: stretch; }
.inv-el { font-weight: 700; font-size: 13px; align-self: center; }
.inv-cell { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 4px 1px; min-height: 58px; border-radius: 10px; border: 1px solid color-mix(in srgb, var(--rc) 35%, transparent); background: rgba(255,255,255,0.03); opacity: 0.45; }
.inv-cell.has { opacity: 1; border-color: var(--rc); background: color-mix(in srgb, var(--rc) 10%, rgba(255,255,255,0.03)); }
.inv-name { font-size: 9.5px; line-height: 1.1; text-align: center; word-break: keep-all; color: var(--ink); }
.inv-n { font-size: 12px; color: var(--rc); font-variant-numeric: tabular-nums; }
.inv-legend, .inv-note { margin: 8px 0 0; font-size: 11px; color: var(--muted); }
.inv-legend i { font-style: normal; font-weight: 700; }

/* 재료 보석 아이콘 (이미지 없이 CSS 로 표현) */
.gem { display: inline-block; width: 22px; height: 22px; flex: none; background: radial-gradient(circle at 32% 28%, rgba(255,255,255,0.75), rgba(255,255,255,0) 42%), var(--ec); box-shadow: 0 0 0 2px var(--rc), 0 0 9px color-mix(in srgb, var(--rc) 70%, transparent); border-radius: 50%; }
.gem-r1 { border-radius: 7px; }
.gem-r2 { transform: rotate(45deg) scale(0.82); border-radius: 4px; }
.gem-r3 { border-radius: 0; clip-path: polygon(25% 5%, 75% 5%, 100% 50%, 75% 95%, 25% 95%, 0 50%); box-shadow: none; filter: drop-shadow(0 0 4px var(--rc)); }
.gem-r4 { border-radius: 0; clip-path: polygon(50% 0, 62% 36%, 100% 38%, 70% 60%, 80% 100%, 50% 76%, 20% 100%, 30% 60%, 0 38%, 38% 36%); box-shadow: none; filter: drop-shadow(0 0 5px var(--rc)); width: 26px; height: 26px; }
.gem-r5 { border-radius: 50%; width: 26px; height: 26px; background: conic-gradient(from 0deg, #ff5f6d, #ffc371, #f7ff7a, #67e8a5, #5ab4ff, #b07cff, #ff6bd6, #ff5f6d); box-shadow: 0 0 0 2px #fff6, 0 0 14px #ff6bd6aa; animation: gemSpin 3s linear infinite; }
@keyframes gemSpin { to { filter: hue-rotate(360deg); } }

/* 드롭 팝업 */
#drop-layer { position: fixed; z-index: 60; top: calc(var(--safe-top) + 56px); left: 50%; transform: translateX(-50%); width: min(92vw, 380px); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.drop-pop { position: relative; display: flex; align-items: center; gap: 10px; padding: 10px 16px 10px 12px; max-width: 100%; border-radius: 14px; background: linear-gradient(180deg, rgba(24,29,42,0.96), rgba(10,13,20,0.96)); border: 1px solid var(--rc); box-shadow: 0 8px 28px rgba(0,0,0,0.5), 0 0 22px color-mix(in srgb, var(--rc) 45%, transparent); animation: dropLife var(--life, 1.2s) cubic-bezier(.2,.8,.2,1) both; }
.drop-pop.is-compact { padding: 6px 12px 6px 8px; }
.drop-text b { display: block; font-size: 14px; color: var(--rc); }
.drop-text small { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.drop-pop.rar-mythic { border-color: transparent; background: linear-gradient(#10131c, #10131c) padding-box, conic-gradient(from 0deg, #ff5f6d, #ffc371, #67e8a5, #5ab4ff, #b07cff, #ff5f6d) border-box; border: 2px solid transparent; }
.drop-pop.rar-legendary, .drop-pop.rar-mythic { transform-origin: center; }
.spark { position: absolute; left: 24px; top: 50%; width: 5px; height: 5px; border-radius: 50%; background: var(--rc); opacity: 0; animation: sparkOut 900ms ease-out var(--d, 0ms) both; }
@keyframes dropLife {
  0% { opacity: 0; transform: translateY(-14px) scale(0.82); }
  10% { opacity: 1; transform: translateY(0) scale(1.06); }
  18% { transform: scale(1); }
  82% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-8px) scale(0.98); }
}
@keyframes sparkOut { 0% { opacity: 1; transform: translate(0, 0) scale(1); } 100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.2); } }
.loot-toast { padding: 8px 14px; border-radius: 12px; background: rgba(20, 24, 34, 0.95); border: 1px solid var(--line); font-size: 13px; animation: dropLife 3.2s ease both; }

/* 번쩍 / 흔들림 */
.fx-flash { position: fixed; inset: 0; z-index: 55; pointer-events: none; opacity: 0; }
.fx-flash.go { animation: fxFlash 650ms ease-out both; }
.fx-flash.rar-epic { background: radial-gradient(circle at 50% 30%, rgba(192,132,252,0.75), rgba(192,132,252,0) 65%); }
.fx-flash.rar-legendary { background: radial-gradient(circle at 50% 30%, rgba(245,197,24,0.85), rgba(245,197,24,0) 70%); }
.fx-flash.rar-mythic { background: conic-gradient(from 0deg at 50% 35%, rgba(255,95,109,0.6), rgba(255,195,113,0.6), rgba(103,232,165,0.6), rgba(90,180,255,0.6), rgba(176,124,255,0.6), rgba(255,95,109,0.6)); }
@keyframes fxFlash { 0% { opacity: 0; } 18% { opacity: var(--flash-a, 0.4); } 100% { opacity: 0; } }
html[data-fx="mid"] { --flash-a: 0.35; --shake: 4px; }
html[data-fx="high"] { --flash-a: 0.6; --shake: 7px; }
html[data-fx="low"] { --flash-a: 0; --shake: 0px; }
.app-shell.fx-shake { animation: fxShake 460ms ease-out; }
@keyframes fxShake {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(var(--shake, 4px), calc(var(--shake, 4px) * -0.6)); }
  30% { transform: translate(calc(var(--shake, 4px) * -1), var(--shake, 4px)); }
  45% { transform: translate(calc(var(--shake, 4px) * 0.7), 0); }
  60% { transform: translate(calc(var(--shake, 4px) * -0.5), calc(var(--shake, 4px) * -0.4)); }
  80% { transform: translate(calc(var(--shake, 4px) * 0.25), 0); }
}
html[data-fx="low"] .spark { display: none; }

/* 내기 패널 (출전 선발 화면) */
.bet-panel { margin: 12px 0; padding: 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--glass); }
.bet-head h3 { margin: 0 0 6px; font-size: 15px; color: var(--gold); }
.bet-head small { font-weight: 400; font-size: 11px; color: var(--muted); margin-left: 6px; }
.bet-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 6px 0; font-size: 13px; }
.bet-row > span:first-child { min-width: 64px; color: var(--muted); }
.bet-select { flex: 1; min-width: 150px; min-height: 38px; padding: 0 8px; border-radius: 10px; border: 1px solid var(--line); background: #10141d; color: var(--ink); font-size: 13px; }
.bet-step { display: inline-flex; align-items: center; gap: 8px; }
.bet-step .seed-btn { min-width: 38px; min-height: 38px; padding: 0; }
.bet-step b { min-width: 24px; text-align: center; font-size: 16px; font-variant-numeric: tabular-nums; }
.bet-max { color: var(--muted); }
.bet-sum { margin: 8px 0 2px; font-size: 13px; color: var(--ink); }
.bet-hint { margin: 2px 0 0; font-size: 11px; color: var(--muted); }

/* 결과 화면 요약 */
.loot-summary { margin: 14px 0 6px; padding: 12px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,0.04); text-align: left; }
.loot-summary h3 { margin: 0 0 8px; font-size: 14px; color: var(--gold); }
.loot-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.loot-list li { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--rc); }
.loot-list li span { flex: 1; color: var(--ink); }
.loot-bet { margin: 10px 0 0; font-size: 13px; line-height: 1.5; }
.loot-bet.is-win { color: #9fe3b4; }
.loot-bet.is-lose, .loot-bet.is-forfeit { color: #ffd2a0; }
.loot-comfort, .loot-empty { margin: 8px 0 0; font-size: 12px; color: var(--muted); }

@media (max-width: 400px) {
  .set-range input { width: 96px; }
  .inv-row { grid-template-columns: 18px repeat(6, minmax(0, 1fr)); gap: 3px; }
  .inv-name { font-size: 8.5px; }
  .top-btn { min-width: 36px; height: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  .drop-pop, .spark, .app-shell.fx-shake, .gem-r5 { animation-duration: 0.01ms !important; }
}
