:root {
  color-scheme: dark;
  --font-body: Alice, "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --font-reading: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mystic: "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --bg-deep: #120b1a;
  --panel-bg: rgba(24, 14, 29, 0.74);
  --panel-bg-strong: rgba(30, 17, 38, 0.88);
  --gold: #ffd58e;
  --gold-strong: #ffb85f;
  --rose: #d889c5;
  --violet: #8c6eff;
  --aqua: #7ce7d7;
  --text: #fff7ed;
  --muted: #f2d8c6;
  --app-viewport-height: 100dvh;
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
}

[hidden] {
  display: none !important;
}

body {
  position: relative;
  isolation: isolate;
  overscroll-behavior-x: none;
  touch-action: pan-y;
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg-deep);
  font-family: var(--font-body);
}

body::before,
body::after {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
}

body::before {
  z-index: -2;
  background: url("./palm-bg.jpg") center center / cover no-repeat;
  opacity: 0.58;
  transform: translateZ(0);
}

body::after {
  z-index: -1;
  background:
    radial-gradient(circle at 50% 26%, rgba(255, 194, 108, 0.18), transparent 30%),
    radial-gradient(circle at 20% 12%, rgba(140, 110, 255, 0.16), transparent 36%),
    linear-gradient(180deg, rgba(7, 4, 12, 0.24), rgba(18, 11, 26, 0.62) 58%, rgba(9, 6, 13, 0.84));
}

:lang(zh) {
  --font-mystic: "Songti SC", "Noto Serif CJK SC", "STSong", serif;
}

:lang(hi) {
  --font-mystic: "Kohinoor Devanagari", "Noto Serif Devanagari", "Nirmala UI", serif;
}

button,
input,
select {
  font-family: var(--font-body);
  max-width: 100%;
  min-width: 0;
}

img,
video,
canvas,
svg {
  max-width: 100%;
}

.app-shell {
  position: relative;
  width: min(100%, 760px);
  max-width: 100vw;
  min-width: 0;
  margin: 0 auto;
  min-height: 100dvh;
  padding: max(18px, env(safe-area-inset-top)) 16px max(126px, calc(42px + env(safe-area-inset-bottom)));
  overflow-x: hidden;
}

.boot-video {
  position: fixed;
  top: 0;
  right: 0;
  bottom: auto;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100svh;
  height: var(--app-viewport-height);
  max-width: 100vw;
  max-height: var(--app-viewport-height);
  z-index: 100;
  display: grid;
  place-items: center;
  background: #1f1728;
  overflow: hidden;
  pointer-events: none;
  transition: opacity 320ms ease, visibility 320ms ease;
}

.boot-video.is-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.boot-video video {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100vw;
  max-height: var(--app-viewport-height);
  object-fit: cover;
  object-position: center center;
  background: #000;
}

.hero {
  padding: 28px 0 16px;
}

body:not(.flow-ready) .hero,
body:not(.flow-ready) .panel,
body:not(.flow-ready) .actions,
body:not(.flow-ready) .bottom-bar {
  display: none;
}

body.cabinet-view .hero,
body.cabinet-view .status-panel,
body.cabinet-view .panel:not(.cabinet-panel),
body.cabinet-view .actions {
  display: none;
}

body.friends-view .hero,
body.friends-view .status-panel,
body.friends-view .panel:not(.friends-panel),
body.friends-view .actions {
  display: none;
}

body.shop-view .hero,
body.shop-view .status-panel,
body.shop-view .panel:not(.shop-panel),
body.shop-view .actions {
  display: none;
}

body.tasks-view .hero,
body.tasks-view .status-panel,
body.tasks-view .panel:not(.tasks-panel),
body.tasks-view .actions {
  display: none;
}

body.result-view .actions {
  display: none;
}

body:not(.upload-stage) .upload-panel,
body:not(.upload-stage) .actions,
body.upload-stage .hero,
body.upload-stage .analysis-choice-panel,
.referral-panel {
  display: none;
}

.step-card {
  display: grid;
  min-height: calc(100dvh - 42px);
  align-content: center;
  gap: 18px;
  padding: 24px 0;
}

.step-card h1 {
  max-width: 12ch;
}

.step-card label {
  margin-top: 8px;
}

.captcha-question {
  margin: 6px 0 0;
  color: var(--gold);
  font-size: 34px;
  font-weight: 900;
  text-shadow: 0 0 22px rgba(255, 184, 95, 0.52);
}

.captcha-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow: 0 0 14px rgba(255, 184, 95, 0.62);
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
  font-family: var(--font-body);
  font-weight: 800;
  text-shadow: 0 2px 18px rgba(255, 184, 95, 0.34), 0 1px 2px rgba(0, 0, 0, 0.72);
}

h1 {
  max-width: 12ch;
  font-size: 42px;
  line-height: 0.98;
}

h2 {
  font-size: 20px;
}

.hero-copy {
  max-width: 34rem;
  margin: 16px 0 0;
  color: var(--muted);
  line-height: 1.45;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.62);
}

