/* ==========================================================================
   Arena Admin - ruhiges Dark-UI, große Touch-Ziele, klare Tabellen
   ========================================================================== */
:root {
  --bg: #0b0e15;
  --surface: #141926;
  --surface-2: #1b2233;
  --line: rgba(255,255,255,.09);
  --line-strong: rgba(255,255,255,.18);
  --text: #eaeefa;
  --muted: #8b95ad;
  --accent: #6c8cff;
  --good: #43d39e;
  --warn: #ffbf4d;
  --danger: #ff6b81;
  --radius: 14px;
  --ease: cubic-bezier(.22,.8,.3,1);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text);
  /* Zahlen und Tabellen bleiben in der Systemschrift lesbar; die
     Spielschrift traegt Titel, Navigation und Knoepfe. */
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; }

@font-face {
  font-family: 'Pixelify Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../assets/fonts/pixelify-sans-latin.woff2') format('woff2');
}

h1, h2, h3, h4, .brand, .nav__item, .btn, .view-title, #view-title {
  font-family: 'Pixelify Sans', system-ui, sans-serif;
  letter-spacing: .02em;
}
body.is-admin { overflow-x: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 18px; margin: 0; font-size: 13px; }

/* ------------------------------------------------------------------ Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login__card {
  width: min(360px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 26px; display: grid; gap: 14px;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.login__card h1 { margin: 0; font-size: 22px; }
.login__card p { margin: 0; font-size: 13px; }

/* ----------------------------------------------------------------- Layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 18px 14px; display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100vh;
}
.brand { font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.brand span { color: var(--accent); }
.nav { display: grid; gap: 4px; }
.nav__item {
  text-align: left; padding: 11px 13px; border-radius: 11px; color: var(--muted);
  font-weight: 500; transition: background .16s var(--ease), color .16s var(--ease);
  min-height: 44px;
}
.nav__item:hover { background: rgba(255,255,255,.04); color: var(--text); }
.nav__item.is-active { background: rgba(108,140,255,.16); color: var(--text); }
.sidebar__foot { margin-top: auto; display: grid; gap: 8px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
  background: rgba(11,14,21,.9); backdrop-filter: blur(10px);
}
.topbar h1 { margin: 0; font-size: 19px; flex: 1; }
.topbar__actions { display: flex; gap: 8px; flex-wrap: wrap; }
#btn-menu { display: none; }
.view { padding: 20px; display: grid; gap: 16px; align-content: start; }

/* ---------------------------------------------------------------- Bausteine */
.btn {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 11px;
  padding: 10px 16px; font-weight: 600; min-height: 42px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: transform .13s var(--ease), background .16s var(--ease), border-color .16s var(--ease);
  text-decoration: none; color: var(--text); white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn--primary { background: linear-gradient(135deg, var(--accent), #8aa2ff); border-color: transparent; }
.btn--ghost { background: transparent; }
.btn--danger { border-color: rgba(255,107,129,.4); color: #ffb3bf; }
.btn--sm { padding: 7px 11px; min-height: 34px; font-size: 13px; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
}
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.stat { display: grid; gap: 4px; }
.stat__label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.stat__value { font-size: 26px; font-weight: 700; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); }
.table th { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.table tr:last-child td { border-bottom: 0; }
.table td.actions { text-align: right; white-space: nowrap; }
.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.thumb { width: 44px; height: 34px; object-fit: contain; image-rendering: pixelated; vertical-align: middle; background: #0d1119; border-radius: 7px; }
.thumb--map { width: 74px; height: 46px; object-fit: cover; }

.badge { font-size: 11px; border-radius: 6px; padding: 3px 7px; border: 1px solid var(--line); color: var(--muted); }
.badge--on { color: var(--good); border-color: rgba(67,211,158,.4); }
.badge--off { color: var(--muted); }
.badge--boss { color: var(--warn); border-color: rgba(255,191,77,.4); }
.badge--common { color: #9aa6c2; }
.badge--rare { color: #58b6ff; border-color: rgba(88,182,255,.4); }
.badge--epic { color: #c07bff; border-color: rgba(192,123,255,.4); }
.badge--legendary { color: #ffb020; border-color: rgba(255,176,32,.4); }

/* ------------------------------------------------------------------ Formular */
.form { display: grid; gap: 14px; }
.grid2 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.field { display: grid; gap: 5px; }
.field > label { font-size: 12px; color: var(--muted); }
.field small { color: var(--muted); font-size: 11px; }
.input, select, textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 13px; outline: none; min-height: 44px;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
textarea { min-height: 78px; resize: vertical; }
.input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(108,140,255,.18); }
.check { display: flex; align-items: center; gap: 9px; font-size: 14px; min-height: 44px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

/* -------------------------------------------------------------------- Modal */
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(5,7,12,.7); backdrop-filter: blur(4px); }
.modal__panel {
  position: relative; width: min(860px, 100%); max-height: 92vh; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  display: grid; grid-template-rows: auto 1fr auto;
  animation: pop .2s var(--ease) both; box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal__head h2 { margin: 0; font-size: 18px; }
.modal__body { padding: 18px; overflow: auto; }
.modal__foot { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.modal--wide .modal__panel { width: min(1200px, 100%); }

.iconbtn {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); display: grid; place-items: center; font-size: 15px;
}

/* ------------------------------------------------------------ Collision-Editor */
.editor { display: grid; gap: 12px; }
.editor__tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.editor__tools .btn.is-active { border-color: var(--accent); background: rgba(108,140,255,.18); }
.editor__stage {
  position: relative; overflow: hidden; touch-action: none;
  background: #06080d; border: 1px solid var(--line); border-radius: 12px;
  height: min(58vh, 520px); cursor: crosshair;
}
.editor__stage canvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; image-rendering: pixelated; }
.editor__hint { font-size: 12px; color: var(--muted); }
.slider { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--muted); }
.slider input { width: 120px; accent-color: var(--accent); }

.hitbox-stage {
  position: relative; background: #0d1119; border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden; display: grid; place-items: center; height: 300px;
}
.hitbox-stage canvas { image-rendering: pixelated; touch-action: none; }

.filedrop {
  border: 1px dashed var(--line-strong); border-radius: 12px; padding: 16px;
  text-align: center; color: var(--muted); font-size: 13px; cursor: pointer;
}
.filedrop input { display: none; }
.preview { display: flex; align-items: center; gap: 12px; }
.preview img { max-width: 120px; max-height: 90px; object-fit: contain; image-rendering: pixelated; background: #0d1119; border-radius: 8px; }

/* ------------------------------------------------------------------- Toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: grid; gap: 8px; }
.toast {
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 11px;
  padding: 11px 15px; font-size: 13.5px; animation: pop .18s var(--ease) both; max-width: 320px;
}
.toast--good { border-color: rgba(67,211,158,.45); }
.toast--error { border-color: rgba(255,107,129,.5); color: #ffc2ca; }

/* --------------------------------------------------------------- Responsive */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 30;
    transform: translateX(-100%); transition: transform .22s var(--ease);
  }
  .sidebar.is-open { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.6); }
  #btn-menu { display: grid; }
  .view { padding: 14px; }
  .table th:nth-child(n+4), .table td:nth-child(n+4) { display: none; }
  .table th.keep, .table td.keep { display: table-cell; }
}

/* --------------------------------------------------------- Sound-Editor */
.soundlist { display: grid; gap: 8px; margin: 12px 0; }
.soundrow {
  display: grid; grid-template-columns: 160px 1fr 120px 44px auto auto auto;
  gap: 10px; align-items: center;
  border: 1px solid var(--line); border-radius: 11px; padding: 9px 12px;
  background: rgba(255, 255, 255, .02); font-size: 13.5px;
}
.soundrow__name { font-weight: 600; }
.soundrow__file { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.soundrow__vol { accent-color: var(--accent); width: 100%; }

/* ------------------------------------------------------- Charakter-Frames */
.framerow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.frameslot {
  position: relative; width: 72px; height: 84px; border-radius: 10px;
  border: 1px solid var(--line); background: #0d1119;
  display: grid; place-items: center; overflow: hidden; cursor: pointer;
}
.frameslot img { max-width: 100%; max-height: 100%; object-fit: contain; image-rendering: pixelated; }
.frameslot.is-empty { border-style: dashed; color: var(--muted); font-size: 11px; }
.frameslot input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.frameslot__x {
  position: absolute; top: 3px; right: 3px; z-index: 2;
  width: 20px; height: 20px; border-radius: 6px; font-size: 11px;
  background: rgba(10, 13, 20, .85); border: 1px solid var(--line); color: var(--danger);
}
.card h4 { margin: 0 0 8px; font-size: 14px; }

@media (max-width: 860px) {
  .soundrow { grid-template-columns: 1fr auto; grid-auto-rows: auto; }
  .soundrow__file { grid-column: 1 / -1; }
}

/* ------------------------------------------------------------ Ton-Editor */
.soundset {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  background: rgba(255, 255, 255, .02); display: grid; gap: 9px; margin-bottom: 10px;
}
.soundset__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.soundset__label { font-weight: 600; font-size: 14px; }
.soundset__head .check { min-height: 32px; }
.soundset__slots { display: grid; gap: 7px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.soundslot {
  position: relative; display: grid; grid-template-columns: 1fr 80px auto auto;
  gap: 6px; align-items: center;
  border: 1px solid var(--line); border-radius: 9px; padding: 6px 8px;
  background: rgba(255, 255, 255, .02); font-size: 12.5px; min-height: 42px;
}
.soundslot.is-empty { border-style: dashed; grid-template-columns: 1fr; }
.soundslot.is-busy { opacity: .5; }
.soundslot__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.soundslot input[type="range"] { width: 100%; accent-color: var(--accent); }
.soundslot input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.soundset__controls { display: flex; gap: 16px; flex-wrap: wrap; }
.soundset__controls .slider input { width: 110px; }


/* Karten-Editor: sichtbarer Unterschied zwischen Schauen und Malen. */
.editor__stage { cursor: crosshair; }
.editor__stage.is-touch { cursor: grab; }
.editor__stage.is-touch:active { cursor: grabbing; }


/* Einzelbild spiegeln - kleiner Knopf unten links im Bildfeld. */
.frameslot__flip {
  position: absolute; left: 3px; bottom: 3px;
  width: 22px; height: 22px; border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(10, 14, 22, .78);
  color: #c8d2e6; font-size: 13px; line-height: 1;
  display: grid; place-items: center; cursor: pointer;
}
.frameslot__flip.is-active { background: #6c8cff; color: #fff; border-color: #6c8cff; }
