/* ==========================================
   SOKOBAN NEO - Style Sheet
   ========================================== */

:root {
  --bg-primary: #0b0f19;
  --bg-secondary: #0f172a;
  --panel-bg: rgba(30, 41, 59, 0.4);
  --panel-border: rgba(255, 255, 255, 0.06);
  --panel-blur: 16px;
  
  --color-primary: #6366f1; /* Indigo */
  --color-primary-glow: rgba(99, 102, 241, 0.4);
  --color-accent: #f43f5e; /* Rose */
  --color-success: #10b981; /* Emerald */
  --color-success-glow: rgba(16, 185, 129, 0.3);
  
  /* Game Elements */
  --color-wall: #1e3a8a; /* Deep Blue */
  --color-wall-border: #3b82f6; /* Bright Blue */
  --color-floor: #111827;
  --color-target: #f43f5e; /* Rose */
  --color-box: #f59e0b; /* Amber */
  --color-box-glow: rgba(245, 158, 11, 0.4);
  
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-pixel: 'Press Start 2P', monospace;
  
  --cell-size: 50px; /* JSで動的に変更されます */
  --board-cols: 10;
  --board-rows: 10;
}

/* リセット & 共通設定 */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.1) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(244, 63, 94, 0.1) 0%, transparent 40%);
  color: #f1f5f9;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  position: relative;
}

/* 画面定義 */
.screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  height: 100dvh; /* Dynamic Viewport Height for mobile browsers */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  opacity: 1;
  transition: opacity 0.3s ease, visibility 0.3s;
  z-index: 10;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch; /* Smooth iOS momentum scrolling */
  padding: 12px 12px 28px 12px;
}

.screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 0;
}

/* タイトル画面 */
#title-screen {
  background: radial-gradient(circle at center, #111827, #030712);
}

.container {
  max-width: 800px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin: 0 auto; /* Strict top alignment guarantees SOKOBAN NEO is at y=0 on load */
  padding-top: 8px;
  padding-bottom: 24px;
}

.logo {
  font-size: clamp(2rem, 7vw, 3.5rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
  margin-top: 2px;
  margin-bottom: 2px;
  color: #ffffff;
  white-space: nowrap;
}

.logo .neon-text {
  color: var(--color-primary);
  text-shadow: 0 0 15px var(--color-primary-glow);
  position: relative;
}

.subtitle {
  font-size: 0.95rem;
  color: #94a3b8;
  max-width: 480px;
  margin-bottom: 16px;
  line-height: 1.4;
}

/* メニューカード (グラスモルフィズム) */
.menu-card {
  background: var(--panel-bg);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 18px;
  width: 100%;
  max-width: 580px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.stage-select-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 14px;
}

.stage-select-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.stage-select-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  white-space: nowrap;
}

#selected-stage-display {
  font-size: 0.92rem;
  color: var(--color-primary);
  font-weight: 600;
  background: rgba(99, 102, 241, 0.15);
  padding: 4px 12px;
  border-radius: 12px;
  border: 1px solid rgba(99, 102, 241, 0.2);
  white-space: nowrap;
  flex-shrink: 0;
  align-self: flex-start;
}

.stage-grid-wrapper {
  max-height: 300px;
  overflow-y: auto;
  padding-right: 5px;
  border-radius: 8px;
}

/* スクロールバー装飾 */
.stage-grid-wrapper::-webkit-scrollbar {
  width: 6px;
}
.stage-grid-wrapper::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}
.stage-grid-wrapper::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}
.stage-grid-wrapper::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

.stage-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 8px;
}

