/* ユーカリダウンタウン：画面の部品の見た目
   canvas（ゲーム画面）の上に、HUD・操作ボタン・会話・メニュー・お店を重ねる。横向き前提。 */
:root {
  --ink: #fff7e8;
  --ink-dim: #c9c0d8;
  --ink-mute: #9a92ae;
  --bg: #140e20;
  --panel: rgba(20, 14, 32, 0.97);
  --panel-2: rgba(44, 32, 66, 0.9);
  --line: rgba(255, 247, 232, 0.18);
  --hp: #4fe07a;
  --hp-back: #5a2030;
  --ki: #4fb8ff;
  --en: #ff6b5a;
  --gold: #ffd24a;
  --accent: #e0435a;
  --accent-ink: #ffffff;
  --btn: rgba(255, 255, 255, 0.14);
  --btn-line: rgba(255, 255, 255, 0.45);
  --btn-on: rgba(255, 210, 74, 0.6);
  --splash-bg: #ffffff;
  --font-display: "Dela Gothic One", "Hiragino Sans", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  --font-body: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Hiragino Sans", system-ui, sans-serif;
  --safe-l: max(10px, env(safe-area-inset-left, 0px));
  --safe-r: max(10px, env(safe-area-inset-right, 0px));
  --safe-b: max(8px, env(safe-area-inset-bottom, 0px));
  --safe-t: max(6px, env(safe-area-inset-top, 0px));
  color-scheme: dark;
}

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
}

body {
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

[hidden] { display: none !important; }

button {
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  background: var(--bg);
}

#cv { position: absolute; inset: 0; display: block; }

/* ---- HUD ---- */
#hud {
  position: absolute;
  top: var(--safe-t);
  left: var(--safe-l);
  right: var(--safe-r);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
  text-shadow: 0 1px 0 #000, 0 0 3px #000;
}
.hud-l { width: 168px; display: grid; gap: 3px; }
.h-top { display: flex; justify-content: space-between; font-family: var(--font-display); font-size: 13px; line-height: 1; }
#h-lv { color: var(--gold); }
.bar {
  position: relative;
  height: 12px;
  border-radius: 3px;
  background: var(--hp-back);
  box-shadow: 0 0 0 1.5px #0d0814;
  overflow: hidden;
}
.bar i { position: absolute; inset: 0 auto 0 0; width: 100%; background: var(--hp); transition: width 0.12s; }
.bar span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 10px; font-weight: 900; line-height: 1; }
.bar.ki { height: 5px; background: #13263a; }
.bar.ki i { background: var(--ki); }
.bar.en { height: 8px; width: 170px; }
.bar.en i { background: var(--en); }
#h-buffs { font-size: 10px; font-weight: 700; color: var(--gold); min-height: 12px; white-space: nowrap; }
#enemy-info { display: none; text-align: center; font-size: 11px; font-weight: 900; margin-top: 2px; }
#enemy-info .bar { margin: 3px auto 0; }
.hud-r { display: flex; align-items: center; gap: 8px; }
.yen { font-size: 12px; font-weight: 700; }
.yen b { font-family: var(--font-display); font-weight: 400; font-size: 16px; color: var(--gold); margin-right: 2px; }
#menu-btn {
  position: relative;
  pointer-events: auto;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--btn-line);
  background: rgba(20, 14, 32, 0.7);
  font-size: 13px;
  text-shadow: none;
}
#menu-badge {
  position: absolute;
  top: -7px;
  right: -7px;
  display: none;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  box-sizing: border-box;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 900;
}

#banner {
  position: absolute;
  top: 22%;
  left: 50%;
  transform: translate(-50%, -6px);
  padding: 8px 22px;
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.06em;
  white-space: nowrap;
  color: var(--ink);
  text-shadow: 0 2px 0 #000, 0 0 8px rgba(0, 0, 0, 0.8);
  border-top: 2px solid var(--gold);
  border-bottom: 2px solid var(--gold);
  background: linear-gradient(90deg, transparent, rgba(20, 14, 32, 0.75) 20%, rgba(20, 14, 32, 0.75) 80%, transparent);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s, transform 0.35s;
}
#banner.show { opacity: 1; transform: translate(-50%, 0); }

