:root {
  --ink: #120d08;
  --panel: #21170e;
  --gold: #e2b34f;
  --gold-light: #ffe3a0;
  --red: #b52d20;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { background: var(--ink); color: #fff4d6; font-family: Georgia, 'Times New Roman', serif; }
button { font: inherit; }

html.standalone,
html.standalone body {
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  background: #000;
}

html.standalone #shell {
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  min-height: 100dvh;
}

#shell {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  width: var(--app-width, 100vw);
  height: var(--app-height, 100vh);
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 25%, rgba(226,179,79,.15), transparent 34%),
    linear-gradient(135deg, #090705 0%, #21130b 48%, #080604 100%);
}

#ambient {
  position: fixed;
  inset: -20%;
  pointer-events: none;
  opacity: .45;
  background-image: repeating-linear-gradient(115deg, transparent 0 30px, rgba(255,255,255,.018) 31px 32px);
  animation: drift 18s linear infinite;
}

html.game-running #ambient { display: none; }

#unity-container, #unity-canvas { width: 100%; height: 100%; }
#unity-container { position: relative; }
#unity-canvas { display: block; background: #000; outline: none; }

#loading-cover, #start-overlay, #rotate-overlay, #error-overlay, #fullscreen-help, #install-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(12,8,5,.96);
}