/* 各ステージボタン */
.stage-item {
  aspect-ratio: 1;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  color: #cbd5e1;
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.stage-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.stage-item.selected {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
  box-shadow: 0 0 15px var(--color-primary-glow);
}

/* クリア済みステージ */
.stage-item.cleared {
  border-color: rgba(16, 185, 129, 0.3);
}

.stage-item.cleared::after {
  content: '✓';
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 0.65rem;
  color: var(--color-success);
  font-weight: bold;
}

.stage-item.cleared.selected::after {
  color: white;
}

/* ボタンの共通設定 */
.btn {
  font-family: var(--font-sans);
  border: none;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  background: #4f46e5;
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  color: white;
}

.btn-danger {
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid rgba(244, 63, 94, 0.2);
  color: var(--color-accent);
}

.btn-danger:hover {
  background: var(--color-accent);
  color: white;
  box-shadow: 0 4px 12px rgba(244, 63, 94, 0.3);
}

.btn-warning {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fbbf24;
}

.btn-warning:hover {
  background: #f59e0b;
  color: #0b0f19;
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
}

.btn-info {
  background: rgba(6, 182, 212, 0.15);
  border: 1px solid rgba(6, 182, 212, 0.3);
  color: #38bdf8;
}

.btn-info:hover {
  background: #0284c7;
  color: white;
  box-shadow: 0 4px 15px rgba(56, 189, 248, 0.4);
}

.btn-info.active {
  background: #0284c7;
  color: white;
  animation: pulse 1.2s infinite alternate;
}

.btn-audio {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 12px;
  font-size: 1.1rem;
}

.btn-audio:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-audio.muted {
  opacity: 0.5;
  filter: grayscale(80%);
}

.header-audio-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-large {
  padding: 14px 28px;
  font-size: 1.1rem;
}

.btn-icon svg {
  transition: transform 0.2s;
}

.btn-icon:hover svg {
  transform: scale(1.1);
}

.footer {
  margin-top: 40px;
  font-size: 0.85rem;
  color: #64748b;
}

/* ゲーム画面 */
#game-screen {
  background: radial-gradient(circle at center, #0f172a, #020617);
}

.game-container {
  max-width: 1000px;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
}

/* 上部コントロールバー */
.game-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel-bg);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 10px 18px;
  z-index: 10;
}

.game-header-top {
  display: flex;
  align-items: center;
  gap: 20px;
}

.stage-info {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stage-info .label {
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: #64748b;
  font-weight: bold;
}

.stage-info .value {
  font-family: var(--font-pixel);
  font-size: 1.4rem;
  color: white;
  margin-top: 2px;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

.stats-group {
  display: flex;
  gap: 20px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-label {
  font-size: 0.75rem;
  color: #94a3b8;
}

.stat-value {
  font-family: var(--font-pixel);
  font-size: 1.1rem;
  color: var(--color-primary);
  margin-top: 4px;
}

.actions {
  display: flex;
  gap: 8px;
}

/* ボード領域 */
.board-wrapper {
  flex-grow: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  overflow: hidden;
  padding: 10px 0;
}

.game-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--board-cols), var(--cell-size));
  grid-template-rows: repeat(var(--board-rows), var(--cell-size));
  gap: 0;
  border-radius: 12px;
  overflow: hidden;
  background-color: var(--color-floor);
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.6);
  border: 4px solid rgba(255, 255, 255, 0.05);
}

/* タイル要素 */
.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 壁タイル */
.cell.wall {
  background: var(--color-wall);
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
}

.cell.wall::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  right: 4px;
  bottom: 4px;
  border: 2px solid var(--color-wall-border);
  border-radius: 4px;
  opacity: 0.65;
  box-shadow: 0 0 4px var(--color-wall-border);
}

/* 床タイル */
.cell.floor {
  background-color: var(--color-floor);
  background-image: 
    radial-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 8px 8px;
}

/* ゴールタイル */
.cell.target {
  background-color: var(--color-floor);
}

.cell.target::after {
  content: '';
  width: 32%;
  height: 32%;
  border-radius: 50%;
  background: var(--color-target);
  box-shadow: 0 0 12px var(--color-target);
  animation: pulse 2s infinite alternate;
}

/* 動的要素 (絶対配置レイヤー) */
.entity {
  position: absolute;
  width: var(--cell-size);
  height: var(--cell-size);
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate(calc(var(--x) * var(--cell-size)), calc(var(--y) * var(--cell-size)));
  transition: transform 0.14s cubic-bezier(0.25, 1, 0.5, 1);
  z-index: 5;
}

/* プレイヤー */
.player-entity {
  z-index: 6;
}

