@import "tutorial.css";
@import "modal.css";
@import "game-menu.css";
@import "character.css";
@import "event/encounter-talent.css";
@import "event/collect-nature-item.css";
@import "event/character-defeat.css";
@import "hook/select-building.css";
@import "hook/select-partner.css";
@import "facility/nature-item-camp.css";
:root{
  --z-index-back:-1;
  --z-index-front:1;
  --z-index-screen:50;
  --z-index-map-control: 100;
  --z-index-map-action-effect: 1000;
  --z-index-map-action-modal: 1100;
  --z-index-main-modal: 2000;
  --z-index-main-action-model: 2100;
  --z-index-effect: 3000;
  --z-index-loading-effect: 5000;
}
*{box-sizing:border-box;}
html{
  -webkit-user-select: none; /* Safari */
  user-select: none;
  overscroll-behavior: none;
  touch-action: none;
}
body{
  -webkit-user-select: none; /* Safari */
  user-select: none;
  overscroll-behavior: none;
  touch-action: none;

  width:100dvw;
  height:100dvh;

  margin: 0;
  background: #17212b;
  color: white;
  font-family: sans-serif;
  font-size: 15px;

  display: flex;
  flex-direction: column;
  align-items: center;
}
body.building-placement-active #main-menu,
body.building-placement-active .action-button,
body.building-placement-active #virtual-joystick {
  pointer-events: none;
  opacity: 0.35;
}
img{
  -webkit-user-select: none; /* Safari */
  user-select: none;
  touch-action: none;
}
input[type="text"], input[type="email"], textarea{
  -webkit-user-select: text;
  user-select: text;
}
summary:focus, details:focus,
summary:focus-visible, details:focus-visible{
  outline:none;
}
h1{
  font-size:1.5rem;
}
h2{
  font-size:1.25rem;
}
button{
  border:none;
}
button:focus,
button:focus-visible{
  outline:none;
}
canvas {
  display: block;
}
/* .background */
.background{
  background-image:url("../imgs/background.jpg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
/* loading screen */
#loading-screen {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: var(--z-index-screen);
  width:100dvw;height:100dvh;
}
/* home screen */
#home-screen {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: var(--z-index-screen);
  width:100dvw;height:100dvh;
}
.home-content {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: var(--z-index-front);
}
.home-title {
  width: min(768px, 100%);
  height: auto;
  margin-top: 25px;
  object-fit: contain;
}
.home-actions {
  margin-top: min(35px, 6%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(320px, calc(100% - 160px));
}
.home-actions .divider{
  display: flex;
  align-items: center;
  color: #eeeeee;
}
.home-actions .divider::before,
.home-actions .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #eeeeee;
}
.home-actions .divider span {
  padding: 0 12px;
}
.home-actions input {
  width: 100%;
  padding: 12px 16px;

  border: 1px solid #997733;
  border-radius: 12px 12px 0px 0px;
  background:rgba(255, 255, 255, 0.9);
  color: #444444;

  font-size: 16px;
  text-align: center;
}
.home-actions input::placeholder{
  color:#888888;
}
.home-actions input:focus,
.home-actions input:focus-visible{
  border-color:rgba(65, 48, 32, 0.8);
  outline:none;
}
.home-actions button {
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 12px;

  font-size: 16px;
  font-weight: bold;

  cursor: pointer;
  transition:transform 0.15s ease;
}
.home-actions button.half-radius{
  border-radius:0px 0px 12px 12px
}
.home-actions button.primary {
  background:rgba(65, 48, 32, 0.8);
  color: #fff5d6;
}
.home-actions button.secondary {
  background:rgba(25, 37, 45, 0.8);
  color: #f0f0f0;
}
.home-actions button:hover {
  transform:translateY(-2px);
}
.home-actions button:active {
  transform:translateY(1px) scale(0.98);
}
.home-actions .message {
  text-align:center;
  color:#ffccaa;
  text-shadow:0px 0px 5px black;
}
.home-actions>.start-user {
  display:flex;
  align-items:center;justify-content:center;gap:5px;
  margin-bottom:5px;
  padding-right:15px; /* shift content a little left to get center visually */
}
.home-actions>.start-user>.picture{
  width:30px;height:30px;opacity:0.9;border-radius:50%;
  box-shadow:0px 0px 5px black;
}
.home-actions>.start-user>.name{
  text-shadow:0px 0px 5px black;
}
/* game screen */
#game-screen {
  width: 100dvw;
  height: 100dvh;

  position: relative;
  overflow: hidden;

  background: #58aee8;
}
#game-screen>canvas#game.building-mode {
  touch-action: none;
  cursor: grab;
}
#game-screen>canvas#game.building-mode:active {
  cursor: grabbing;
}
#game-screen>#basic {
  position: absolute;
  left: 10px;
  top: 10px;

  background: rgba(0,0,0,0.3);

  padding: 10px 14px;
  border-radius: 8px;
  line-height:25px;

  cursor:pointer;
}
#game-screen>#basic>.resource{
  display: flex;
  align-items: center;
}
#game-screen>#basic>.resource>img.icon{
  width:24px;
  height:24px;
  margin:0px 5px;
}
#game-screen>#basic>.resource>.flow{
  font-size:0.85em;
  color:#a8e6a3;
  margin-left:5px;
  transform:translateY(-3px);
}
#game-screen>#basic>.resource>.flow::before{
  content:"+"
}
#game-screen>#basic>.resource>.flow-negative{
  color:#ff8888;;
}
#game-screen>#basic>.resource>.flow-negative::before{
  content:""
}
#game-screen>#basic>.resource-timer {
  position: relative;
  height: 5px;
  margin: 10px 0px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 5px;
}
#game-screen>#basic #resource-timer-progress {
  width: 0;
  height: 100%;
  background: #78a86a;
  border-radius: inherit;
}
#game-screen>#basic #resource-timer-text {
  position: absolute; right: 0px; top: 7px;
  font-size: 10px;
  height: 10px;
  line-height: 10px;
  overflow: visible;
  color: #ddd;
}
#game-screen>#info {
  position: absolute;
  right: 10px;
  top: 10px;

  background: rgba(0,0,0,0.3);

  padding: 10px 14px;
  border-radius: 8px;
  line-height:25px;

  pointer-events: none;
}
@media (max-width: 768px) {
  #game-screen>#basic,
  #game-screen>#info{
    font-size:13px;
    line-height:20px;
  }
  #game-screen>#basic>.resource>img.icon{
    width:20px;
    height:20px;
  }
}
#game-screen>#update-effects{
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  font-size: 16px;
  z-index: var(--z-index-effect);
  pointer-events: none;
  user-select: none;
}
#game-screen>#update-effects>.update-effect{
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;

  white-space: nowrap;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.8);

  animation: update-float-up 800ms ease-out forwards;
}
#game-screen>#update-effects>.update-effect.positive {
  color: #a8e6a3;
}
#game-screen>#update-effects>.update-effect.negative {
  color: #ff8888;
}
#game-screen>#update-effects>.update-effect img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}
@keyframes update-float-up {
  0% {
    opacity: 0;
    transform: translateY(15px) scale(0.8);
  }
  20% {
    opacity: 1;
    transform: translateY(0) scale(1.1);
  }
  65% {
    opacity: 1;
    transform: translateY(-15px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-40px) scale(0.95);
  }
}
/* -------------------
顯示在玩家下方的即時訊息
--------------------- */
#game-screen>#instant-message {
  position: absolute;
  left: 50%;
  top: calc(50% + 20px);

  width: max-content;
  max-width: min(300px, 80vw);
  padding: 6px 8px;

  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;

  color: #f7f0df;
  font-size: 13px;
  text-align: left;
  overflow-wrap: anywhere;

  transform: translateX(-50%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;

  transition:opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
}
#game-screen>#instant-message.show {
  opacity: 1;
  visibility: visible;
}
#game-screen>#instant-message>.line{
  display:flex;align-items:center;
}
#game-screen>#instant-message>.line>img{
  width:16px;height:16px;margin-right:4px;
}
/* ---------------
Virtual Joystick
---------------- */
#virtual-joystick {
  display: none;
}
/* 只有觸控裝置顯示 */
@media (hover: none) and (pointer: coarse) {
  #virtual-joystick {
    position: absolute;
    left: 15px;
    bottom: calc(65px + env(safe-area-inset-bottom));
    width: 150px;
    height: 150px;
    display: block;
    z-index: var(--z-index-map-control);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
  }
  .joystick-base {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 150px;
    height: 150px;
    transform:translate(-50%, -50%);
    border:1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.1);
  }
  .joystick-stick {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 32px;
    height: 32px;
    transform:translate(-50%, -50%);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    background:rgba(0, 0, 0, 0.3);
    box-shadow:0 4px 12px rgba(0, 0, 0, 0.3);
    pointer-events: none;
  }
  #virtual-joystick.active .joystick-stick {
    background:rgba(0, 0, 0, 0.6);
  }
  #virtual-joystick .joystick-hint {
    position: absolute;
    color:rgba(255, 255, 255, 0.2);
    font-size: 18px;
    pointer-events: none;
  }
  #virtual-joystick .joystick-hint.up {
    left: 50%;
    top: 8px;
    transform: translateX(-50%);
  }
  #virtual-joystick .joystick-hint.right {
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
  }
  #virtual-joystick .joystick-hint.down {
    left: 50%;
    bottom: 8px;
    transform: translateX(-50%);
  }
  #virtual-joystick .joystick-hint.left {
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
  }
}
/* ---------------
Zoom Control
---------------- */
#map-zoom-control {
  position: absolute;
  right: 10px;
  top: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  z-index: var(--z-index-map-control);
}
#map-zoom-control button {
  width: 35px;
  height: 35px;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: white;
  font-size: 24px;
  cursor: pointer;
}
#map-zoom-control button#zoom-middle-button {
  height:15px;
  background: rgba(0, 0, 0, 0.2);
}
#map-zoom-control button:hover,
#map-zoom-control button#zoom-middle-button:hover{
  background: rgba(0, 0, 0, 0.6);
}
#map-zoom-control button:disabled,
#map-zoom-control button#zoom-middle-button:disabled{
  opacity:0.2;
  cursor:default;
}
@media (max-width: 1024px) {
  #map-zoom-control {
    top:80px;
  }
  #map-zoom-control button{
    width:25px;height:25px;
    font-size:18px;
  }
  #map-zoom-control button#zoom-middle-button {
    height:12px;
  }
}
/* ---------------
Action Button
---------------- */
.action-button {
  position: absolute;

  width: 54px;
  height: 54px;
  padding:10px;

  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.8);
  background:rgba(0, 0, 0, 0.3);
  box-shadow:0 4px 12px rgba(0, 0, 0, 0.3);
  color: white;
  cursor: pointer;

  z-index: var(--z-index-map-control);
  transition: background-color 0.2s ease, opacity 0.2s ease;

  overflow: hidden;
  isolation: isolate;
}
.action-button .action-cooldown {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;

  background: conic-gradient(rgba(255, 255, 255, 0.5) var(--cooldown-progress, 0%), transparent 0);
}
.action-button-cooling {
  cursor: not-allowed;
}
.action-button-cooling .action-cooldown {
  opacity: 1;
}
.action-button-progress {
  position: absolute;
  inset: 0;
  z-index: var(--z-index-back);
  background: rgba(0, 0, 0, 0.5);
  transform-origin:left center;
  transform: scaleX(0);
  pointer-events: none;
}
.action-button-label{
  position: relative;
  z-index: var(--z-index-front);
}
.action-button-label{
  width:100%;height:100%;
}
.action-button:disabled {
  cursor: not-allowed;
  opacity: 0.3;
}
.action-button:not(:disabled):hover {
  background: rgba(0, 0, 0, 0.6);
}
.action-button:not(:disabled):active {
  transform:translateX(-50%) scale(0.96);
}
/* -----------------------
Action Button for Different Operations
------------------------- */
#enter-button{
  left: calc(50% - 64px);
  bottom: calc(90px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
}
#explore-button{
  left: calc(50%);
  bottom: calc(90px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
}
#build-button {
  left: calc(50% + 64px);
  bottom: calc(90px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
}
#attack-button {
  left: calc(50%);
  bottom: calc(160px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
}
@media (max-width: 1024px) {
  #enter-button{
    left:auto;
    right: 105px;
    bottom: calc(70px + env(safe-area-inset-bottom));
    transform: none;
  }
  #explore-button{
    left:auto;
    right: 75px;
    bottom: calc(130px + env(safe-area-inset-bottom));
    transform: none;
  }
  #build-button {
    left:auto;
    right: 15px;
    bottom: calc(160px + env(safe-area-inset-bottom));
    transform: none;
  }
  #attack-button {
    width: 64px; height:64px;
    left: auto;
    right:15px;
    bottom: calc(70px + env(safe-area-inset-bottom));
    transform: none;
  }
}
/* ---------------
Sharing/Common Styling
---------------- */
/* .hide */
.hide {
  display: none !important;
}
/* .loading */
.loading{
	position:fixed;top:0px;left:0px;
	width:100%;height:100vh;
  z-index:var(--z-index-loading-effect);
  padding:0px;
	background-color:rgba(255,255,255,0);
}
.loading>.progress{
	width:0%;height:2px;
	background-color:var(--brand-color);
	animation:progress 3s;
	animation-iteration-count:infinite;
	animation-fill-mode:forwards;
}
@keyframes progress{
	0%{width:0%;}
	100%{width:100%;}
}