/* LITTLE ODYSSEY — タイトル・HUD・スマホの操作・致命的なエラー(工程1・工程6) */

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #1e1e1e;
  color: #e8eef4;
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
}

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#title {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, calc(100% - 32px));
  box-sizing: border-box;
  padding: 28px 28px 22px;
  background: rgba(14, 20, 28, 0.62);
  border: 1px solid rgba(220, 232, 244, 0.22);
  border-radius: 10px;
  text-align: center;
  backdrop-filter: blur(4px);
  /* ログインの欄(工程11)で背が伸びた。スマホの横向きでも下まで届くように */
  max-height: calc(100% - 24px);
  overflow-y: auto;
}

#title[hidden], #hud[hidden], #fatal[hidden], #touch[hidden], #stick[hidden], #notice[hidden], .bar[hidden], #looks[hidden],
#account [hidden], #emotes[hidden], #chat[hidden], .name[hidden], #crosshair[hidden], #panel[hidden], #panel button[hidden], #quests[hidden], #hud #journal-btn[hidden] {
  display: none;
}

#title h1 {
  margin: 8px 0 10px;
  font-size: 30px;
  letter-spacing: 0.14em;
  font-weight: 600;
}

#title .lead {
  margin: 0 0 8px;
  font-size: 15px;
}

#title .wip {
  margin: 0 0 18px;
  font-size: 12px;
  color: #b8c6d4;
}

#home-link {
  position: absolute;
  left: 14px;
  top: 10px;
  font-size: 12px;
  color: #c8d6e4;
  text-decoration: none;
  border: 1px solid rgba(210, 225, 240, 0.3);
  border-radius: 4px;
  padding: 2px 8px;
}

#home-link:hover {
  color: #fff;
  border-color: rgba(210, 225, 240, 0.6);
}

button {
  font: inherit;
  color: #10161c;
  background: #e6eef6;
  border: 0;
  border-radius: 6px;
  padding: 10px 22px;
  cursor: pointer;
}

button:hover {
  background: #ffffff;
}

#tier-note {
  margin: 14px 0 0;
  font-size: 11px;
  color: #9fb0c0;
}

#hud {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  padding: 8px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  align-items: center;
  font-size: 12px;
  background: linear-gradient(rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0));
  pointer-events: none;
}

#hud p {
  margin: 0;
}

#hud button {
  pointer-events: auto;
  padding: 4px 12px;
  font-size: 12px;
}

#hud #sound {
  margin-left: auto;
}

#readout {
  font-variant-numeric: tabular-nums;
  color: #d8e4ee;
}

#help {
  color: #b8c6d4;
}

#fatal {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(480px, calc(100% - 32px));
  box-sizing: border-box;
  padding: 20px;
  background: #2a1d1d;
  border: 1px solid #a05050;
  border-radius: 8px;
}

/* 工程6: 知らせ・スタミナと体力の棒 */
#notice {
  position: fixed;
  left: 50%;
  top: 22%;
  transform: translateX(-50%);
  margin: 0;
  padding: 6px 14px;
  font-size: 14px;
  background: rgba(10, 16, 22, 0.55);
  border-radius: 6px;
  pointer-events: none;
  white-space: nowrap;
}

.bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: min(220px, 40vw);
  height: 6px;
  background: rgba(10, 16, 22, 0.55);
  border-radius: 3px;
  overflow: hidden;
  pointer-events: none;
}

.bar i {
  display: block;
  height: 100%;
  width: 100%;
}

#stamina {
  bottom: 64px;
}

#stamina i {
  background: #9bd47a;
}

#stamina.tired i {
  background: #d4a04a;
}

#hp {
  bottom: 76px;
}

#hp i {
  background: #e06a5a;
}

/* スマホの操作。左の仮想スティックは触った所に出る */
#touch {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

