/* ファラオ王国 国作りMAP — ページUI（ファラオデザインシステム準拠） */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%;
  background: var(--ph-bg);
  color: var(--ph-ink);
  font-family: var(--ph-font);
  overflow: hidden;
  -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
}
#app { position: fixed; inset: 0; }
#phaser-game { position: absolute; inset: 0; }
#phaser-game canvas { display: block; width: 100% !important; height: 100% !important; image-rendering: pixelated; }

/* ---- タイトル / ロード ---- */
#title-screen {
  position: absolute; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at 50% 120%, rgba(217,119,87,.14), transparent 60%),
    var(--ph-bg);
  transition: opacity .6s ease;
}
#title-screen.fade { opacity: 0; pointer-events: none; }
.title-card {
  background: var(--ph-card); border: 1px solid var(--ph-line);
  border-radius: var(--ph-radius); box-shadow: var(--ph-shadow);
  padding: 36px 40px; text-align: center; max-width: 420px; width: calc(100% - 32px);
}
.title-logo { width: 200px; max-width: 70%; height: auto; margin: 0 auto 12px; display: block; filter: drop-shadow(0 4px 12px rgba(0,0,0,.35)); }
.title-name {
  font-family: var(--ph-font-disp); font-size: 40px; color: var(--ph-ink-strong);
  letter-spacing: .12em; margin: 6px 0 2px;
}
.title-sub { color: var(--ph-coral); font-size: 16px; letter-spacing: .2em; margin-bottom: 22px; }
#load-bar {
  height: 8px; border-radius: 4px; background: var(--ph-bg2);
  border: 1px solid var(--ph-line); overflow: hidden; margin-bottom: 16px;
}
#load-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--ph-coral), var(--ph-gold)); transition: width .2s; }
#start-btn {
  font-family: var(--ph-font-disp); font-size: 18px; letter-spacing: .15em;
  color: var(--ph-bg); background: var(--ph-gold);
  border: none; border-radius: var(--ph-radius-sm);
  padding: 12px 42px; cursor: pointer; transition: transform .15s, background .2s;
}
#start-btn:disabled { background: var(--ph-line); color: var(--ph-ink2); cursor: wait; }
#start-btn:not(:disabled):hover { transform: translateY(-2px); background: var(--ph-gold-bright); }
.hud-logo { height: 22px; width: auto; vertical-align: -5px; margin-right: 2px; }
.temple-links {
  margin-top: 8px; max-height: 150px; overflow-y: auto; text-align: left;
  display: flex; flex-direction: column; gap: 4px;
  border-top: 1px solid var(--ph-line); padding-top: 8px;
}
.temple-links a { color: var(--ph-gold); font-size: 13px; text-decoration: none; }
.temple-links a:hover { text-decoration: underline; color: var(--ph-gold-bright); }

/* ---- HUD ---- */
#hud-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  pointer-events: none;
}
.hud-title {
  font-family: var(--ph-font-disp); font-size: 18px; color: var(--ph-ink-strong);
  background: rgba(26,25,21,.78); border: 1px solid var(--ph-line);
  border-radius: var(--ph-radius-sm); padding: 6px 14px; letter-spacing: .1em;
}
.hud-actions { display: flex; gap: 8px; pointer-events: auto; }
.hud-btn {
  font-family: var(--ph-font); font-weight: 700; font-size: 12px;
  color: var(--ph-ink); background: rgba(38,38,36,.88);
  border: 1px solid var(--ph-line); border-radius: var(--ph-radius-sm);
  padding: 8px 12px; cursor: pointer;
}
.hud-btn.active { border-color: var(--ph-coral); color: var(--ph-coral); }
#hud-bottom {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: max(10px, env(safe-area-inset-bottom)); z-index: 20;
  font-size: 11px; color: var(--ph-ink2);
  background: rgba(26,25,21,.72); border: 1px solid var(--ph-line);
  border-radius: var(--ph-radius-sm); padding: 5px 14px; pointer-events: none;
}
#hud-bottom span { font-family: var(--ph-font-num); color: var(--ph-gold); font-variant-numeric: tabular-nums; }

/* ---- パネル共通 ---- */
.panel {
  position: absolute; z-index: 30;
  background: rgba(38,38,36,.94); border: 1px solid var(--ph-line);
  border-radius: var(--ph-radius); box-shadow: var(--ph-shadow);
  transition: opacity .25s, transform .25s;
}
.panel.hidden { opacity: 0; pointer-events: none; transform: translateY(6px); }

