:root {
  color-scheme: dark;
  background: #031d2d;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  overscroll-behavior: none;
  background:
    radial-gradient(circle at 50% -18%, rgba(39, 181, 188, .28), transparent 46%),
    linear-gradient(155deg, #031d2d, #052f47 65%, #06485b);
}

body {
  min-height: 100svh;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}

button,
input { font: inherit; }

button { cursor: pointer; }

[hidden] { display: none !important; }

#manuvia-shift-v2 {
  --navy: #04283f;
  --navy-dark: #031d2d;
  --navy-soft: #073650;
  --blue: #008bd2;
  --cyan: #27b5bc;
  --lime: #82c83e;
  --ice: #eaf7f7;
  --ink: #183846;
  --orange: #ff9d32;
  --white: #fff;
  width: 100%;
  color: var(--white);
}

.app {
  position: relative;
  width: min(1120px, 100%);
  min-height: calc(100svh - max(16px, env(safe-area-inset-top) + env(safe-area-inset-bottom)));
  overflow: hidden;
  margin: 0 auto;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 28px;
  background:
    radial-gradient(circle at 86% 5%, rgba(39, 181, 188, .22), transparent 28%),
    linear-gradient(165deg, var(--navy) 0%, #06344d 55%, #07536a 100%);
  box-shadow: 0 28px 90px rgba(0, 0, 0, .3);
}

.app-header {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
  background: rgba(4, 40, 63, .62);
  backdrop-filter: blur(16px);
}

.brand-lockup,
.registration-brand {
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand-pictogram {
  width: 39px;
  height: 39px;
  display: block;
  border-radius: 10px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .2);
}

.brand-name {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -.045em;
}

.contest-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid rgba(130, 200, 62, .2);
  border-radius: 999px;
  color: #e0fac8;
  background: rgba(130, 200, 62, .14);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .08em;
}

.contest-badge i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 10px rgba(130, 200, 62, .8);
}

.player-strip {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 18px;
  color: #b8d5db;
  font-size: 11px;
}

.player-strip strong { color: var(--white); }

.best-score { font-variant-numeric: tabular-nums; }

.workspace { padding: 0 12px 76px; }

.view[hidden] { display: none; }

.role-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin: 0 0 8px;
}

.role-button {
  min-width: 0;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  overflow: hidden;
  padding: 3px 8px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 12px;
  color: #b8d4da;
  background: rgba(255, 255, 255, .06);
  font-size: 11px;
  font-weight: 700;
  transition: border-color .2s ease, background .2s ease, transform .2s ease;
}

.role-button:hover { transform: translateY(-1px); }

.role-button[aria-pressed="true"] {
  border-color: rgba(39, 181, 188, .85);
  color: var(--white);
  background: linear-gradient(135deg, rgba(0, 139, 210, .25), rgba(39, 181, 188, .18));
  box-shadow: inset 0 0 0 1px rgba(39, 181, 188, .12), 0 8px 22px rgba(0, 0, 0, .14);
}

.role-button:disabled { cursor: default; opacity: .58; transform: none; }

.role-avatar {
  width: 42px;
  height: 48px;
  flex: 0 0 42px;
  display: block;
  background-image: url('/manuvia-role-heroes-v2-opt.png');
  background-repeat: no-repeat;
  background-size: 400% 100%;
  filter: drop-shadow(0 5px 6px rgba(0, 0, 0, .28));
}

.role-0 { background-position: 0 50%; }
.role-1 { background-position: 33.333% 50%; }
.role-2 { background-position: 66.666% 50%; }
.role-3 { background-position: 100% 50%; }

.game-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(3, 20, 31, .04), rgba(3, 20, 31, .3)),
    url('/manuvia-factory-background-v3.jpg') center center / cover no-repeat,
    #08283a;
  box-shadow: inset 0 0 50px rgba(0, 0, 0, .18), 0 20px 42px rgba(0, 0, 0, .24);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.game-shell::after {
  position: absolute;
  z-index: 2;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 42%, transparent 35%, rgba(1, 16, 25, .24) 100%);
  content: "";
}

