/* ============================================================
   KENOS CRAFT — player cabinet
   Тот же войд-язык, что у лендинга (style.css): живой звёздный
   фон (void.js), плёнка-грейн, виньетка, кастомный курсор.
   Два состояния: премиум-окно ЛОГИНА → дашборд с секциями
   (Overview / Shop / Wallet / Account).
   ============================================================ */

:root {
  --bg: #070512;
  --bg-deep: #040309;
  --panel: rgba(18, 14, 36, 0.55);
  --panel-2: rgba(28, 22, 52, 0.42);
  --ink: #e8e6f2;
  --ink-dim: #9b96b4;
  --ink-faint: #565170;
  --mint: #7dd8ff;
  --mint-dim: rgba(125, 216, 255, 0.35);
  --violet: #8b7bff;
  --ghost: #cfc4ff;
  --line: rgba(155, 150, 180, 0.16);
  --line-bright: rgba(125, 216, 255, 0.4);
  --danger: #ff7a8a;
  --ok: #74e0a8;
  --font-display: "Clash Display", sans-serif;
  --font-body: "General Sans", sans-serif;
  --font-mono: "Martian Mono", monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* Атрибут hidden ДОЛЖЕН побеждать классы с display ниже (.boot/.portal/.app/.view),
   иначе скрытые состояния (загрузка, неактивные секции) остаются видимыми. */
[hidden] { display: none !important; }

html { scroll-behavior: auto; }

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  cursor: none;
}

img, canvas { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: none; }
::selection { background: var(--mint); color: var(--bg-deep); }
strong { color: var(--ghost); font-weight: 600; }
.accent { color: var(--mint); }
.mono { font-family: var(--font-mono); letter-spacing: 0.08em; }

@media (pointer: coarse), (max-width: 820px) {
  body, button { cursor: auto; }
  .cursor { display: none; }
}

/* ============ ATMOSPHERE (как у лендинга) ============ */
.void-canvas {
  position: fixed; inset: 0; z-index: 0;
  width: 100%; height: 100%; pointer-events: none;
}
.grain {
  position: fixed; inset: -50%; z-index: 90; pointer-events: none; opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='256' height='256'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain-shift 0.9s steps(4) infinite;
}
@keyframes grain-shift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-2%, 3%); }
  50% { transform: translate(3%, -2%); }
  75% { transform: translate(-3%, -3%); }
  100% { transform: translate(2%, 2%); }
}
.vignette {
  position: fixed; inset: 0; z-index: 89; pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(4, 3, 9, 0.6) 100%);
}

/* ---- кастомный курсор ---- */
.cursor { position: fixed; top: 0; left: 0; z-index: 999; pointer-events: none; }
.cursor__dot {
  position: absolute; width: 6px; height: 6px; margin: -3px 0 0 -3px;
  background: var(--mint); border-radius: 50%;
}
.cursor__ring {
  position: absolute; width: 34px; height: 34px; margin: -17px 0 0 -17px;
  border: 1px solid var(--mint-dim); border-radius: 50%;
  transition: border-color 0.25s ease;
}
.cursor.is-hover .cursor__ring { border-color: var(--mint); }

@media (max-width: 820px) {
  .grain { display: none; }
}

/* ============ BOOT ============ */
.boot { position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; pointer-events: none; }
.boot__spin {
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--mint);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   LOGIN PORTAL — отдельное полноэкранное окно входа
   ============================================================ */
.portal {
  position: relative; z-index: 2;
  min-height: 100vh; display: grid; place-items: center;
  padding: 80px 20px 60px;
}
.portal__back {
  position: fixed; top: 26px; left: clamp(18px, 5vw, 48px); z-index: 6;
  font-size: 10px; letter-spacing: 0.22em; color: var(--ink-faint);
  display: inline-flex; align-items: center; gap: 8px; transition: color 0.25s ease;
}
.portal__back:hover { color: var(--mint); }

.portal__card {
  position: relative;
  z-index: 1;                 /* над .portal__glow (z:0), которое теперь снаружи карточки */
  width: 100%; max-width: 430px;
  padding: clamp(30px, 5vw, 46px) clamp(26px, 5vw, 42px) clamp(28px, 4vw, 38px);
  text-align: center;
  background:
    linear-gradient(180deg, rgba(20, 16, 40, 0.72), rgba(10, 8, 24, 0.66));
  border: 1px solid var(--line);
  border-radius: 22px;
  backdrop-filter: blur(14px);
  box-shadow:
    0 40px 120px -50px rgba(0, 0, 0, 0.95),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  overflow: hidden;
  animation: portal-in 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}
