:root {
  --bg: #14001f; --bg2: #1f0533; --panel: #26093d; --line: #4b1d6b;
  --green: #39ff14; --yellow: #ffe600; --pink: #ff2bd6; --cyan: #19f3ff; --red: #ff3b3b; --orange: #ff8a00;
  --text: #f6eaff; --dim: #b89ccc;
  --title: Impact, 'Arial Black', 'Segoe UI Black', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 20% -10%, #3a0a5c 0%, transparent 60%),
              radial-gradient(900px 500px at 110% 10%, #4d0040 0%, transparent 55%), var(--bg);
  color: var(--text); font: 14px/1.4 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh; padding-bottom: 40px;
}
button { font: inherit; color: inherit; cursor: pointer; }
h2 { font-family: var(--title); font-weight: 400; letter-spacing: .5px; font-size: 18px; margin: 0 0 10px; color: var(--yellow); }
.sub { color: var(--dim); font-size: 12px; }
.hidden { display: none !important; }

/* ---------- шапка ---------- */
.top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 2px solid var(--pink);
  background: linear-gradient(90deg, #2a0045, #14001f 60%, #2a0030); box-shadow: 0 0 24px #ff2bd655; }
.brand { flex: 1 1 260px; min-width: 0; }
.logo { margin: 0; font-family: var(--title); font-weight: 400; font-size: 30px; line-height: 1; letter-spacing: 1px;
  color: var(--green); text-shadow: 0 0 8px #39ff14aa, 3px 3px 0 #000; }
.logo span { color: var(--pink); text-shadow: 0 0 10px #ff2bd6, 3px 3px 0 #000; }
.studio { color: var(--dim); font-size: 12px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.studio b { color: var(--cyan); }
.fake-timer { border: 2px solid var(--yellow); background: #000; color: var(--yellow); border-radius: 8px; padding: 6px 10px;
  font-family: var(--title); letter-spacing: .5px; animation: blink 1s steps(2) infinite; }
.fake-timer b { color: var(--red); font-variant-numeric: tabular-nums; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs button { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 11px; }
.tabs button.on { border-color: var(--green); box-shadow: 0 0 10px #39ff1466; color: var(--green); }
.icon-btn { min-width: 40px; }

/* ---------- ресурсы ---------- */
.res { position: sticky; top: 0; z-index: 20; display: grid; grid-template-columns: 1fr 1fr 2fr; gap: 10px; padding: 10px 16px;
  background: #14001fee; backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.r { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; min-width: 0; }
.r-lbl { font-size: 12px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-val { font-family: var(--title); font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.r-hype .r-val { color: var(--orange); } .r-money .r-val { color: var(--yellow); }
.r-sub { font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }
.face { font-size: 18px; vertical-align: -2px; }
.thermo { position: relative; height: 16px; margin: 6px 0 4px; border-radius: 10px; background: #0c0014; border: 1px solid var(--line); overflow: hidden; }
.thermo i { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 10px; transition: width .25s;
  background: #39ff14; box-shadow: 0 0 10px currentColor; }
.thermo em { position: absolute; top: 0; bottom: 0; width: 1px; background: #ffffff55; }
.r-tox.z1 { border-color: #ffe60088; } .r-tox.z2 { border-color: var(--orange); box-shadow: 0 0 14px #ff8a0055; }
.r-tox.z3 { border-color: var(--red); box-shadow: 0 0 18px #ff3b3b88; animation: pulse 1s infinite; }
.effects { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; min-height: 0; }
.effects:empty { display: none; }
.eff { font-size: 12px; padding: 3px 8px; border-radius: 20px; background: #000a; border: 1px solid var(--line); }
.eff.bad { border-color: var(--red); color: #ffb3b3; } .eff.good { border-color: var(--green); color: #c8ffbd; }

/* ---------- раскладка ---------- */
.tab { display: none; padding: 14px 16px; }
.tab.on { display: block; }
#tab-game.on { display: grid; grid-template-columns: 300px 1fr 320px; gap: 14px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.panel-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* ---------- кликер ---------- */
.clicker { text-align: center; }
.big-btn { position: relative; width: 100%; aspect-ratio: 1.6; border-radius: 22px; border: 4px solid var(--yellow);
  background: radial-gradient(circle at 50% 35%, #ff5be3, #b8009a 60%, #6a0059); color: #fff;
  font-family: var(--title); font-size: 30px; line-height: 1; text-shadow: 3px 3px 0 #000;
  box-shadow: 0 0 0 4px #000, 0 0 30px #ff2bd6aa, inset 0 -8px 0 #0004; animation: glow 1.6s infinite; user-select: none; touch-action: manipulation; }
.big-btn:active { transform: scale(.96); }
.big-btn small { display: block; font-size: 15px; margin-top: 8px; color: var(--yellow); }
.hint { margin-top: 8px; font-size: 12px; color: var(--dim); }
.floater { position: fixed; pointer-events: none; z-index: 60; font-family: var(--title); color: var(--orange); font-size: 20px;
  text-shadow: 2px 2px 0 #000; animation: floatUp .9s ease-out forwards; }

/* ---------- строки и кнопки ---------- */
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px dashed var(--line); }
.row:first-of-type { border-top: 0; }
.row > div { min-width: 0; }
.lvl { color: var(--cyan); font-size: 12px; }
.buy { position: relative; border: 2px solid var(--green); background: linear-gradient(#2d6b12, #164a05); color: #fff; border-radius: 10px;
  padding: 7px 10px; font-weight: 700; white-space: nowrap; box-shadow: 0 0 10px #39ff1444; }
.buy:not(:disabled):hover { filter: brightness(1.2); }
.buy:not(:disabled) { animation: borderBlink 1.2s infinite; }
.buy:disabled { cursor: not-allowed; border-color: #555; background: #2a2433; color: #8d8199; box-shadow: none; animation: none; }
.buy.hype:not(:disabled) { border-color: var(--orange); background: linear-gradient(#8a3c00, #552300); }
.buy.free:not(:disabled) { border-color: var(--cyan); background: linear-gradient(#00627a, #003a4a); }
.buy.danger:not(:disabled) { border-color: var(--red); background: linear-gradient(#a3001e, #5c0011); }
.buy.small { font-size: 12px; padding: 6px 9px; }
.buy.wide { width: 100%; padding: 12px; font-family: var(--title); font-weight: 400; font-size: 18px; letter-spacing: .5px; }
.buy .old { text-decoration: line-through; color: #ff9b9b; font-weight: 400; font-size: 11px; }
.buy .disc { display: inline-block; background: var(--red); color: #fff; font-size: 10px; padding: 1px 4px; border-radius: 4px; margin-left: 3px; transform: rotate(-4deg); }
.buy:disabled .disc { background: #555; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

/* ---------- механики ---------- */
.mechs { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-top: 8px; }
.mech { position: relative; background: linear-gradient(160deg, #2e0b4a, #1d0630); border: 1px solid var(--line); border-radius: 14px; padding: 11px;
  display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.mech.on { border-color: #39ff1488; box-shadow: 0 0 14px #39ff1422; }
.mech.off { opacity: .8; border-style: dashed; }
.mech.next { border-color: var(--yellow); box-shadow: 0 0 14px #ffe60033; }
.mech.hidden-m { filter: grayscale(1) brightness(.5); }
.mech.hidden-m .m-flavor, .mech.hidden-m .m-stats, .mech.hidden-m .m-extra, .mech.hidden-m .buy, .mech.hidden-m .switch, .mech.hidden-m .m-bar { display: none; }
.mech.locked .switch, .mech.locked .m-bar, .mech.locked .m-extra { display: none; }
.m-head { display: flex; align-items: center; gap: 9px; }
.m-icon { font-size: 30px; line-height: 1; }
.m-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.m-title b { font-size: 14px; }
.m-lvl { font-size: 12px; color: var(--cyan); }
.m-flavor { font-size: 12px; font-style: italic; color: #e2c9f5; }
.m-stats { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.m-inc { color: var(--yellow); } .m-tox { color: #ff9b9b; }
.m-extra { font-size: 11px; color: var(--dim); min-height: 0; }
.m-extra:empty { display: none; }
.m-bar { height: 5px; background: #0c0014; border-radius: 4px; overflow: hidden; }
.m-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), var(--pink)); }
.mech .buy { width: 100%; white-space: normal; }
.mech .stamp { position: absolute; top: 8px; right: 52px; font-size: 10px; background: var(--yellow); color: #000; padding: 1px 5px; border-radius: 4px; transform: rotate(6deg); font-weight: 800; }
.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: #3a2a46; border-radius: 20px; transition: .2s; cursor: pointer; border: 1px solid var(--line); }
.switch span::before { content: ''; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px; background: #ccc; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: #1d7a07; border-color: var(--green); }
.switch input:checked + span::before { transform: translateX(18px); background: #fff; }
.switch input:focus-visible + span { outline: 2px solid var(--cyan); }

/* ---------- персонал ---------- */
.staff { padding: 9px 0; border-top: 1px dashed var(--line); display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 5px 8px; align-items: center; }
.staff .s-icon { grid-row: span 3; align-self: start; }
.staff .buy { grid-column: 2; justify-self: start; max-width: 100%; }
.staff:first-child { border-top: 0; }
.staff .s-icon { font-size: 24px; }
.staff .s-name b { font-size: 13px; }
.staff .s-cnt { color: var(--cyan); font-size: 12px; }
.staff .s-desc { grid-column: 2; font-size: 11px; color: var(--dim); }
.staff .s-joke { font-style: italic; color: #e2c9f5; }
.staff.locked { opacity: .55; }

/* ---------- лента ---------- */
.log { max-height: 420px; overflow: auto; display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.log div { padding: 6px 8px; border-radius: 8px; background: #0005; border-left: 3px solid var(--line); }
.log .event { border-color: var(--orange); } .log .ach { border-color: var(--yellow); } .log .dead { border-color: var(--red); background: #3a0010; }
.log .crisis { border-color: var(--cyan); } .log .scandal { border-color: var(--pink); } .log .unlock { border-color: var(--green); }
.log .award { border-color: var(--yellow); background: #3a3000; } .log .prestige { border-color: var(--pink); }
.log time { color: var(--dim); margin-right: 5px; font-variant-numeric: tabular-nums; }

/* ---------- ачивки / стата / престиж ---------- */
.ach-cat { margin: 16px 0 8px; font-family: var(--title); font-size: 16px; color: var(--cyan); letter-spacing: .5px; }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.ach { display: flex; gap: 10px; padding: 9px; border-radius: 10px; background: #0005; border: 1px solid var(--line); opacity: .55; }
.ach.got { opacity: 1; border-color: var(--yellow); background: linear-gradient(135deg, #3d2a00, #1d0630); }
.ach .a-ico { font-size: 22px; }
.ach b { display: block; font-size: 13px; }
.ach .sub { font-size: 11px; }
.ach.clickable { cursor: pointer; opacity: .8; border-style: dashed; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 18px; }
.stats div { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.stats div span:last-child { text-align: right; color: var(--yellow); font-variant-numeric: tabular-nums; }
.stats .wide { grid-column: 1 / -1; display: block; }
.stats .wide span:last-child { display: block; text-align: left; color: var(--dim); margin-top: 4px; }
.prestige { max-width: 760px; margin: 0 auto; }
.pp-bar { height: 18px; border-radius: 10px; background: #0c0014; border: 1px solid var(--line); overflow: hidden; }
.pp-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--pink), var(--yellow)); }
.names { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; margin: 16px 0; }
.names div { background: #0005; border-radius: 10px; padding: 10px; }
.names b { display: block; color: var(--cyan); }
.names .arrow { background: none; font-size: 24px; }
.gain { font-size: 16px; color: var(--green); }

/* ---------- тосты, модалки, конфетти ---------- */
.toasts { position: fixed; right: 12px; bottom: 12px; z-index: 70; display: flex; flex-direction: column-reverse; gap: 8px; width: min(360px, calc(100vw - 24px)); pointer-events: none; }
.toast { pointer-events: auto; background: #1d0630f2; border: 2px solid var(--pink); border-radius: 12px; padding: 9px 12px; font-size: 13px;
  box-shadow: 0 6px 24px #000a; animation: toastIn .3s ease-out; }
.toast.tach { border-color: var(--yellow); background: linear-gradient(135deg, #4a3500f2, #1d0630f2); }
.toast.social { border-color: var(--cyan); }
.toast.bad { border-color: var(--red); }
.toast.buyp { border-color: var(--green); }
.toast .t-h { font-family: var(--title); letter-spacing: .5px; color: var(--yellow); display: block; margin-bottom: 2px; }
.toast.out { animation: toastOut .35s forwards; }
.modal-bg { position: fixed; inset: 0; z-index: 80; background: #000b; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--panel); border: 2px solid var(--pink); border-radius: 16px; padding: 18px; max-width: 520px; width: 100%; box-shadow: 0 0 40px #ff2bd666; max-height: 90vh; overflow: auto; }
.modal h3 { font-family: var(--title); font-weight: 400; font-size: 22px; margin: 0 0 10px; color: var(--yellow); }
.modal p { margin: 8px 0; }
.modal .btns { justify-content: flex-end; }
.modal pre { background: #000; color: var(--green); padding: 10px; border-radius: 8px; overflow: auto; font-size: 12px; }
.modal textarea { width: 100%; min-height: 90px; background: #0c0014; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px; font: 12px monospace; }
.confetti { position: fixed; z-index: 75; pointer-events: none; font-size: 18px; animation: fly 1.1s ease-out forwards; }
.shake { animation: shake .5s; }
.flash-red::after { content: ''; position: fixed; inset: 0; background: #ff000033; pointer-events: none; z-index: 90; animation: fade 1s forwards; }
.foot { text-align: center; color: var(--dim); font-size: 11px; padding: 10px 16px; }
.self-ad { border: 2px dashed var(--yellow); text-align: center; }
.ad-tag { display: inline-block; font-size: 10px; background: var(--yellow); color: #000; padding: 1px 6px; border-radius: 4px; margin-bottom: 4px; }
.scandal { border-color: var(--pink); box-shadow: 0 0 16px #ff2bd644; }

@keyframes blink { 50% { border-color: var(--red); } }
@keyframes glow { 50% { box-shadow: 0 0 0 4px #000, 0 0 46px #ff2bd6, inset 0 -8px 0 #0004; } }
@keyframes pulse { 50% { box-shadow: 0 0 26px #ff3b3b; } }
@keyframes borderBlink { 50% { box-shadow: 0 0 16px #39ff1499; } }
@keyframes floatUp { to { transform: translateY(-60px); opacity: 0; } }
@keyframes fly { to { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; } }
@keyframes toastIn { from { transform: translateX(30px); opacity: 0; } }
@keyframes toastOut { to { transform: translateX(30px); opacity: 0; } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
@keyframes fade { to { opacity: 0; } }

@media (max-width: 1180px) {
  #tab-game.on { grid-template-columns: 280px 1fr; }
  .col-right { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  body { overflow-x: hidden; }
  .top { padding: 8px 10px; gap: 8px; }
  .logo { font-size: 22px; }
  .tabs { gap: 4px; }
  .tabs button { padding: 5px 8px; font-size: 12px; }
  .toast { font-size: 12px; padding: 7px 10px; }
  .res { grid-template-columns: 1fr 1fr; padding: 6px 8px; gap: 6px; }
  .r { padding: 5px 9px; border-radius: 10px; }
  .r-lbl, .r-sub { font-size: 11px; }
  .thermo { height: 10px; margin: 4px 0 2px; }
  .r-tox { grid-column: 1 / -1; }
  .r-val { font-size: 19px; }
  #tab-game.on { grid-template-columns: 1fr; }
  .col-right { grid-template-columns: 1fr; }
  .tab { padding: 10px; }
  .big-btn { aspect-ratio: 2.4; font-size: 26px; }
  .fake-timer { font-size: 12px; }
  .names { grid-template-columns: 1fr; }
  .names .arrow { transform: rotate(90deg); text-align: center; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
