:root {
  --night: #120d1c;
  --night-2: #1b1429;
  --panel: #241a35;
  --panel-2: #2f2344;
  --edge: #07050b;
  --text: #ece4f7;
  --dim: #a99bbf;
  --gold: #f4c542;
  --gold-2: #c98d1d;
  --violet: #b072ff;
  --violet-2: #6d3fc4;
  --mint: #6ee7a8;
  --red: #e0524a;
  --grass: #5f9e37;
  --dirt: #6e4b2c;
  --px: "Press Start 2P", monospace;
  --serif: "Philosopher", Georgia, serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--night);
  background-image:
    radial-gradient(1200px 600px at 80% -10%, rgba(176, 114, 255, .18), transparent 60%),
    radial-gradient(900px 500px at -10% 40%, rgba(244, 197, 66, .07), transparent 60%);
  color: var(--text);
  font: 17px/1.55 var(--serif);
  min-height: 100vh;
  overflow-x: hidden;
  display: flex; flex-direction: column;
}
img { image-rendering: pixelated; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ── частицы зачарования ── */
.sparks { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.spark {
  position: absolute; bottom: -20px;
  font-family: var(--px); font-size: 10px;
  color: var(--violet); text-shadow: 0 0 8px currentColor;
  animation: rise linear infinite; opacity: 0;
}
.spark.gold { color: var(--gold); }
@keyframes rise {
  0% { transform: translate(0, 0); opacity: 0; }
  10% { opacity: .9; }
  90% { opacity: .6; }
  100% { transform: translate(var(--dx, 30px), -105vh); opacity: 0; }
}

/* ── шапка ── */
.hero { position: relative; min-height: 560px; display: flex; flex-direction: column; isolation: isolate; }
.hero-bg {
  position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(180deg, rgba(18, 13, 28, .35) 0%, rgba(40, 18, 70, .45) 45%, var(--night) 96%),
    url("img/hero.jpg") center 35% / cover no-repeat;
  filter: saturate(1.1);
}
.top { display: flex; justify-content: space-between; align-items: center; padding: 18px clamp(16px, 4vw, 48px); gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); }
.brand img { width: 40px; height: 40px; border: 3px solid var(--edge); box-shadow: 0 0 0 2px var(--gold-2); }
.brand span { font: 12px var(--px); letter-spacing: 1px; text-shadow: 2px 2px 0 #000; }

.hero-text { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 20px 16px 90px; }
.kicker { font: 10px var(--px); color: var(--mint); text-shadow: 2px 2px 0 #000; margin: 0 0 18px; letter-spacing: 1px; }
.logo {
  margin: 0; font: clamp(20px, 6.6vw, 76px)/1.1 var(--px); max-width: 100%; letter-spacing: 2px;
  color: #fff;
  text-shadow: 4px 4px 0 #3a2160, 8px 8px 0 rgba(0, 0, 0, .55), 0 0 40px rgba(176, 114, 255, .6);
}
.logo span {
  color: var(--gold);
  text-shadow: 4px 4px 0 #7a4c08, 8px 8px 0 rgba(0, 0, 0, .55), 0 0 40px rgba(244, 197, 66, .55);
}
.tagline { max-width: 620px; margin: 22px 0 0; font-size: 20px; font-style: italic; text-shadow: 0 2px 6px #000; }
.stats { display: flex; gap: 14px; margin-top: 28px; }
.stat {
  background: rgba(18, 13, 28, .75); border: 3px solid var(--edge);
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, .12), inset -2px -2px 0 rgba(0, 0, 0, .5);
  padding: 10px 18px; min-width: 120px;
}
.stat b { display: block; font: 16px var(--px); color: var(--gold); text-shadow: 2px 2px 0 #000; }
.stat span { font-size: 14px; color: var(--dim); }

/* полоса земли с травой */
.ground {
  position: absolute; left: 0; right: 0; bottom: 0; height: 48px;
  background:
    linear-gradient(180deg, transparent 0 14px, rgba(0,0,0,.25) 14px 16px, transparent 16px),
    repeating-linear-gradient(90deg, rgba(0,0,0,.18) 0 8px, transparent 8px 16px, rgba(255,255,255,.06) 16px 24px, transparent 24px 40px),
    linear-gradient(180deg, var(--grass) 0 14px, var(--dirt) 14px);
  border-top: 3px solid #3f6d22;
  box-shadow: 0 -2px 0 #8bc95a inset;
  -webkit-mask: linear-gradient(180deg, #000 60%, transparent);
          mask: linear-gradient(180deg, #000 60%, transparent);
  image-rendering: pixelated;
}

/* ── панели в стиле интерфейса Minecraft ── */
.panel {
  background: var(--panel);
  border: 4px solid var(--edge);
  box-shadow: inset 3px 3px 0 rgba(255, 255, 255, .1), inset -3px -3px 0 rgba(0, 0, 0, .45), 0 10px 30px rgba(0, 0, 0, .4);
}
.mc-btn {
  cursor: pointer; border: 3px solid var(--edge);
  background: linear-gradient(#6f6a7c, #4c4759);
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, .3), inset -2px -3px 0 rgba(0, 0, 0, .4);
  color: #f2f2f2; font: 10px/1 var(--px); padding: 12px 16px; letter-spacing: .5px;
  text-shadow: 2px 2px 0 #2b2b2b; transition: filter .12s, transform .06s;
  white-space: nowrap;
}
.mc-btn:hover { filter: brightness(1.15); outline: 2px solid #fff; outline-offset: -5px; }
.mc-btn:active { transform: translateY(1px); }
.mc-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.mc-btn:disabled { filter: grayscale(1) brightness(.7); cursor: default; outline: none; }
.mc-btn--gold { background: linear-gradient(#f4c542, #b97b12); color: #2a1800; text-shadow: 1px 1px 0 rgba(255,255,255,.35); }
.mc-btn--red { background: linear-gradient(#d4554c, #8f2621); }

/* ── основная часть ── */
.wrap { flex: 1; width: 100%; position: relative; z-index: 1; max-width: 1240px; margin: -10px auto 0; padding: 0 clamp(16px, 3vw, 32px) 60px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; padding: 14px; margin-bottom: 26px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  cursor: pointer; border: 3px solid var(--edge); background: var(--panel-2); color: var(--dim);
  font: 9px var(--px); padding: 9px 11px;
  box-shadow: inset 2px 2px 0 rgba(255,255,255,.08), inset -2px -2px 0 rgba(0,0,0,.35);
}
.chip:hover { color: var(--text); }
.chip.on { background: var(--violet-2); color: #fff; box-shadow: inset 2px 2px 0 rgba(255,255,255,.25), inset -2px -2px 0 rgba(0,0,0,.35), 0 0 14px rgba(176,114,255,.45); }
.chip small { opacity: .7; margin-left: 4px; }
.search { display: flex; align-items: center; gap: 8px; background: var(--night); border: 3px solid var(--edge); padding: 0 10px; flex: 0 1 280px; min-width: 0; }
.search span { color: var(--dim); }
.search input { background: none; border: 0; outline: 0; padding: 9px 0; width: 100%; min-width: 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 22px; }
.card { cursor: pointer; display: flex; flex-direction: column; transition: transform .15s, box-shadow .15s; animation: pop .35s both; }
.card:hover { transform: translateY(-4px); box-shadow: inset 3px 3px 0 rgba(255,255,255,.1), inset -3px -3px 0 rgba(0,0,0,.45), 0 0 0 2px var(--violet), 0 14px 34px rgba(109, 63, 196, .45); }
.card:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
@keyframes pop { from { opacity: 0; transform: translateY(10px); } }
.thumb { position: relative; aspect-ratio: 16 / 9; background: #0b0811 center / cover no-repeat; image-rendering: auto; border-bottom: 4px solid var(--edge); overflow: hidden; }
.thumb::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(0,0,0,.6)); }
.thumb.noimg { background-image: repeating-conic-gradient(#1e1630 0 25%, #171124 0 50%); background-size: 32px 32px; }
.play {
  position: absolute; left: 50%; top: 50%; translate: -50% -50%; z-index: 1;
  width: 56px; height: 56px; display: grid; place-items: center;
  background: rgba(18,13,28,.8); border: 3px solid var(--gold); color: var(--gold);
  font: 16px var(--px); opacity: 0; transition: opacity .15s, scale .15s; scale: .85;
}
.card:hover .play { opacity: 1; scale: 1; }
.dur { position: absolute; right: 8px; bottom: 8px; z-index: 1; font: 9px var(--px); background: rgba(0,0,0,.75); padding: 5px 6px; }
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-body h3 { margin: 0; font-size: 19px; line-height: 1.25; overflow-wrap: anywhere; }
.card-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--dim); font-size: 14px; margin-top: auto; }
.badge { font: 8px var(--px); padding: 5px 7px; background: var(--violet-2); color: #fff; border: 2px solid var(--edge); }
.badge[data-cat="Боссы"] { background: #a8322b; }
.badge[data-cat="Постройки"] { background: #3d7d33; }
.badge[data-cat="Приключения"] { background: #2b6aa8; }
.badge[data-cat="Сюжет"] { background: #7a4fc9; }
.badge[data-cat="Прочее"] { background: #5b5566; }

.empty { text-align: center; padding: 48px 20px; }
.empty h2 { font: 16px var(--px); color: var(--gold); text-shadow: 2px 2px 0 #000; margin: 22px 0 8px; }
.empty p { color: var(--dim); margin: 0 0 22px; }
.chest {
  width: 72px; height: 64px; margin: 0 auto; position: relative;
  background: linear-gradient(180deg, #a86f2c 0 40%, #2a1a0b 40% 46%, #8e5a1f 46%);
  border: 4px solid var(--edge); box-shadow: inset 3px 3px 0 rgba(255,255,255,.2), inset -3px -3px 0 rgba(0,0,0,.35);
  animation: bob 2.4s ease-in-out infinite;
}
.chest::after { content: ""; position: absolute; left: 50%; top: 32%; width: 12px; height: 16px; translate: -50% 0; background: #cfd3d6; border: 3px solid var(--edge); }
@keyframes bob { 50% { transform: translateY(-6px); } }

.foot { position: relative; z-index: 1; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 22px clamp(16px, 4vw, 48px); border-top: 4px solid var(--edge); background: #0d0915; font: 9px/1.8 var(--px); }
.dim { color: var(--dim); }

/* ── окна ── */
.dlg { border: 0; padding: 0; background: none; color: var(--text); width: min(620px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
.dlg--wide { width: min(1040px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgba(8, 5, 14, .78); backdrop-filter: blur(3px); }
.dlg[open] { animation: pop .2s both; }
.dlg-body { position: relative; padding: 22px; }
.dlg-title { font: 13px/1.5 var(--px); color: var(--gold); margin: 0 0 18px; text-shadow: 2px 2px 0 #000; }
.row { display: flex; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 6px; font: 9px var(--px); color: var(--dim); min-width: 150px; }
.field.grow { flex: 1; }
.field input, .field select, .field textarea {
  font: 16px var(--serif); background: var(--night); border: 3px solid var(--edge); color: var(--text);
  padding: 9px 10px; outline: none; resize: vertical;
  box-shadow: inset 2px 2px 0 rgba(0,0,0,.4);
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--violet); }
.err { color: var(--red); min-height: 1.2em; margin: 10px 0 0; font-size: 15px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.grow { flex: 1; }
.preview { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 8px; background: var(--night-2); border: 3px solid var(--edge); }
.preview img { width: 120px; aspect-ratio: 16/9; object-fit: cover; border: 2px solid var(--edge); image-rendering: auto; }
.preview span { font-size: 15px; color: var(--dim); overflow-wrap: anywhere; }
.card { text-decoration: none; color: inherit; position: relative; }
.yt { position: absolute; left: 8px; bottom: 8px; z-index: 1; font: 8px var(--px); background: #c4302b; color: #fff; padding: 5px 6px; border: 2px solid var(--edge); }
.card-edit {
  position: absolute; right: 8px; top: 8px; z-index: 2; cursor: pointer;
  width: 34px; height: 34px; display: grid; place-items: center;
  background: rgba(18,13,28,.85); border: 3px solid var(--edge); color: var(--text); font-size: 15px;
  opacity: 0; transition: opacity .15s;
}
.card:hover .card-edit, .card:focus-within .card-edit { opacity: 1; }
.card-edit:hover { color: var(--gold); }
.card-desc { margin: 0; color: var(--dim); font-size: 15px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.field + .row, .field + .preview { margin-top: 14px; }
@media (hover: none) { .card-edit { opacity: 1; } }

@media (max-width: 600px) {
  .hero { min-height: 480px; }
  .brand span { display: none; }
  .top .mc-btn { padding: 10px 12px; font-size: 9px; }
  .stats { width: 100%; max-width: 260px; }
  .tagline { font-size: 18px; }
  .stats { flex-direction: column; gap: 10px; }
  .search { flex: 1 1 100%; }
  .dlg-body { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .spark, .chest, .card, .dlg[open] { animation: none; }
}

/* ── вход ── */
.login { max-width: 420px; margin: 20px auto 0; padding: 28px 24px; text-align: center; }
.login-icon { width: 64px; height: 64px; border: 3px solid var(--edge); box-shadow: 0 0 0 2px var(--gold-2), 0 0 30px rgba(176,114,255,.5); }
.login .dlg-title { margin: 16px 0 6px; }
.login > p { margin: 0 0 18px; font-size: 15px; }
.login form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.login .mc-btn { align-self: stretch; padding: 14px; }
.remember { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--dim); cursor: pointer; }
.remember input { accent-color: var(--violet); width: 16px; height: 16px; }
.login .err { margin: 0; min-height: 0; }
.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