.panel {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid rgba(255, 213, 142, 0.34);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 213, 142, 0.14), rgba(124, 231, 215, 0.06)),
    var(--panel-bg);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.34), inset 0 0 28px rgba(255, 184, 95, 0.06);
  backdrop-filter: blur(14px);
}

.status-panel {
  display: none;
  color: var(--muted);
}

.referral-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
}

.referral-panel p:not(.eyebrow) {
  margin: 8px 0 0;
  color: #d8c9bd;
  font-size: 13px;
  line-height: 1.4;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.section-head strong {
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 213, 142, 0.18);
  color: #ffe5b7;
  font-size: 13px;
  white-space: nowrap;
  box-shadow: 0 0 18px rgba(255, 184, 95, 0.18);
}

.upload-panel {
  display: grid;
  gap: 9px;
  margin-top: 8px;
  padding: 12px;
}

.upload-panel h2 {
  font-size: 18px;
}

.upload-panel .choice-copy {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.35;
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.upload-panel label {
  font-size: 12px;
}

.upload-panel input[type="file"],
.upload-panel input[type="number"] {
  min-height: 36px;
  padding: 7px;
  font-size: 12px;
}

.upload-panel input[type="number"] {
  font-size: 16px;
}

label {
  display: grid;
  gap: 6px;
  color: #fff4e4;
  font-size: 14px;
  font-weight: 700;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.55);
}

select,
input[type="file"],
input[type="number"],
input[type="text"] {
  width: 100%;
  min-height: 40px;
  border: 1px solid rgba(255, 213, 142, 0.42);
  border-radius: 8px;
  background: rgba(17, 10, 25, 0.72);
  color: var(--text);
  padding: 9px;
  font-size: 16px;
  box-shadow: inset 0 0 18px rgba(255, 184, 95, 0.08), 0 8px 24px rgba(0, 0, 0, 0.18);
}

input[type="file"] {
  font-size: 12px;
}

select:focus,
input[type="file"]:focus,
input[type="number"]:focus,
input[type="text"]:focus {
  outline: 2px solid rgba(255, 213, 142, 0.36);
  outline-offset: 2px;
}

.consent {
  grid-template-columns: 20px 1fr;
  align-items: start;
  color: #f3dfce;
  font-weight: 500;
  line-height: 1.35;
}

.consent input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
}

.actions {
  position: fixed;
  right: 0;
  bottom: calc(72px + env(safe-area-inset-bottom));
  left: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  width: min(100vw, 760px);
  max-width: 100vw;
  margin: 0 auto;
  padding: 8px 16px;
  background: linear-gradient(180deg, transparent, rgba(18, 11, 26, 0.94) 28%);
  z-index: 5;
}

.payment-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(9, 5, 14, 0.74);
  backdrop-filter: blur(14px);
}

.payment-modal__card {
  display: grid;
  width: min(100%, 420px);
  max-width: 100%;
  min-width: 0;
  gap: 14px;
  padding: 18px;
  border: 1px solid rgba(255, 213, 142, 0.34);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 213, 142, 0.12), rgba(140, 110, 255, 0.1)),
    var(--panel-bg-strong);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.52), 0 0 34px rgba(255, 184, 95, 0.12);
}

.payment-modal__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.choice-copy {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.48);
}

.main-analysis-choice,
.result-next,
.analysis-continue {
  margin-top: 14px;
}

.result-panel {
  max-width: 100%;
  min-width: 0;
  margin-bottom: 92px;
}

#resultText {
  max-width: 100%;
  overflow-x: hidden;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  word-break: break-word;
}

.result-next {
  width: 100%;
}

.cabinet-panel {
  display: grid;
  gap: 14px;
}

.cabinet-profile {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 8px 12px;
  align-items: center;
}

.cabinet-profile .eyebrow,
.cabinet-profile h2,
.cabinet-profile .cabinet-user {
  grid-column: 2;
}

.cabinet-avatar {
  grid-row: 1 / span 4;
  width: 54px;
  height: 54px;
  border: 1px solid rgba(255, 213, 142, 0.48);
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 22px rgba(255, 184, 95, 0.28);
}

.cabinet-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.cabinet-stat {
  min-width: 0;
  padding: 10px;
  border: 1px solid rgba(255, 213, 142, 0.24);
  border-radius: 8px;
  background: rgba(17, 10, 25, 0.5);
}

.cabinet-stat span,
.shop-status {
  display: block;
  overflow-wrap: anywhere;
}

.cabinet-stat strong {
  display: block;
  color: var(--text);
  font-size: 18px;
}

.cabinet-list {
  display: grid;
  gap: 12px;
}

.cabinet-card {
  display: grid;
  min-width: 0;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(255, 213, 142, 0.28);
  border-radius: 8px;
  background: rgba(17, 10, 25, 0.58);
  box-shadow: inset 0 0 22px rgba(255, 184, 95, 0.05);
}

.cabinet-card h3,
.cabinet-card p {
  margin: 0;
}

