:root {
  --gold1: #fff3a0; --gold2: #ffc727; --gold3: #d98a0b;
  --blue: #2f7cf6; --red: #ea4440;
  --ink: #1d1530;
  --panel: #241a4a; --panel2: #18113a;
  --elixir1: #f59cff; --elixir2: #b51fd1;
  --display: "Lilita One", "Nunito", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #0d0a22; color: #fff;
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif; font-weight: 800;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
#app {
  position: relative; height: 100%; max-width: 560px; margin: 0 auto;
  display: flex; flex-direction: column; overflow: hidden;
  background: radial-gradient(120% 60% at 50% 0%, #3a2a7a 0%, #1a1240 55%, #0f0a2a 100%);
  box-shadow: 0 0 60px #000;
}
.txt-outline, .pname, #timer, .card .nm, .card .cost span, .drop span, #banner, #countdown, h2, .btn, #overTitle {
  text-shadow: 0 2px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 -2px 0 var(--ink),
    1.5px 1.5px 0 var(--ink), -1.5px 1.5px 0 var(--ink), 1.5px -1.5px 0 var(--ink), -1.5px -1.5px 0 var(--ink);
}

/* ───────── Kopfzeile ───────── */
#topbar {
  flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6px;
  padding: 6px 8px; background: linear-gradient(#2b2060, #1a1342); border-bottom: 3px solid #0c0820;
}
.plate { display: flex; flex-direction: column; gap: 2px; padding: 4px 10px; border-radius: 10px; min-width: 0; }
.plate.enemy { background: linear-gradient(90deg, #c2282b, #ea444000); align-items: flex-start; }
.plate.me { background: linear-gradient(270deg, #1f62d8, #2f7cf600); align-items: flex-end; }
.pname { font-family: var(--display); font-size: 17px; letter-spacing: .02em; line-height: 1; white-space: nowrap; }
.pname small { font-family: "Nunito"; font-size: 11px; opacity: .85; margin-left: 3px; }
.crownRow { display: flex; gap: 2px; }
.crownRow svg { width: 22px; height: 19px; fill: #3a3060; stroke: none; transition: transform .3s; }
.crownRow svg.on { fill: url(#gGold); animation: crownPop .5s ease-out; filter: drop-shadow(0 0 4px #ffcf3a); }
@keyframes crownPop { 0% { transform: scale(0) rotate(-30deg); } 70% { transform: scale(1.5); } 100% { transform: scale(1); } }
#timerBox {
  text-align: center; background: #0c0820; border: 2px solid #4a3a8a; border-radius: 10px; padding: 3px 12px 4px;
  box-shadow: inset 0 -3px 0 #00000080;
}
#timerLabel { font-size: 9px; text-transform: uppercase; letter-spacing: .06em; color: #b9b0e8; white-space: nowrap; }
#timer { font-family: var(--display); font-size: 24px; line-height: 1; font-variant-numeric: tabular-nums; }
#timerBox.x2 #timerLabel { color: #f59cff; }
#timerBox.ot { border-color: #ffb020; }
#timerBox.ot #timer { color: #ffcf3a; }
#timerBox.low #timer { color: #ff6b6b; animation: pulse .6s infinite alternate; }
@keyframes pulse { to { transform: scale(1.1); } }

/* ───────── Arena ───────── */
#arenaWrap { position: relative; flex: 1 1 auto; min-height: 0; background: #1d3b1d; }
#arena { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
#banner {
  position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%) scale(.6); opacity: 0;
  font-family: var(--display); font-size: 30px; color: #fff; white-space: nowrap; pointer-events: none;
  padding: 8px 26px; border-radius: 14px;
  background: linear-gradient(90deg, #0000, #000a 20%, #000a 80%, #0000);
  transition: opacity .25s, transform .35s cubic-bezier(.2, 1.6, .4, 1);
}
#banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#banner.small { font-size: 20px; }
#countdown {
  position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%); pointer-events: none;
  font-family: var(--display); font-size: 110px; color: #ffd84a; opacity: 0;
}
#countdown.tick { animation: cd .9s ease-out; }
@keyframes cd { 0% { opacity: 0; transform: translate(-50%, -50%) scale(2.2); } 25% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -50%) scale(.8); } }
.iconBtn {
  position: absolute; right: 8px; top: 8px; width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid #ffffff40; background: #0008; font-size: 16px; cursor: pointer; padding: 0; z-index: 2;
}

/* ───────── Hand & Elixier ───────── */
#bottom {
  flex: none; padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(#3b2a1c, #24170e); border-top: 4px solid #6b4a2a;
  box-shadow: inset 0 3px 0 #8a6338;
}
#handRow { display: flex; gap: 7px; align-items: flex-end; }
#next { width: 14%; text-align: center; font-size: 10px; color: #e7d3b5; flex: none; }
#next .card { margin-top: 3px; }
#hand { flex: 1; min-width: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }

.card {
  position: relative; aspect-ratio: 5 / 6; border-radius: 9px; cursor: pointer; touch-action: none;
  padding: 3px; background: linear-gradient(160deg, #e6ecf7, #8c9ab8);
  box-shadow: 0 3px 0 #0008, inset 0 0 0 2px #0004;
  transition: transform .14s, filter .2s, box-shadow .14s;
}
.card.r-rare { background: linear-gradient(160deg, #ffd59a, #e0761c); }
.card.r-epic { background: linear-gradient(160deg, #f2b8ff, #9b2fd0); }
.card .art {
  width: 100%; height: 100%; border-radius: 7px; overflow: hidden; position: relative;
  border: 2px solid var(--ink); background: #333;
}
.card .art img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.card .nm {
  position: absolute; left: 0; right: 0; bottom: 3px; text-align: center; font-family: var(--display);
  font-size: clamp(9px, 2.6vw, 12px); line-height: 1; padding: 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.drop {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: radial-gradient(circle at 35% 30%, #ffe1ff, var(--elixir1) 30%, var(--elixir2) 85%);
  border: 2px solid var(--ink); box-shadow: inset -2px -2px 0 #0003;
}
.drop span { transform: rotate(45deg); font-family: var(--display); font-size: 15px; line-height: 1; }
.card .drop { position: absolute; left: -7px; top: -7px; z-index: 2; }
.drop.big { width: 38px; height: 38px; flex: none; }
.drop.big span { font-size: 21px; }
.drop.sm { width: 22px; height: 22px; } .drop.sm span { font-size: 11px; }
#next .card .drop { width: 20px; height: 20px; left: -5px; top: -5px; } #next .card .drop span { font-size: 11px; }
#next .card .nm { display: none; }
.card.poor { filter: grayscale(.9) brightness(.65); }
.card.sel { transform: translateY(-12px) scale(1.04); box-shadow: 0 0 0 3px #fff, 0 0 18px 4px #ffd84a, 0 8px 12px #000a; }
.card.fresh { animation: deal .35s ease-out; }
@keyframes deal { from { transform: translateY(40px) scale(.6); opacity: 0; } }

#elixirRow { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
#elixirBar {
  position: relative; flex: 1; height: 24px; border-radius: 12px; overflow: hidden;
  background: #1a0f22; border: 3px solid var(--ink); box-shadow: inset 0 3px 0 #0006;
}
#elixirFill {
  height: 100%; width: 50%;
  background: linear-gradient(#ffc6ff, #e254f5 40%, #a01ac0);
  box-shadow: inset 0 -3px 0 #0003, inset 0 3px 0 #fff6;
}
#elixirTicks { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(10, 1fr); }
#elixirTicks i { border-right: 2px solid #1d153088; }
#elixirTicks i:last-child { border-right: 0; }
#x2 {
  font-family: var(--display); font-size: 18px; color: #f59cff; width: 30px; text-align: center;
  opacity: 0; transition: opacity .3s;
}
#x2.on { opacity: 1; animation: pulse .5s infinite alternate; }

/* ───────── Screens ───────── */
.screen {
  position: absolute; inset: 0; z-index: 10; overflow-y: auto; padding: 14px 12px 30px;
  background:
    radial-gradient(90% 50% at 50% 0%, #5a3cc0aa, #0000 70%),
    repeating-linear-gradient(45deg, #ffffff05 0 12px, #0000 12px 24px),
    linear-gradient(#22185a, #120c33);
}
.screen.hidden, .modal.hidden { display: none; }
.menuInner { max-width: 520px; margin: 0 auto; }
.menuInner.center { text-align: center; padding-top: 6vh; }
.logo { text-align: center; margin: 8px 0 14px; line-height: .85; font-family: var(--display); }
.logo span { display: block; letter-spacing: .03em; }
.logo .l1, .logo .l2 {
  font-size: 58px; background: linear-gradient(#fff6c0, #ffcc33 50%, #e08a0a); -webkit-background-clip: text; background-clip: text;
  color: transparent; -webkit-text-stroke: 3px var(--ink); filter: drop-shadow(0 5px 0 var(--ink));
}
.logo .l2 { font-size: 46px; background: linear-gradient(#e0ecff, #7fb2ff 50%, #2f62d8); -webkit-background-clip: text; background-clip: text; }
.box {
  background: linear-gradient(#2e2268, #221852); border: 3px solid #0c0820; border-radius: 16px;
  padding: 10px; margin-bottom: 12px; box-shadow: inset 0 2px 0 #ffffff18, 0 4px 0 #0007;
}
.secHead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
h2 { font-family: var(--display); font-weight: 400; font-size: 21px; margin: 0; letter-spacing: .02em; }
.secHead small { opacity: .65; font-size: 12px; }
.avg { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #e2d8ff; }
#deckSlots, #collection { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 8px; }
#deckSlots .slot {
  aspect-ratio: 5 / 6; border-radius: 9px; border: 3px dashed #ffffff30; display: flex; align-items: center; justify-content: center;
  color: #ffffff40; font-size: 26px;
}
#collection .card.in { filter: brightness(.45) saturate(.4); }
#collection .card.in::after {
  content: "✓"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 34px; color: #7dff9a; text-shadow: 0 2px 0 #000;
}
.diffBox h2 { margin-bottom: 8px; }
.diff { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.btn, .diff button {
  font-family: var(--display); font-size: 17px; color: #fff; cursor: pointer; letter-spacing: .02em;
  padding: 10px 14px; border-radius: 12px; border: 3px solid var(--ink);
  background: linear-gradient(#5d7fe0, #3653b8); box-shadow: inset 0 -4px 0 #0004, inset 0 2px 0 #fff5, 0 3px 0 #0008;
  transition: transform .08s;
}
.diff button { background: linear-gradient(#4a3d8a, #2e2468); font-size: 15px; padding: 9px 4px; }
.diff button.on { background: linear-gradient(#5d9bff, #2f62d8); box-shadow: inset 0 -4px 0 #0004, inset 0 2px 0 #fff5, 0 0 0 2px #fff, 0 3px 0 #0008; }
.btn:active, .diff button:active { transform: translateY(2px); }
.btn.gold { background: linear-gradient(#fff07a, #ffbf1f 50%, #e88a0a); color: #fff; }
.btn.huge { display: block; width: 100%; font-size: 30px; padding: 14px; margin: 6px 0 12px; }
.btn.wide { display: block; width: 100%; }
.btn:disabled { filter: grayscale(1); opacity: .6; cursor: not-allowed; }
.help summary { cursor: pointer; font-family: var(--display); font-size: 18px; font-weight: 400; }
.help li { margin: 5px 0; font-size: 14px; color: #ddd6ff; font-weight: 700; }

/* Detail-Modal */
.modal { position: absolute; inset: 0; z-index: 20; background: #000b; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modalBox {
  width: 100%; max-width: 420px; background: linear-gradient(#3a2c80, #221852); border: 3px solid var(--ink);
  border-radius: 18px; padding: 14px; box-shadow: 0 10px 40px #000, inset 0 2px 0 #fff3;
  animation: pop .25s cubic-bezier(.2, 1.6, .4, 1);
}
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
.dTop { display: flex; gap: 14px; align-items: center; }
#dCard { width: 110px; flex: none; }
#dName { font-family: var(--display); font-weight: 400; font-size: 26px; margin: 2px 0 4px; }
#dDesc { margin: 0; color: #ddd6ff; font-size: 14px; font-weight: 700; }
#dRarity { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
#dStats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 14px 0; }
#dStats div { background: #0006; border-radius: 10px; padding: 6px 10px; display: flex; justify-content: space-between; gap: 6px; font-size: 13px; }
#dStats b { color: #ffd84a; font-family: var(--display); font-weight: 400; font-size: 15px; }
.row { display: flex; gap: 8px; } .row .btn { flex: 1; }

/* Ergebnis */
#overTitle { font-family: var(--display); font-size: 64px; color: #ffd84a; animation: pop .5s cubic-bezier(.2, 1.6, .4, 1); }
#overTitle.lose { color: #ff7a7a; } #overTitle.draw { color: #cfd8ff; }
#overCrowns { display: flex; justify-content: center; align-items: center; gap: 24px; margin: 14px 0 6px; }
#overCrowns .side { display: flex; flex-direction: column; align-items: center; gap: 6px; }
#overCrowns .side span { font-family: var(--display); font-size: 16px; }
#overCrowns .crownRow svg { width: 40px; height: 35px; }
#overCrowns .vs { font-family: var(--display); font-size: 26px; opacity: .6; }
#overText { color: #ddd6ff; font-size: 16px; }
#overStats { display: flex; justify-content: center; gap: 10px; margin: 10px 0 22px; flex-wrap: wrap; }
#overStats div { background: #0006; border-radius: 12px; padding: 8px 14px; font-size: 13px; }
#overStats b { display: block; font-family: var(--display); font-weight: 400; font-size: 22px; color: #ffd84a; }

@media (max-height: 700px) {
  .card .nm { display: none; }
  #elixirRow { margin-top: 7px; }
  #elixirBar { height: 20px; }
}

/* ───────── Erweiterung: alle Karten ───────── */
.card.r-legendary { background: linear-gradient(135deg, #7dfcff, #b38cff 35%, #ff9de0 65%, #ffe27a); }
.card.r-champion { background: linear-gradient(160deg, #fff3a0, #ffbf1f 45%, #b8670a); box-shadow: 0 3px 0 #0008, 0 0 10px #ffcf3a88; }
#filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
#filters::-webkit-scrollbar { display: none; }
#filters button, .mini {
  font-family: var(--display); font-size: 14px; color: #fff; cursor: pointer; white-space: nowrap;
  padding: 6px 12px; border-radius: 10px; border: 2px solid var(--ink); background: #3a2d7a; box-shadow: inset 0 -3px 0 #0004;
}
#filters button.on { background: linear-gradient(#5d9bff, #2f62d8); }
.toolRow { display: flex; justify-content: space-between; margin: 4px 0 10px; }
.mini { font-size: 13px; padding: 5px 10px; background: #2a2060; }
@media (min-width: 480px) { #collection { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

#abilityBtn {
  position: absolute; left: 14px; bottom: 26px; width: 62px; height: 62px; border-radius: 50%; padding: 0; z-index: 3;
  border: 3px solid #ffd84a; background: #000; overflow: visible; cursor: pointer; box-shadow: 0 4px 10px #000a;
  filter: grayscale(.6) brightness(.8); transition: transform .1s, filter .2s;
}
#abilityBtn.hidden { display: none; }
#abilityBtn img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
#abilityBtn .cdo { position: absolute; inset: 0; border-radius: 50%; }
#abilityBtn .drop { position: absolute; right: -6px; top: -6px; }
#abilityBtn .abName {
  position: absolute; left: -6px; bottom: -17px; white-space: nowrap;
  font-family: var(--display); font-size: 11px; background: #000c; padding: 1px 6px; border-radius: 6px;
}
#abilityBtn.ready { filter: none; animation: abil 1s infinite alternate; }
@keyframes abil { to { box-shadow: 0 0 0 4px #ffd84a88, 0 0 22px #ffd84a; } }
#abilityBtn:active { transform: scale(.92); }

#overDeck { margin: 0 0 18px; }
#overDeck small { opacity: .7; }
#overDeck .mini { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; padding: 6px; background: #0005; border: 0; box-shadow: none; margin-top: 4px; }
#overDeck img { width: 100%; border-radius: 6px; border: 2px solid var(--ink); }
