/* ================================================================
   LootForge minigame — lives in the fun tab, dressed in workbench.
   Hairlines + mono chrome from IdeaForge; rarity glow stays, because
   a case opening without glow is a spreadsheet.
   ================================================================ */

/* ---- arcade shell ---- */
.fun-wrap { max-width: 1180px; margin: 0 auto; }
.fun-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.fun-head h2 { margin: 0; font-size: 0.95rem; text-transform: lowercase; }
.fun-head h2::before { content: ":: "; color: var(--acc); }
.fun-sub { font-size: 0.66rem; color: var(--muted); }
.fun-head .grow { flex: 1; }
.fun-head .lg-chip:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---- game bar (wallet + subtabs) ---- */
.lf-game { border: 1px solid var(--line-2); background: var(--bg); }
.lf-bar {
  display: flex; align-items: center; gap: 14px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line-2);
  background: var(--bg-2);
  flex-wrap: wrap;
}
.lf-wallet { display: flex; align-items: baseline; gap: 8px; }
.lf-eglyph {
  width: 11px; height: 11px; align-self: center;
  background: var(--acc);
  clip-path: polygon(50% 0%, 90% 35%, 75% 100%, 25% 100%, 10% 35%);
  animation: lf-epulse 2.2s ease-in-out infinite;
}
@keyframes lf-epulse { 0%,100% { opacity: 0.8; } 50% { opacity: 1; transform: scale(1.18); } }
.lf-count {
  font-size: 1.15rem; font-weight: 800; color: var(--acc);
  font-variant-numeric: tabular-nums;
}
.lf-elabel { font-size: 0.6rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; }
.lf-rates { display: flex; gap: 8px; font-size: 0.66rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.lf-rates .sep { color: var(--line-2); }
.lf-grow { flex: 1; }
.lf-savehint { font-size: 0.6rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.lf-tbtn {
  background: none; border: none; color: var(--muted); font-size: 0.68rem;
  padding: 3px 8px;
  transition: color var(--fast);
}
.lf-tbtn:hover { color: var(--ink); }
.lf-tabs { display: flex; border: 1px solid var(--line-2); }
.lf-tab {
  padding: 5px 13px;
  border: none; border-right: 1px solid var(--line);
  background: transparent; color: var(--muted);
  font-size: 0.72rem;
  transition: background var(--fast), color var(--fast);
  text-transform: lowercase;
}
.lf-tab:last-child { border-right: none; }
.lf-tab:hover { color: var(--ink); background: var(--bg-2); }
.lf-tab.active { background: var(--acc); color: var(--acc-ink); font-weight: 700; }
.lf-tab b { font-size: 0.58rem; margin-left: 3px; font-weight: 700; }
.lf-tab.active b { color: var(--acc-ink); }
.lf-tab:not(.active) b { color: var(--acc); }

.lf-views { padding: 16px; }
.lf-view { display: none; }
.lf-view.active { display: block; animation: lf-in 200ms ease; }
@keyframes lf-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---- rarity system ---- */
.rarity-tag {
  font-size: 0.58rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--rc);
}
.glyph { display: inline-block; line-height: 0; }
.prismatic {
  background: linear-gradient(100deg, #ff5c5c, #ffb84d, #ffe66d, #6dffb8, #6dc7ff, #b86dff, #ff6dd8, #ff5c5c) !important;
  background-size: 300% 100% !important;
  animation: prisma-roll 3s linear infinite;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
@keyframes prisma-roll { to { background-position: 300% 0; } }
.prismatic-border {
  border: 1px solid transparent !important;
  background:
    linear-gradient(var(--bg-2), var(--bg-2)) padding-box,
    linear-gradient(115deg, #ff5c5c, #ffb84d, #ffe66d, #6dffb8, #6dc7ff, #b86dff, #ff6dd8) border-box !important;
}

/* ---- anvil (clicker) ---- */
#view-fun .forge-wrap { display: grid; grid-template-columns: 1fr 300px; gap: 14px; max-width: none; }
@media (max-width: 950px) { #view-fun .forge-wrap { grid-template-columns: 1fr; } }
.anvil-zone {
  position: relative;
  border: 1px solid var(--line-2);
  background: var(--bg);
  background-image: radial-gradient(var(--dot) 1px, transparent 1px);
  background-size: 22px 22px;
  min-height: 420px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  overflow: hidden;
}
.anvil-zone::before, .anvil-zone::after {
  content: "+"; position: absolute; color: var(--muted); font-size: 11px; opacity: 0.7;
}
.anvil-zone::before { top: -6px; left: -4px; }
.anvil-zone::after { bottom: -6px; right: -4px; }
.anvil-title {
  font-size: 0.62rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 4px;
}
.anvil-title::before { content: ":: "; color: var(--acc); }
#anvil-btn {
  background: none; border: none; padding: 18px;
  transition: transform 70ms ease;
  filter: drop-shadow(0 10px 26px color-mix(in srgb, var(--acc) 22%, transparent));
}
#anvil-btn:hover { transform: scale(1.03); }
#anvil-btn:active { transform: scale(0.96) translateY(3px); }
#anvil-btn svg { display: block; }
#anvil-btn .anvil-body { fill: var(--bg-3); stroke: var(--line-2); }
#anvil-btn .anvil-glow { fill: var(--acc); opacity: 0.9; }
.strike-hint { font-size: 0.66rem; color: var(--muted); margin-top: 2px; }
.strike-hint b { color: var(--acc); font-weight: 700; }

.floater {
  position: absolute;
  font-weight: 800; font-size: 0.95rem;
  color: var(--acc);
  pointer-events: none;
  animation: float-up 900ms ease-out forwards;
  font-variant-numeric: tabular-nums;
  z-index: 5;
}
.floater.crit { font-size: 1.4rem; color: var(--st-forging); }
@keyframes float-up {
  0% { opacity: 0; transform: translateY(6px) scale(0.8); }
  15% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-60px) scale(1.05); }
}

.forge-side { display: flex; flex-direction: column; gap: 10px; }
.lf-panel {
  border: 1px solid var(--line-2); background: var(--bg);
  padding: 12px 14px;
  position: relative;
}
.lf-panel::before { content: "+"; position: absolute; top: -6px; left: -4px; color: var(--muted); font-size: 11px; opacity: 0.7; }
.lf-panel h3 {
  margin: -12px -14px 9px; padding: 6px 11px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
  font-size: 0.6rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-2);
}
.lf-panel h3::before { content: ":: "; color: var(--acc); }
.stat-row { display: flex; justify-content: space-between; font-size: 0.72rem; padding: 2.5px 0; color: var(--ink-2); }
.stat-row b { color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 700; }
.stat-row .gold { color: var(--acc); }
.next-chest { margin-top: 6px; }
.tip-line { font-size: 0.66rem; color: var(--muted); margin-top: 7px; line-height: 1.6; }
.tip-line::before { content: "// "; color: var(--line-2); }

/* ---- crates ---- */
.crates-wrap { max-width: none; }
.crates-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.crates-head h2 { margin: 0; font-size: 0.88rem; text-transform: lowercase; }
.crates-head h2::before { content: ":: "; color: var(--acc); }
.crates-head .sub { font-size: 0.64rem; color: var(--muted); }
.crate-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.crate-card {
  border: 1px solid var(--line-2);
  border-top: 3px solid var(--accent, var(--line-2));
  background: var(--bg);
  padding: 13px 15px;
  transition: border-color var(--fast);
}
.crate-card:hover { border-color: var(--accent); }
.crate-name { font-size: 0.88rem; font-weight: 800; display: flex; align-items: baseline; gap: 10px; }
.crate-price { margin-left: auto; color: var(--acc); font-variant-numeric: tabular-nums; font-weight: 700; font-size: 0.8rem; white-space: nowrap; }
.crate-price::after { content: " ◆"; font-size: 0.7em; }
.crate-desc { font-size: 0.72rem; color: var(--muted); margin: 4px 0 9px; font-family: var(--serif); font-style: italic; }
.odds-strip { display: flex; height: 7px; border: 1px solid var(--line); margin-bottom: 7px; }
.odds-strip span { min-width: 2px; }
.odds-legend { display: flex; flex-wrap: wrap; gap: 3px 11px; font-size: 0.58rem; margin-bottom: 11px; }
.odds-legend .ol { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-variant-numeric: tabular-nums; }
.odds-legend .dot { width: 7px; height: 7px; }
.crate-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.crate-actions .btn { font-size: 0.68rem; padding: 6px 10px; }
.crate-items-note { font-size: 0.6rem; color: var(--muted); margin-top: 8px; }
.crate-items-note b { color: var(--ink-2); }

/* ---- open overlay / reels ---- */
#open-overlay {
  position: fixed; inset: 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  display: none;
  align-items: center; justify-content: center;
  z-index: 60;
  padding: 20px;
}
#open-overlay.show { display: flex; }
.open-box {
  width: min(1040px, 96vw);
  border: 1px solid var(--ink);
  background: var(--bg);
  box-shadow: var(--hard-shadow);
}
.open-head {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 13px;
  border-bottom: 1px solid var(--line-2);
  background: var(--bg-2);
}
.oh-title { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.oh-hint { font-size: 0.6rem; color: var(--muted); margin-left: auto; }

#reels { padding: 16px 0 4px; }
.reel {
  position: relative;
  height: 124px;
  overflow: hidden;
  margin: 0 13px 11px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}
.reel.small { height: 94px; }
.reel-track {
  position: absolute; top: 0; left: 0; height: 100%;
  display: flex; gap: 6px;
  padding: 8px 0;
  will-change: transform;
}
.reel-marker {
  position: absolute; top: 0; bottom: 0; left: 50%;
  width: 2px; margin-left: -1px;
  background: var(--acc);
  box-shadow: 0 0 10px color-mix(in srgb, var(--acc) 80%, transparent);
  z-index: 3;
}
.reel-marker::before, .reel-marker::after {
  content: ""; position: absolute; left: 50%; translate: -50% 0;
  border: 6px solid transparent;
}
.reel-marker::before { top: -1px; border-top-color: var(--acc); }
.reel-marker::after { bottom: -1px; border-bottom-color: var(--acc); }
.reel-card {
  flex: 0 0 116px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  border: 1px solid var(--line-2);
  border-bottom: 3px solid var(--rc);
  background: var(--bg);
  padding: 7px 6px 5px;
}
.reel.small .reel-card { flex-basis: 94px; }
.reel-card .glyph { color: var(--rc); }
.reel-card .glyph svg { width: 38px; height: 38px; }
.reel.small .reel-card .glyph svg { width: 28px; height: 28px; }
.reel-card .rn {
  font-size: 0.54rem; color: var(--ink-2); text-align: center; line-height: 1.25;
  max-height: 2.6em; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.reel-card.won { animation: won-pop 500ms ease both; box-shadow: 0 0 18px -2px color-mix(in srgb, var(--rc) 70%, transparent); }
@keyframes won-pop { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1.06); } }

