:root {
  --bg-dark: #0a090d;
  --panel-bg: rgba(18, 15, 24, 0.86);
  --border-gold: rgba(212, 168, 87, 0.45);
  --accent-crimson: #e63946;
  --accent-amber: #f4a261;
  --accent-gold: #ffd166;
  --accent-emerald: #2ec4b6;
  --accent-purple: #9d4edd;
  --text-light: #f5f2eb;
  --text-muted: #b5afa6;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at center, #1b1521 0%, #07060a 100%);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  color: var(--text-light);
  touch-action: none;
}

#app-shell {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* スマホ縦画面フレーム：PCでは縦長スマホサイズ、スマホ実機では全画面 */
#phone-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 480px;
  max-height: 920px;
  background: #120e16;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.9), 0 0 0 2px rgba(212, 168, 87, 0.28);
}

@media (min-width: 500px) and (min-height: 700px) {
  #phone-viewport {
    height: 95vh;
    aspect-ratio: 9 / 16.5;
    border-radius: 26px;
  }
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}

/* 上部HUD */
#hud-top {
  position: relative;
  z-index: 10;
  padding: 10px 12px 6px;
  background: linear-gradient(180deg, rgba(8, 6, 12, 0.92) 0%, rgba(8, 6, 12, 0.65) 75%, rgba(8, 6, 12, 0) 100%);
  pointer-events: none;
}

.hud-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.stage-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.stage-badge {
  background: linear-gradient(135deg, #3a1c28, #1d1422);
  border: 1px solid var(--border-gold);
  color: var(--accent-gold);
  font-weight: 800;
  font-size: 0.82rem;
  padding: 4px 10px;
  border-radius: 6px;
  text-shadow: 0 1px 3px #000;
  letter-spacing: 0.03em;
}

.enemy-counter {
  background: rgba(25, 16, 24, 0.85);
  border: 1px solid rgba(230, 57, 70, 0.5);
  color: #ffb3b8;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
}

.enemy-counter span {
  color: #ff4d5a;
  font-size: 0.92rem;
  font-weight: 900;
}

.top-utility-btns {
  display: flex;
  gap: 6px;
  pointer-events: auto;
}

.util-btn {
  background: rgba(28, 24, 38, 0.92);
  border: 1px solid rgba(212, 168, 87, 0.45);
  color: var(--text-light);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 5px 9px;
  border-radius: 7px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: transform 0.1s, background 0.15s;
}

.util-btn:active {
  transform: scale(0.94);
}

.util-btn.sound-off {
  opacity: 0.65;
  border-color: rgba(160, 160, 160, 0.35);
}

.hud-row-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.player-status-panel {
  flex: 1;
  background: rgba(14, 12, 20, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 7px 10px;
  backdrop-filter: blur(4px);
}

.hp-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.72rem;
  font-weight: 800;
  margin-bottom: 3px;
}

.hp-label {
  color: #72efdd;
  letter-spacing: 0.06em;
}

.hp-value {
  color: #fff;
  font-family: monospace;
  font-size: 0.8rem;
}

.hp-bar-track {
  position: relative;
  width: 100%;
  height: 11px;
  background: #231924;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  margin-bottom: 6px;
}

.hp-bar-damage {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: #ffbe0b;
  transition: width 0.35s ease-out;
}

.hp-bar-fill {
  position: relative;
  height: 100%;
  background: linear-gradient(90deg, #16db93 0%, #2ec4b6 60%, #80ffdb 100%);
  box-shadow: 0 0 8px rgba(46, 196, 182, 0.6);
  transition: width 0.12s ease-out;
}

.hp-bar-fill.low-hp {
  background: linear-gradient(90deg, #d90429 0%, #ef233c 100%);
}

/* 武器ステータスバー */
.weapon-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(255, 209, 102, 0.12);
  border: 1px solid rgba(255, 209, 102, 0.35);
  color: var(--accent-gold);
}

.weapon-status.empty {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}

.weapon-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.weapon-durability-wrap {
  flex: 1;
  min-width: 44px;
  height: 6px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid rgba(255, 209, 102, 0.4);
}

.weapon-durability-fill {
  height: 100%;
  background: linear-gradient(90deg, #f77f00, #ffd166);
  transition: width 0.15s;
}

.weapon-durability-text {
  font-family: monospace;
  font-size: 0.73rem;
  color: #fff;
}

/* 敵レーダー */
.radar-panel {
  position: relative;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(16, 28, 24, 0.9) 0%, rgba(8, 12, 14, 0.95) 100%);
  border: 2px solid rgba(212, 168, 87, 0.55);
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.8), inset 0 0 10px rgba(46, 196, 182, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#radar-canvas {
  border-radius: 50%;
  display: block;
}

.radar-caption {
  position: absolute;
  bottom: -2px;
  background: #18131e;
  color: var(--accent-gold);
  font-size: 0.54rem;
  font-weight: 800;
  padding: 0 5px;
  border-radius: 4px;
  border: 1px solid rgba(212, 168, 87, 0.4);
  letter-spacing: 0.08em;
}

/* ボスHPゲージ */
.boss-hud {
  margin-top: 8px;
  background: rgba(24, 8, 14, 0.88);
  border: 1.5px solid rgba(230, 57, 70, 0.75);
  border-radius: 9px;
  padding: 6px 10px;
  box-shadow: 0 0 16px rgba(230, 57, 70, 0.35);
  animation: bossPulse 2s infinite alternate;
}

@keyframes bossPulse {
  from { box-shadow: 0 0 10px rgba(230, 57, 70, 0.3); }
  to { box-shadow: 0 0 20px rgba(230, 57, 70, 0.65); }
}

.boss-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 900;
  color: #ffccd5;
  margin-bottom: 4px;
  text-shadow: 0 1px 4px #000;
}

.boss-name {
  flex: 1;
  margin-left: 5px;
  color: #ff4d6d;
  letter-spacing: 0.04em;
}

.boss-hp-text {
  font-family: monospace;
  font-size: 0.76rem;
  color: #fff;
}

.boss-bar-track {
  position: relative;
  width: 100%;
  height: 12px;
  background: #1c080d;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 100, 120, 0.45);
}

.boss-bar-damage {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: #ffd166;
  transition: width 0.4s ease-out;
}

.boss-bar-fill {
  position: relative;
  height: 100%;
  background: linear-gradient(90deg, #800f2f 0%, #c9184a 50%, #ff4d6d 100%);
  transition: width 0.1s ease-out;
}

/* ステージ演出バナー */
.center-banner {
  position: absolute;
  top: 34%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  text-align: center;
  background: linear-gradient(90deg, rgba(10, 8, 14, 0) 0%, rgba(20, 12, 24, 0.92) 20%, rgba(20, 12, 24, 0.92) 80%, rgba(10, 8, 14, 0) 100%);
  border-top: 1.5px solid var(--border-gold);
  border-bottom: 1.5px solid var(--border-gold);
  padding: 14px 10px;
  z-index: 15;
  pointer-events: none;
  animation: bannerPop 0.35s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes bannerPop {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.85); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.banner-sub {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--accent-amber);
  letter-spacing: 0.2em;
  margin-bottom: 3px;
}

.banner-title {
  font-size: 1.35rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 10px rgba(230, 57, 70, 0.85);
  margin-bottom: 4px;
}

.banner-desc {
  font-size: 0.82rem;
  color: #e0d8cf;
}

/* 武器拾いヒント */
.pickup-hint {
  position: absolute;
  bottom: 205px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(24, 18, 10, 0.92);
  border: 1.5px solid var(--accent-gold);
  color: #fff3cc;
  font-size: 0.76rem;
  padding: 6px 12px;
  border-radius: 20px;
  z-index: 12;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.7);
}

.pickup-hint strong {
  color: var(--accent-gold);
}

/* 下部コントローラー */
#controls-bottom {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 16px;
  background: linear-gradient(0deg, rgba(8, 6, 12, 0.94) 0%, rgba(8, 6, 12, 0.72) 78%, rgba(8, 6, 12, 0) 100%);
  gap: 8px;
}

