/* ============================================================
   初期ドラクエ風スタイル（黒背景・白二重枠・ドットフォント）
   ============================================================ */
* { box-sizing: border-box; }

body {
  background: #000;
  color: #fff;
  font-family: 'DotGothic16', 'Hiragino Kaku Gothic ProN', 'Meiryo', monospace;
  margin: 0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 10px 0;
}

#frame {
  width: 512px;
  max-width: 100vw;
  padding: 0 4px;
}

/* ---- HUD ---- */
#hud {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 10px;
  border: 3px solid #fff;
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 4px;
}

#hint {
  font-size: 12px;
  color: #ffd700;
  padding: 0 4px 6px;
  min-height: 18px;
}

/* HUDの音楽・図鑑ボタンは小さく */
#btn-bgm, #btn-zukan {
  font-size: 12px;
  padding: 0 8px;
  border-width: 2px;
}

/* ---- ゲーム画面 ---- */
#wrap { position: relative; }

canvas {
  width: 100%;
  display: block;
  background: #000;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border: 2px solid #333;
}

/* ---- メッセージウィンドウ ---- */
#msgwin {
  position: absolute;
  left: 2%;
  right: 2%;
  bottom: 2%;
  background: rgba(0, 0, 0, 0.92);
  border: 4px double #fff;
  border-radius: 8px;
  padding: 10px 24px 16px 14px;
  min-height: 112px;
  font-size: 15px;
  line-height: 1.7;
}

#msgtext { white-space: pre-wrap; }

.choice {
  padding: 1px 4px 1px 24px;
  position: relative;
  cursor: pointer;
}
.choice.sel { color: #ffd700; }
.choice.sel::before {
  content: '▶';
  position: absolute;
  left: 4px;
}
.choice:hover { color: #ffd700; }

#msg-arrow {
  position: absolute;
  right: 10px;
  bottom: 4px;
  animation: blink 0.9s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---- タイトル・エンディング ---- */
#title-screen, #ending {
  position: absolute;
  inset: 0;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  padding: 16px;
  z-index: 5;
}

#title-screen h1 {
  font-size: 34px;
  margin: 0;
  letter-spacing: 6px;
}
#title-screen .sub { margin: 0 0 10px; color: #ffd700; }
#title-screen .help { font-size: 12px; color: #aaa; line-height: 1.8; margin: 8px 0 0; }
#title-screen .credit { font-size: 11px; color: #777; line-height: 1.7; margin: 0; }
.links { font-size: 12px; margin: 10px 0 0; }
.links a { color: #8fd3ff; margin: 0 8px; }

#ending h2 { margin: 0; color: #ffd700; }
#ending-text {
  font-size: 14px;
  line-height: 1.9;
  max-width: 460px;
  overflow-y: auto;    /* 文章がふえても枠内でスクロールできるように */
  min-height: 0;
}
#ending-text .after { font-size: 12px; color: #bbb; line-height: 1.8; margin: 8px 0; }
#ending-text .stats { font-size: 12px; color: #ffd700; margin: 6px 0 10px; }
#ending-text .rankmsg { font-size: 12px; color: #bbb; }
#ending-text .rank-high { color: #ffd700; }
#ending-text .rank-legend {
  color: #ffd700;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.9);
  animation: legend-glow 1.6s ease-in-out infinite alternate;
}
@keyframes legend-glow {
  from { text-shadow: 0 0 4px rgba(255, 215, 0, 0.5); }
  to   { text-shadow: 0 0 12px rgba(255, 215, 0, 1); }
}

/* ---- 旅の図鑑 ---- */
#zukan {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.96);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px;
  z-index: 5;
}
#zukan h2 { margin: 0; color: #ffd700; font-size: 18px; }
#zukan-body {
  flex: 1;
  overflow-y: auto;
  width: 100%;
  max-width: 460px;
  font-size: 13px;
  line-height: 1.7;
}
#zukan-body h3 {
  color: #ffd700;
  font-size: 14px;
  margin: 10px 0 4px;
  border-bottom: 1px solid #555;
}
#zukan-body .entry { margin: 0 0 8px; }
#zukan-body .entry .desc { color: #bbb; font-size: 12px; }
#zukan-body .locked { color: #666; }
#btn-zukan-close { font-size: 13px; padding: 4px 20px; }

button.dq {
  background: #000;
  color: #fff;
  border: 3px solid #fff;
  border-radius: 6px;
  font-family: inherit;
  font-size: 16px;
  padding: 6px 24px;
  cursor: pointer;
}
button.dq:hover { background: #333; }
button.dq:active { background: #555; }

.hidden { display: none !important; }

/* ---- タッチパッド（タッチ端末のみ表示） ---- */
#pad {
  display: none;
  justify-content: space-between;
  align-items: center;        /* 十字キーが3段のプラス形状になったため、中央揃えで左右ボタンと高さが一致する */
  margin-top: 72px;           /* 上ボタンがゲーム画面に近すぎるため間隔を広げる */
  padding: 0 10px;
  user-select: none;
  -webkit-user-select: none;
}

@media (pointer: coarse) {
  #pad { display: flex; }
}

#dpad {
  display: grid;
  grid-template-areas:
    '. up .'
    'left . right'
    '. down .';
  gap: 4px;
}
#dpad button { width: 52px; height: 52px; font-size: 18px; padding: 0; }
#dpad button[data-d='up'] { grid-area: up; }
#dpad button[data-d='left'] { grid-area: left; }
#dpad button[data-d='down'] { grid-area: down; }
#dpad button[data-d='right'] { grid-area: right; }

#btn-a {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  font-size: 20px;
  padding: 0;                /* .dq の左右パディングを打ち消す（Ａの中心ずれ対策） */
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  margin-right: 26px;        /* 右端に寄りすぎるため十字キーのボタン半個分左にずらす */
}
