:root {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100svh;
  font-family: Arial, "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  background: radial-gradient(circle at 50% 20%, #1a1a2e, #0a0a14 60%);
  color: #f5f5f5;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.app-root {
  height: 100svh;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
  /* ゲーム領域ではブラウザのスクロール／ピンチ／長押し選択を抑える（howtoplay 等は .app-root 未使用） */
  touch-action: none;
  overscroll-behavior: none;
}

/* 論理解像度 480×720 の比率を保ち、画面に収まる最大サイズで表示 */
.canvas-stage {
  width: min(100vw, calc(100svh * 480 / 720));
  max-height: 100svh;
  aspect-ratio: 480 / 720;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #3a3a5a;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 0 60px rgba(80, 60, 200, 0.08);
  touch-action: none;
  position: relative;
}

/* 名前入力フェーズ以外は画面外（フォーカス用に DOM は残す） */
.canvas-stage .game-name-input {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

/* 論理 480×720 の入力ボックス位置（canvas-stage と同じ縦横比）に重ねる */
.canvas-stage.name-input-active .game-name-input {
  left: calc(100% * 80 / 480);
  top: calc(100% * 280 / 720);
  width: calc(100% * 320 / 480);
  height: calc(100% * 56 / 720);
  opacity: 1;
  pointer-events: auto;
  z-index: 30;
  margin: 0;
  padding: 0 10px;
  box-sizing: border-box;
  /* 16px 未満だと iOS Safari がフォーカス時にズームする */
  font: bold 16px Arial, "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  color: #fff;
  background: rgba(22, 22, 32, 0.96);
  border: 2px solid #ffd54a;
  border-radius: 8px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  user-select: text;
  -webkit-user-select: text;
  touch-action: manipulation;
}

/* grid+height:100% だとリサイズ時に縦だけ伸びるブラウザがあるため、幅基準で aspect-ratio を維持 */
#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 480 / 720;
  max-width: 100%;
  max-height: 100%;
  background: #1a1a1a;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.hud {
  position: absolute;
  top: 10px;
  right: 10px;
  pointer-events: none;
  z-index: 100;
}

.dev-toggle {
  display: none; /* 初期は非表示 */
  font-size: 13px;
  align-items: center;
  gap: 8px;
  opacity: 0.6;
}

.editor-panel {
  width: min(480px, 100%);
  display: grid;
  gap: 8px;
}

.editor-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.editor-panel button {
  padding: 6px 10px;
  border: 1px solid #666;
  border-radius: 6px;
  background: #2b2b2b;
  color: #f5f5f5;
  cursor: pointer;
}

.editor-help {
  margin: 0;
  font-size: 12px;
  opacity: 0.85;
}

#txtJson {
  width: 100%;
  background: #161616;
  color: #f5f5f5;
  border: 1px solid #555;
  border-radius: 6px;
  padding: 8px;
  font-family: Consolas, monospace;
}