/* 左：大型バーチャルジョイスティック */
.joystick-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 145px;
  flex-shrink: 0;
}

.joystick-base {
  position: relative;
  width: 126px;
  height: 126px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(45, 38, 58, 0.65) 0%, rgba(18, 14, 24, 0.88) 100%);
  border: 2.5px solid rgba(212, 168, 87, 0.45);
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.8), 0 4px 14px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

.joystick-dir {
  position: absolute;
  font-size: 0.65rem;
  color: rgba(212, 168, 87, 0.35);
  pointer-events: none;
}
.dir-n { top: 6px; left: 50%; transform: translateX(-50%); }
.dir-s { bottom: 6px; left: 50%; transform: translateX(-50%); }
.dir-w { left: 7px; top: 50%; transform: translateY(-50%); }
.dir-e { right: 7px; top: 50%; transform: translateY(-50%); }

.joystick-stick {
  position: absolute;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffd166 0%, #c88a32 65%, #6e4514 100%);
  border: 2px solid rgba(255, 240, 200, 0.8);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.75);
  pointer-events: none;
  transform: translate(0px, 0px);
}

.joystick-caption {
  margin-top: 5px;
  font-size: 0.66rem;
  color: var(--text-muted);
  font-weight: 700;
}

/* 右：アクションボタン群 */
.action-buttons-zone {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.act-btn {
  position: relative;
  height: 70px;
  border-radius: 14px;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  background: linear-gradient(160deg, rgba(44, 34, 54, 0.92), rgba(22, 17, 30, 0.96));
  color: var(--text-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.65);
  transition: transform 0.08s, border-color 0.15s;
  touch-action: none;
}

.act-btn:active,
.act-btn.pressed {
  transform: scale(0.92);
}

.act-btn.primary-punch {
  background: linear-gradient(160deg, #6b202b, #361018);
  border-color: rgba(255, 107, 107, 0.65);
}

.act-btn.bite-btn {
  background: linear-gradient(160deg, #1b4d3e, #102a24);
  border-color: rgba(46, 196, 182, 0.6);
}

.act-btn.tech-btn {
  background: linear-gradient(160deg, #2b2d5c, #171833);
  border-color: rgba(130, 160, 255, 0.55);
}

.act-btn.weapon-btn {
  background: linear-gradient(160deg, #59411a, #2b1f0c);
  border-color: rgba(255, 209, 102, 0.55);
}

.act-btn.weapon-btn.ready-highlight {
  border-color: #ffd166;
  box-shadow: 0 0 15px rgba(255, 209, 102, 0.75);
  animation: weaponGlow 0.9s infinite alternate;
}

@keyframes weaponGlow {
  from { box-shadow: 0 0 8px rgba(255, 209, 102, 0.45); }
  to { box-shadow: 0 0 18px rgba(255, 209, 102, 0.95); }
}

.btn-key {
  position: absolute;
  top: 3px;
  right: 5px;
  font-size: 0.56rem;
  font-family: monospace;
  color: rgba(255, 255, 255, 0.6);
  background: rgba(0, 0, 0, 0.45);
  padding: 1px 4px;
  border-radius: 4px;
}

.btn-emoji {
  font-size: 1.35rem;
  line-height: 1.1;
  margin-bottom: 2px;
}

.btn-title {
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.btn-sub {
  font-size: 0.58rem;
  color: #ccc4ba;
}

.cd-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 0%;
  background: rgba(0, 0, 0, 0.72);
  pointer-events: none;
  transition: height 0.05s linear;
}

/* モーダル共通 */
.modal-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(6, 5, 10, 0.84);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.modal-card {
  width: 100%;
  max-height: 90%;
  background: linear-gradient(180deg, #1f1929 0%, #120e18 100%);
  border: 2px solid var(--border-gold);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.9);
  overflow-y: auto;
}

.modal-header h2 {
  font-size: 1.12rem;
  color: var(--accent-gold);
  margin-bottom: 8px;
  text-align: center;
}

.modal-body {
  font-size: 0.8rem;
  line-height: 1.5;
  color: #e9e4dc;
  overflow-y: auto;
}

.lead-text {
  background: rgba(255, 255, 255, 0.05);
  padding: 8px 10px;
  border-radius: 8px;
  margin-bottom: 10px;
  border-left: 3px solid var(--accent-crimson);
}

.guide-section {
  margin-bottom: 10px;
}

.guide-section h3 {
  font-size: 0.85rem;
  color: var(--accent-amber);
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding-bottom: 2px;
}

.guide-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.guide-list li {
  background: rgba(0, 0, 0, 0.28);
  padding: 5px 8px;
  border-radius: 6px;
}

.guide-list.compact li {
  padding: 4px 8px;
}

kbd {
  background: #2f283d;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.72rem;
  font-family: monospace;
  color: var(--accent-gold);
}

.small-note {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.modal-footer {
  margin-top: 12px;
  display: flex;
  justify-content: center;
}

.primary-cta-btn {
  width: 100%;
  padding: 12px 16px;
  font-size: 1rem;
  font-weight: 900;
  color: #1a1105;
  background: linear-gradient(135deg, #ffd166 0%, #f4a261 100%);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(244, 162, 97, 0.45);
  transition: transform 0.1s;
}

.primary-cta-btn:active {
  transform: scale(0.96);
}

.secondary-cta-btn {
  width: 100%;
  padding: 11px 16px;
  font-size: 0.92rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #4a3b5c 0%, #2b2138 100%);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  cursor: pointer;
}

/* リザルト画面 */
.result-card {
  text-align: center;
  align-items: center;
}

.result-badge {
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.2em;
  padding: 3px 12px;
  border-radius: 12px;
  background: rgba(255, 209, 102, 0.2);
  color: var(--accent-gold);
  margin-bottom: 6px;
}

.result-title {
  font-size: 1.55rem;
  font-weight: 900;
  margin-bottom: 6px;
}

.result-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.stats-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.stat-box {
  background: rgba(0, 0, 0, 0.38);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.stat-val {
  font-size: 1.05rem;
  font-weight: 900;
  color: #fff;
}

.stat-val.rank-s {
  color: #ffd166;
  text-shadow: 0 0 10px rgba(255, 209, 102, 0.7);
}

.result-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hidden {
  display: none !important;
}