#stick {
  position: fixed;
  width: 112px;
  height: 112px;
  margin: -56px 0 0 -56px;
  border-radius: 50%;
  border: 2px solid rgba(230, 240, 250, 0.4);
  background: rgba(10, 16, 22, 0.2);
}

#stick i {
  position: absolute;
  left: 34px;
  top: 34px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(230, 240, 250, 0.55);
}

#btn-jump {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(28px, env(safe-area-inset-bottom));
  width: 74px;
  height: 74px;
  padding: 0;
  border-radius: 50%;
  background: rgba(230, 240, 250, 0.35);
  color: #fff;
  font-size: 15px;
  pointer-events: auto;
  touch-action: none;
}

/* PC(細かい指し示しができて浮かせられる)では丸いボタンとスマホの説明を隠す(RPG 2026-09-04 の判定) */
@media (hover: hover) and (pointer: fine) {
  #touch {
    display: none;
  }

  .touch-only {
    display: none;
  }
}

@media not ((hover: hover) and (pointer: fine)) {
  .pc-only {
    display: none;
  }
}

/* 工程7: 見た目を選ぶ(右に寄せた札。スマホでは下) */
#title button.sub, #looks button.sub {
  background: rgba(230, 238, 246, 0.18);
  color: #e8eef4;
  border: 1px solid rgba(220, 232, 244, 0.35);
}

#title button.sub {
  margin-left: 8px;
}

#looks {
  position: fixed;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: min(300px, calc(100% - 32px));
  box-sizing: border-box;
  padding: 14px 16px;
  background: rgba(14, 20, 28, 0.62);
  border: 1px solid rgba(220, 232, 244, 0.22);
  border-radius: 10px;
  backdrop-filter: blur(4px);
}

#looks h2 {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.1em;
}

.look-row {
  display: grid;
  grid-template-columns: 5.5em 32px 1fr 32px;
  align-items: center;
  gap: 6px;
  margin: 6px 0;
  font-size: 13px;
}

.look-row button {
  padding: 4px 0;
  font-size: 15px;
}

.look-name {
  text-align: center;
  white-space: nowrap;
}

.look-label {
  color: #b8c6d4;
}

.look-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.look-actions button {
  padding: 8px 12px;
  font-size: 13px;
}

@media (max-width: 640px) {
  #looks {
    top: auto;
    bottom: 12px;
    transform: none;
    right: 16px;
    max-height: 55vh;
    overflow-y: auto;
  }
}

/* 工程11: 島へ入る(アカウント)・定型文・近くの人の名前 */
#account {
  margin: 0 0 14px;
  padding: 12px 0 4px;
  border-top: 1px solid rgba(220, 232, 244, 0.18);
}

#account input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
  color: #e8eef4;
  background: rgba(8, 12, 18, 0.55);
  border: 1px solid rgba(220, 232, 244, 0.3);
  border-radius: 6px;
}

.acc-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
}

#title .acc-row button.sub {
  margin-left: 0;
}

#acc-status {
  margin: 0 0 10px;
  font-size: 13px;
  color: #d8e4ee;
  min-height: 1em;
}

#acc-status.error {
  color: #f0a090;
}

#acc-code-show {
  margin: 0 0 10px;
  padding: 8px;
  font-size: 13px;
  background: rgba(240, 200, 120, 0.14);
  border: 1px solid rgba(240, 200, 120, 0.5);
  border-radius: 6px;
  user-select: all;
}

button.link {
  background: none;
  border: 0;
  padding: 4px 6px;
  color: #b8c6d4;
  font-size: 12px;
  text-decoration: underline;
}

button.link:hover {
  background: none;
  color: #fff;
}

#acc-delete-box {
  margin: 6px 0 0;
  font-size: 12px;
  color: #9fb0c0;
}

#acc-delete-box summary {
  cursor: pointer;
}

#acc-delete-box input {
  margin-top: 8px;
}

#title .or {
  margin: 0 0 8px;
  font-size: 12px;
  color: #9fb0c0;
}