#toast {
  position: absolute;
  top: calc(var(--safe-t) + 58px);
  left: 50%;
  transform: translateX(-50%);
  max-width: min(560px, 80%);
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(20, 14, 32, 0.88);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 6;
}
#toast.show { opacity: 1; }

/* ---- 操作 ---- */
#controls { position: absolute; inset: 0; pointer-events: none; }
#stage:not([data-mode="play"]) #controls { display: none; }
#stage[data-mode="title"] #hud { display: none; }

#stick-zone {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 46%;
  height: 72%;
  pointer-events: auto;
}
#stick-base {
  position: absolute;
  left: calc(var(--safe-l) + 62px);
  top: calc(100% - var(--safe-b) - 62px);
  width: 104px;
  height: 104px;
  margin: -52px 0 0 -52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.3);
  pointer-events: none;
}
#stick-base.on { background: rgba(255, 255, 255, 0.14); border-color: rgba(255, 255, 255, 0.5); }
#stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  border: 2px solid rgba(255, 255, 255, 0.7);
}

#btns {
  position: absolute;
  right: var(--safe-r);
  bottom: var(--safe-b);
  width: 230px;
  height: 200px;
  pointer-events: none;
}
.btn {
  position: absolute;
  width: 66px;
  height: 66px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--btn-line);
  background: var(--btn);
  font-size: 13px;
  line-height: 1.1;
  text-shadow: 0 1px 2px #000;
  pointer-events: auto;
  touch-action: none;
}
.btn.mid { width: 56px; height: 56px; font-size: 11px; }
.btn.small { width: 48px; height: 48px; font-family: var(--font-display); font-weight: 400; font-size: 18px; color: var(--gold); }
.btn.on { background: var(--btn-on); border-color: var(--gold); transform: scale(0.94); }
#b-k { right: 4px; bottom: 44px; }
#b-p { right: 78px; bottom: 8px; }
#b-j { right: 8px; bottom: 120px; }
#b-g { right: 84px; bottom: 84px; }
#b-s { right: 152px; bottom: 50px; }
#act-btn {
  position: absolute;
  right: 136px;
  bottom: 140px;
  display: none;
  place-items: center;
  min-width: 84px;
  height: 40px;
  padding: 0 14px;
  border-radius: 20px;
  border: 2px solid #fff3c8;
  background: var(--gold);
  color: #2a1a00;
  font-size: 15px;
  font-weight: 900;
  pointer-events: auto;
  touch-action: none;
  box-shadow: 0 2px 0 #8a6a10;
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(1.06); } }

/* ---- 会話 ---- */
#dialog {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-b) + 4px);
  transform: translateX(-50%);
  width: min(700px, calc(100% - var(--safe-l) - var(--safe-r) - 20px));
  box-sizing: border-box;
  min-height: 86px;
  padding: 12px 18px 14px;
  border-radius: 14px;
  background: var(--panel);
  border: 2px solid var(--line);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}
#dlg-name { font-family: var(--font-display); font-size: 15px; margin-bottom: 4px; }
#dlg-text { margin: 0; font-size: 17px; font-weight: 700; line-height: 1.6; min-height: 2em; }
#dialog.narr #dlg-text { color: var(--ink-dim); }
#dlg-next { position: absolute; right: 14px; bottom: 8px; color: var(--gold); font-size: 12px; animation: blink 0.8s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---- メニュー・お店（シート） ---- */
.sheet {
  position: absolute;
  top: var(--safe-t);
  bottom: var(--safe-b);
  left: 50%;
  transform: translateX(-50%);
  width: min(760px, calc(100% - var(--safe-l) - var(--safe-r)));
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  background: var(--panel);
  border: 2px solid var(--line);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.sheet header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}
