/* Sowheart web loader: same palette as Resources/UI/Farm.uss (cream panel, wood text, gold road) over the
   sign-in backdrop's sky (AuthBackdrop: #7EC7E2 fading to #FFECC8 at the horizon) and rolling hills. */
@font-face {
  font-family: "Mali";
  src: url("Mali-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

:root {
  --sky-top: #7EC7E2;
  --sky-horizon: #FFECC8;
  --hill-far: #A9D47A;
  --hill-near: #91C95B;
  --leaf-dark: #437A3A;
  --outline: #49352D;
  --cream: #FFF0C9;
  --cream-2: #FBE5B4;
  --paper: #F5D79B;
  --paper-dark: #E3BF7E;
  --wood-dark: #65402E;
  --text-2: #795E4D;
  --gold: #F2B84B;
  --gold-dark: #C68A2E;
  --gold-light: #FFDE8C;
  --progress-fill: #9C6118;
  --primary: #347A2E;
  --primary-hover: #2F6B2A;
  --primary-lip: #245420;
  --danger-text: #B84A3E;
  --pad-top: max(16px, env(safe-area-inset-top));
  --pad-right: max(16px, env(safe-area-inset-right));
  --pad-bottom: max(16px, env(safe-area-inset-bottom));
  --pad-left: max(16px, env(safe-area-inset-left));
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--sky-top);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  font-family: "Mali", "Comic Neue", "Segoe Print", cursive;
  font-weight: 700;
  color: var(--wood-dark);
}

/* ---------- game canvas: the whole viewport ---------- */
#sh-stage {
  position: fixed;
  inset: 0;
  background: linear-gradient(to bottom, var(--sky-top), var(--sky-horizon));
}
#unity-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: transparent;
  outline: none;
  touch-action: none;
}

/* ---------- loader ---------- */
#sh-loader {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  overflow: hidden;
  transition: opacity 0.5s ease, visibility 0.5s;
}
#sh-loader.sh-done { opacity: 0; visibility: hidden; }
#sh-loader[hidden] { display: none; }

.sh-sky {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, var(--sky-top) 0%, #B5DDE6 48%, var(--sky-horizon) 78%);
}
.sh-sun {
  position: absolute;
  left: 50%;
  bottom: 22%;
  width: min(60vmin, 520px);
  aspect-ratio: 1;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 222, 140, 0.75) 0%, rgba(255, 236, 200, 0.35) 45%, rgba(255, 236, 200, 0) 70%);
  animation: sh-breathe 5s ease-in-out infinite;
}
.sh-cloud {
  position: absolute;
  height: 34px;
  border-radius: 34px;
  background: rgba(255, 255, 255, 0.85);
  filter: drop-shadow(0 3px 0 rgba(73, 53, 45, 0.08));
}
.sh-cloud::before, .sh-cloud::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: inherit;
}
.sh-cloud::before { width: 54px; height: 54px; left: 18%; top: -26px; }
.sh-cloud::after { width: 40px; height: 40px; left: 52%; top: -18px; }
.sh-cloud-a { width: 150px; top: 12%; left: -170px; animation: sh-drift 48s linear infinite; }
.sh-cloud-b { width: 110px; top: 24%; left: -130px; opacity: 0.8; animation: sh-drift 66s linear -24s infinite; }
.sh-hill {
  position: absolute;
  left: -20%;
  right: -20%;
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
}
.sh-hill-far { bottom: 0; height: 30%; background: var(--hill-far); left: -40%; right: 10%; }
.sh-hill-near { bottom: 0; height: 20%; background: var(--hill-near); border-top: 4px solid #62A94F; left: -10%; right: -30%; }

.sh-content {
  position: relative;
  z-index: 1;
  margin: auto;
  width: 100%;
  max-width: 640px;
  padding: var(--pad-top) var(--pad-right) var(--pad-bottom) var(--pad-left);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(14px, 3.2vh, 32px);
}

.sh-brand { display: flex; flex-direction: column; align-items: center; text-align: center; }
.sh-emblem {
  width: clamp(96px, 22vmin, 168px);
  height: auto;
  filter: drop-shadow(0 6px 0 rgba(73, 53, 45, 0.18));
  animation: sh-bob 3.2s ease-in-out infinite;
}
.sh-titles { display: flex; flex-direction: column; align-items: center; }
.sh-wordmark { width: clamp(220px, 58vmin, 400px); height: auto; margin-top: -4px; }
.sh-tagline {
  margin: 4px 0 0;
  padding: 4px 16px;
  border-radius: 999px;
  background: rgba(73, 53, 45, 0.72);
  color: var(--cream);
  font-size: clamp(13px, 1.9vmin, 16px);
  letter-spacing: 0.3px;
}

.sh-panel {
  width: min(100%, 520px);
  padding: 16px 20px 18px;
  border-radius: 22px;
  background: rgba(255, 240, 201, 0.96);
  border: 3px solid var(--outline);
  border-bottom-width: 7px;
  box-shadow: 0 10px 24px rgba(73, 53, 45, 0.18);
}
.sh-panel[hidden] { display: none; }

.sh-status-row { display: flex; align-items: center; gap: 10px; min-height: 26px; font-size: 17px; }
.sh-pulse {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold-dark);
  animation: sh-pulse 1.2s ease-in-out infinite;
}
#sh-status { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#sh-percent { flex: none; font-variant-numeric: tabular-nums; color: var(--progress-fill); }