#open-results { padding: 4px 13px 14px; display: none; }
#open-results.show { display: block; }
.results-grid { display: flex; flex-wrap: wrap; gap: 9px; justify-content: center; padding: 5px 0 10px; }
.result-card {
  width: 162px;
  border: 1px solid var(--line-2);
  background: var(--bg-2);
  padding: 13px 10px 10px;
  text-align: center;
  animation: result-in 380ms ease both;
}
@keyframes result-in { from { opacity: 0; transform: translateY(9px) scale(0.93); } to { opacity: 1; transform: none; } }
.result-card .glyph { color: var(--rc); }
.result-card .glyph svg { width: 48px; height: 48px; filter: drop-shadow(0 0 9px color-mix(in srgb, var(--rc) 55%, transparent)); }
.result-card .nm { font-size: 0.68rem; font-weight: 700; margin: 6px 0 3px; line-height: 1.3; }
.result-card .cpc-gain { font-size: 0.58rem; color: var(--acc); margin-top: 4px; font-variant-numeric: tabular-nums; }
.result-card .dupe { font-size: 0.55rem; color: var(--muted); }
.results-summary { text-align: center; font-size: 0.68rem; color: var(--ink-2); padding-bottom: 10px; }
.results-summary b { color: var(--acc); }
.results-actions { display: flex; gap: 7px; justify-content: center; flex-wrap: wrap; }