.sheet-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
  padding: 10px 14px 14px;
  user-select: none;
}
.x {
  margin-left: auto;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1.5px solid var(--btn-line);
  background: rgba(255, 255, 255, 0.08);
  font-size: 14px;
  flex: none;
}
#menu-tabs { display: flex; gap: 4px; overflow-x: auto; }
#menu-tabs button {
  padding: 8px 12px;
  border-radius: 9px;
  border: 0;
  background: transparent;
  color: var(--ink-dim);
  font-size: 14px;
  white-space: nowrap;
}
#menu-tabs button.on { background: var(--ink); color: var(--bg); }

.m-goal { margin: 0 0 10px; padding: 8px 10px; border-radius: 10px; background: rgba(255, 210, 74, 0.12); border: 1px solid rgba(255, 210, 74, 0.35); font-size: 13px; line-height: 1.6; }
.m-goal b { color: var(--gold); margin-right: 8px; }
.m-row { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 2px; font-size: 14px; }
.big { font-family: var(--font-display); font-weight: 400; font-size: 22px; }
.hot { color: var(--accent); }
.m-stat {
  display: grid;
  grid-template-columns: 80px 70px 1fr 44px 44px;
  align-items: center;
  gap: 8px;
  padding: 6px 2px;
  border-top: 1px solid var(--line);
}
.m-label { font-weight: 900; font-size: 15px; }
.m-val { font-family: var(--font-display); font-size: 18px; }
.m-val em { font-style: normal; font-family: var(--font-body); font-size: 12px; color: var(--hp); }
.m-note { font-size: 11px; color: var(--ink-mute); }
.m-pm {
  width: 44px;
  height: 36px;
  border-radius: 10px;
  border: 1.5px solid var(--btn-line);
  background: rgba(255, 255, 255, 0.1);
  font-size: 20px;
  line-height: 1;
}
.m-pm:disabled { opacity: 0.3; }
.m-small { margin: 10px 0 0; font-size: 12px; line-height: 1.6; color: var(--ink-mute); }
.m-none { color: var(--ink-mute); font-size: 13px; }
.m-slot { padding: 8px 0; border-top: 1px solid var(--line); }
.m-slot-head { display: flex; gap: 10px; align-items: baseline; margin-bottom: 6px; }
.m-slot-head b { font-size: 15px; }
.m-slot-head span { font-size: 11px; color: var(--ink-mute); }
.m-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--btn-line);
  background: rgba(255, 255, 255, 0.06);
  font-size: 13px;
}
.chip.on { background: var(--gold); border-color: var(--gold); color: #2a1a00; }
.m-desc { margin: 4px 0 0; font-size: 12px; font-weight: 500; color: var(--ink-dim); line-height: 1.5; }
.m-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 2px; border-top: 1px solid var(--line); font-size: 14px; }
.m-use {
  flex: none;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--btn-line);
  background: rgba(255, 255, 255, 0.1);
  font-size: 13px;
}

#shop-name {
  margin: 0;
  padding: 4px 14px;
  border-radius: 8px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 17px;
  color: #fff;
  white-space: nowrap;
}
#shop-yen { font-size: 12px; color: var(--ink-dim); }
#shop-msg { margin: 0; padding: 8px 16px; font-size: 14px; font-weight: 700; line-height: 1.5; border-bottom: 1px solid var(--line); min-height: 1.5em; }
.s-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; padding: 8px 2px; border-top: 1px solid var(--line); }
.s-row:first-child { border-top: 0; }
.s-info b { font-size: 15px; }
.s-info p { margin: 2px 0 0; font-size: 12px; font-weight: 500; color: var(--ink-dim); line-height: 1.45; }
.s-price { font-family: var(--font-display); font-size: 14px; color: var(--gold); white-space: nowrap; }
.s-buy {
  min-width: 80px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 14px;
}
.s-buy:disabled { background: rgba(255, 255, 255, 0.12); color: var(--ink-mute); }
.s-row.owned .s-info { opacity: 0.6; }