#title > button.sub:first-of-type {
  margin-left: 0;
}

#emotes {
  position: fixed;
  left: 50%;
  bottom: max(10px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  width: min(640px, calc(100% - 120px));
}

#emotes button {
  padding: 4px 8px;
  font-size: 12px;
  background: rgba(230, 238, 246, 0.22);
  color: #f0f4f8;
  border: 1px solid rgba(220, 232, 244, 0.3);
}

#chat {
  position: fixed;
  left: 12px;
  bottom: 96px;
  margin: 0;
  max-width: min(360px, calc(100% - 120px));
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-line;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

.name {
  position: fixed;
  transform: translate(-50%, -100%);
  padding: 1px 6px;
  font-size: 12px;
  white-space: nowrap;
  color: #f4f8fb;
  background: rgba(10, 16, 22, 0.45);
  border-radius: 4px;
  pointer-events: none;
}

/* 工程12: 戦い。敵の名前札・弓の照準・スマホの戦いのボタン(島の中だけ) */
.name.enemy {
  color: #ffd2c4;
  background: rgba(60, 14, 10, 0.5);
  letter-spacing: 0.02em;
}

#crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.85)) center / 2px 18px no-repeat,
    linear-gradient(rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.85)) center / 18px 2px no-repeat;
  opacity: 0.8;
}

#touch .fight {
  position: fixed;
  width: 54px;
  height: 54px;
  padding: 0;
  border-radius: 50%;
  background: rgba(230, 240, 250, 0.3);
  color: #fff;
  font-size: 14px;
  pointer-events: auto;
  touch-action: none;
  display: none;
}

#touch.online .fight {
  display: block;
}

#btn-attack {
  right: max(104px, calc(env(safe-area-inset-right) + 86px));
  bottom: max(36px, env(safe-area-inset-bottom));
}

#btn-heavy {
  right: max(98px, calc(env(safe-area-inset-right) + 80px));
  bottom: max(100px, calc(env(safe-area-inset-bottom) + 64px));
}

#btn-potion {
  right: max(26px, env(safe-area-inset-right));
  bottom: max(116px, calc(env(safe-area-inset-bottom) + 80px));
}

#btn-weapon {
  right: max(160px, calc(env(safe-area-inset-right) + 142px));
  bottom: max(80px, calc(env(safe-area-inset-bottom) + 44px));
}

/* 工程13: 町の人と話す・宝箱・手帳の欄と、受けている依頼 */
#panel {
  position: fixed;
  left: 50%;
  bottom: max(60px, calc(env(safe-area-inset-bottom) + 48px));
  transform: translateX(-50%);
  width: min(560px, calc(100% - 32px));
  max-height: 60%;
  overflow-y: auto;
  box-sizing: border-box;
  padding: 14px 16px 12px;
  background: rgba(14, 20, 28, 0.82);
  border: 1px solid rgba(220, 232, 244, 0.28);
  border-radius: 10px;
  backdrop-filter: blur(4px);
}

#panel h3 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
}

#panel p {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-line;
}

#panel-opts {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0 0 10px;
}

#panel-opts button {
  text-align: left;
  padding: 6px 10px;
  font-size: 13px;
}

#panel-close {
  padding: 4px 12px;
  font-size: 12px;
  background: rgba(230, 238, 246, 0.18);
  color: #e8eef4;
  border: 1px solid rgba(220, 232, 244, 0.35);
}

#quests {
  position: fixed;
  right: 12px;
  top: 48px;
  margin: 0;
  max-width: min(320px, calc(100% - 24px));
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-line;
  text-align: right;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

#btn-talk {
  right: max(26px, env(safe-area-inset-right));
  bottom: max(180px, calc(env(safe-area-inset-bottom) + 144px));
}

.name.npc {
  color: #e8f4dc;
  background: rgba(20, 44, 22, 0.5);
}
