/* Minecraft-Optik komplett aus CSS - es werden bewusst keine Mojang-Assets ausgeliefert. */

:root {
  --dirt: #8b5a2b;
  --dirt-dark: #6b4423;
  --grass: #5d9c3c;
  --grass-dark: #4a7c2f;
  --stone: #7f7f7f;
  --stone-dark: #5a5a5a;
  --obsidian: #1d1121;
  --obsidian-light: #2e1b3d;
  --gui: #c6c6c6;
  --gui-light: #ffffff;
  --gui-dark: #555555;
  --gui-frame: #1e1e1e;
  --xp: #80ff20;
  --redstone: #d63a3a;
  --redstone-dark: #8f2020;
  --gold: #ffd700;
  --text: #f4f4f4;
  --text-shadow: #3f3f3f;
  --font-pixel: "Press Start 2P", "Courier New", monospace;
  --font-body: ui-monospace, "DejaVu Sans Mono", "Courier New", monospace;
}

/* Pixelweave, aus dem alle Blocktexturen aufgebaut sind. */
.tex,
.face,
.bg-scroll,
.week__cell {
  background-blend-mode: normal;
  background-image:
    linear-gradient(90deg, rgba(0, 0, 0, .16) 0 25%, transparent 25% 50%, rgba(255, 255, 255, .08) 50% 75%, transparent 75%),
    linear-gradient(0deg, rgba(0, 0, 0, .12) 0 25%, transparent 25% 50%, rgba(255, 255, 255, .06) 50% 75%, transparent 75%);
  background-size: 16px 16px, 16px 16px;
  background-position: 0 0, 8px 8px;
}

* { box-sizing: border-box; }

/* Muss nach den display-Regeln greifen, sonst gewinnt display:flex/grid. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  position: relative;
  font-family: var(--font-body);
  color: var(--text);
  background: #1a1410;
  overflow-x: hidden;
  image-rendering: pixelated;
  text-shadow: 2px 2px 0 var(--text-shadow);
}

button, input, select, a { font-family: inherit; }

h1, h2, .mc-btn, .status-label, .xp__level {
  font-family: var(--font-pixel);
  font-weight: 400;
  letter-spacing: .02em;
}

.sprite-sheet { position: absolute; width: 0; height: 0; }

/* ---------- Hintergrund ---------- */

.bg-scroll {
  position: fixed;
  inset: -20vh 0 -20vh 0;
  z-index: -3;
  background-color: var(--dirt);
  filter: brightness(.45);
}

.bg-sky {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  transition: background 3s linear;
  background: linear-gradient(180deg, rgba(10, 20, 50, .55), rgba(0, 0, 0, .35));
}