/* верхняя неоновая кромка карточки */
.portal__card::before {
  content: ""; position: absolute; top: 0; left: 14%; right: 14%; height: 1px;
  background: linear-gradient(90deg, transparent, var(--mint), transparent);
}
/* мягкое пульсирующее свечение ЗА карточкой (сиблинг .portal__card,
   позиционируется в центре .portal — иначе overflow карточки его срезал) */
.portal__glow {
  position: absolute; z-index: 0;
  top: 50%; left: 50%;
  width: min(540px, 92vw); height: 420px;
  transform: translate(-50%, -56%);
  background: radial-gradient(closest-side, rgba(139, 123, 255, 0.45), transparent 72%);
  filter: blur(34px); opacity: 0.55;
  animation: portal-pulse 6s ease-in-out infinite;
  pointer-events: none;
}
@keyframes portal-pulse {
  0%, 100% { opacity: 0.4; transform: translate(-50%, -56%) scale(1); }
  50% { opacity: 0.72; transform: translate(-50%, -52%) scale(1.06); }
}
@keyframes portal-in {
  from { opacity: 0; transform: translateY(18px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.portal__logo {
  width: 52px; height: 52px; margin: 0 auto 22px;
  filter: drop-shadow(0 0 16px rgba(125, 216, 255, 0.4));
}
.portal__label { font-size: 10px; color: var(--mint); letter-spacing: 0.32em; }
.portal__title {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(28px, 6vw, 38px); line-height: 1.04; margin-top: 14px;
}
.portal__hint { color: var(--ink-dim); font-size: 13.5px; margin-top: 14px; }
.portal__foot { font-size: 10px; color: var(--ink-faint); letter-spacing: 0.1em; margin-top: 22px; }

/* ---- forms ---- */
.form { margin-top: 26px; display: grid; gap: 15px; text-align: left; }
.form--compact { margin-top: 18px; gap: 13px; max-width: 420px; }
.field { display: grid; gap: 7px; }
.field__label { font-size: 9.5px; color: var(--ink-faint); letter-spacing: 0.2em; }
.field__input {
  width: 100%; font: inherit; font-size: 15px; color: var(--ink);
  background: rgba(7, 5, 18, 0.65); border: 1px solid var(--line); border-radius: 11px;
  padding: 13px 15px; transition: 0.18s; outline: none; cursor: text;
}
.field__input::placeholder { color: var(--ink-faint); }
.field__input:focus { border-color: var(--line-bright); box-shadow: 0 0 0 3px rgba(125, 216, 255, 0.12); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.16em;
  padding: 14px 22px; border-radius: 11px; border: 1px solid transparent; transition: 0.18s;
}
.btn--primary { background: var(--mint); color: #06121a; font-weight: 700; width: 100%; }
.btn--primary:hover { box-shadow: 0 0 26px -6px var(--mint); transform: translateY(-1px); }
.btn--ghost { border-color: var(--line); color: var(--ink-dim); }
.btn--ghost:hover { border-color: var(--line-bright); color: var(--ink); }
.btn[disabled] { opacity: 0.55; pointer-events: none; }
.btn.is-busy .btn__text { opacity: 0.5; }

.form__error, .form__msg { font-size: 12px; letter-spacing: 0.02em; min-height: 1px; }
.form__error { color: var(--danger); }
.form__msg.is-err { color: var(--danger); }
.form__msg.is-ok { color: var(--ok); }

/* ============================================================
   APP — дашборд после входа
   ============================================================ */
.app { position: relative; z-index: 2; min-height: 100vh; display: flex; flex-direction: column; }

/* ---- верхняя панель ---- */
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  padding: 14px clamp(16px, 4vw, 44px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(7, 5, 18, 0.78), rgba(7, 5, 18, 0.18));
}
.appbar__logo { display: flex; align-items: center; gap: 11px; flex: 0 0 auto; }
.appbar__logo img { filter: drop-shadow(0 0 8px rgba(125, 216, 255, 0.3)); }
.appbar__name { font-family: var(--font-display); font-weight: 600; letter-spacing: 0.04em; font-size: 17px; }

.appnav { display: flex; gap: 4px; margin: 0 auto; }
.appnav__item {
  position: relative; font-size: 10.5px; letter-spacing: 0.16em; color: var(--ink-dim);
  padding: 10px 14px; border-radius: 9px; transition: color 0.2s ease, background 0.2s ease;
}
.appnav__item:hover { color: var(--ink); }
.appnav__item.is-active { color: var(--mint); background: rgba(125, 216, 255, 0.07); }
.appnav__item.is-active::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: 3px; height: 1px;
  background: var(--mint); box-shadow: 0 0 8px var(--mint);
}

.appbar__right { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; margin-left: auto; }
.userchip {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 6px 12px 6px 6px; border: 1px solid var(--line); border-radius: 999px;
  font-size: 13px; color: var(--ink);
}
.userchip__av {
  width: 24px; height: 24px; border-radius: 50%;
  background: linear-gradient(140deg, var(--violet), var(--mint));
  display: grid; place-items: center; color: #06121a;
  font-family: var(--font-display); font-weight: 700; font-size: 12px;
}
.appbar__logout {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.16em; color: var(--ink-dim);
  border: 1px solid var(--line); border-radius: 999px; padding: 9px 15px; transition: 0.2s;
}
.appbar__logout:hover { color: var(--ink); border-color: var(--line-bright); }

/* ---- область контента ---- */
.appmain {
  flex: 1; width: 100%; max-width: 1080px; margin: 0 auto;
  padding: clamp(26px, 5vw, 52px) clamp(16px, 4vw, 44px) 90px;
}
.view { display: grid; gap: 24px; animation: view-in 0.4s ease both; }
@keyframes view-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.section-head h2 { font-family: var(--font-display); font-weight: 600; font-size: clamp(22px, 4vw, 30px); }
.section-head .mono { font-size: 10px; color: var(--ink-faint); letter-spacing: 0.2em; }

/* ---- карточка идентичности (Overview) ---- */
.idcard {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: clamp(20px, 4vw, 30px); display: flex; align-items: center; gap: 20px;
}
.avatar {
  width: 66px; height: 66px; border-radius: 16px; flex: 0 0 auto;
  background: linear-gradient(140deg, var(--violet), var(--mint));
  display: grid; place-items: center; color: #06121a;
  font-family: var(--font-display); font-weight: 700; font-size: 27px;
  box-shadow: 0 0 30px -10px var(--mint);
}
.idcard__greet { font-size: 9.5px; color: var(--ink-faint); letter-spacing: 0.22em; }
.idcard__name { font-family: var(--font-display); font-weight: 600; font-size: clamp(24px, 5vw, 34px); line-height: 1.1; margin: 4px 0 10px; }
.idcard__meta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.badge {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase;
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-dim);
}
.badge[data-tier="serf"]      { color: #9b96b4; border-color: rgba(155,150,180,0.4); }
.badge[data-tier="freeman"]   { color: #7dd8ff; border-color: rgba(125,216,255,0.5); }
.badge[data-tier="knight"]    { color: #8b7bff; border-color: rgba(139,123,255,0.55); }
.badge[data-tier="baron"]     { color: #ffcf6b; border-color: rgba(255,207,107,0.55); }
.badge[data-tier="sovereign"] { color: #ff9bd6; border-color: rgba(255,155,214,0.6); box-shadow: 0 0 18px -6px #ff9bd6; }

.status { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-dim); }
.status i { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-faint); }
.status.is-online i { background: var(--ok); box-shadow: 0 0 10px var(--ok); }

/* ---- сетка статов ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.card {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 16px;
  padding: 20px 22px; position: relative; overflow: hidden;
}
.card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--mint), transparent); opacity: 0.5;
}
.card__label { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.2em; color: var(--ink-faint); }
.card__value { font-family: var(--font-display); font-weight: 600; font-size: clamp(26px, 5vw, 34px); margin-top: 8px; line-height: 1; font-variant-numeric: tabular-nums; }
.card__sub { font-size: 11.5px; color: var(--ink-dim); margin-top: 8px; }
.card__value.is-empty { color: var(--ink-faint); }
.card__spark { margin-top: 12px; width: 100%; height: 34px; display: block; }
.card__spark path { fill: none; stroke: var(--mint); stroke-width: 2; }
.card__spark .area { fill: url(#sparkfill); stroke: none; }

/* ---- общая панель ---- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: clamp(20px, 4vw, 28px); }
.panel__title { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-faint); letter-spacing: 0.22em; margin-bottom: 8px; }
.panel__lead { color: var(--ink-dim); font-size: 14px; margin-bottom: 18px; }

.action { border-top: 1px solid var(--line); padding-top: 6px; }
.action__summary {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  list-style: none; cursor: none; padding: 14px 0; font-size: 15px; color: var(--ink);
}
@media (pointer: coarse), (max-width: 820px) { .action__summary { cursor: pointer; } }
.action__summary::-webkit-details-marker { display: none; }
.action__summary::after { content: "+"; color: var(--mint); font-size: 20px; line-height: 1; }
details[open] .action__summary::after { content: "\2013"; }
.action__hint { font-size: 9.5px; color: var(--ink-faint); letter-spacing: 0.12em; }

.note { font-size: 11px; color: var(--ink-faint); letter-spacing: 0.04em; }

/* ============ SHOP / WALLET — фундамент ("скоро") ============ */
.soon-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; border: 1px dashed var(--line-bright); border-radius: 14px;
  background: rgba(125, 216, 255, 0.04); color: var(--ink-dim); font-size: 13.5px;
}
.soon-banner b { color: var(--mint); font-weight: 600; }

.pill-soon {
  font-family: var(--font-mono); font-size: 8.5px; letter-spacing: 0.2em; color: var(--mint);
  border: 1px solid var(--mint-dim); border-radius: 999px; padding: 3px 9px;
}

/* плитки магазина */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.tile {
  position: relative; background: var(--panel-2); border: 1px solid var(--line); border-radius: 16px;
  padding: 24px 22px; display: grid; gap: 10px; transition: border-color 0.3s ease, transform 0.3s ease;
}
.tile.is-locked { opacity: 0.72; }
.tile__icon { font-family: var(--font-mono); font-size: 22px; color: var(--mint); }
.tile__name { font-family: var(--font-display); font-weight: 600; font-size: 19px; }
.tile__desc { color: var(--ink-dim); font-size: 13.5px; }
.tile__foot { display: flex; align-items: center; justify-content: flex-end; margin-top: 4px; }

/* строки кошелька / методов пополнения */
.method { display: flex; align-items: center; gap: 16px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel-2); }
.method.is-locked { opacity: 0.72; }
.method__icon { font-family: var(--font-mono); font-size: 20px; color: var(--mint); width: 28px; text-align: center; flex: 0 0 auto; }
.method__body { flex: 1; }
.method__name { font-weight: 600; color: var(--ink); }
.method__desc { font-size: 12.5px; color: var(--ink-dim); }
.method__cta { flex: 0 0 auto; }
.stack { display: grid; gap: 12px; }

/* ---- member-since строка на id-карте ---- */
.idcard__since { margin-top: 10px; font-size: 10px; color: var(--ink-faint); letter-spacing: 0.08em; }

/* ============ PREFERENCES — тоглы ============ */
.pref {
  display: flex; align-items: center; gap: 16px; padding: 16px 18px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--panel-2);
}
.pref__text { flex: 1; min-width: 0; }
.pref__label { font-weight: 600; color: var(--ink); }
.pref__desc { font-size: 12.5px; color: var(--ink-dim); margin-top: 2px; }
.pref__flash { font-size: 9.5px; letter-spacing: 0.12em; color: var(--ink-faint); flex: 0 0 auto; }
.pref__flash.is-ok { color: var(--ok); }
.pref__flash.is-err { color: var(--danger); }

/* переключатель */
.switch {
  flex: 0 0 auto; border: 0; background: none; padding: 4px; cursor: none;
  border-radius: 999px;
}
@media (pointer: coarse), (max-width: 820px) { .switch { cursor: pointer; } }
.switch__track {
  display: block; width: 46px; height: 26px; border-radius: 999px;
  background: rgba(155, 150, 180, 0.18); border: 1px solid var(--line);
  position: relative; transition: background 0.25s ease, border-color 0.25s ease;
}
.switch__thumb {
  position: absolute; top: 50%; left: 3px; transform: translateY(-50%);
  width: 18px; height: 18px; border-radius: 50%; background: var(--ink-dim);
  transition: left 0.25s ease, background 0.25s ease;
}
.switch.is-on .switch__track { background: rgba(125, 216, 255, 0.22); border-color: var(--line-bright); }
.switch.is-on .switch__thumb { left: 23px; background: var(--mint); box-shadow: 0 0 10px var(--mint); }
.switch.is-unknown .switch__track { border-style: dashed; }
.switch.is-busy { opacity: 0.5; }
.switch:hover .switch__track { border-color: var(--line-bright); }

/* ---- responsive ---- */
@media (max-width: 760px) {
  .appbar { flex-wrap: wrap; }
  .appbar__logo { order: 1; }
  .appbar__right { order: 2; margin-left: auto; }
  .appnav {
    order: 3; width: 100%; margin: 4px -4px -2px; padding: 4px;
    overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .appnav::-webkit-scrollbar { display: none; }
  .appnav__item { flex: 0 0 auto; }
}
@media (max-width: 480px) {
  .idcard { flex-direction: column; align-items: flex-start; }
  .cards { grid-template-columns: 1fr 1fr; }
  .appbar__name { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .boot__spin, .grain, .portal__glow, .portal__card, .view { animation: none; }
  .btn--primary:hover { transform: none; }
}