.cabinet-meta,
.cabinet-user,
.cabinet-subtitle {
  color: var(--muted);
  font-size: 13px;
}

.cabinet-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cabinet-images a {
  padding: 8px 10px;
  border: 1px solid rgba(255, 211, 143, 0.52);
  border-radius: 8px;
  color: #ffe5b7;
  font-size: 13px;
  text-decoration: none;
}

.cabinet-folder-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.cabinet-wallet {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 213, 142, 0.26);
  border-radius: 8px;
  background: rgba(17, 10, 25, 0.54);
}

.cabinet-wallet-value {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.friends-panel {
  display: grid;
  gap: 14px;
}

.friends-actions,
.shop-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.shop-methods {
  display: grid;
  gap: 10px;
}

.shop-panel {
  display: grid;
  min-width: 0;
  gap: 14px;
}

.shop-method {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(255, 213, 142, 0.28);
  border-radius: 8px;
  background: rgba(17, 10, 25, 0.56);
}

.shop-method-stars {
  border-color: rgba(255, 213, 142, 0.48);
}

.shop-method-ton {
  border-color: rgba(124, 231, 215, 0.46);
}

.friends-list,
.tasks-list {
  display: grid;
  gap: 10px;
}

.friend-card,
.task-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(255, 213, 142, 0.25);
  border-radius: 8px;
  background: rgba(17, 10, 25, 0.56);
}

.friend-card h3,
.task-card h3 {
  margin: 0;
  font-size: 15px;
}

.friend-card p,
.task-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.premium-mark {
  color: var(--gold);
  font-weight: 800;
  text-shadow: 0 0 14px rgba(255, 184, 95, 0.55);
}

.ton-payment-box {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(255, 213, 142, 0.36);
  border-radius: 8px;
  background: rgba(17, 10, 25, 0.54);
}

.ton-payment-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  min-width: 0;
  padding: 10px;
  border: 1px solid rgba(255, 213, 142, 0.2);
  border-radius: 8px;
  background: rgba(7, 4, 12, 0.38);
}

.ton-payment-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.ton-payment-row strong {
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ton-payment-link {
  display: grid;
  min-height: 48px;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--gold), var(--rose));
  color: #2a1830;
  font-weight: 900;
  text-decoration: none;
  box-shadow: 0 0 24px rgba(255, 184, 95, 0.28);
}

.cabinet-folder {
  cursor: default;
}

.scan-toast {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(9, 5, 14, 0.58);
  backdrop-filter: blur(10px);
}

.scan-toast__card {
  width: min(100%, 360px);
  padding: 16px;
  border: 1px solid rgba(255, 213, 142, 0.38);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 213, 142, 0.12), rgba(140, 110, 255, 0.12)),
    var(--panel-bg-strong);
  color: var(--text);
  text-align: center;
  font-weight: 800;
  line-height: 1.35;
  white-space: pre-line;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.52), 0 0 34px rgba(255, 184, 95, 0.18);
}

.bottom-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  width: min(100vw, 760px);
  max-width: 100vw;
  margin: 0 auto;
  padding: 12px 10px max(12px, env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, rgba(34, 18, 43, 0.78), rgba(10, 6, 15, 0.96)),
    rgba(18, 11, 26, 0.94);
  border-top: 1px solid rgba(255, 213, 142, 0.32);
  box-shadow: 0 -12px 36px rgba(0, 0, 0, 0.44), inset 0 1px 0 rgba(255, 213, 142, 0.12);
  backdrop-filter: blur(16px);
}

.bottom-bar button {
  min-width: 0;
  min-height: 54px;
  padding: 8px 4px;
  font-family: var(--font-body);
  font-size: 12px;
  line-height: 1.12;
  white-space: normal;
  overflow-wrap: anywhere;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 213, 142, 0.98), rgba(216, 137, 197, 0.94)),
    var(--gold);
  color: #2a1830;
  font-family: var(--font-body);
  font-weight: 900;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.28), 0 0 22px rgba(255, 184, 95, 0.3);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.22);
}

button:disabled {
  opacity: 0.55;
  box-shadow: none;
}

button.ghost {
  border: 1px solid rgba(255, 213, 142, 0.58);
  background: rgba(17, 10, 25, 0.48);
  color: #ffe5b7;
  box-shadow: inset 0 0 18px rgba(255, 184, 95, 0.07), 0 0 18px rgba(140, 110, 255, 0.12);
  text-shadow: 0 0 12px rgba(255, 184, 95, 0.42);
}

pre {
  margin: 14px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: #fff3e5;
  font-family: var(--font-reading);
  line-height: 1.45;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5);
}

@media (max-width: 560px) {
  h1 {
    max-width: 11ch;
    font-size: 36px;
  }

  .sections-grid,
  .actions,
  .referral-panel,
  .cabinet-folder-actions,
  .friends-actions,
  .shop-actions,
  .payment-modal__actions {
    grid-template-columns: 1fr;
  }

}
