:root {
  --ink: #56364b;
  --panel: #fff8fc;
  --pink: #ff79b8;
  --pink-hot: #f1539c;
  --pink-light: #ffe1ef;
  --violet: #a98ae8;
  --cream: #fffaf2;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { background: #fff0f7; color: var(--ink); font-family: 'Avenir Next', 'Trebuchet MS', sans-serif; }
button { font: inherit; }

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

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 14% 20%, rgba(255,255,255,.94) 0 5%, transparent 5.3%),
    radial-gradient(circle at 84% 78%, rgba(255,255,255,.8) 0 7%, transparent 7.3%),
    radial-gradient(circle at 50% 22%, rgba(255,151,198,.3), transparent 28%),
    linear-gradient(145deg, #fff9fc 0%, #ffe3f1 48%, #eee7ff 100%);
}

#ambient {
  position: fixed;
  inset: -20%;
  pointer-events: none;
  opacity: .68;
  background-image:
    radial-gradient(circle, rgba(255,126,184,.15) 0 4px, transparent 4.5px),
    radial-gradient(circle at 72% 25%, rgba(174,145,238,.22), transparent 18%);
  background-size: 42px 42px, auto;
  filter: saturate(.92);
  animation: drift 24s ease-in-out infinite alternate;
}

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

#loading-cover, #start-overlay, #rotate-overlay, #error-overlay, #fullscreen-help {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 35%, rgba(255,255,255,.92), transparent 28%),
    linear-gradient(145deg, rgba(255,249,252,.98), rgba(255,224,240,.98) 52%, rgba(238,231,255,.98));
}

.brand-mark {
  position: relative;
  z-index: 0;
  color: #fff;
  font-family: 'Cooper Black', 'Avenir Next', 'Trebuchet MS', sans-serif;
  font-size: clamp(44px, 7.7vw, 86px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: .025em;
  white-space: nowrap;
  -webkit-text-stroke: 2px rgba(220,74,146,.7);
  text-shadow:
    0 4px 0 #e987b7,
    0 8px 18px rgba(190,96,143,.2);
}
.brand-mark::before {
  content: '';
  position: absolute;
  inset: -24px -34px -20px;
  z-index: -1;
  border: 2px solid rgba(255,255,255,.82);
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255,255,255,.72), rgba(255,184,217,.2) 58%, transparent 72%);
  box-shadow: 0 12px 35px rgba(205,111,159,.12);
  transform: rotate(-2deg);
}
.brand-mark::after {
  content: '✦';
  position: absolute;
  top: -30px;
  right: -28px;
  color: #fff;
  font-family: Georgia, serif;
  font-size: .34em;
  -webkit-text-stroke: 0;
  text-shadow: -24px 38px 0 #ffc3df, 0 0 12px rgba(255,255,255,.9);
}
.brand-mark span {
  color: var(--pink-hot);
  background: linear-gradient(180deg, #ffaed3 0%, #f367aa 55%, #c987dc 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand-mark.large { font-size: clamp(46px, 8vw, 90px); }
.loading-copy { margin-top: 34px; color: #9b7089; font-size: clamp(14px, 1.5vw, 17px); font-weight: 600; letter-spacing: .03em; }

#progress-track {
  width: min(460px, 78vw);
  height: 9px;
  margin-top: 26px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,.92);
  border-radius: 20px;
  background: rgba(255,255,255,.48);
  box-shadow: inset 0 1px 5px rgba(178,104,144,.16), 0 6px 18px rgba(196,117,158,.1);
}
#progress-bar {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #c7a8f5, #ff89be, #ffc6df, #ff89be);
  background-size: 220% 100%;
  box-shadow: 0 2px 10px rgba(238,93,160,.24);
  transition: width .18s ease;
  animation: pink-flow 1.8s linear infinite;
}
#loading-percent { margin-top: 10px; color: #d25f99; font-family: 'Avenir Next', sans-serif; font-weight: 800; }

#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: 2px solid rgba(255,255,255,.9);
  border-radius: 14px;
  background: rgba(255,170,210,.88) url('fullscreen-button.png') center/22px no-repeat;
  box-shadow: 0 8px 22px rgba(192,103,150,.18);
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

#start-overlay, #rotate-overlay, #error-overlay, #fullscreen-help { display: none; }
.start-card { width: min(760px, calc(100vw - 28px)); max-height: calc(100vh - 28px); max-height: calc(var(--app-height, 100vh) - 28px); overflow: auto; text-align: center; padding: 44px 32px 34px; border: 2px solid rgba(255,255,255,.9); border-radius: 32px; background: rgba(255,250,253,.82); box-shadow: 0 24px 70px rgba(151,91,126,.16); backdrop-filter: blur(14px); }
.start-card p { color: #9b7089; font-weight: 600; }
#start-button {
  margin-top: 18px;
  padding: 13px 34px;
  border: 2px solid rgba(255,255,255,.82);
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #c4a3ef, #f47caf 55%, #ffafd2);
  box-shadow: 0 10px 24px rgba(209,105,158,.2), inset 0 1px rgba(255,255,255,.45);
  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: #9b7089; }
.phone-icon { width: 70px; height: 118px; border: 4px solid #f58ab9; border-radius: 20px; box-shadow: 0 10px 28px rgba(205,112,159,.18); 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(100,65,87,.2);
}

.fullscreen-help-card {
  width: min(560px, calc(100vw - 36px));
  max-width: 100%;
  max-height: 100%;
  padding: 22px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,.9);
  border-radius: 24px;
  background: rgba(255,248,252,.96);
  box-shadow: 0 20px 60px rgba(132,79,111,.18);
  text-align: center;
  display: flex;
  flex-direction: column;
}

.fullscreen-help-card strong,
.fullscreen-help-card span { display: block; }
.fullscreen-help-card strong { color: #c9528e; font-size: 18px; }
.fullscreen-help-card span { min-height: 0; margin-top: 10px; overflow-y: auto; color: #79576b; line-height: 1.45; }
#fullscreen-help-close {
  flex: 0 0 auto;
  margin-top: 16px;
  padding: 9px 24px;
  border: 2px solid rgba(255,255,255,.82);
  border-radius: 9px;
  color: #fff;
  background: linear-gradient(135deg, #c4a3ef, #f47caf 55%, #ffafd2);
  font-weight: 800;
}

@keyframes rotate-phone { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(90deg); } }
@keyframes drift { to { transform: translate3d(3%, 2%, 0) scale(1.02); } }
@keyframes pink-flow { to { background-position: -220% 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(32px, 10vh, 60px); }
  .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; }
}