/* ---- タイトル ---- */
#title {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at center, rgba(20, 14, 32, 0.25), rgba(20, 14, 32, 0.78));
}
.t-box { text-align: center; padding: 0 20px; }
.t-sub { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: 0.3em; color: var(--ink-dim); text-shadow: 0 1px 2px #000; }
#title h1 {
  margin: 4px 0 2px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(30px, 9vh + 6px, 60px);
  line-height: 1.1;
  color: var(--ink);
  text-shadow: 0 3px 0 #2a1440, 0 0 14px rgba(0, 0, 0, 0.7);
}
#title h1 span {
  display: block;
  font-size: 1.3em;
  color: var(--gold);
  text-shadow: 0 4px 0 #8a2a10, 0 0 16px rgba(0, 0, 0, 0.7);
}
.t-catch { margin: 6px 0 14px; font-size: 15px; font-weight: 900; text-shadow: 0 1px 3px #000; }
#t-main, #t-confirm { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; align-items: center; }
#t-confirm p { width: 100%; margin: 0 0 4px; font-weight: 700; text-shadow: 0 1px 3px #000; }
#title button {
  min-width: 140px;
  padding: 12px 22px;
  border-radius: 999px;
  border: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 18px;
  color: #2a1a00;
  background: var(--gold);
  box-shadow: 0 3px 0 #8a6a10;
}
#title button#t-cont, #title button#t-no { background: var(--ink); color: var(--bg); box-shadow: 0 3px 0 #8a8290; }
#title button:disabled { opacity: 0.4; }
#title button:active { transform: translateY(2px); box-shadow: none; }
.t-note { margin: 12px 0 0; font-size: 12px; color: var(--ink-dim); text-shadow: 0 1px 2px #000; }
.fs-btn { display: block; }
#title .fs-btn {
  position: absolute;
  top: calc(var(--safe-t) + 4px);
  right: calc(var(--safe-r) + 4px);
  min-width: 0;
  padding: 8px 14px;
  border: 1.5px solid var(--btn-line);
  border-radius: 10px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
  background: rgba(20, 14, 32, 0.7);
  box-shadow: none;
}
.t-disclaimer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--safe-b);
  margin: 0;
  padding: 0 max(16px, env(safe-area-inset-left, 0px)) 0 max(16px, env(safe-area-inset-right, 0px));
  font-size: 11px;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
  color: var(--ink);
  text-shadow: 0 1px 2px #000, 0 0 4px #000;
}

/* ---- パネル（やられた・エンディング） ---- */
#panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, calc(100% - 40px));
  max-height: calc(100% - 24px);
  overflow-y: auto;
  box-sizing: border-box;
  padding: 18px 22px;
  border-radius: 16px;
  background: var(--panel);
  border: 2px solid var(--gold);
  text-align: center;
}
#p-title { margin: 0 0 8px; font-family: var(--font-display); font-weight: 400; font-size: 26px; color: var(--gold); }
#p-text { margin: 0 0 14px; white-space: pre-line; font-size: 14px; font-weight: 700; line-height: 1.7; color: var(--ink-dim); }
#p-btn {
  padding: 11px 30px;
  border-radius: 999px;
  border: 0;
  background: var(--gold);
  color: #2a1a00;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 17px;
}

/* ---- 起動時の制作会社ロゴ ---- */
#splash {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  background: var(--splash-bg);
  transition: opacity 0.5s ease;
}
#splash img {
  width: min(66vh, 66vw);
  height: auto;
  animation: splash-in 0.8s ease-out both;
}
#splash.out { opacity: 0; pointer-events: none; }
@keyframes splash-in {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  #splash img { animation: none; }
}

/* ---- 縦向きのとき ---- */
#rotate { display: none; }
@media (orientation: portrait) and (pointer: coarse) {
  #rotate {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: grid;
    place-items: center;
    background: var(--bg);
    text-align: center;
    font-weight: 900;
    font-size: 18px;
  }
  .rot-icon { display: inline-block; font-size: 56px; color: var(--gold); animation: rot 2s ease-in-out infinite; }
  @keyframes rot { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(90deg); } }
}

@media (max-height: 340px) {
  .btn { width: 58px; height: 58px; }
  .btn.mid { width: 50px; height: 50px; }
  #b-j { bottom: 108px; }
  #b-g { bottom: 76px; right: 76px; }
  #b-p { right: 70px; }
  #b-s { right: 136px; }
  #act-btn { bottom: 124px; right: 124px; }
  #dlg-text { font-size: 15px; }
}
