body { padding: 0; margin: 0; background: #bfe3f7 }
#unity-container { position: fixed; width: 100%; height: 100%; }
#unity-canvas { width: 100%; height: 100%; background: #231F20 }
#unity-loading-bar { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: none }
#unity-logo { width: 154px; height: 130px; background: url('unity-logo-dark.png') no-repeat center }
#unity-progress-bar-empty { margin-left: auto; margin-right: auto; width: 141px; height: 18px; margin-top: 10px; background: url('progress-bar-empty-dark.png') no-repeat center }
#unity-progress-bar-full { width: 0%; height: 18px; margin-top: 10px; background: url('progress-bar-full-dark.png') no-repeat center }
/* Outside the game container and above the start screen, so warnings during load stay visible. */
#unity-warning { position: fixed; left: 50%; top: calc(16px + env(safe-area-inset-top)); transform: translate(-50%); z-index: 10000; display: none; width: min(560px, calc(100% - 32px)) }

/* ---- Start screen (Super AI Engineer, MANGO 41) ---- */
.sk {
  --ink: #1f2a44;
  --ink-soft: #3d4a66;
  --paper: #fbfaf6;
  --bar: #2f7fc1;
  --bar-done: #3d8a4a;
  --action: #c24e36;
  --action-hover: #a93f2a;
  --waiting: #646d86;
  position: fixed;
  inset: 0;
  z-index: 9999;
  box-sizing: border-box;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow: auto;
  overscroll-behavior: contain;
  color: var(--ink);
  font-family: "Anuphan", "Noto Sans Thai", "Thonburi", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.7;
}
.sk[hidden] { display: none }
.sk .nw { white-space: nowrap }

.sk-scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block }
.sk-boat { transition: transform .4s ease-out }
.sk-bob { transform-box: fill-box; transform-origin: 50% 100% }
.sk-flag { opacity: 0; transition: opacity .2s }
.sk[data-state="waiting"] .sk-flag { opacity: 1 }
.sk[data-state="ready"] .sk-door { fill: #f2c94c }
.sk-waves path { animation: sk-drift 6s ease-in-out infinite alternate }
@keyframes sk-drift { to { transform: translateX(12px) } }

.sk-panel, .sk-error {
  position: relative;
  box-sizing: border-box;
  width: min(460px, calc(100% - 32px));
  margin: clamp(16px, 7vh, 72px) 0 32px clamp(16px, 7vw, 96px);
  padding: 28px 28px 24px;
  background: var(--paper);
  border-radius: 20px;
  box-shadow: 0 2px 0 rgba(31, 42, 68, .08), 0 18px 40px rgba(31, 42, 68, .12);
}
.sk-panel[hidden], .sk-error[hidden] { display: none }

.sk-org { margin: 0 0 4px; font-size: 15px; color: var(--ink-soft) }
.sk h1 { margin: 0; font-size: clamp(30px, 4.2vw, 40px); line-height: 1.2; font-weight: 700; letter-spacing: 0 }
.sk-lead { margin: 10px 0 22px; color: var(--ink-soft) }

.sk-progress { position: relative; --p: 0 }
.sk-progress-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-weight: 600 }
.sk-percent { font-variant-numeric: tabular-nums }
.sk-track { height: 12px; margin-top: 6px; background: #dbe9f3; border-radius: 999px; overflow: hidden }
.sk-fill { width: 0; height: 100%; background: var(--bar); border-radius: 999px; transition: width .3s ease-out }
.sk[data-state="ready"] .sk-fill { background: var(--bar-done) }
.sk[data-preparing] .sk-fill {
  background-image: repeating-linear-gradient(-45deg, rgba(255, 255, 255, .45) 0 6px, transparent 6px 12px);
  background-size: 17px 17px;
  animation: sk-flow .9s linear infinite;
}
@keyframes sk-flow { to { background-position: 17px 0 } }
.sk[data-preparing] .sk-bob { animation: sk-bob 1.8s ease-in-out infinite }
@keyframes sk-bob { 50% { transform: translateY(-5px) rotate(-2deg) } }

/* Small screens: the panel covers the sea, so the boat sails along the progress bar instead. */
.sk-barboat { display: none }
.sk-boat-in-bar .sk-boat { display: none }
.sk-boat-in-bar .sk-track { margin-top: 30px }
.sk-boat-in-bar .sk-barboat {
  display: block;
  position: absolute;
  bottom: 6px;
  left: calc(var(--p) * (100% - 26px));
  width: 26px;
  height: 27px;
  transition: left .3s ease-out;
}
.sk-boat-in-bar .sk-progress-head { position: relative; top: 0 }
.sk-boat-in-bar .sk-barboat { --sail: #86c1ea } /* the white sail would vanish against the panel */

.sk-enter {
  display: block;
  width: 100%;
  min-height: 52px;
  margin-top: 20px;
  padding: 12px 20px;
  border: 0;
  border-radius: 14px;
  background: var(--action);
  color: #fff;
  font: inherit;
  font-size: 19px;
  font-weight: 700;
  cursor: pointer;
}
.sk-enter:hover { background: var(--action-hover) }
.sk-enter:focus-visible, .sk-secondary:focus-visible, .sk-error summary:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px }
.sk-enter[hidden] { display: none }
.sk[data-state="waiting"] .sk-enter { background: var(--waiting); cursor: progress }
.sk-secondary {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 10px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.sk-note { margin: 8px 0 0; font-size: 15px; color: var(--ink-soft) }
.sk-note[hidden] { display: none }

.sk-controls { margin-top: 22px; padding-top: 18px; border-top: 1px solid #e6e1d6 }
.sk-controls h2 { margin: 0 0 8px; font-size: 17px; font-weight: 700 }
.sk-keys { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin: 0 }
.sk-keys[hidden] { display: none }
#sk-keys-desktop > div:first-child { grid-column: 1 / -1 } /* WASD needs the full row */
#sk-keys-touch { grid-template-columns: 1fr }
.sk-keys > div { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; min-width: 0 }
.sk-keys dt { display: flex; gap: 3px; flex-shrink: 0; font-weight: 600 }
.sk-keys dd { margin: 0; color: var(--ink-soft) }
.sk kbd {
  display: inline-block;
  min-width: 26px;
  padding: 0 6px;
  border: 1px solid #cfc8b8;
  border-bottom-width: 3px;
  border-radius: 6px;
  background: #fff;
  font: 600 14px/24px "Anuphan", system-ui, sans-serif;
  text-align: center;
  color: var(--ink);
}

.sk-error h2 { margin: 0 0 8px; font-size: 24px }
.sk-error p { margin: 0 }
.sk-error details { margin-top: 16px; font-size: 15px; color: var(--ink-soft) }
.sk-error summary { display: list-item; min-height: 44px; padding: 10px 0; box-sizing: border-box; cursor: pointer; text-decoration: underline; text-underline-offset: 3px }
.sk-error pre { white-space: pre-wrap; word-break: break-word; font-size: 13px; background: #f1ede4; padding: 10px; border-radius: 8px }

.sk-banner { padding: 10px 14px; border-radius: 12px; font: 15px/1.6 "Anuphan", system-ui, sans-serif; background: #fbfaf6; color: #1f2a44; box-shadow: 0 6px 18px rgba(31, 42, 68, .15) }
.sk-banner-warning { background: #fff4c9 }
.sk-banner-error { background: #fde2dd }

/* Loading only: a slim card at the bottom centre, under the sailing boat. */
.sk-panel.sk-loader {
  position: fixed;
  left: 50%;
  bottom: calc(clamp(20px, 7vh, 56px) + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(420px, calc(100% - 32px));
  margin: 0;
  padding: 14px 22px 18px;
}
.sk-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap }
.sk { transition: opacity .4s ease }
.sk.sk-leaving { opacity: 0 }

/* Phones and narrow windows */
@media (max-width: 600px) {
  .sk { font-size: 16px }
  .sk-panel, .sk-error { width: auto; margin: 12px 12px 24px; padding: 22px 18px 18px; border-radius: 16px }
  .sk-lead { margin-bottom: 18px }
}
@media (max-width: 380px) {
  .sk-keys { grid-template-columns: 1fr }
}
/* Tablets and small laptops: keep the panel clear of the island */
@media (min-width: 601px) and (max-width: 1024px) {
  .sk-panel, .sk-error { margin-left: 24px }
}
/* Landscape phones: short screens, so trim the panel instead of making people scroll to the button */
@media (max-height: 520px) and (orientation: landscape) {
  .sk-panel, .sk-error { width: min(420px, 55vw); margin: 10px 0 12px 16px; padding: 16px 18px 14px }
  .sk h1 { font-size: 26px; margin-bottom: 8px }
  .sk-lead, .sk-org { display: none }
  .sk-enter { margin-top: 12px; min-height: 46px }
  .sk-controls { margin-top: 12px; padding-top: 10px }
  .sk-controls .sk-note { display: none }
}
/* Large screens */
@media (min-width: 1600px) {
  .sk { font-size: 18px }
  .sk-panel, .sk-error { width: 500px; margin-left: 140px }
}
@media (prefers-reduced-motion: reduce) {
  .sk-boat, .sk-fill, .sk-flag, .sk-boat-in-bar .sk-barboat { transition: none }
  .sk-waves path, .sk[data-preparing] .sk-fill, .sk[data-preparing] .sk-bob { animation: none }
}