.game-shell canvas {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.hud {
  position: absolute;
  z-index: 8;
  top: max(10px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: repeat(4, minmax(54px, 72px));
  gap: 5px;
  pointer-events: none;
}

.hud > span {
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 10px;
  background: rgba(3, 29, 45, .72);
  box-shadow: 0 8px 18px rgba(0, 0, 0, .18);
  backdrop-filter: blur(10px);
}

.hud small,
.bonus-chip small {
  display: block;
  color: #9bc8cf;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.hud strong {
  display: block;
  margin-top: 2px;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.bonus-chip {
  position: absolute;
  z-index: 9;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  min-width: 155px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 6px;
  border: 1px solid rgba(130, 200, 62, .55);
  border-radius: 999px;
  background: rgba(3, 29, 45, .84);
  box-shadow: 0 0 28px rgba(130, 200, 62, .22);
  transform: translateX(-50%);
  backdrop-filter: blur(10px);
}

.bonus-chip > i {
  width: 38px;
  height: 38px;
  display: block;
  flex: 0 0 38px;
  background-image: url('/tool-powerups-v2-opt.png');
  background-repeat: no-repeat;
  background-size: 400% 100%;
  object-fit: cover;
  border-radius: 50%;
}

.bonus-chip strong {
  display: block;
  margin-top: 1px;
  color: #edffd9;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.fullscreen-button {
  position: absolute;
  z-index: 24;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  min-height: 37px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: 10px;
  color: var(--white);
  background: rgba(3, 29, 45, .76);
  font-size: 11px;
  font-weight: 700;
  backdrop-filter: blur(10px);
}

.game-overlay {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 9px;
  padding: 24px clamp(24px, 9vw, 120px);
  color: var(--white);
  background:
    radial-gradient(circle at 50% 28%, rgba(39, 181, 188, .24), transparent 38%),
    linear-gradient(180deg, rgba(3, 25, 39, .58), rgba(3, 25, 39, .9));
  text-align: center;
  backdrop-filter: blur(4px);
}

.game-overlay[hidden] { display: none; }

.game-overlay .eyebrow,
.leaderboard-head p,
.registration-card .eyebrow {
  margin: 0;
  color: #b9ef84;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .13em;
}

.game-overlay h1 {
  margin: 0;
  font-size: clamp(28px, 4.5vw, 48px);
  font-weight: 650;
  letter-spacing: -.045em;
}

.game-overlay > p:not(.eyebrow) {
  max-width: 650px;
  margin: 0;
  color: #d4e9ec;
  font-size: clamp(11px, 1.65vw, 15px);
  line-height: 1.45;
}

.game-overlay > small {
  color: #91b9c0;
  font-size: 9px;
}

.control-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: min(520px, 100%);
}

.control-legend span {
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 10px;
  color: #c5dde1;
  background: rgba(255, 255, 255, .07);
  font-size: 10px;
}

.control-legend b {
  display: block;
  margin-bottom: 2px;
  color: var(--white);
  font-size: 9px;
  letter-spacing: .07em;
}

.primary-button {
  min-height: 46px;
  padding: 0 22px;
  border: 0;
  border-radius: 11px;
  color: var(--navy);
  background: linear-gradient(135deg, #9cda61, var(--lime));
  box-shadow: 0 13px 28px rgba(130, 200, 62, .3);
  font-weight: 750;
}

.primary-button:disabled { cursor: wait; opacity: .65; }

.touch-controls {
  position: absolute;
  z-index: 12;
  right: 0;
  bottom: max(13px, env(safe-area-inset-bottom));
  left: 0;
  display: flex;
  align-items: end;
  justify-content: space-between;
  padding: 0 max(18px, env(safe-area-inset-right)) 0 max(18px, env(safe-area-inset-left));
  pointer-events: none;
}

.touch-controls button {
  border: 1px solid rgba(255, 255, 255, .2);
  color: var(--white);
  background: rgba(3, 29, 45, .72);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .25), inset 0 1px rgba(255, 255, 255, .08);
  backdrop-filter: blur(9px);
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.touch-controls button:active,
.touch-controls button.is-active {
  border-color: rgba(130, 200, 62, .9);
  background: rgba(39, 181, 188, .82);
  transform: scale(.96);
}

.jump-control {
  width: clamp(82px, 13vw, 122px);
  height: clamp(82px, 13vw, 122px);
  display: grid;
  place-content: center;
  border-radius: 50%;
}

.jump-control i {
  font-size: clamp(22px, 4vw, 38px);
  font-style: normal;
  line-height: .8;
}

.jump-control span {
  margin-top: 7px;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .12em;
}

.move-controls {
  position: relative;
  display: flex;
  gap: 8px;
  padding-bottom: 17px;
}

.move-controls button {
  width: clamp(70px, 11vw, 104px);
  height: clamp(70px, 11vw, 104px);
  border-radius: 22px;
  font-size: clamp(20px, 3.5vw, 32px);
}

.move-controls small {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  color: rgba(220, 242, 245, .72);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .14em;
  text-align: center;
}

.rotate-hint { display: none; }

.status-line {
  min-height: 20px;
  margin: 7px 2px 0;
  color: #b1d3d8;
  font-size: 11px;
  text-align: center;
}

.power-guide {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin-top: 8px;
}

.power-guide article {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px 5px 5px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 11px;
  color: #a9cbd1;
  background: rgba(255, 255, 255, .055);
  font-size: 8px;
  line-height: 1.35;
}

.power-guide strong {
  display: block;
  overflow: hidden;
  color: var(--white);
  font-size: 8px;
  letter-spacing: .04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-preview {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: block;
  background-image: url('/tool-powerups-v2-opt.png');
  background-repeat: no-repeat;
  background-size: 400% 100%;
  filter: drop-shadow(0 4px 5px rgba(0, 0, 0, .24));
}

.tool-0 { background-position: 0 50%; }
.tool-1 { background-position: 33.333% 50%; }
.tool-2 { background-position: 66.666% 50%; }
.tool-3 { background-position: 100% 50%; }

.leaderboard-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 5px;
}

.leaderboard-head h2 {
  margin: 5px 0 0;
  font-size: 27px;
  letter-spacing: -.035em;
}

.leaderboard-head > span {
  color: #9ec4cb;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .1em;
}

.leaderboard {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: rank;
}

.leaderboard li {
  min-height: 48px;
  counter-increment: rank;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 8px 13px;
  border-radius: 12px;
  color: #d7e9ec;
  background: rgba(255, 255, 255, .08);
  font-size: 12px;
}

.leaderboard li::before {
  color: #8eb5bc;
  content: counter(rank) ".";
  font-variant-numeric: tabular-nums;
}

.leaderboard li:nth-child(-n+3) { background: rgba(39, 181, 188, .18); }

.leaderboard li.is-player {
  color: #efffdf;
  background: rgba(130, 200, 62, .2);
  box-shadow: inset 3px 0 var(--lime);
}

.leader-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leader-score { font-weight: 750; font-variant-numeric: tabular-nums; }

.rules {
  margin-top: 12px;
  padding: 15px;
  border-radius: 13px;
  color: var(--ink);
  background: rgba(255, 255, 255, .95);
}

.rules h3 { margin: 0; color: var(--navy); font-size: 13px; }
.rules ul { display: grid; gap: 6px; margin: 8px 0 0; padding-left: 18px; color: #5d747d; font-size: 10px; line-height: 1.45; }

.bottom-nav {
  position: absolute;
  z-index: 30;
  right: 12px;
  bottom: 12px;
  left: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  padding: 5px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 14px;
  background: rgba(4, 40, 63, .92);
  backdrop-filter: blur(12px);
}

.nav-button {
  min-height: 43px;
  border: 0;
  border-radius: 10px;
  color: #aacbd1;
  background: transparent;
  font-weight: 700;
}

.nav-button[aria-selected="true"] { color: var(--navy); background: var(--white); }

.registration {
  position: absolute;
  z-index: 60;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background:
    radial-gradient(circle at 17% 10%, rgba(39, 181, 188, .3), transparent 31%),
    rgba(3, 29, 45, .97);
  backdrop-filter: blur(14px);
}

.registration-card {
  width: min(820px, 100%);
  display: grid;
  grid-template-columns: minmax(230px, .82fr) minmax(280px, 1.18fr);
  gap: 28px;
  padding: clamp(20px, 4vw, 34px);
  border-radius: 22px;
  color: var(--ink);
  background: var(--white);
  box-shadow: 0 28px 75px rgba(0, 0, 0, .36);
}

.registration-brand { margin-bottom: 20px; }
.registration-brand img { width: 48px; height: 48px; border-radius: 12px; }
.registration-brand span { color: var(--navy); font-size: 22px; font-weight: 650; letter-spacing: -.045em; }

.registration-card h1 {
  margin: 8px 0 0;
  color: var(--navy);
  font-size: clamp(27px, 4vw, 39px);
  letter-spacing: -.045em;
}

.registration-intro > p:not(.eyebrow) { margin: 9px 0 0; color: #607983; font-size: 12px; line-height: 1.55; }
.field-grid { display: grid; gap: 9px; }
.field { display: grid; gap: 5px; color: #4e6973; font-size: 10px; font-weight: 700; }

.field input {
  width: 100%;
  min-height: 45px;
  padding: 0 12px;
  border: 1px solid #cbdde1;
  border-radius: 9px;
  color: var(--ink);
  background: #fbfdfd;
  font-size: 16px;
}

.field input:focus { border-color: var(--cyan); outline: 3px solid rgba(39, 181, 188, .18); }

.consent { display: flex; align-items: flex-start; gap: 8px; margin-top: 11px; color: #5d747d; font-size: 10px; line-height: 1.42; }
.consent input { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 1px; accent-color: var(--cyan); }
.form-error { margin: 7px 0 0; color: #a13b40; font-size: 10px; }
.registration-fields .primary-button { width: 100%; margin-top: 12px; }
.privacy { display: block; margin-top: 8px; color: #85999f; font-size: 8px; line-height: 1.4; text-align: center; }

.game-shell:fullscreen,
.game-shell.is-fallback-fullscreen {
  width: 100vw;
  height: 100vh;
  height: 100svh;
  max-width: none;
  max-height: none;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
  background-position: center center;
}

.game-shell.is-fallback-fullscreen {
  position: fixed;
  z-index: 1000;
  inset: 0;
}

body.game-immersive { overflow: hidden; padding: 0; }

@media (max-width: 720px) {
  body { padding: 0; }
  .app { min-height: 100svh; border: 0; border-radius: 0; }
  .app-header { min-height: 55px; padding: 8px 12px; }
  .brand-pictogram { width: 34px; height: 34px; }
  .brand-name { font-size: 18px; }
  .contest-badge { padding: 6px 8px; font-size: 8px; }
  .player-strip { padding: 6px 12px; }
  .workspace { padding-right: 8px; padding-left: 8px; }
  .role-button { height: 51px; padding: 2px; font-size: 8px; }
  .role-avatar { width: 34px; height: 43px; flex-basis: 34px; }
  .role-button span { display: none; }
  .fullscreen-button span { display: none; }
  .fullscreen-button { width: 38px; padding: 0; font-size: 16px; }
  .power-guide { grid-template-columns: 1fr 1fr; }
  .registration-card { grid-template-columns: 1fr; gap: 16px; max-width: 520px; }
  .registration-brand { margin-bottom: 10px; }
}

@media (orientation: landscape) and (max-height: 620px) {
  body { padding: 0; overflow: auto; }
  .app { width: 100%; min-height: 100svh; border: 0; border-radius: 0; }
  .app-header { min-height: 46px; padding: 5px 12px; }
  .brand-pictogram { width: 31px; height: 31px; border-radius: 8px; }
  .brand-name { font-size: 17px; }
  .player-strip { min-height: 29px; padding: 3px 12px; font-size: 9px; }
  .workspace { padding: 0 7px 60px; }
  .role-row { position: absolute; z-index: 35; top: 5px; left: 50%; width: min(390px, 50vw); margin: 0; transform: translateX(-50%); }
  .role-button { height: 36px; border-radius: 9px; }
  .role-avatar { width: 29px; height: 34px; flex-basis: 29px; }
  .game-shell { max-height: calc(100svh - 82px); margin: 0 auto; }
  .status-line { margin-top: 3px; font-size: 9px; }
  .power-guide { display: none; }
  .bottom-nav { right: 7px; bottom: 7px; left: 7px; }
  .nav-button { min-height: 36px; font-size: 11px; }
  .registration { place-items: start center; }
  .registration-card { grid-template-columns: .85fr 1.15fr; gap: 20px; width: min(760px, 96%); padding: 16px 20px; }
  .registration-brand { margin-bottom: 8px; }
  .registration-brand img { width: 38px; height: 38px; }
  .registration-card h1 { font-size: 27px; }
  .registration-intro > p:not(.eyebrow) { font-size: 10px; }
  .field-grid { grid-template-columns: 1fr 1fr; gap: 7px; }
  .field:first-child { grid-column: 1 / -1; }
  .field input { min-height: 37px; }
  .consent { margin-top: 7px; font-size: 8px; }
  .registration-fields .primary-button { min-height: 39px; margin-top: 7px; }
  .privacy { margin-top: 5px; }
}

@media (orientation: portrait) and (max-width: 900px) {
  .rotate-hint {
    position: absolute;
    z-index: 50;
    inset: 0;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 7px;
    padding: 28px;
    color: var(--white);
    background: rgba(3, 29, 45, .95);
    text-align: center;
    backdrop-filter: blur(12px);
  }

  .registration:not([hidden]) ~ * .rotate-hint { display: none; }
  .rotate-phone { font-size: 45px; color: var(--lime); transform: rotate(-25deg); }
  .rotate-hint strong { font-size: 20px; }
  .rotate-hint span { max-width: 250px; color: #b7d4da; font-size: 11px; line-height: 1.45; }
}

@media (max-height: 440px) {
  .hud { grid-template-columns: repeat(4, 58px); }
  .hud > span { padding: 5px 6px; }
  .hud strong { font-size: 12px; }
  .bonus-chip { top: 7px; min-width: 130px; }
  .bonus-chip > i { width: 31px; height: 31px; flex-basis: 31px; }
  .fullscreen-button { top: 7px; }
  .game-overlay { gap: 6px; padding-top: 15px; padding-bottom: 15px; }
  .game-overlay h1 { font-size: 28px; }
  .game-overlay > p:not(.eyebrow) { max-width: 570px; font-size: 10px; }
  .control-legend span { padding: 6px 8px; font-size: 8px; }
  .primary-button { min-height: 38px; }
  .jump-control { width: 76px; height: 76px; }
  .move-controls button { width: 67px; height: 67px; border-radius: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
