/*
 * RoRe page styles: the loading screen shown before the game draws anything. Loaded after the inline
 * styles of index.html, which it overrides.
 */
html,
body {
  background: #0b0e1a;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

/* The loading screen: the game's own title picture (the login screen's background, so the two
   run into each other), with the spinner and the text on a dark band along the bottom. */
#ro-preloader {
  background: #0b0e1a url("loading.jpg") center top / cover no-repeat;
  justify-content: flex-end;
  gap: 12px;
  padding-bottom: max(7vh, calc(env(safe-area-inset-bottom) + 20px));
  box-sizing: border-box;
}
#ro-preloader::before {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 34%;
  background: linear-gradient(transparent, rgba(11, 14, 26, 0.78));
  pointer-events: none;
}
#ro-preloader > * {
  position: relative;
}

#ro-preloader .pre-spinner {
  width: 44px;
  height: 44px;
  margin: 0;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  animation-duration: 0.9s;
}

#ro-preloader .pre-text {
  margin: 0;
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    "Noto Sans Thai",
    "Leelawadee UI",
    Tahoma,
    sans-serif;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

#ro-preloader .pre-text span {
  animation: none;
}

@media (prefers-reduced-motion: reduce) {
  #ro-preloader .pre-spinner {
    animation-duration: 2.4s;
  }
}

/*
 * The in-game web window (rore-boot.js): a site opened over the game, with a bar to get back.
 */
.rore-web {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  flex-direction: column;
  background: #0b0e1a;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
  animation: rore-web-in 0.2s ease-out;
}

@keyframes rore-web-in {
  from {
    transform: translateY(16px);
  }
}

.rore-web-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  height: 56px;
  padding: 0 8px;
  background: #151a2e;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    "Noto Sans Thai",
    "Leelawadee UI",
    Tahoma,
    sans-serif;
  color: #f4f5fa;
}

.rore-web-bar button {
  flex: none;
  height: 44px;
  margin: 0;
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.rore-web-back {
  background: #5b63e6;
}

.rore-web-back:active {
  background: #4a50cf;
}

.rore-web-external {
  background: rgba(255, 255, 255, 0.08);
  font-weight: 500 !important;
}

.rore-web-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  font-size: 14px;
  color: #b9bfd3;
}

.rore-web-frame {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 0;
  background: #fff;
}

@media (max-width: 420px) {
  .rore-web-title {
    display: none;
  }

  .rore-web-external {
    margin-left: auto !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rore-web {
    animation: none;
  }
}

/*
 * The touch HUD (MobileUI, `mobileHud: true`) shows the character's values itself and puts this class
 * on <body> while it does. The BasicInfo window stays a live component -- everything that updates it
 * keeps working -- but is not drawn twice.
 */
body.rore-hud > [id^="BasicInfo"] {
  visibility: hidden !important;
  pointer-events: none !important;
}

/*
 * Window text in Tahoma, the face the Thai client draws its windows with. Phones do not ship Tahoma,
 * so the stack continues with the client's own defaults. Inherited through the components' shadow roots.
 */
html body {
  font-family: Tahoma, "SCDream", Arial, "Liberation Sans", Arimo, sans-serif;
}

/*
 * Classic interface under the touch HUD (`body.rore-hud`, set by MobileUI.js).
 *
 * Gone: the cash shop icon (the HUD's shop button opens the shop) and the shortcut bar, whose slots
 * the skill buttons show -- it comes back, mid-screen, while the skill list or the inventory is open,
 * to drag into. Moved: the chat box into the gap between the joystick and the skill buttons, the
 * status icons and the quest list under the character panel, clear of the buttons on the right.
 */
body.rore-hud > #CashShopIcon,
body.rore-hud > #ShortCut {
  visibility: hidden !important;
  pointer-events: none !important;
}
body.rore-hud > #ChatBox {
  --rore-chat-width: max(200px, calc(100vw - 132vmin));
  top: auto !important;
  bottom: 4.6vmin !important;
  left: 51vmin !important;
}
/* Buffs and debuffs: just under the character panel, beside the tools column, in rows from the
   left (the rows are the component's own stylesheet). */