/* ---- inventory ---- */
.inv-wrap { max-width: none; }
.inv-head { display: flex; align-items: center; gap: 11px; flex-wrap: wrap; margin-bottom: 11px; }
.inv-head h2 { margin: 0; font-size: 0.88rem; text-transform: lowercase; }
.inv-head h2::before { content: ":: "; color: var(--acc); }
.inv-head .sub { font-size: 0.62rem; color: var(--muted); }
.inv-head .grow { flex: 1; }
.inv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 9px; }
.inv-card {
  position: relative;
  border: 1px solid var(--line-2);
  border-bottom: 3px solid var(--rc);
  background: var(--bg);
  padding: 13px 9px 9px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--fast);
}
.inv-card:hover { border-color: var(--rc); }
.inv-card .glyph { color: var(--rc); }
.inv-card .glyph svg { width: 40px; height: 40px; filter: drop-shadow(0 0 7px color-mix(in srgb, var(--rc) 40%, transparent)); }
.inv-card .nm { font-size: 0.64rem; font-weight: 700; margin: 7px 0 2px; line-height: 1.3; min-height: 2.6em; }
.inv-card .count-badge {
  position: absolute; top: 4px; right: 5px;
  font-size: 0.56rem; font-weight: 700; color: var(--ink-2);
  background: var(--bg-3); border: 1px solid var(--line);
  padding: 0 5px;
}
.inv-card .cpc-line { font-size: 0.55rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.inv-empty {
  border: 1px dashed var(--line-2);
  padding: 52px 20px; text-align: center; color: var(--muted); font-size: 0.74rem;
}
.inv-empty .kao { font-size: 1.1rem; display: block; margin-bottom: 8px; color: var(--ink-2); }

/* ---- game modals ---- */
.mbd {
  position: fixed; inset: 0; z-index: 70;
  background: color-mix(in srgb, var(--bg) 74%, transparent);
  display: grid; place-items: center; padding: 20px;
}
.mbox {
  width: 370px; max-width: 94vw;
  border: 1px solid var(--ink);
  background: var(--bg);
  box-shadow: var(--hard-shadow);
  text-align: center;
  padding: 24px 20px 18px;
  position: relative;
}
.mbox .glyph { color: var(--rc); }
.mbox .glyph svg { width: 76px; height: 76px; filter: drop-shadow(0 0 16px color-mix(in srgb, var(--rc) 55%, transparent)); }
.mbox .nm { font-size: 0.98rem; font-weight: 800; margin: 11px 0 3px; }
.mbox .flavor { font-family: var(--serif); font-size: 0.82rem; color: var(--muted); font-style: italic; margin: 9px 0 13px; line-height: 1.6; }
.mbox .meta { font-size: 0.62rem; color: var(--ink-2); display: flex; justify-content: center; gap: 14px; margin-bottom: 14px; font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.mbox .meta b { color: var(--acc); }
.mbox .actions { display: flex; gap: 7px; justify-content: center; flex-wrap: wrap; }
.mbox .x {
  position: absolute; top: 6px; right: 6px;
  border: none; background: none; color: var(--muted); font-size: 0.66rem; padding: 4px 8px;
}
.mbox .x:hover { color: var(--ink); }

/* ---- fx ---- */
#fx-canvas { position: fixed; inset: 0; pointer-events: none; z-index: 80; }
#flash {
  position: fixed; inset: 0; pointer-events: none; z-index: 55;
  background: var(--flash-c, #fff);
  opacity: 0;
}
#flash.go { animation: flash-anim 700ms ease-out; }
@keyframes flash-anim { 0% { opacity: 0.5; } 100% { opacity: 0; } }
body.shake #app { animation: lf-shake 400ms ease; }
@keyframes lf-shake {
  0%, 100% { transform: none; }
  20% { transform: translate(-6px, 2px); }
  40% { transform: translate(5px, -3px); }
  60% { transform: translate(-4px, -2px); }
  80% { transform: translate(3px, 2px); }
}