.player-sprite {
  width: 80%;
  height: 80%;
  border-radius: 35%;
  background: linear-gradient(135deg, #a78bfa, #6366f1);
  border: 2px solid white;
  box-shadow: 0 4px 10px rgba(99, 102, 241, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.1s;
}

/* プレイヤーの顔 */
.player-face {
  font-family: monospace;
  font-weight: bold;
  font-size: 1.1rem;
  color: white;
  letter-spacing: -1px;
}

/* プレイヤーの足 */
.player-sprite::before, .player-sprite::after {
  content: '';
  position: absolute;
  bottom: -4px;
  width: 25%;
  height: 25%;
  background: #4f46e5;
  border-radius: 50%;
  z-index: -1;
}
.player-sprite::before { left: 15%; }
.player-sprite::after { right: 15%; }

/* プレイヤーの向き */
.entity.dir-left .player-sprite { transform: scaleX(-1); }
.entity.dir-right .player-sprite { transform: scaleX(1); }

/* プレイヤーのアクション中 */
.entity.moving .player-sprite {
  animation: bounce 0.14s ease-out;
}

/* 荷物 (Crate) */
.box-entity {
  z-index: 5;
}

.box-sprite {
  width: 78%;
  height: 78%;
  background: linear-gradient(135deg, #fbbf24, #d97706);
  border: 2px solid #f59e0b;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

/* 荷物の上のバッテン */
.box-sprite::before {
  content: '✕';
  font-size: 1.2rem;
  font-weight: 800;
  color: rgba(0, 0, 0, 0.35);
}

/* ゴールの上に乗っている荷物 */
.box-entity.on-target .box-sprite {
  background: linear-gradient(135deg, #34d399, #059669);
  border-color: #10b981;
  box-shadow: 0 0 15px var(--color-success-glow);
}

.box-entity.on-target .box-sprite::before {
  color: rgba(255, 255, 255, 0.5);
  content: '✓';
}

/* 操作パネル */
.controls-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.mobile-controls {
  display: none; /* デフォルト非表示、メディアクエリでスマホ時に表示 */
  justify-content: center;
}

/* 十字キー (D-Pad) */
.dpad {
  position: relative;
  width: 170px;
  height: 170px;
}

.dpad-btn {
  position: absolute;
  width: 52px;
  height: 52px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.1s, transform 0.1s;
  touch-action: manipulation;
}

.dpad-btn:active {
  background: var(--color-primary);
  color: white;
  transform: scale(0.95);
  border-color: var(--color-primary);
  box-shadow: 0 0 10px var(--color-primary-glow);
}

.dpad-up { top: 0; left: 59px; }
.dpad-left { top: 59px; left: 0; }
.dpad-right { top: 59px; right: 0; }
.dpad-down { bottom: 0; left: 59px; }

.dpad-center {
  position: absolute;
  top: 59px;
  left: 59px;
  width: 52px;
  height: 52px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 12px;
}

.desktop-tips {
  font-size: 0.85rem;
  color: #64748b;
  text-align: center;
}

.desktop-tips span {
  display: inline-block;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: 1px 6px;
  margin: 0 2px;
  color: #94a3b8;
  font-family: monospace;
}

/* クリアモーダル */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(3, 7, 18, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.3s ease, visibility 0.3s;
}

.modal-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modal-content {
  background: var(--panel-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  width: 90%;
  max-width: 440px;
  padding: 35px 30px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  text-align: center;
  transform: translateY(0);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.hidden .modal-content {
  transform: translateY(30px);
}

.modal-stars {
  font-size: 2.5rem;
  color: #fbbf24;
  text-shadow: 0 0 15px rgba(251, 191, 36, 0.4);
  margin-bottom: 15px;
  display: flex;
  justify-content: center;
  gap: 8px;
}

.star {
  display: inline-block;
}

.modal-content h2 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  margin-bottom: 5px;
  background: linear-gradient(to right, #34d399, #059669);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

#clear-stage-text {
  color: #94a3b8;
  font-size: 1rem;
  margin-bottom: 25px;
}

.clear-stats {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 16px;
  padding: 15px;
  justify-content: space-around;
  margin-bottom: 30px;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.clear-stat-item {
  display: flex;
  flex-direction: column;
}

.clear-stat-item .stat-label {
  font-size: 0.8rem;
  color: #64748b;
}

.clear-stat-item .stat-value {
  font-family: var(--font-pixel);
  font-size: 1.2rem;
  color: white;
  margin-top: 5px;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-actions .btn {
  width: 100%;
}

/* アニメーションキーフレーム */
@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.6; }
  100% { transform: scale(1.1); opacity: 1; }
}

@keyframes bounce {
  0% { transform: scale(1); }
  50% { transform: scale(0.9, 1.1) translateY(-4px); }
  100% { transform: scale(1); }
}

.animate-star-1 { animation: starPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }
.animate-star-2 { animation: starPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) 0.15s forwards; opacity: 0; }
.animate-star-3 { animation: starPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s forwards; opacity: 0; }

@keyframes starPop {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ==========================================
   レスポンシブメディアクエリ
   ========================================== */

/* スマホ対応 */
@media (max-width: 768px) {
  .logo {
    font-size: clamp(1.8rem, 6.5vw, 2.5rem);
    margin-top: 4px;
    margin-bottom: 2px;
  }
  
  .subtitle {
    font-size: 0.88rem;
    padding: 0 5px;
    margin-bottom: 12px;
    line-height: 1.35;
  }
  
  .menu-card {
    padding: 14px 12px;
    gap: 12px;
    border-radius: 16px;
  }

  .stage-grid-wrapper {
    /* 1〜20(4行)を完全表示し、5行目の数字「21〜25」の頭がちょうど良く見える高さ */
    max-height: 328px;
  }
  
  .stage-grid {
    grid-template-columns: repeat(5, 1fr); /* スマホは5列に */
    gap: 6px;
  }
  
  .game-header {
    flex-direction: column;
    gap: 8px;
    padding: 8px 10px;
    width: 100%;
  }

  .game-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 8px;
  }

  .actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 4px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }

  .actions .btn {
    padding: 6px 6px;
    font-size: 0.8rem;
    gap: 3px;
    flex: 1;
    justify-content: center;
    min-width: 0;
  }

  .btn-label {
    font-size: 0.75rem;
  }
  
  .stage-info .value {
    font-size: 1.1rem;
  }
  
  .stat-value {
    font-size: 0.9rem;
  }
  
  .mobile-controls {
    display: flex; /* スマホでは十字キーを表示 */
  }
  
  .desktop-tips {
    display: none; /* スマホではデスクトップの操作説明を非表示 */
  }
  
  .game-container {
    padding: 5px 0;
  }

  .btn-large {
    padding: 12px 20px;
    font-size: 1rem;
  }
}

/* 狭いスマホ画面 (横幅440px以下) */
@media (max-width: 440px) {
  .actions .btn {
    padding: 6px 4px;
  }
  .btn-label {
    display: none; /* アイコンのみにして全ボタンを画面内に完璧に収める */
  }
}

/* モバイル高さ対応 (iPhone Safari/Chromeなど) */
@media (max-height: 720px) {
  .logo {
    font-size: 1.7rem;
    margin-top: 2px;
    margin-bottom: 2px;
  }
  .subtitle {
    margin-bottom: 8px;
    font-size: 0.8rem;
    line-height: 1.3;
  }
  .menu-card {
    padding: 10px 12px;
    gap: 10px;
  }
  .stage-grid-wrapper {
    max-height: 308px;
  }
  .dpad {
    width: 140px;
    height: 140px;
  }
  .dpad-btn {
    width: 44px;
    height: 44px;
  }
  .dpad-up { top: 0; left: 48px; }
  .dpad-left { top: 48px; left: 0; }
  .dpad-right { top: 48px; right: 0; }
  .dpad-down { bottom: 0; left: 48px; }
  .dpad-center { top: 48px; left: 48px; width: 44px; height: 44px; }
}

/* ==========================================
   ヒント & 自動解法 & デッドロック表示
   ========================================== */

.hint-toast {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(245, 158, 11, 0.4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 8px 18px;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 15px rgba(245, 158, 11, 0.2);
  z-index: 50;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-size: 0.9rem;
  color: #f8fafc;
  pointer-events: none;
  white-space: nowrap;
}

.hint-toast.deadlock-toast {
  border-color: rgba(244, 63, 94, 0.6);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 20px rgba(244, 63, 94, 0.3);
  color: #fecdd3;
}

.hint-toast.hidden {
  opacity: 0;
  transform: translate(-50%, -15px) scale(0.95);
  visibility: hidden;
}

.hint-arrow-entity {
  position: absolute;
  width: var(--cell-size);
  height: var(--cell-size);
  left: calc(var(--x) * var(--cell-size));
  top: calc(var(--y) * var(--cell-size));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 15;
  pointer-events: none;
  animation: hintArrowFloat 0.8s ease-in-out infinite alternate;
}

.hint-arrow-icon {
  font-size: calc(var(--cell-size) * 0.65);
  color: #fbbf24;
  text-shadow: 0 0 12px rgba(245, 158, 11, 0.8), 0 0 25px rgba(251, 191, 36, 0.5);
  font-weight: 800;
  line-height: 1;
}

@keyframes hintArrowFloat {
  0% { transform: scale(0.9); opacity: 0.7; }
  100% { transform: scale(1.18); opacity: 1; }
}

/* ==========================================
   ビジュアルテーマ & スキン定義
   ========================================== */

/* Theme 1: 🎮 8-Bit Retro Pixel */
[data-theme="retro"] {
  --bg-primary: #051408;
  --bg-secondary: #0a240f;
  --panel-bg: rgba(10, 36, 15, 0.88);
  --panel-border: rgba(34, 197, 94, 0.35);
  --panel-blur: 0px;

  --color-primary: #22c55e;
  --color-primary-glow: rgba(34, 197, 94, 0.5);
  --color-accent: #ef4444;
  --color-success: #4ade80;

  --color-wall: #15803d;
  --color-wall-border: #4ade80;
  --color-floor: #06200a;
  --color-target: #ef4444;
  --color-box: #eab308;
  --color-box-glow: rgba(234, 179, 8, 0.4);

  --font-sans: 'Press Start 2P', monospace;
}

[data-theme="retro"] body {
  background-image: 
    linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
    linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
  background-size: 100% 4px, 6px 100%;
}

[data-theme="retro"] .cell.wall {
  background: #166534;
  border: 3px solid #22c55e;
  box-shadow: inset 0 0 0 2px #052e16;
}

[data-theme="retro"] .box-sprite {
  background: #ca8a04;
  border: 3px solid #fef08a;
  border-radius: 0px;
}

[data-theme="retro"] .player-sprite {
  border-radius: 4px;
  background: #16a34a;
}

/* Theme 2: 🪵 Classic Warehouse Wood */
[data-theme="wood"] {
  --bg-primary: #1c140e;
  --bg-secondary: #2a1d15;
  --panel-bg: rgba(42, 29, 21, 0.88);
  --panel-border: rgba(180, 83, 9, 0.35);
  --panel-blur: 10px;

  --color-primary: #d97706;
  --color-primary-glow: rgba(217, 119, 6, 0.4);
  --color-accent: #dc2626;
  --color-success: #16a34a;

  --color-wall: #78350f;
  --color-wall-border: #b45309;
  --color-floor: #29180e;
  --color-target: #f59e0b;
  --color-box: #9a3412;
  --color-box-glow: rgba(154, 52, 18, 0.4);

  --font-sans: 'Outfit', sans-serif;
}

[data-theme="wood"] .cell.wall {
  background: linear-gradient(135deg, #78350f, #451a03);
  border: 2px solid #b45309;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.6);
}

[data-theme="wood"] .box-sprite {
  background: linear-gradient(135deg, #b45309, #78350f);
  border: 2px solid #f59e0b;
  border-radius: 4px;
}

[data-theme="wood"] .player-sprite {
  background: linear-gradient(135deg, #d97706, #92400e);
}

/* Theme 3: 📐 Minimal Blueprint */
[data-theme="blueprint"] {
  --bg-primary: #071e3d;
  --bg-secondary: #0c2b56;
  --panel-bg: rgba(12, 43, 86, 0.8);
  --panel-border: rgba(56, 189, 248, 0.3);
  --panel-blur: 16px;

  --color-primary: #0284c7;
  --color-primary-glow: rgba(2, 132, 199, 0.4);
  --color-accent: #f43f5e;
  --color-success: #10b981;

  --color-wall: #0369a1;
  --color-wall-border: #38bdf8;
  --color-floor: #0c2646;
  --color-target: #38bdf8;
  --color-box: #0284c7;
  --color-box-glow: rgba(2, 132, 199, 0.4);

  --font-sans: 'Outfit', monospace;
}

[data-theme="blueprint"] body {
  background-image: 
    linear-gradient(rgba(56, 189, 248, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.12) 1px, transparent 1px);
  background-size: 20px 20px;
}

[data-theme="blueprint"] .cell.wall {
  background: #0284c7;
  border: 1px solid #7dd3fc;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

[data-theme="blueprint"] .box-sprite {
  background: rgba(2, 132, 199, 0.8);
  border: 2px dashed #7dd3fc;
  border-radius: 6px;
}

/* テーマモーダル & カードスタイル */
.theme-modal-content {
  max-width: 520px;
  width: 92%;
  text-align: center;
}

.modal-subtext {
  font-size: 0.9rem;
  color: #94a3b8;
  margin-top: 4px;
}

.theme-options-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 18px 0;
}

.theme-option-card {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.theme-option-card:hover {
  background: rgba(255, 255, 255, 0.09);
  transform: translateX(4px);
}

.theme-option-card.selected {
  border-color: var(--color-primary);
  background: rgba(99, 102, 241, 0.15);
  box-shadow: 0 0 15px var(--color-primary-glow);
}

.theme-option-icon {
  font-size: 1.8rem;
}

.theme-option-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.theme-option-name {
  font-weight: 600;
  font-size: 0.98rem;
  color: #ffffff;
}

.theme-option-desc {
  font-size: 0.8rem;
  color: #94a3b8;
}


