:root {
  color-scheme: dark;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  background: #021824;
  --navy: #04283f;
  --navy-deep: #031d2d;
  --blue: #008bd2;
  --cyan: #27b5bc;
  --lime: #82c83e;
  --orange: #ffad3f;
  --red: #ff5d57;
  --white: #fff;
  --muted: #a8cbd2;
}

* { box-sizing: border-box; }
html, body { min-width: 320px; min-height: 100%; margin: 0; }
body {
  min-height: 100svh;
  overflow-x: hidden;
  color: var(--white);
  background:
    radial-gradient(circle at 50% -20%, rgba(39, 181, 188, .28), transparent 45%),
    linear-gradient(160deg, #031d2d, #052f45 56%, #073e51);
}
button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

#manuvia-packing-line { min-height: 100svh; }
.app {
  position: relative;
  width: min(1180px, 100%);
  min-height: 100svh;
  margin: 0 auto;
  padding-bottom: 70px;
  overflow: hidden;
  background: rgba(3, 29, 45, .54);
  box-shadow: 0 0 80px rgba(0, 0, 0, .28);
}

.app-header {
  min-height: 62px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
  background: rgba(3, 29, 45, .82);
}
.brand-main-logo { width: min(190px, 28vw); max-height: 38px; object-fit: contain; object-position: left center; }
.shift-title { display: grid; gap: 2px; text-align: center; }
.shift-title span { color: #b6d8de; font-size: 11px; font-weight: 750; letter-spacing: .16em; }
.shift-title strong { font-size: 15px; letter-spacing: .05em; }
.contest-badge {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid rgba(130, 200, 62, .25);
  border-radius: 999px;
  color: #dff7c7;
  background: rgba(130, 200, 62, .13);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
}
.contest-badge i { width: 7px; height: 7px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 12px rgba(130, 200, 62, .8); }

.player-strip {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 6px 20px;
  color: #a7c8cf;
  font-size: 13px;
}
.player-strip strong { color: #fff; font-weight: 700; font-variant-numeric: tabular-nums; }
.workspace { padding: 0 16px; }
.view { width: 100%; }

.game-shell {
  position: relative;
  width: 100%;
  overflow: hidden;
  isolation: isolate;
  aspect-ratio: 16 / 9;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 20px;
  background: #07283a;
  box-shadow: inset 0 0 70px rgba(0, 0, 0, .2), 0 24px 50px rgba(0, 0, 0, .26);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.factory-background {
  position: absolute;
  z-index: 0;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(3, 29, 45, .06) 0%, rgba(3, 29, 45, .08) 48%, rgba(3, 29, 45, .4) 100%),
    url('/manuvia-factory-front-v1.png') center 46% / cover no-repeat;
  transform: scale(1.01);
  transition: opacity .5s ease;
}
.game-shell::after {
  position: absolute;
  z-index: 7;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 54% 48%, transparent 42%, rgba(0, 11, 18, .34) 100%);
  content: "";
}
.factory-sign {
  position: absolute;
  z-index: 1;
  top: 5.5%;
  left: 42%;
  width: 16%;
  height: 9%;
  display: grid;
  place-items: center;
  padding: 4px 12px;
  border: 1px solid rgba(0, 139, 210, .34);
  border-radius: 4px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 0 30px rgba(39, 181, 188, .22);
  transition: opacity .35s ease;
}
.factory-sign img { width: 90%; height: 80%; object-fit: contain; }
.game-shell canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#character-canvas { z-index: 2; opacity: 0; pointer-events: none; transition: opacity .5s ease; }
#game-canvas { z-index: 3; transition: opacity .25s ease; }
.game-shell.scene-3d-ready .factory-background,
.game-shell.scene-3d-ready .factory-sign { opacity: 0; }
.game-shell.scene-3d-ready #character-canvas { opacity: 1; }
.game-shell.scene-3d-ready #game-canvas { opacity: 0; pointer-events: none; }
.game-shell.scene-3d-ready::after {
  background: radial-gradient(circle at 50% 47%, transparent 48%, rgba(0, 10, 17, .2) 100%);
}

.hud {
  position: absolute;
  z-index: 12;
  top: max(10px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: repeat(4, minmax(78px, 112px));
  gap: 6px;
}
.hud > span {
  position: relative;
  min-width: 0;
  overflow: hidden;
  padding: 8px 12px 9px;
  border: 1px solid rgba(74, 205, 236, .72);
  border-radius: 8px 8px 13px 8px;
  background: linear-gradient(145deg, rgba(8, 43, 62, .94), rgba(2, 24, 37, .82));
  box-shadow: 0 9px 20px rgba(0, 0, 0, .28), inset 0 1px rgba(220, 250, 255, .16), 0 0 14px rgba(32, 185, 207, .1);
  backdrop-filter: blur(13px) saturate(1.25);
  clip-path: polygon(0 0, 90% 0, 100% 24%, 100% 100%, 9% 100%, 0 78%);
  transform: perspective(700px) rotateX(-1.5deg);
}
.hud > span::before { position: absolute; top: 0; left: 8%; width: 62%; height: 1px; background: linear-gradient(90deg, transparent, #93efff, transparent); content: ""; }
.hud small { display: block; color: #a7ced5; font-size: 9px; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
.hud strong { display: block; margin-top: 3px; font-size: 19px; line-height: 1; text-shadow: 0 0 12px rgba(39, 181, 188, .25); font-variant-numeric: tabular-nums; }
.lives-hud strong { color: #fff; }
.lives-hud strong::before { margin-right: 5px; color: var(--red); content: "♥"; }

.decision-guide {
  position: absolute;
  z-index: 11;
  top: 12px;
  right: max(12px, env(safe-area-inset-right));
  display: grid;
  gap: 5px;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .06em;
}
.decision-guide span {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border: 1px solid rgba(66, 195, 224, .52);
  border-radius: 6px 6px 10px 6px;
  background: linear-gradient(135deg, rgba(3, 35, 51, .92), rgba(2, 20, 31, .75));
  box-shadow: 0 7px 16px rgba(0, 0, 0, .25), inset 0 1px rgba(255, 255, 255, .09);
  backdrop-filter: blur(12px);
}
.decision-guide i { width: 8px; height: 8px; border-radius: 50%; }
.guide-good i { background: var(--lime); }
.guide-bad i { background: var(--red); }

.sound-button, .fullscreen-button {
  position: absolute;
  z-index: 14;
  top: 76px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 9px;
  color: #d8ecef;
  background: rgba(3, 29, 45, .72);
  font-size: 11px;
  font-weight: 700;
  backdrop-filter: blur(9px);
}
.sound-button { right: 134px; }
.fullscreen-button { right: 12px; }

.pack-button {
  position: absolute;
  z-index: 16;
  right: max(22px, env(safe-area-inset-right));
  bottom: max(19px, env(safe-area-inset-bottom));
  width: clamp(132px, 21vw, 210px);
  min-height: clamp(74px, 13vw, 104px);
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  align-content: center;
  align-items: center;
  column-gap: 10px;
  padding: 10px 18px;
  border: 2px solid rgba(231, 255, 207, .9);
  border-radius: 14px 14px 23px 14px;
  color: #05283e;
  background: linear-gradient(155deg, #c7ff82 0%, #8cdd43 48%, #63a829 100%);
  box-shadow: 0 10px 0 #315f22, 0 18px 32px rgba(0, 0, 0, .4), 0 0 34px rgba(130, 233, 63, .36), inset 0 2px rgba(255, 255, 255, .76), inset 0 -6px 14px rgba(45, 104, 24, .24);
  text-align: left;
  clip-path: polygon(0 0, 91% 0, 100% 17%, 100% 100%, 8% 100%, 0 83%);
  transform: translateY(-4px) perspective(700px) rotateX(1deg);
  transition: transform .1s ease, filter .1s ease;
  touch-action: manipulation;
}
.pack-button:active, .pack-button.is-active { transform: translateY(5px) scale(.97) perspective(700px) rotateX(-2deg); filter: brightness(1.13); box-shadow: 0 2px 0 #315f22, 0 9px 18px rgba(0, 0, 0, .38), 0 0 42px rgba(130, 233, 63, .52), inset 0 2px rgba(255, 255, 255, .72); }
.pack-button:disabled { cursor: default; filter: saturate(.4); opacity: .56; }
.pack-icon { grid-row: 1 / 3; display: grid; place-items: center; width: 40px; height: 40px; border: 2px solid rgba(5, 40, 62, .58); border-radius: 10px; background: rgba(255, 255, 255, .14); box-shadow: inset 0 2px 5px rgba(255, 255, 255, .45); font-size: 24px; }
.pack-button strong { font-size: clamp(17px, 2.5vw, 25px); line-height: 1; letter-spacing: .035em; }
.pack-button small { margin-top: 4px; font-size: 9px; font-weight: 700; letter-spacing: .02em; }

.reaction-flash {
  position: absolute;
  z-index: 15;
  left: 50%;
  top: 31%;
  min-width: 210px;
  padding: 11px 18px;
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 12px;
  color: #fff;
  background: rgba(3, 29, 45, .9);
  box-shadow: 0 14px 36px rgba(0, 0, 0, .3);
  font-size: 18px;
  font-weight: 850;
  letter-spacing: .04em;
  text-align: center;
  transform: translate(-50%, -50%);
  animation: reaction-pop .65s ease both;
}
.reaction-flash.is-good { color: #e7ffd1; border-color: rgba(130, 200, 62, .7); }
.reaction-flash.is-bad { color: #fff0ef; border-color: rgba(255, 93, 87, .78); }
@keyframes reaction-pop { 0% { opacity: 0; transform: translate(-50%, -35%) scale(.86); } 20%, 70% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -62%) scale(.96); } }

.game-overlay {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  padding: 34px max(22px, 7vw);
  color: #fff;
  background: linear-gradient(110deg, rgba(3, 29, 45, .96), rgba(4, 40, 63, .76) 58%, rgba(3, 29, 45, .9));
  backdrop-filter: blur(4px);
  text-align: center;
}
.game-overlay .eyebrow { margin: 0; color: #a9edf0; font-size: 11px; font-weight: 800; letter-spacing: .17em; }
.game-overlay h1 { margin: 0; font-size: clamp(28px, 5vw, 52px); line-height: .98; letter-spacing: -.045em; }
.game-overlay > p:not(.eyebrow) { max-width: 620px; margin: 0; color: #d5e9ec; font-size: clamp(13px, 1.6vw, 17px); line-height: 1.45; }
.game-overlay > small { color: #9fc2c8; font-size: 10px; }
.overlay-rules { display: grid; grid-template-columns: repeat(3, minmax(122px, 170px)); gap: 7px; margin: 5px 0; }
.overlay-rules > span { min-height: 70px; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; align-items: center; column-gap: 8px; padding: 9px 11px; border: 1px solid rgba(255, 255, 255, .13); border-radius: 11px; background: rgba(255, 255, 255, .08); text-align: left; }
.overlay-rules b { font-size: 10px; letter-spacing: .04em; }
.overlay-rules small { color: #b8d4d9; font-size: 9px; }
.sample-product { grid-row: 1 / 3; position: relative; width: 34px; height: 30px; display: block; border: 2px solid #cdf1ae; border-radius: 5px; background: linear-gradient(135deg, #e6f4dc, #78b844); box-shadow: inset 0 0 0 4px rgba(255, 255, 255, .16); }
.sample-product::after { position: absolute; left: 13px; top: -2px; width: 5px; height: 30px; background: rgba(255, 255, 255, .5); content: ""; }
.sample-product.bad { border-color: #ffaaa7; background: linear-gradient(135deg, #f1dcda, #a94b48); transform: skew(-7deg) rotate(-5deg); }
.sample-product.bad::before { position: absolute; z-index: 2; left: 12px; top: -6px; color: #fff; font-size: 30px; font-style: normal; content: "⚡"; transform: rotate(12deg); }
.sample-heart { grid-row: 1 / 3; color: var(--red); font-size: 33px; font-style: normal; text-align: center; text-shadow: 0 0 16px rgba(255, 93, 87, .5); }
.primary-button {
  min-width: 210px;
  min-height: 46px;
  padding: 0 22px;
  border: 0;
  border-radius: 12px;
  color: #05283e;
  background: linear-gradient(145deg, #b0f46c, #82c83e);
  box-shadow: 0 12px 26px rgba(0, 0, 0, .24), 0 0 22px rgba(130, 200, 62, .18);
  font-size: 15px;
  font-weight: 800;
}
.primary-button:disabled { cursor: default; opacity: .54; }

.rotate-hint { display: none; }
.status-line { min-height: 22px; margin: 8px 2px 0; color: #b5d3d8; font-size: 13px; text-align: center; }

.leaderboard-view { max-width: 720px; margin: 0 auto; padding: 8px 0 30px; }
.leaderboard-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; padding: 8px 4px 14px; }
.leaderboard-head p { margin: 0 0 4px; color: #9fced5; font-size: 10px; font-weight: 800; letter-spacing: .14em; }
.leaderboard-head h2 { margin: 0; font-size: 28px; }
.leaderboard-head > span { color: #9bc2c8; font-size: 11px; font-weight: 700; }
.leaderboard { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; counter-reset: rank; }
.leaderboard li { counter-increment: rank; min-height: 52px; display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; padding: 8px 14px; border: 1px solid rgba(255, 255, 255, .08); border-radius: 12px; background: rgba(255, 255, 255, .07); }
.leaderboard li::before { color: #91b7bd; content: counter(rank) "."; }
.leaderboard li:nth-child(-n+3) { background: rgba(39, 181, 188, .14); }
.leaderboard li.is-player { border-color: rgba(130, 200, 62, .46); background: rgba(130, 200, 62, .15); }
.leader-score { font-weight: 800; font-variant-numeric: tabular-nums; }
.empty-leaderboard { grid-template-columns: 1fr !important; color: #b5d3d8; text-align: center; }
.empty-leaderboard::before { display: none; }
.rules { margin-top: 14px; padding: 18px; border-radius: 14px; color: #193a47; background: rgba(255, 255, 255, .95); }
.rules h3 { margin: 0; color: var(--navy); font-size: 17px; }
.rules ul { display: grid; gap: 7px; margin: 10px 0; padding-left: 20px; color: #526c75; font-size: 14px; line-height: 1.45; }
.rules p { margin: 10px 0 0; }
.rules a { color: #087ab5; font-weight: 700; }

.bottom-nav {
  position: absolute;
  z-index: 26;
  left: 50%;
  bottom: 10px;
  width: min(360px, calc(100% - 32px));
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 5px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 14px;
  background: rgba(3, 29, 45, .9);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .25);
  backdrop-filter: blur(14px);
  transform: translateX(-50%);
}
.nav-button { min-height: 42px; border: 0; border-radius: 10px; color: #aecdd2; background: transparent; font-size: 14px; font-weight: 750; }
.nav-button[aria-selected="true"] { color: #062a40; background: #fff; }

.registration {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 18px;
  background:
    radial-gradient(circle at 18% 8%, rgba(39, 181, 188, .28), transparent 34%),
    rgba(3, 29, 45, .97);
  backdrop-filter: blur(12px);
}
.registration-card {
  width: min(820px, 100%);
  display: grid;
  grid-template-columns: .86fr 1.14fr;
  overflow: hidden;
  border-radius: 22px;
  color: #183846;
  background: #fff;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .38);
}
.registration-intro { padding: 26px; color: #fff; background: linear-gradient(145deg, #053653, #007bad 62%, #27b5bc); }
.registration-intro > img { width: 185px; max-width: 100%; filter: brightness(0) invert(1); }
.registration-intro .eyebrow { margin: 34px 0 0; color: #d6fbfd; font-size: 10px; font-weight: 800; letter-spacing: .14em; }
.registration-intro h1 { margin: 7px 0 0; font-size: 32px; letter-spacing: -.04em; }
.registration-intro > p:last-child { margin: 10px 0 0; color: #d7ebee; font-size: 13px; line-height: 1.5; }
.registration-fields { padding: 24px 26px; }
.field-grid { display: grid; gap: 10px; }
.field { position: relative; display: grid; gap: 5px; color: #46636d; font-size: 12px; font-weight: 750; }
.field > span { position: absolute; top: 0; right: 0; color: #789099; font-size: 9px; font-weight: 600; }
.field input { width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid #cadde1; border-radius: 9px; color: #173845; 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: 12px; color: #5a727b; font-size: 11px; line-height: 1.45; }
.consent input { width: 18px; height: 18px; flex: 0 0 auto; margin: 0; accent-color: var(--cyan); }
.consent a { color: #057bb7; }
.form-error, .verification-message { margin: 9px 0 0; padding: 8px 10px; border-radius: 8px; font-size: 11px; line-height: 1.4; }
.form-error { color: #8b2f31; background: #fff0ef; }
.verification-message { color: #255f27; background: #effbe6; }
.verification-message p { margin: 0; }
.registration-fields > .primary-button { width: 100%; margin-top: 13px; }
.privacy { display: block; margin-top: 8px; color: #7a9299; font-size: 9px; line-height: 1.4; text-align: center; }

body.game-immersive { overflow: hidden; }
.game-shell.is-fallback-fullscreen,
.game-shell:fullscreen,
.game-shell:-webkit-full-screen {
  position: fixed;
  z-index: 80;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
}

@media (max-width: 900px) and (orientation: landscape), (max-width: 760px) {
  .app { min-height: 100svh; padding-bottom: 0; }
  .app-header { min-height: 44px; grid-template-columns: 1fr auto; padding: 6px 12px; }
  .brand-main-logo { max-height: 30px; }
  .shift-title { display: none; }
  .contest-badge { font-size: 9px; }
  .player-strip { min-height: 28px; padding: 4px 12px; font-size: 10px; }
  .workspace { padding: 0 8px; }
  .game-shell { height: calc(100svh - 80px); min-height: 286px; aspect-ratio: auto; border-radius: 14px; }
  .hud { grid-template-columns: repeat(4, minmax(62px, 82px)); gap: 4px; }
  .hud > span { padding: 5px 7px 6px; }
  .hud small { font-size: 7px; }
  .hud strong { font-size: 14px; }
  .decision-guide { top: 55px; right: 8px; font-size: 7px; }
  .decision-guide span { padding: 4px 6px; }
  .sound-button, .fullscreen-button { top: auto; bottom: 9px; min-height: 29px; padding: 0 8px; font-size: 8px; }
  .sound-button { right: 188px; }
  .fullscreen-button { right: 81px; }
  .pack-button { right: 10px; bottom: 48px; width: 144px; min-height: 66px; padding: 8px 11px; border-radius: 14px; }
  .pack-icon { width: 30px; height: 30px; font-size: 19px; }
  .pack-button strong { font-size: 17px; }
  .pack-button small { font-size: 7px; }
  .game-overlay { gap: 6px; padding: 18px 28px; }
  .game-overlay h1 { font-size: 28px; }
  .game-overlay > p:not(.eyebrow) { max-width: 540px; font-size: 11px; line-height: 1.35; }
  .overlay-rules { grid-template-columns: repeat(3, 126px); gap: 5px; }
  .overlay-rules > span { min-height: 54px; padding: 6px 8px; }
  .sample-product { width: 28px; height: 25px; }
  .sample-product::after { left: 11px; height: 25px; }
  .sample-product.bad::before { left: 9px; top: -7px; font-size: 27px; }
  .sample-heart { font-size: 27px; }
  .primary-button { min-height: 40px; }
  .game-overlay > small { font-size: 8px; }
  .status-line { display: none; }
  .bottom-nav { display: none; }
  .registration { padding: 8px; }
  .registration-card { width: min(760px, 100%); grid-template-columns: .78fr 1.22fr; border-radius: 16px; }
  .registration-intro, .registration-fields { padding: 14px 16px; }
  .registration-intro > img { width: 130px; }
  .registration-intro .eyebrow { margin-top: 17px; font-size: 8px; }
  .registration-intro h1 { font-size: 24px; }
  .registration-intro > p:last-child { font-size: 10px; }
  .field-grid { gap: 6px; }
  .field { gap: 3px; font-size: 9px; }
  .field input { min-height: 34px; font-size: 14px; }
  .consent { margin-top: 7px; font-size: 8px; }
  .consent input { width: 16px; height: 16px; }
  .registration-fields > .primary-button { min-height: 35px; margin-top: 7px; font-size: 11px; }
  .privacy { font-size: 7px; }
}

@media (orientation: portrait) and (max-width: 760px) {
  .app { padding-bottom: 64px; }
  .game-shell { min-height: 64svh; aspect-ratio: auto; }
  .game-shell > :not(.rotate-hint) { visibility: hidden; }
  .rotate-hint {
    position: absolute;
    z-index: 40;
    inset: 0;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 8px;
    padding: 30px;
    color: #fff;
    background: linear-gradient(155deg, #04283f, #086078);
    text-align: center;
  }
  .rotate-hint div { font-size: 48px; color: #9fe6e9; }
  .rotate-hint strong { font-size: 21px; }
  .rotate-hint span { color: #c7e0e4; font-size: 14px; }
  .registration-card { display: block; }
  .registration-intro { padding-bottom: 16px; }
  .registration-intro .eyebrow { margin-top: 14px; }
  .registration-intro > p:last-child { display: none; }
}

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