* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  background: #000;
  height: 100%;
  font-family: 'DotGothic16', 'MS Gothic', monospace;
  color: #fff;
  overflow: hidden;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

#game-wrap {
  /* 画面が小さいときは JS で transform: scale() を当てて縮小する */
  width: 720px;
  height: 560px;
  flex-shrink: 0;
}

#game {
  position: relative;
  width: 720px;
  height: 560px;
  background: #000;
  image-rendering: pixelated;
  user-select: none;
}

#game.shake { animation: shake 0.25s; }
@keyframes shake {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-8px, 4px); }
  40% { transform: translate(8px, -4px); }
  60% { transform: translate(-6px, -3px); }
  80% { transform: translate(6px, 3px); }
  100% { transform: translate(0, 0); }
}

#scene {
  display: block;
  width: 720px;
  height: 400px;
  image-rendering: pixelated;
}

/* DQ風ウィンドウ: 黒地 + 白の二重枠 + 角丸 */
.win {
  position: absolute;
  background: #000;
  border: 3px solid #fff;
  border-radius: 8px;
  box-shadow: 0 0 0 3px #000, inset 0 0 0 1px #000;
  outline: 1px solid #fff;
  outline-offset: -7px;
  padding: 14px 16px;
  font-size: 20px;
  line-height: 1.55;
  z-index: 10;
}

.hidden { display: none !important; }

/* ステータスウィンドウ */
#status-win {
  top: 10px;
  left: 10px;
  min-width: 150px;
  font-size: 18px;
  padding: 10px 14px;
}
.status-name {
  text-align: center;
  border-bottom: 2px solid #fff;
  margin-bottom: 6px;
  padding-bottom: 2px;
}
.status-table { border-collapse: collapse; width: 100%; }
.status-table td { padding: 0 2px; white-space: nowrap; }
.status-table td:last-child { text-align: right; }

/* プレイヤーHPバー(ポケモン風) */
#player-hp-bar {
  margin-top: 6px;
  height: 8px;
  background: #333;
  border: 1px solid #fff;
}
#player-hp-bar div {
  height: 100%;
  width: 100%;
  background: #4caf50;
  transition: width 0.4s, background 0.4s;
}

/* BGM切替ボタン */
#bgm-toggle {
  position: absolute;
  right: 10px;
  bottom: 162px;
  z-index: 60;
  background: #000;
  border: 2px solid #fff;
  border-radius: 6px;
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  padding: 3px 10px;
  cursor: pointer;
}
#bgm-toggle:hover { background: #333; }

/* コマンドウィンドウ */
#cmd-win {
  top: 10px;
  right: 10px;
  min-width: 220px;
  max-width: 420px;
  z-index: 20;
}
#cmd-title {
  text-align: center;
  border-bottom: 2px solid #fff;
  margin-bottom: 8px;
  padding-bottom: 2px;
}
#cmd-title:empty { display: none; }
#cmd-list { list-style: none; }
#cmd-list li {
  padding: 2px 4px 2px 30px;
  position: relative;
  white-space: nowrap;
  cursor: pointer;
}
#cmd-list li.sel::before {
  content: '▶';
  position: absolute;
  left: 4px;
  animation: blink-cursor 0.6s steps(1) infinite;
}
@keyframes blink-cursor { 50% { opacity: 0; } }
#cmd-list li .meta {
  float: right;
  margin-left: 24px;
  color: #ccc;
}
#cmd-list li.disabled { color: #777; }

/* メッセージウィンドウ */
#msg-win {
  left: 10px;
  right: 10px;
  bottom: 10px;
  height: 142px;
  cursor: pointer;
}
#msg-text {
  white-space: pre-wrap;
  height: 100%;
  overflow: hidden;
}
#msg-arrow {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  animation: blink-cursor 0.5s steps(1) infinite;
  display: none;
}
#msg-win.waiting #msg-arrow { display: block; }

/* 名前入力 */
#name-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
}
#name-win {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}
#name-input {
  display: block;
  margin: 14px auto 10px;
  background: #000;
  border: 2px solid #fff;
  color: #fff;
  font-family: inherit;
  font-size: 22px;
  text-align: center;
  width: 200px;
  padding: 4px;
}
#name-ok {
  background: #000;
  border: 2px solid #fff;
  border-radius: 4px;
  color: #fff;
  font-family: inherit;
  font-size: 18px;
  padding: 4px 18px;
  cursor: pointer;
}
#name-ok:hover { background: #333; }