body.rore-hud > #StatusIcons {
  top: 23vmin !important;
  right: auto !important;
  left: 13vmin !important;
}
body.rore-hud > #QuestWindow {
  top: 30vmin !important;
  right: auto !important;
  left: 34vmin !important;
}
@media (orientation: portrait) {
  body.rore-hud > #ChatBox {
    --rore-chat-width: calc(100vw - 54vmin);
    left: 52vmin !important;
  }
  body.rore-hud > #StatusIcons {
    top: 60vmin !important;
    left: 14vmin !important;
  }
  body.rore-hud > #QuestWindow {
    top: 60vmin !important;
    left: 16vmin !important;
  }
}

/* Under the HUD, on a screen that is not very wide, the gap between the joystick and the skill
   buttons is too small for the chat box: it goes under the character panel, beside the tools. */
@media (orientation: landscape) and (max-aspect-ratio: 17/10) {
  body.rore-hud > #ChatBox {
    --rore-chat-width: min(62vmin, calc(100vw - 96vmin));
    top: 29vmin !important;
    bottom: auto !important;
    left: 14vmin !important;
  }
  body.rore-hud > #StatusIcons,
  body.rore-hud > #QuestWindow {
    top: 62vmin !important;
    left: 50vmin !important;
  }
}

/* The chat box takes its width from the page under the HUD, so the shrink-to-fit that windows get
   on a small screen must not shrink it a second time. */
body.rore-hud > #ChatBox {
  transform: none !important;
  zoom: 1 !important;
}

/* Server announcements: top of the screen, in the middle (the component centres itself), on a
   soft dark band so they read over the scene and over the HUD's own text. */
body.rore-hud > #Announce {
  top: 1.5vmin !important;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(13, 16, 34, 0.55);
}

/*
 * The HUD is the bottom layer of the interface: every window opens above its buttons. As the top
 * layer (the touch controls' own z-index) the skill buttons sat on the NPC's message and its Close
 * button. The NPC window itself opens in the middle of the screen.
 */
body.rore-hud > #MobileUI {
  z-index: 45 !important;
}
body.rore-hud > #NpcBox {
  top: max(8px, calc(50% - 110px)) !important;
  left: calc(50% - 138px) !important;
}

/* "Phones only", for a visitor on a PC (rore-boot.js). Over everything, and not dismissable. */
.rore-notice {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(13, 16, 34, 0.86);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: #fff;
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    "Noto Sans Thai",
    "Leelawadee UI",
    Tahoma,
    sans-serif;
  text-align: center;
}
.rore-notice > div {
  max-width: 420px;
  padding: 28px 32px;
  border: 1px solid rgba(241, 201, 107, 0.75);
  border-radius: 16px;
  background: rgba(20, 23, 42, 0.92);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.rore-notice strong {
  display: block;
  margin-bottom: 10px;
  color: #ffe7a6;
  font-size: 20px;
}
.rore-notice p {
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
}

/* "Install first" (rore-boot.js, requireInstall): the same panel, with the steps. */
.rore-install ol {
  margin: 16px 0 0;
  padding-left: 22px;
  font-size: 15px;
  line-height: 1.7;
  text-align: left;
}
.rore-install li + li {
  margin-top: 6px;
}
.rore-install b {
  color: #ffe7a6;
}
.rore-install .rore-key {
  display: inline-block;
  min-width: 22px;
  padding: 0 4px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 6px;
  line-height: 20px;
  text-align: center;
}
.rore-install button {
  margin-top: 18px;
  padding: 12px 36px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #7584ff, #8e5cf6);
  color: #fff;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
}

/* "Clear cache", on the login screen only (rore-boot.js). Out of the way, big enough for a thumb. */
.rore-clear-cache {
  position: fixed;
  left: max(12px, env(safe-area-inset-left));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 60;
  padding: 9px 16px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  background: rgba(20, 23, 42, 0.62);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: #fff;
  font:
    600 14px/1.2 system-ui,
    -apple-system,
    "Segoe UI",
    "Noto Sans Thai",
    "Leelawadee UI",
    Tahoma,
    sans-serif;
  cursor: pointer;
}
.rore-clear-cache[hidden] {
  display: none;
}
.rore-clear-cache:active {
  background: rgba(91, 99, 230, 0.8);
}
