* {
  box-sizing: border-box;
  -webkit-user-select: none;
  user-select: none;
}
body {
  margin: 0;
  color: #00e676;
  font-family: monospace;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start; /* ← center から flex-start に変更 */
  min-height: 100vh;
  background-color: #121212; 
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

/* ローディング画面 */
#loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(10, 10, 10, 0.95);
  color: #ffffff;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  transition: opacity 0.6s ease;
}

#loader.loaded {
  opacity: 0;
  pointer-events: none;
}

.loader-content {
  text-align: center;
  letter-spacing: 0.1em;
}

.brand-name {
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
}

.loading-text {
  font-size: 1.2rem;
  color: #888888;
  animation: blink 1.2s infinite; 
}

@keyframes blink {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* --- スマホ表示をベースにしたコンテナ設定 --- */
.game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100vw;
  max-width: 360px;
  height: 100vh;
  max-height: 640px;
  position: relative;
  overflow: hidden;
  margin: 0 auto;
}

/* 画面共通ベース */
.view-screen {
  width: 100%;
  height: 100%; 
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.hidden {
  display: none !important;
}

/* --- 1. タイトル画面 --- */
#select-screen {
  background-image: url('../images/r_title.png');
  background-size: 100% 100% ;
  background-position: center top;
  background-repeat: no-repeat;
  padding-top: 180px;
}

/* --- 2. ゲームプレイ画面 --- */
#play-screen {
  background-image: url('../images/recordshop.png');
  background-size: 100% 100%;       
  background-position: center top;
  background-repeat: no-repeat;
  background-color: #121212;
}

.version-label {
  margin-top: 40px; 
  font-size: 0.85rem; 
  color: #e0e0e0; 
  letter-spacing: 1px;
}

/* ステージ選択 UI */
.carousel-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin: 30px 0;
}

.stage-card {
  width: 140px;
  min-height: 55px; 
  height: auto;
  padding: 8px 10px;
  background-color: #1e1e1e;
  border: 2px solid #90caf9;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: #fff;
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
  user-select: none;
}

#card-stage-num {
  font-size: 1.1rem;
  line-height: 1.2;
}

#select-best-record {
  color: #ffb74d;
  font-size: 0.75rem;
  margin-top: 4px;
  font-family: monospace;
  font-weight: normal;
}

.arrow-btn {
  background: none;
  border: 1px solid #555;
  color: #00e676;
  font-size: 1.2rem;
  padding: 10px 15px;
  cursor: pointer;
  border-radius: 4px;
}

.arrow-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.start-btn {
  background-color: #2e7d32;
  color: white;
  font-size: 1.2rem;
  font-family: monospace;
  padding: 12px 40px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.start-btn:hover {
  background-color: #388e3c;
}

#clear-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 10;
}

.clear-message {
  font-size: 24px;
  color: #00e676;
  font-weight: bold;
  margin-bottom: 20px;
  text-shadow: 0 0 10px #00e676;
  animation: pulse 1.5s infinite;
}

#btn-next {
  padding: 10px 20px;
  background: #00e676;
  border: none;
  border-radius: 4px;
  font-weight: bold;
  cursor: pointer;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* ゲームエリア UI */
.screen-label {
  font-size: 18px;
  margin: 4px 0 2px 0;
  letter-spacing: 1px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(11, 21px);
  grid-template-rows: repeat(9, 21px);
  gap: 1px;
  padding: 3px;
  border: 2px solid #444;
  border-radius: 4px;
  background-color: #222;
  opacity: 0.9;
}

#real-world {
  background-color: #2b2622;
  border-color: #8c6d53;
}

#spirit-world {
  background-color: #151a24;
  border-color: #4a6fa5;
}

.cell {
  width: 21px;
  height: 21px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  background-color: rgba(255, 255, 255, 0.03);
  border-radius: 1px;
  background-size: cover;
  background-position: center;
  image-rendering: pixelated;
}

.wall { 
  background-color: #444; 
}

.cell.img-player-real,
.cell.img-player-spirit {
  background-image: url('../images/r_player.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.cell.img-box {
  background-image: url('../images/r_box.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.cell.img-ghost {
  background-image: url('../images/r_obake.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.cell.img-cat {
  background-image: url('../images/r_neko.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.cell.img-shadow {
  background-image: url('../images/r_kage.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.cell.hit-ghost {
  animation: ghostHit 0.5s ease-in-out infinite alternate;
  z-index: 100;
  position: relative;
}

@keyframes ghostHit {
  0% { transform: scale(1); }
  100% {
    transform: scale(2.0);
    filter: drop-shadow(0 0 10px #ef5350);
  }
}

.interface {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
  padding: 0 12px;
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(3, 44px);
  gap: 3px;
  touch-action: none;
}

.btn {
  background-color: #2a2a2a;
  color: #fff;
  border: 1px solid #444;
  border-radius: 6px;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.btn:active {
  background-color: #555;
}

.info-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
  padding: 0 8px;
}

.stage-badge {
  font-size: 12px;
  font-weight: bold;
  color: #00e676;
  background-color: #000;
  padding: 4px 8px;
  border: 1px solid #333;
  border-radius: 4px;
  letter-spacing: 1px;
}

#status {
  font-size: 12px;
  height: 16px;
  text-align: center;
  color: #ffb74d;
}

.action-btns {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#btn-reset, #btn-select {
  width: 50px;
  height: 36px;
  border-radius: 4px;
  color: #fff;
  font-size: 12px;
  font-weight: bold;
  border: none;
  font-family: monospace;
}

#btn-reset {
  background: #8e0000;
  border: 1px solid #b71c1c;
}
#btn-reset:active { background: #d32f2f; }

#btn-select {
  background: #333;
  border: 1px solid #555;
}
#btn-select:active { background: #555; }

/* PC表示（画面幅600px以上）の調整 */

/* PC表示（画面幅600px以上）の調整 */
@media (min-width: 600px) {
  body {
    justify-content: center; /* PCの時だけ上下中央寄せにする */
  }

  .game-container {
    width: 360px;
    height: 640px;
    border: 2px solid #444;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), 0 0 15px rgba(0, 230, 118, 0.2);
    padding: 10px;
    margin: auto; /* 上下左右中央に浮せる */
  }
}








