:root {
  color-scheme: dark;
  font-family: Inter, ui-rounded, "SF Pro Rounded", system-ui, -apple-system, sans-serif;
  background: #0c3045;
}

* {
  box-sizing: border-box;
}

html,
body,
#axie-town-app {
  width: 100%;
  height: 100%;
  height: 100dvh;
  margin: 0;
  overflow: hidden;
  background: #0c3045;
  overscroll-behavior: none;
}

button {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#unity-container {
  position: fixed;
  top: env(safe-area-inset-top, 0px);
  right: env(safe-area-inset-right, 0px);
  bottom: env(safe-area-inset-bottom, 0px);
  left: env(safe-area-inset-left, 0px);
  overflow: hidden;
  background: #102f43;
  touch-action: none;
}

#unity-canvas {
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  outline: none;
  transition: opacity 220ms ease-out;
}

#unity-canvas.ready {
  opacity: 1;
}

#unity-loading,
#launch-gate,
#compatibility-error,
#settings-panel {
  position: absolute;
  inset: 0;
}

#unity-loading {
  z-index: 20;
  display: grid;
  place-items: end center;
  padding: clamp(24px, 8vh, 72px) 24px;
  background:
    linear-gradient(180deg, rgba(6, 42, 63, 0.04), rgba(6, 42, 63, 0.28)),
    #3cc5e8 url("atia-loading.jpg") center / cover no-repeat;
}

.loading-card {
  width: min(420px, 76vw);
  padding: 14px 18px 16px;
  color: #143648;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 20px;
  background: rgba(255, 249, 221, 0.9);
  box-shadow: 0 12px 36px rgba(4, 39, 62, 0.24);
  backdrop-filter: blur(10px);
}

.loading-title {
  margin-bottom: 4px;
  font-size: 18px;
  font-weight: 800;
}

#loading-status {
  min-height: 20px;
  font-size: 13px;
  font-weight: 650;
}

.progress-track {
  height: 9px;
  margin-top: 10px;
  overflow: hidden;
  border: 1px solid rgba(20, 54, 72, 0.22);
  border-radius: 999px;
  background: rgba(20, 54, 72, 0.14);
}

#progress-value {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #36b8e1, #0b759f);
  transition: width 100ms linear;
}

#launch-gate,
#compatibility-error {
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 30% 20%, rgba(88, 220, 244, 0.26), transparent 44%),
    linear-gradient(145deg, #0c3045, #0d5877);
}

.gate-card {
  width: min(420px, 92vw);
  padding: clamp(24px, 5vw, 40px);
  color: #17384a;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 28px;
  background: #fff7db;
  box-shadow: 0 24px 70px rgba(2, 27, 44, 0.36);
}

.gate-card img {
  border-radius: 22px;
  box-shadow: 0 8px 22px rgba(10, 65, 91, 0.18);
}

.gate-card h1 {
  margin: 14px 0 8px;
  font-size: clamp(26px, 6vw, 42px);
  line-height: 1;
}

.gate-card p {
  margin: 0 0 20px;
  line-height: 1.45;
}

#gate-note {
  display: block;
  margin-top: 12px;
  color: #587281;
  font-size: 12px;
}

.primary-button,
.secondary-button {
  padding: 12px 20px;
  color: white;
  font-weight: 800;
  border-radius: 999px;
  background: #087da8;
  box-shadow: 0 8px 18px rgba(8, 125, 168, 0.25);
}

.primary-button:active,
.secondary-button:active,
.shell-button:active,
.option-grid button:active {
  transform: translateY(1px);
}

#shell-controls {
  position: absolute;
  z-index: 30;
  top: max(12px, env(safe-area-inset-top, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
  display: flex;
  gap: 8px;
}

.shell-button,
.close-button {
  display: grid;
  place-items: center;
  color: #17384a;
  font-size: 22px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 14px;
  background: rgba(255, 249, 221, 0.9);
  box-shadow: 0 8px 22px rgba(3, 35, 54, 0.22);
  backdrop-filter: blur(10px);
}

#settings-panel {
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 25, 39, 0.56);
  backdrop-filter: blur(8px);
}

.settings-card {
  width: min(460px, 92vw);
  max-height: min(640px, 90dvh);
  overflow: auto;
  padding: 22px;
  color: #17384a;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 24px;
  background: #fff7db;
  box-shadow: 0 24px 70px rgba(2, 27, 44, 0.42);
}

.settings-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.settings-heading h2,
.settings-heading p {
  margin: 0;
}

.settings-heading p {
  margin-top: 4px;
  color: #527181;
  font-size: 13px;
}

.close-button {
  flex: 0 0 44px;
  border-color: rgba(13, 83, 112, 0.14);
  background: rgba(13, 83, 112, 0.08);
  box-shadow: none;
}

.settings-section {
  margin-top: 20px;
}

.settings-section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.settings-section-heading h3 {
  margin: 0;
  font-size: 14px;
}

.settings-section-heading span {
  color: #527181;
  font-size: 12px;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.option-grid button {
  padding: 10px 8px;
  color: #385968;
  font-weight: 750;
  border: 1px solid rgba(13, 83, 112, 0.16);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.54);
}

.option-grid button.selected {
  color: white;
  border-color: #087da8;
  background: #087da8;
}

.diagnostic-line,
.install-help,
.release-line {
  margin: 8px 0;
  color: #527181;
  font-size: 12px;
  line-height: 1.45;
}

.secondary-button {
  width: 100%;
  margin-top: 12px;
}

.release-line {
  margin-top: 16px;
  opacity: 0.74;
}

#unity-warning {
  position: absolute;
  z-index: 60;
  right: 12px;
  bottom: 12px;
  left: 12px;
  pointer-events: none;
}

.warning-message {
  width: min(680px, 94vw);
  margin: 8px auto;
  padding: 10px 14px;
  color: #17384a;
  border-radius: 12px;
  background: #fff7db;
  box-shadow: 0 8px 24px rgba(3, 35, 54, 0.25);
}

.warning-message.error {
  color: white;
  background: #a93838;
}

[hidden] {
  display: none !important;
}

@media (max-height: 480px) and (orientation: landscape) {
  .gate-card {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 18px;
    width: min(700px, 92vw);
    padding: 20px 24px;
    text-align: left;
  }

  .gate-card img {
    grid-row: 1 / span 4;
  }

  .gate-card h1 {
    margin-top: 2px;
  }

  .gate-card p {
    margin-bottom: 10px;
  }

  .gate-card .primary-button,
  .gate-card #gate-note {
    justify-self: start;
  }

  .loading-card {
    width: min(460px, 58vw);
  }
}

@media (max-width: 520px) {
  .option-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  #unity-canvas,
  #progress-value {
    transition: none;
  }
}
