/* ==========================================================================
   Mining Legends: Fenster & Oberfläche im Pixel-Look der Seite
   ========================================================================== */

.app-window { max-width: 1060px; }

.ml-app {
  --pixel: 'Schmilley Pixel', 'Courier New', monospace;
  --ol: #0b0620;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  height: min(74vh, 660px);
  min-height: 420px;
  color: #f3f0ff;
  font-family: var(--pixel);
  -webkit-font-smoothing: none;
  border: 1px solid;
  border-color: #808080 #fff #fff #808080;
  background: #120d3d;
}

.ml-app img { image-rendering: pixelated; }
.ml-app [hidden] { display: none !important; }

/* ---------- 3D-Bereich ---------- */

.ml-stage {
  position: relative;
  overflow: hidden;
  background: #0d0a14;
  outline: none;
}
.ml-stage:focus-visible { box-shadow: inset 0 0 0 3px #ffd21f; }

#ml-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  touch-action: none;
  cursor: crosshair;
}

/* Röhrenmonitor-Zeilen */
.ml-stage::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(180deg, rgba(0, 0, 0, .14) 0 1px, transparent 1px 3px);
}

.ml-hud {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.ml-stats {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ml-stat {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: max-content;
  padding: 4px 10px 5px 6px;
  background: rgba(10, 6, 30, .72);
  box-shadow: 0 -3px 0 0 var(--ol), 0 3px 0 0 var(--ol), -3px 0 0 0 var(--ol), 3px 0 0 0 var(--ol);
  font-size: 18px;
  text-shadow: 2px 2px 0 #000;
}

.ml-effects {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.ml-effect {
  padding: 3px 8px 4px;
  font-size: 14px;
  color: #000;
  box-shadow: 0 -3px 0 0 var(--ol), 0 3px 0 0 var(--ol), -3px 0 0 0 var(--ol), 3px 0 0 0 var(--ol);
}
.ml-effect--haste { background: #ffd23f; }
.ml-effect--luck { background: #4be08a; }

/* Fadenkreuz aus Pixeln */
.ml-cross {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 4px;
  margin: -2px 0 0 -2px;
  background: #fff;
  box-shadow: 0 -4px #fff, 0 4px #fff, -4px 0 #fff, 4px 0 #fff, 0 -8px #fff, 0 8px #fff, -8px 0 #fff, 8px 0 #fff;
  opacity: .8;
  mix-blend-mode: difference;
}

.ml-bar {
  position: absolute;
  top: calc(50% + 20px);
  left: 50%;
  width: 80px;
  height: 8px;
  margin-left: -40px;
  background: rgba(0, 0, 0, .6);
  box-shadow: 0 0 0 2px var(--ol);
}
.ml-bar span { display: block; height: 100%; width: 0; background: #ffd21f; }

.ml-toasts {
  position: absolute;
  top: 12px;
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: 60%;
  transform: translateX(-50%);
}
.ml-toast {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 5px;
  background: rgba(10, 6, 30, .85);
  color: var(--c, #fff);
  font-weight: 700;
  font-size: 15px;
  box-shadow: 0 -3px 0 0 var(--c), 0 3px 0 0 var(--c), -3px 0 0 0 var(--c), 3px 0 0 0 var(--c);
  animation: ml-toast 2.6s steps(10) forwards;
}
@keyframes ml-toast {
  0% { opacity: 0; transform: translateY(-6px); }
  10%, 80% { opacity: 1; transform: none; }
  100% { opacity: 0; }
}

.ml-hint {
  position: absolute;
  bottom: 86px;
  left: 50%;
  margin: 0;
  padding: 4px 10px 5px;
  background: rgba(10, 6, 30, .8);
  font-size: 16px;
  color: #ffe98a;
  white-space: nowrap;
  transform: translateX(-50%);
  animation: ml-blink 1.2s steps(2, jump-none) infinite;
}
@keyframes ml-blink { 50% { opacity: .4; } }

/* Hotbar wie im Lieblings-Klötzchenspiel */
.ml-hotbar {
  position: absolute;
  bottom: 12px;
  left: 50%;
  display: flex;
  gap: 4px;
  padding: 4px;
  background: rgba(20, 20, 20, .75);
  box-shadow: 0 0 0 3px var(--ol);
  transform: translateX(-50%);
  pointer-events: auto;
}
.ml-slot {
  position: relative;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 0;
  background: #5a5a5a;
  box-shadow: inset 3px 3px 0 #2e2e2e, inset -3px -3px 0 #8b8b8b;
  cursor: pointer;
}
.ml-slot.is-active { box-shadow: 0 0 0 3px #fff, inset 3px 3px 0 #2e2e2e, inset -3px -3px 0 #8b8b8b; z-index: 1; }
.ml-slot .ml-dur { position: absolute; left: 6px; right: 6px; bottom: 5px; }
.ml-slot__n {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 11px;
  color: #ddd;
  text-shadow: 1px 1px 0 #000;
}

.ml-slot__count {
  position: absolute;
  right: 4px;
  bottom: 9px;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  text-shadow: 2px 2px 0 #000;
}

.ml-mute {
  position: absolute;
  right: 12px;
  bottom: 14px;
  padding: 4px 8px 5px;
  border: 0;
  background: rgba(10, 6, 30, .8);
  color: #ffe98a;
  font: 700 13px var(--pixel);
  box-shadow: 0 -3px 0 0 var(--ol), 0 3px 0 0 var(--ol), -3px 0 0 0 var(--ol), 3px 0 0 0 var(--ol);
  cursor: pointer;
  pointer-events: auto;
}
.ml-mute.is-off { color: #8a80b8; text-decoration: line-through; }
.ml-mute:focus-visible { outline: 2px dashed #fff; outline-offset: 4px; }

.ml-dur {
  display: block;
  height: 4px;
  background: #1a1a1a;
}
.ml-dur > span { display: block; height: 100%; }

/* ---------- Fenster im Spiel (Crate, Name) ---------- */

.ml-modal {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(0, 560px);
  justify-content: center;
  align-content: center;
  padding: 16px;
  background: rgba(5, 3, 15, .7);
}

.ml-box {
  min-width: 0;
  padding: 18px 18px 20px;
  background: linear-gradient(180deg, #2e1160 0 50%, #230c4a 50% 100%);
  box-shadow:
    0 -4px 0 0 #ffd21f, 0 4px 0 0 #ffd21f, -4px 0 0 0 #ffd21f, 4px 0 0 0 #ffd21f,
    10px 10px 0 0 rgba(0, 0, 0, .5);
  text-align: center;
}

.ml-roll__title { margin: 0 0 14px; font-weight: 700; font-size: 24px; text-shadow: 2px 2px 0 #000; }

.ml-roll__window {
  position: relative;
  overflow: hidden;
  height: 84px;
  background: #0b0620;
  box-shadow: inset 0 0 0 3px #000;
}
.ml-roll__strip {
  display: flex;
  height: 100%;
  will-change: transform;
}
.ml-roll__item {
  flex: none;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 10px 4px;
  background: #1c0b3e;
  box-shadow: inset 0 -6px 0 0 var(--c);
}
.ml-roll__item.is-win { background: #3a1576; box-shadow: inset 0 -6px 0 0 var(--c), 0 0 0 3px #fff; }
.ml-roll__marker {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 4px;
  margin-left: -2px;
  background: #ffd21f;
  box-shadow: 0 0 0 2px #000;
}

.ml-roll__result {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 32px;
  margin: 14px 0 6px;
  font-weight: 700;
  font-size: 20px;
  text-shadow: 2px 2px 0 #000;
}

.ml-roll__buttons {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
}

.ml-roll__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding: 4px;
}
.ml-roll__cell {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 8px 4px 10px;
  background: #1c0b3e;
  box-shadow: inset 0 -5px 0 0 var(--c);
  animation: ml-pop .3s steps(3) both;
}
.ml-roll__qty { position: absolute; top: 4px; right: 6px; font-weight: 700; font-size: 14px; color: #fff; text-shadow: 2px 2px 0 #000; }
.ml-roll__name { font-size: 11px; line-height: 1.2; color: var(--c); }
@keyframes ml-pop {
  from { opacity: 0; transform: scale(.6); }
}

.ml-welcome { text-align: left; }
.ml-welcome p { margin: 0 0 12px; font-size: 16px; line-height: 1.35; color: #e9dcff; }
.ml-welcome__title {
  font-weight: 700;
  font-size: 30px !important;
  color: #fff !important;
  text-align: center;
  text-shadow: 3px 3px 0 #5865f2, 5px 5px 0 #000;
}
.ml-welcome label { display: block; margin-bottom: 6px; font-size: 14px; color: #3fe0cf; }
.ml-welcome input {
  width: 100%;
  padding: 8px 10px;
  border: 0;
  background: #0b0620;
  color: #fff;
  font: 700 20px var(--pixel);
  box-shadow: inset 0 0 0 3px #5b4a8a;
}
.ml-welcome input:focus { outline: none; box-shadow: inset 0 0 0 3px #ffd21f; }
.ml-error { min-height: 1em; margin: 6px 0 0 !important; font-size: 13px !important; color: #ff8a8a !important; }

/* ---------- Knöpfe ---------- */

.ml-btn {
  flex: none;
  padding: 6px 12px 8px;
  border: 0;
  background: linear-gradient(180deg, #8a8a8a 0 50%, #6e6e6e 50% 100%);
  color: #fff;
  font: 700 14px var(--pixel);
  text-shadow: 1px 1px 0 #000;
  box-shadow:
    0 -3px 0 0 var(--ol), 0 3px 0 0 var(--ol), -3px 0 0 0 var(--ol), 3px 0 0 0 var(--ol),
    inset 0 3px 0 0 rgba(255, 255, 255, .3), inset 0 -3px 0 0 rgba(0, 0, 0, .3);
  cursor: pointer;
}
.ml-btn:hover { filter: brightness(1.15); }
.ml-btn:active { transform: translate(2px, 2px); }
.ml-btn:focus-visible { outline: 3px dashed #fff; outline-offset: 5px; }
.ml-btn:disabled { filter: grayscale(1) brightness(.6); cursor: default; transform: none; }
.ml-btn--gold { background: linear-gradient(180deg, #ffe07a 0 50%, #ffc857 50% 100%); color: #2b1300; text-shadow: none; }

.ml-link {
  padding: 0;
  border: 0;
  background: none;
  color: #7fd8ff;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* ---------- Seitenleiste ---------- */

.ml-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 4px solid #0b0620;
  background:
    repeating-linear-gradient(180deg, rgba(255, 255, 255, .03) 0 4px, transparent 4px 8px),
    #1a0f45;
}

.ml-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 3px;
  padding: 6px 6px 0;
  background: #0b0620;
}
.ml-tab {
  padding: 8px 2px 9px;
  border: 0;
  background: #2e2457;
  color: #c9bfff;
  font: 700 13px var(--pixel);
  cursor: pointer;
}
.ml-tab[aria-selected="true"] { background: #1a0f45; color: #ffd21f; }
.ml-tab:focus-visible { outline: 2px dashed #fff; outline-offset: -4px; }

.ml-panel__body {
  flex: 1;
  overflow: auto;
  padding: 12px 12px 18px;
}

.ml-h {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 14px 0 8px;
  font-size: 16px;
  color: #ffe98a;
  text-shadow: 2px 2px 0 #000;
}
.ml-h:first-child { margin-top: 0; }

.ml-list,
.ml-keys,
.ml-board { margin: 0; padding: 0; list-style: none; }
.ml-list { display: grid; gap: 8px; }

.ml-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: rgba(0, 0, 0, .28);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .3);
}
.ml-row__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ml-row__main b { font-size: 15px; }
.ml-row__main small { display: flex; align-items: center; gap: 4px; font-size: 12px; color: #c9bfff; }
.ml-row .ml-dur { width: 100%; }
.ml-count { font-weight: 700; font-size: 15px; }
.ml-tag { font-size: 12px; color: #4be04b; }

.ml-keys {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.ml-keycell {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 6px 0;
  background: rgba(0, 0, 0, .28);
  font-size: 15px;
}

.ml-empty { margin: 0; padding: 8px; font-size: 14px; color: #c9bfff; }

.ml-crate {
  padding: 8px;
  background: rgba(0, 0, 0, .28);
  box-shadow: inset 4px 0 0 var(--c);
}
.ml-crate__head { display: flex; align-items: center; gap: 10px; }
.ml-crate__multi { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }

.ml-pickgroup { display: grid; gap: 0; }
.ml-merge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px 8px;
  background: rgba(0, 0, 0, .18);
  font-size: 12px;
  color: #c9bfff;
}
.ml-merge span { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.ml-x { color: #fff; }
.ml-small--top { margin: -2px 0 8px; }
.ml-crate__loot { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; padding-left: 50px; }
.ml-crate__loot span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  background: rgba(0, 0, 0, .35);
  box-shadow: inset 0 -3px 0 var(--c);
}

.ml-me { margin: 0 0 12px; font-size: 14px; line-height: 1.4; }
.ml-board { counter-reset: none; display: grid; gap: 4px; }
.ml-rank {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 6px;
  padding: 5px 8px;
  background: rgba(0, 0, 0, .28);
  font-size: 14px;
}
.ml-rank:nth-child(1) .ml-rank__pos { color: #ffd21f; }
.ml-rank:nth-child(2) .ml-rank__pos { color: #d6d6d6; }
.ml-rank:nth-child(3) .ml-rank__pos { color: #d8a07a; }
.ml-rank.is-me { background: rgba(255, 210, 31, .18); }
.ml-rank__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ml-small { margin: 12px 0 0; font-size: 12px; color: #9f95d0; }

/* ---------- Handy ---------- */

@media (max-width: 760px) {
  .ml-app {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }
  .ml-stage { aspect-ratio: 4 / 3; }
  .ml-panel { border-left: 0; border-top: 4px solid #0b0620; max-height: 520px; }
  .ml-slot { width: 42px; height: 42px; }
  .ml-slot img { width: 26px; height: 26px; }
  .ml-hotbar { max-width: calc(100% - 16px); overflow-x: auto; }
  .ml-hint { bottom: 70px; font-size: 13px; }
  .ml-stat { font-size: 15px; }
  .ml-toasts { max-width: 90%; }
  .ml-toast { font-size: 13px; }
  .ml-mute { top: 12px; bottom: auto; }
  .ml-effects { top: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  .ml-hint { animation: none; }
}

/* ---------- Level, Combo, Quests, Dialoge ---------- */

.ml-stat--level { gap: 6px; font-size: 16px; }
.ml-stars { color: #c25bff; font-weight: 700; text-shadow: 2px 2px 0 #000; }
.ml-xp {
  display: inline-block;
  width: 70px;
  height: 6px;
  background: #1a1a1a;
  box-shadow: 0 0 0 2px #000;
}
.ml-xp > span { display: block; height: 100%; background: #4be04b; }
.ml-xp--big { display: block; width: 100%; height: 10px; }

.ml-combo {
  position: absolute;
  top: calc(50% + 36px);
  left: 50%;
  padding: 3px 10px 4px;
  background: rgba(10, 6, 30, .8);
  color: #ffd21f;
  font-weight: 700;
  font-size: 16px;
  white-space: nowrap;
  text-shadow: 2px 2px 0 #000;
  transform: translateX(-50%);
  box-shadow: 0 -3px 0 0 var(--ol), 0 3px 0 0 var(--ol), -3px 0 0 0 var(--ol), 3px 0 0 0 var(--ol);
}
.ml-combo.is-max { color: #ff6bd6; animation: ml-blink .5s steps(2, jump-none) infinite; }

.ml-levelcard {
  display: grid;
  gap: 8px;
  padding: 10px;
  background: rgba(0, 0, 0, .28);
  font-size: 13px;
}
.ml-levelcard small { font-size: 12px; color: #c9bfff; line-height: 1.35; }
.ml-btn--purple { background: linear-gradient(180deg, #c98bff 0 50%, #9a4bf0 50% 100%); }

.ml-quest {
  display: grid;
  gap: 6px;
  padding: 8px;
  background: rgba(0, 0, 0, .28);
}
.ml-quest.is-claimed { opacity: .55; }
.ml-quest__top, .ml-quest__bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ml-quest__top b { font-size: 14px; }
.ml-quest__rw { display: flex; gap: 2px; flex: none; }
.ml-quest__bottom small { font-size: 12px; color: #c9bfff; }
.ml-quest__bar { height: 6px; }

.ml-dialog { text-align: left; }
.ml-dialog .ml-roll__title { text-align: center; color: #ffd21f; }
.ml-dialog__body p { margin: 0 0 10px; font-size: 15px; line-height: 1.4; color: #e9dcff; }
.ml-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 4px 0 12px; }
.ml-day {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 6px 0;
  background: #1c0b3e;
  font-size: 10px;
  color: #9f95d0;
}
.ml-day.is-done { opacity: .45; }
.ml-day.is-today { background: #3a1576; box-shadow: 0 0 0 3px #ffd21f; color: #ffd21f; }
.ml-daily-reward { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 20px !important; color: #fff !important; }
.ml-tab { font-size: 12px; }
