:root {
  --bg: #15131c;
  --panel: #211e2b;
  --panel-2: #2b2738;
  --text: #f2eff8;
  --muted: #a49db5;
  --win: #4ad48a;
  --lose: #f0566a;
  --accent: #f5c04a;
  --glow: #9a96a8;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(circle at 50% 0%, #2a2440 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", sans-serif;
  min-height: 100vh;
}
button { font: inherit; color: inherit; cursor: pointer; }

.app { max-width: 520px; margin: 0 auto; padding: 16px 16px 40px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.top h1 { font-size: 22px; margin: 0; letter-spacing: -0.5px; }
.tabs { display: flex; gap: 6px; background: var(--panel); padding: 4px; border-radius: 12px; }
.tab { border: 0; background: transparent; padding: 8px 12px; border-radius: 9px; color: var(--muted); }
.tab.active { background: var(--panel-2); color: var(--text); font-weight: 700; }
.tabs.locked .tab { pointer-events: none; opacity: .6; }

.stage { text-align: center; margin-top: 18px; }
.weapon-wrap {
  height: 190px; display: grid; place-items: center;
  filter: drop-shadow(0 0 14px var(--glow));
  transition: filter .4s;
}
.weapon-wrap svg { height: 180px; width: auto; }
.weapon-wrap.shake { animation: shake .4s; }
.weapon-wrap.flash { animation: flash .6s; }
@keyframes shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-10px) rotate(-3deg); } 40% { transform: translateX(9px) rotate(3deg); } 60% { transform: translateX(-6px); } 80% { transform: translateX(4px); } }
@keyframes flash { 0% { transform: scale(1); } 40% { transform: scale(1.12); filter: brightness(1.8); } 100% { transform: scale(1); } }

.weapon-name { font-size: 26px; font-weight: 800; margin-top: 6px; }
#levelText { color: var(--glow); }
.tier { color: var(--muted); font-size: 14px; margin-top: 2px; }

.info { margin-top: 14px; background: var(--panel); border-radius: 14px; padding: 12px 14px; display: grid; gap: 8px; }
.odds { font-size: 15px; }
.odds b { color: var(--accent); font-size: 18px; }
.streak { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); flex-wrap: wrap; }
.dots { display: inline-flex; gap: 5px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--panel-2); border: 1px solid #45405a; }
.dot.on { background: var(--lose); border-color: var(--lose); }
.streak-warn { color: var(--lose); font-weight: 700; }

.result { text-align: center; margin: 16px 0 10px; font-size: 18px; font-weight: 700; min-height: 26px; }
.result.win { color: var(--win); }
.result.lose { color: var(--lose); }

.boxes {
  display: grid; grid-template-columns: repeat(var(--cols, 5), 1fr);
  gap: var(--gap, 8px); margin: 0 auto; max-width: 440px;
}
.box {
  aspect-ratio: 1; border: 0; border-radius: var(--radius, 10px);
  background: linear-gradient(160deg, #c08a3e, #8a5a22);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.25), 0 2px 0 rgba(0,0,0,.3);
  font-size: var(--font, 22px); display: grid; place-items: center; padding: 0;
  transition: transform .12s, background .25s, opacity .25s;
}
.box::before { content: "?"; font-weight: 800; color: rgba(255,240,210,.85); }
.box:hover:not(:disabled) { transform: translateY(-2px) scale(1.04); }
.box:disabled { cursor: default; }
.box.open::before { content: none; }
.box.open.win { background: linear-gradient(160deg, #5ee09a, #2b9b5d); }
.box.open.lose { background: var(--panel-2); box-shadow: none; }
.box.open.win::after { content: "★"; color: #fff; }
.box.open.lose::after { content: "✕"; color: #6b6480; }
.box.picked { outline: 3px solid var(--accent); outline-offset: 2px; transform: scale(1.1); z-index: 1; }
.box.dim { opacity: .55; }

.stats { margin-top: 18px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats div { background: var(--panel); border-radius: 12px; padding: 10px; text-align: center; display: grid; gap: 2px; }
.stats b { font-size: 20px; }
.stats span { font-size: 12px; color: var(--muted); }

.table { margin-top: 16px; background: var(--panel); border-radius: 14px; padding: 12px 14px; }
.table summary { cursor: pointer; font-weight: 700; }
.rules { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 10px 0; }
.rules b { color: var(--text); }
.table table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 5px 4px; text-align: center; border-bottom: 1px solid #332e42; }
.table th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--panel); }
.table tbody { display: block; max-height: 320px; overflow-y: auto; }
.table thead, .table tbody tr { display: table; width: 100%; table-layout: fixed; }
.table tr.current td { background: #3a3350; color: var(--accent); font-weight: 700; }

.reset { display: block; margin: 20px auto 0; background: transparent; border: 1px solid #45405a; color: var(--muted); padding: 8px 14px; border-radius: 10px; font-size: 13px; }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: grid; place-items: center; padding: 16px; z-index: 10; }
.overlay[hidden] { display: none; }
.overlay-card { background: var(--panel); border-radius: 18px; padding: 24px; text-align: center; max-width: 340px; width: 100%; }
.overlay-card .big { font-size: 30px; font-weight: 800; color: var(--accent); }
.overlay-card button { margin-top: 12px; background: var(--accent); color: #241a05; border: 0; padding: 10px 20px; border-radius: 10px; font-weight: 700; }