#minimap-panel { top: 58px; right: 12px; padding: 10px; }
#minimap {
  width: 200px; height: auto; aspect-ratio: 170 / 160; image-rendering: pixelated;
  border-radius: 8px; border: 1px solid var(--ph-line); display: block;
}
.panel-caption { margin-top: 6px; font-size: 10px; color: var(--ph-ink2); text-align: center; }

#rank-panel { top: 58px; right: 12px; padding: 14px 16px; width: 240px; max-height: 60vh; overflow-y: auto; }
.panel-head {
  font-family: var(--ph-font-disp); font-size: 15px; color: var(--ph-ink-strong);
  border-bottom: 2px solid var(--ph-coral); padding-bottom: 6px; margin-bottom: 8px;
}
.panel-sub { font-size: 10px; color: var(--ph-ink2); font-family: var(--ph-font); }
#rank-list { list-style: none; }
#rank-list li {
  display: flex; align-items: baseline; gap: 8px;
  padding: 5px 2px; border-bottom: 1px dashed var(--ph-line); font-size: 13px;
}
#rank-list .r-no { font-family: var(--ph-font-num); color: var(--ph-coral); width: 20px; text-align: right; }
#rank-list li:nth-child(-n+3) .r-no { color: var(--ph-gold-bright); }
#rank-list .r-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#rank-list .r-pp { font-family: var(--ph-font-num); color: var(--ph-gold); font-variant-numeric: tabular-nums; }
#rank-legend { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--ph-line); }
#rank-legend .lg { display: inline-flex; align-items: center; gap: 5px; font-size: 10px; color: var(--ph-ink2); margin: 2px 8px 2px 0; }
#rank-legend .lg i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---- 検索 ---- */
#search-panel { top: 58px; right: 12px; padding: 14px 16px; width: 250px; }
#search-input {
  width: 100%; font-family: var(--ph-font); font-size: 14px;
  color: var(--ph-ink); background: var(--ph-bg2);
  border: 1px solid var(--ph-line); border-radius: var(--ph-radius-sm);
  padding: 8px 12px; outline: none;
}
#search-input:focus { border-color: var(--ph-coral); }
#search-results { list-style: none; margin-top: 6px; max-height: 46vh; overflow-y: auto; }
#search-results li {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  padding: 7px 4px; border-bottom: 1px dashed var(--ph-line);
  font-size: 13px; cursor: pointer; border-radius: 6px;
}
#search-results li:hover { background: var(--ph-coral-soft); }
#search-results .s-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#search-results .s-pp { font-family: var(--ph-font-num); color: var(--ph-gold); font-size: 12px; white-space: nowrap; }
#search-results .s-none { color: var(--ph-ink2); cursor: default; }

/* ---- 住民ポップアップ ---- */
#info-popup {
  left: 50%; bottom: 120px; transform: translateX(-50%);
  padding: 16px 26px 14px; text-align: center; min-width: 220px;
}
#info-popup.hidden { transform: translateX(-50%) translateY(8px); }
#info-close {
  position: absolute; top: 6px; right: 10px; background: none; border: none;
  color: var(--ph-ink2); font-size: 18px; cursor: pointer;
}
#info-glyph { font-size: 26px; color: var(--ph-gold); }
#info-name { font-family: var(--ph-font-disp); font-size: 18px; color: var(--ph-ink-strong); margin: 2px 0; }
#info-rank { font-size: 11px; color: var(--ph-coral); margin-bottom: 4px; }
#info-pp { font-family: var(--ph-font-num); font-size: 20px; color: var(--ph-gold); font-variant-numeric: tabular-nums; }
#info-pp small { font-size: 11px; color: var(--ph-ink2); font-family: var(--ph-font); }

/* ---- D-pad ---- */
#dpad {
  position: absolute; z-index: 25;
  right: 18px; bottom: max(46px, calc(env(safe-area-inset-bottom) + 40px));
  display: grid; grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(3, 52px);
}
.dpad-button {
  background: rgba(38,38,36,.85); border: 1px solid var(--ph-line);
  color: var(--ph-gold); font-size: 18px; border-radius: 14px;
  cursor: pointer; touch-action: none;
}
.dpad-button:active { background: var(--ph-coral-soft); border-color: var(--ph-coral); color: var(--ph-coral); }
.dpad-up { grid-area: 1 / 2; }
.dpad-left { grid-area: 2 / 1; }
.dpad-right { grid-area: 2 / 3; }
.dpad-down { grid-area: 3 / 2; }

@media (pointer: fine) and (min-width: 900px) {
  #dpad { opacity: .45; }
  #dpad:hover { opacity: 1; }
}
@media (max-width: 600px) {
  #minimap { width: 140px; }
  #rank-panel { width: 200px; }
  .title-name { font-size: 32px; }
}