.brand-mark {
  color: var(--gold-light);
  font-size: clamp(36px, 7vw, 78px);
  font-weight: 900;
  line-height: .95;
  letter-spacing: .08em;
  white-space: nowrap;
  text-shadow: 0 2px 0 #6d3e15, 0 0 30px rgba(226,179,79,.35);
}
.brand-mark span { color: #d13b28; }
.brand-mark.large { font-size: clamp(38px, 8vw, 82px); }
.loading-copy { margin-top: 14px; color: #cdbb91; font-size: 15px; letter-spacing: .04em; }

#progress-track {
  width: min(460px, 78vw);
  height: 9px;
  margin-top: 26px;
  overflow: hidden;
  border: 1px solid #70532b;
  border-radius: 20px;
  background: #070503;
}
#progress-bar { width: 0; height: 100%; background: linear-gradient(90deg, var(--red), var(--gold)); transition: width .18s ease; }
#loading-percent { margin-top: 9px; color: var(--gold); font-family: Consolas, monospace; }

#fullscreen-button {
  display: none;
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  width: 42px;
  height: 42px;
  border: 1px solid #e6bd63;
  border-radius: 9px;
  background: rgba(20,14,8,.78) url('fullscreen-button.png') center/22px no-repeat;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

#start-overlay, #rotate-overlay, #error-overlay, #fullscreen-help, #install-overlay { display: none; }

#install-button {
  display: none;
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 30;
  padding: 10px 17px;
  border: 1px solid #356f7c;
  border-radius: 999px;
  color: #9dfbea;
  background: rgba(9, 19, 43, .92);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
  font-weight: 800;
  letter-spacing: .02em;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

#install-overlay {
  z-index: 45;
  align-items: center;
  justify-content: flex-start;
  padding: max(24px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  overflow-y: auto;
  background-color: #080e21;
  background-image:
    linear-gradient(rgba(111, 137, 213, .105) 1px, transparent 1px),
    linear-gradient(90deg, rgba(111, 137, 213, .105) 1px, transparent 1px),
    radial-gradient(circle at 18% 10%, rgba(53, 232, 207, .1), transparent 32%),
    radial-gradient(circle at 90% 90%, rgba(110, 83, 255, .12), transparent 34%);
  background-size: 74px 74px, 74px 74px, auto, auto;
}

.install-card {
  width: min(980px, 100%);
  min-height: 100%;
  padding: clamp(18px, 4vw, 54px) 0 24px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  text-align: left;
}

.install-brand-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; color: #f4f6ff; }
.install-brand { font-size: clamp(13px, 2vw, 18px); font-weight: 900; letter-spacing: .22em; }
.install-ready { display: inline-flex; align-items: center; gap: 10px; color: #79f2df; font-size: clamp(13px, 2vw, 18px); font-weight: 800; white-space: nowrap; }
.install-ready i { display: block; width: 13px; height: 13px; border-radius: 50%; background: #69f1dc; box-shadow: 0 0 0 10px rgba(105, 241, 220, .11); }
.install-rule { height: 1px; margin-top: clamp(20px, 4vw, 42px); background: linear-gradient(90deg, rgba(141, 161, 223, .52), rgba(141, 161, 223, .22), transparent); }
.install-kicker { margin: clamp(26px, 5vw, 66px) 0 1em; color: #65e9d4; font-size: clamp(15px, 2.8vw, 28px); font-weight: 900; letter-spacing: clamp(.04em, .16vw, .16em); line-height: 1.3; white-space: nowrap; }
#install-message { max-width: 860px; margin: 0; color: #d8def2; font-size: clamp(18px, 3vw, 29px); line-height: 1.38; }
#install-context-copy { display: none; max-width: 880px; margin: 22px 0 0; color: #8795bd; font-size: clamp(15px, 2vw, 20px); line-height: 1.5; }
#install-context-copy.native-ready { color: #9dfbea; }

.install-image-gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-top: 28px; }
.install-image-card { margin: 0; overflow: hidden; border: 1px solid #354777; border-radius: 22px; background: #131e42; box-shadow: 0 18px 50px rgba(0, 0, 0, .25); }
.install-image-card img { display: block; width: 100%; height: auto; image-rendering: auto; }
.install-image-card figcaption { padding: 13px 16px 16px; color: #c7d0e9; font-size: 15px; line-height: 1.4; }

@media (max-width: 640px) {
  .install-image-gallery { grid-template-columns: 1fr; gap: 16px; }
  .install-image-card { border-radius: 18px; }
}
.install-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 12px; margin-top: 20px; margin-bottom: 24px; }
#install-now-button { padding: 12px 22px; border-radius: 11px; font-weight: 800; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
#install-now-button { border: 1px solid #72f0dc; color: #061b25; background: linear-gradient(135deg, #8dfff0, #5ddfcf); box-shadow: 0 8px 22px rgba(93, 223, 207, .2); }

@media (max-width: 640px) {
  #install-button { top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); padding: 8px 13px; font-size: 13px; }
  .install-card { padding-top: 10px; }
  .install-brand-row { align-items: flex-start; }
  .install-brand { letter-spacing: .16em; }
  .install-ready { gap: 8px; font-size: 12px; }
  .install-ready i { width: 10px; height: 10px; box-shadow: 0 0 0 7px rgba(105, 241, 220, .11); }
  .install-kicker { max-width: none; font-size: 14px; letter-spacing: .05em; }
  #install-message { font-size: 19px; }
}

.start-card { width: min(720px, calc(100vw - 28px)); max-height: calc(100vh - 28px); max-height: calc(var(--app-height, 100vh) - 28px); overflow: auto; text-align: center; padding: 32px; border: 1px solid #6e4d26; border-radius: 20px; background: rgba(26,18,10,.88); box-shadow: 0 30px 90px #000; }
.start-card p { color: #c9b68c; }
#start-button {
  margin-top: 18px;
  padding: 13px 34px;
  border: 1px solid #ffd579;
  border-radius: 10px;
  color: #251506;
  background: linear-gradient(#ffd875, #c98c27);
  font-weight: 800;
  font-size: 20px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

#rotate-overlay { gap: 13px; text-align: center; padding: 30px; }
#rotate-overlay span { color: #bcae8d; }
.phone-icon { width: 70px; height: 118px; border: 4px solid var(--gold); border-radius: 15px; animation: rotate-phone 1.5s ease-in-out infinite; }
#error-message { max-width: 600px; padding: 24px; color: #ffd0c8; text-align: center; }

#fullscreen-help {
  position: absolute;
  z-index: 40;
  width: 100%;
  height: 100%;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  overflow: hidden;
  background: rgba(5, 4, 3, .72);
}

.fullscreen-help-card {
  width: min(560px, calc(100vw - 36px));
  max-width: 100%;
  max-height: 100%;
  padding: 22px;
  overflow: hidden;
  border: 1px solid #e6bd63;
  border-radius: 14px;
  background: #21170e;
  box-shadow: 0 20px 70px #000;
  text-align: center;
  display: flex;
  flex-direction: column;
}

.fullscreen-help-card strong,
.fullscreen-help-card span { display: block; }
.fullscreen-help-card strong { color: var(--gold-light); font-size: 18px; }
.fullscreen-help-card span { min-height: 0; margin-top: 10px; overflow-y: auto; color: #e7d7b5; line-height: 1.45; }
#fullscreen-help-close {
  flex: 0 0 auto;
  margin-top: 16px;
  padding: 9px 24px;
  border: 1px solid #ffd579;
  border-radius: 9px;
  color: #251506;
  background: linear-gradient(#ffd875, #c98c27);
  font-weight: 800;
}

@keyframes rotate-phone { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(90deg); } }
@keyframes drift { to { transform: translate3d(8%, 4%, 0); } }

@media (orientation: landscape) and (max-height: 640px) {
  #start-overlay {
    padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }

  .start-card {
    width: min(760px, 100%);
    max-height: 100%;
    padding: clamp(10px, 3vh, 20px) 24px;
    border-radius: 14px;
  }

  .brand-mark.large { font-size: clamp(30px, 10vh, 56px); letter-spacing: .045em; }
  .start-card p { margin: 8px 0; font-size: clamp(13px, 3.5vh, 17px); }
  #start-button { margin-top: 4px; padding: 9px 28px; font-size: 17px; }

  #fullscreen-help {
    padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }

  .fullscreen-help-card {
    width: min(720px, 100%);
    padding: clamp(8px, 3vh, 16px) 18px;
    border-radius: 10px;
  }

  .fullscreen-help-card strong { font-size: clamp(14px, 4.5vh, 18px); line-height: 1.15; }
  .fullscreen-help-card span { margin-top: 6px; font-size: clamp(12px, 3.8vh, 15px); line-height: 1.25; }
  #fullscreen-help-close { margin-top: 8px; padding: 6px 20px; font-size: 14px; }
}

@media (orientation: landscape) and (max-height: 340px) {
  .fullscreen-help-card { padding: 7px 14px; }
  .fullscreen-help-card strong { font-size: 13px; }
  .fullscreen-help-card span { margin-top: 4px; font-size: 11px; line-height: 1.2; }
  #fullscreen-help-close { margin-top: 6px; padding: 5px 18px; font-size: 13px; }
}