.sh-road {
  position: relative;
  margin-top: 12px;
  height: 14px;
  border-radius: 7px;
  background: var(--paper);
  border: 2px solid var(--paper-dark);
}
.sh-road-fill {
  position: relative;
  height: 100%;
  width: 0;
  border-radius: 6px;
  background: var(--progress-fill);
  border-top: 3px solid var(--gold);
  transition: width 0.25s ease-out;
}
.sh-comet {
  position: absolute;
  right: -12px;
  top: 50%;
  width: 24px;
  height: 24px;
  margin-top: -12px;
  border-radius: 50%;
  background: radial-gradient(circle, #FFF6D8 0 30%, var(--gold) 31% 42%, rgba(255, 222, 140, 0.5) 43%);
}

/* ---------- error ---------- */
.sh-error { text-align: center; }
.sh-error-title { margin: 0 0 6px; font-size: 22px; color: var(--wood-dark); }
.sh-error-text { margin: 0 0 12px; font-size: 15px; line-height: 1.45; color: var(--text-2); }
.sh-error-detail { margin: 0 0 14px; text-align: left; font-size: 12px; color: var(--text-2); }
.sh-error-detail[hidden] { display: none; }
.sh-error-detail summary { cursor: pointer; text-align: center; }
.sh-error-detail pre {
  margin: 8px 0 0;
  padding: 8px 10px;
  max-height: 120px;
  overflow: auto;
  border-radius: 10px;
  background: var(--cream-2);
  white-space: pre-wrap;
  word-break: break-word;
  font: 12px/1.4 ui-monospace, Consolas, monospace;
}
.sh-btn {
  min-height: 46px;
  min-width: 160px;
  padding: 8px 24px;
  border-radius: 14px;
  border: 2px solid var(--primary-lip);
  border-bottom-width: 5px;
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-size: 17px;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease;
}
.sh-btn:hover { background: var(--primary-hover); transform: translateY(-2px); }
.sh-btn:active { transform: translateY(1px); border-bottom-width: 3px; }
.sh-btn:focus-visible { outline: 3px solid #2F7C9A; outline-offset: 3px; }

/* ---------- toasts (engine warnings) ---------- */
#sh-toasts {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: var(--pad-bottom);
  transform: translateX(-50%);
  width: min(92vw, 460px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.sh-toast {
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(73, 53, 45, 0.9);
  color: var(--cream);
  font-size: 14px;
  border: 2px solid rgba(255, 240, 201, 0.22);
  transition: opacity 0.4s ease;
}
.sh-toast-warn { background: var(--gold); color: #3A2410; border-color: var(--gold-dark); }
.sh-toast-out { opacity: 0; }

/* ---------- fullscreen button (desktop, near the top edge) ---------- */
#sh-fullscreen {
  position: fixed;
  z-index: 15;
  top: 8px;
  left: 50%;
  width: 40px;
  height: 40px;
  margin-left: -20px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 2px solid var(--outline);
  border-bottom-width: 4px;
  background: rgba(73, 53, 45, 0.86);
  color: var(--cream);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
#sh-fullscreen[hidden] { display: none; }
#sh-fullscreen.sh-fs-show, #sh-fullscreen:focus-visible { opacity: 1; pointer-events: auto; }
#sh-fullscreen.sh-fs-on svg { transform: rotate(180deg); }

/* ---------- small and landscape screens ---------- */
@media (max-height: 520px) and (orientation: landscape) {
  .sh-content { max-width: 860px; flex-direction: row; justify-content: center; gap: 24px; }
  .sh-brand { flex-direction: row; gap: 12px; }
  .sh-emblem { width: clamp(80px, 24vh, 128px); }
  .sh-wordmark { width: clamp(180px, 34vw, 300px); }
  .sh-titles { align-items: center; }
  .sh-panel { width: min(46vw, 420px); }
}
@media (max-width: 360px) {
  .sh-panel { padding: 12px 14px 14px; }
  .sh-status-row { font-size: 15px; }
}

@keyframes sh-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes sh-breathe { 0%, 100% { opacity: 0.85; } 50% { opacity: 1; } }
@keyframes sh-pulse { 0%, 100% { transform: scale(0.8); opacity: 0.6; } 50% { transform: scale(1.15); opacity: 1; } }
@keyframes sh-drift { from { transform: translateX(0); } to { transform: translateX(calc(100vw + 340px)); } }

@media (prefers-reduced-motion: reduce) {
  .sh-emblem, .sh-sun, .sh-cloud, .sh-pulse { animation: none; }
  .sh-road-fill { transition: none; }
}