.particles {
  position: fixed;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.damage-flash {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  opacity: 0;
  background: #b81414;
}

/* ---------- Kopfzeile ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px clamp(12px, 4vw, 32px);
}

.title {
  margin: 0;
  font-size: clamp(14px, 3.6vw, 26px);
  color: var(--gui-light);
  text-shadow: 3px 3px 0 var(--text-shadow);
}

.topbar__actions { display: flex; gap: 8px; }

/* ---------- GUI-Panel ---------- */

.panel {
  position: relative;
  padding: clamp(16px, 3vw, 28px);
  color: #2b2b2b;
  text-shadow: none;
  background: var(--gui);
  box-shadow:
    inset 4px 4px 0 rgba(255, 255, 255, .75),
    inset -4px -4px 0 var(--gui-dark),
    0 0 0 4px var(--gui-frame),
    0 8px 0 rgba(0, 0, 0, .45);
}

.panel__title {
  margin: 0 0 16px;
  font-size: clamp(11px, 2.2vw, 15px);
  color: #2b2b2b;
}

/* ---------- Buttons im GUI-Stil ---------- */

.mc-btn {
  display: inline-block;
  padding: 14px 18px;
  min-height: 48px;
  font-size: clamp(9px, 1.8vw, 12px);
  line-height: 1.4;
  color: var(--text);
  text-align: center;
  text-decoration: none;
  text-shadow: 2px 2px 0 var(--text-shadow);
  background: #9a9a9a;
  border: 0;
  border-radius: 0;
  cursor: pointer;
  box-shadow:
    inset 3px 3px 0 rgba(255, 255, 255, .55),
    inset -3px -3px 0 rgba(0, 0, 0, .45),
    0 0 0 3px var(--gui-frame);
}

.mc-btn:hover:not(:disabled) { background: #adadad; outline: 2px solid var(--gui-light); outline-offset: -8px; }
.mc-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.mc-btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow:
    inset -3px -3px 0 rgba(255, 255, 255, .35),
    inset 3px 3px 0 rgba(0, 0, 0, .45),
    0 0 0 3px var(--gui-frame);
}

.mc-btn:disabled { filter: grayscale(.7) brightness(.7); cursor: not-allowed; }

.mc-btn--small { padding: 10px 12px; min-height: 40px; font-size: 10px; }
.mc-btn--primary { position: relative; overflow: hidden; background: #3f8f3f; }
.mc-btn--primary:hover:not(:disabled) { background: #4fa84f; }
.mc-btn--danger { background: var(--redstone-dark); }
.mc-btn--danger:hover:not(:disabled) { background: var(--redstone); }

/* ---------- Layout ---------- */

.layout {
  display: grid;
  gap: clamp(16px, 3vw, 28px);
  grid-template-columns: 1fr;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 clamp(12px, 4vw, 32px) 64px;
}

/* Ohne min-width:0 schrumpfen Grid-Items nicht unter ihre Inhaltsbreite. */
.layout > .panel { min-width: 0; }

@media (min-width: 900px) {
  .layout { grid-template-columns: 1.15fr .85fr; align-items: start; }
  .panel--status { grid-row: span 2; }
}

/* ---------- Fackeln ---------- */

.torch {
  position: absolute;
  top: 24px;
  width: 10px;
  height: 34px;
  background: linear-gradient(var(--dirt-dark), #4a3018);
  box-shadow: 0 0 0 2px var(--gui-frame);
}

.torch--left { left: -22px; }
.torch--right { right: -22px; }

.torch__flame {
  position: absolute;
  top: -12px;
  left: -3px;
  width: 16px;
  height: 16px;
  background:
    linear-gradient(180deg, #fff2a8 0 25%, var(--gold) 25% 55%, #ff8a1f 55% 100%);
  box-shadow: 0 0 18px 8px rgba(255, 170, 40, .45);
}

@media (max-width: 640px) { .torch { display: none; } }

/* ---------- Statusblock (CSS-3D-Wuerfel) ---------- */

.cube-stage {
  position: relative;
  display: grid;
  place-items: center;
  height: 200px;
  margin: 8px 0 4px;
  perspective: 700px;
}

.cube {
  position: relative;
  width: 108px;
  height: 108px;
  transform-style: preserve-3d;
  will-change: transform;
}

.face {
  position: absolute;
  inset: 0;
  background-color: var(--stone);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .3);
}

.face--front  { transform: translateZ(54px); }
.face--back   { transform: rotateY(180deg) translateZ(54px); }
.face--left   { transform: rotateY(-90deg) translateZ(54px); filter: brightness(.78); }
.face--right  { transform: rotateY(90deg) translateZ(54px); filter: brightness(.86); }
.face--top    { transform: rotateX(90deg) translateZ(54px); filter: brightness(1.12); }
.face--bottom { transform: rotateX(-90deg) translateZ(54px); filter: brightness(.6); }

/* Grasblock: gruene Oberseite, gezackte Kante an den Seiten. */
[data-block="grass"] .face { background-color: var(--dirt); }
[data-block="grass"] .face--top { background-color: var(--grass); }
[data-block="grass"] .face--front,
[data-block="grass"] .face--back,
[data-block="grass"] .face--left,
[data-block="grass"] .face--right {
  background-image:
    linear-gradient(180deg, var(--grass) 0 20%, transparent 20%),
    repeating-linear-gradient(90deg, var(--grass) 0 9px, transparent 9px 18px),
    linear-gradient(90deg, rgba(0, 0, 0, .16) 0 25%, transparent 25% 50%, rgba(255, 255, 255, .08) 50% 75%, transparent 75%),
    linear-gradient(0deg, rgba(0, 0, 0, .12) 0 25%, transparent 25% 50%, rgba(255, 255, 255, .06) 50% 75%, transparent 75%);
  background-size: 100% 100%, 18px 26px, 16px 16px, 16px 16px;
  background-repeat: no-repeat, repeat-x, repeat, repeat;
  background-position: 0 0, 0 0, 0 0, 8px 8px;
}

[data-block="cobblestone"] .face { background-color: var(--stone); }
[data-block="obsidian"] .face { background-color: var(--obsidian); }
[data-block="obsidian"] .face--top { background-color: var(--obsidian-light); }

[data-block="furnace"] .face { background-color: var(--stone-dark); }

.furnace-face { display: none; }

[data-block="furnace"] .face--front .furnace-face {
  position: absolute;
  display: block;
  inset: 22% 18% 18% 18%;
  background: #16120f;
  box-shadow: inset 0 0 0 3px #3b3b3b;
}

.furnace-face i {
  position: absolute;
  bottom: 4px;
  width: 12px;
  height: 0;
  background: linear-gradient(180deg, var(--gold), #ff6a00);
}

.furnace-face i:first-child { left: 18%; }
.furnace-face i:last-child { right: 18%; }

.cube-shadow {
  position: absolute;
  bottom: 12px;
  width: 90px;
  height: 12px;
  background: rgba(0, 0, 0, .4);
  filter: blur(2px);
}

.cube-break {
  position: absolute;
  width: 130px;
  height: 130px;
  opacity: 0;
  pointer-events: none;
  background-image:
    linear-gradient(115deg, transparent 46%, rgba(0, 0, 0, .85) 46% 50%, transparent 50%),
    linear-gradient(65deg, transparent 30%, rgba(0, 0, 0, .7) 30% 33%, transparent 33%),
    linear-gradient(160deg, transparent 60%, rgba(0, 0, 0, .75) 60% 64%, transparent 64%);
}

/* ---------- Status, Fortschritt, Aktionen ---------- */

.status-label {
  margin: 4px 0 16px;
  font-size: clamp(11px, 2.4vw, 16px);
  text-align: center;
  color: #2b2b2b;
}

.status-label[data-state="online"] { color: #1f7a1f; }
.status-label[data-state="offline"] { color: #6a6a6a; }
.status-label[data-state="starting"],
.status-label[data-state="booting"],
.status-label[data-state="stopping"] { color: #a86000; }

.smelt {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 16px;
}

.smelt__fire {
  width: 22px;
  height: 22px;
  background: linear-gradient(180deg, #fff2a8 0 20%, var(--gold) 20% 55%, #ff6a00 55%);
  box-shadow: 0 0 0 2px var(--gui-frame);
}

.smelt__arrow {
  position: relative;
  display: block;
  width: 120px;
  height: 18px;
  background: #8a8a8a;
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, .35), 0 0 0 2px var(--gui-frame);
}

.smelt__arrow i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--gold);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.address {
  display: grid;
  gap: 6px;
  margin: 20px 0 0;
  padding: 12px;
  font-size: 13px;
  color: #f0f0f0;
  background: rgba(0, 0, 0, .72);
  box-shadow: 0 0 0 2px var(--gui-frame);
}

.address > div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; }
.address dt { color: #a8a8a8; }
.address dd { margin: 0; color: var(--xp); user-select: all; word-break: break-all; }

.hint {
  margin: 14px 0 0;
  font-size: 12px;
  text-align: center;
  color: #4a4a4a;
  min-height: 1.2em;
}

/* ---------- Spieler ---------- */

.hearts { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; }

.heart { width: 20px; height: 20px; fill: currentColor; color: #6e6e6e; }
.heart--full { color: var(--redstone); }

.players__count { margin: 0 0 12px; font-size: 13px; color: #2b2b2b; }

.player-list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 8px;
  list-style: none;
  background: rgba(0, 0, 0, .72);
  box-shadow: 0 0 0 2px var(--gui-frame);
}

.player-list:empty { display: none; }

.player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  font-size: 13px;
  color: var(--text);
  background: rgba(255, 255, 255, .06);
}

.player__head {
  width: 26px;
  height: 26px;
  background: var(--grass);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .6);
  object-fit: cover;
}

.players__empty { margin: 12px 0 0; font-size: 12px; color: #5a5a5a; }

/* ---------- Zeitplan ---------- */

.xp { margin-bottom: 18px; text-align: center; }

.xp__level {
  display: block;
  margin-bottom: 4px;
  font-size: 16px;
  color: var(--xp);
  text-shadow: 2px 2px 0 #1c3b06;
}

.xp__bar {
  height: 12px;
  background: #3a3a3a;
  box-shadow: 0 0 0 2px var(--gui-frame);
}

.xp__fill { height: 100%; width: 0; background: var(--xp); transition: width 1s linear; }
.xp__caption { margin: 6px 0 0; font-size: 11px; color: #4a4a4a; }

.week {
  display: grid;
  grid-template-columns: repeat(7, minmax(64px, 1fr));
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 16px;
}

.week__day { display: grid; gap: 4px; align-content: start; }

.week__name {
  padding: 4px 0;
  font-size: 10px;
  text-align: center;
  color: #f4f4f4;
  background: #4a4a4a;
  box-shadow: 0 0 0 2px var(--gui-frame);
}

.week__cell {
  min-height: 34px;
  padding: 4px 2px;
  font-size: 10px;
  line-height: 1.3;
  text-align: center;
  color: #fff;
  background-color: var(--grass-dark);
  border: 0;
  cursor: pointer;
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, .3), inset -2px -2px 0 rgba(0, 0, 0, .35), 0 0 0 2px var(--gui-frame);
}

.week__cell:hover { background-color: var(--redstone-dark); }
.week__cell--static { cursor: default; }
.week__cell--static:hover { background-color: var(--grass-dark); }
.week__empty { min-height: 34px; background: rgba(0, 0, 0, .12); }

.window-form,
.settings {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.field { display: grid; gap: 4px; font-size: 11px; color: #2b2b2b; }
.field--check { display: flex; align-items: center; gap: 8px; }

.field input,
.field select {
  padding: 8px;
  font-size: 13px;
  color: var(--text);
  background: #2b2b2b;
  border: 0;
  border-radius: 0;
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, .6), 0 0 0 2px #8a8a8a;
}

.field input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--grass); }

/* ---------- Toasts, Chat, Modal ---------- */

.toasts {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 100;
  display: grid;
  gap: 8px;
  justify-items: end;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(340px, 90vw);
  padding: 12px 16px;
  font-size: 11px;
  color: var(--text);
  background: rgba(15, 15, 15, .95);
  box-shadow: 0 0 0 2px #4a4a4a, 0 0 0 4px var(--gui-frame);
}

.toast__icon { width: 24px; height: 24px; flex: 0 0 auto; background: var(--grass); box-shadow: 0 0 0 2px #000; }
.toast--stop .toast__icon { background: var(--redstone); }
.toast__title { font-family: var(--font-pixel); font-size: 9px; color: var(--gold); }
.toast__text { margin-top: 6px; font-size: 12px; }

.chat {
  position: fixed;
  bottom: 12px;
  left: 12px;
  z-index: 100;
  display: grid;
  gap: 4px;
  max-width: min(420px, 92vw);
  pointer-events: none;
}

.chat__line {
  padding: 6px 10px;
  font-size: 12px;
  color: #ff5555;
  background: rgba(0, 0, 0, .55);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, .72);
}

.modal[hidden] { display: none; }

.modal__box { max-width: 420px; text-align: center; }
.modal__box h2 { font-size: 13px; }
.modal__box p { font-size: 13px; color: #3a3a3a; }
