* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: #0a180a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans JP', sans-serif;
  user-select: none;
  overflow: hidden;
}
canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
}
#controls {
  margin-top: 7px;
  font-size: 11px;
  color: #334;
  letter-spacing: 0.06em;
}

/* ── スマホ対応 ─────────────────────── */
#game-wrapper {
  position: fixed;
  inset: 0;
}
#game-wrapper canvas {
  width: 100%;
  height: 100%;
}
#ui-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  color: #edf3e9;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans JP', sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
#ui-layer [hidden] { display: none !important; }
.ui-panel {
  background: rgba(12, 19, 18, 0.84);
  border: 1px solid rgba(219, 229, 210, 0.24);
  border-radius: 8px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(2px);
}
#player-hud {
  position: absolute;
  top: 2.5%;
  left: 2.2%;
  width: min(38vw, 420px);
  min-width: 250px;
  padding: 10px 12px;
}
.hud-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.hud-label { font-size: clamp(11px, 1.05vw, 15px); font-weight: 750; letter-spacing: 0.04em; }
.hud-value { color: #fff; font-variant-numeric: tabular-nums; }
.ui-bar {
  position: relative;
  height: clamp(10px, 1.5vh, 16px);
  margin-top: 5px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(0, 0, 0, 0.8);
  border-radius: 999px;
}
.ui-bar-fill { height: 100%; width: 0; transition: width 100ms linear; }
#hp-fill { background: linear-gradient(#ff755f, #c62f27); }
#exp-fill { background: linear-gradient(#84ee91, #3eaa58); }
.hud-badges { display: flex; gap: 7px; margin-top: 7px; }
.hud-badge {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: clamp(10px, 0.9vw, 13px);
  font-weight: 750;
  background: rgba(43, 57, 75, 0.92);
  border: 1px solid rgba(173, 197, 224, 0.3);
}
.hud-badge.level { color: #211706; background: #e8bd4d; border-color: #fff0a0; }
#run-hud {
  position: absolute;
  top: 2.5%;
  right: 2.2%;
  width: min(25vw, 275px);
  min-width: 190px;
  padding: 9px 12px;
}
.run-row { display: flex; justify-content: space-between; gap: 14px; font-size: clamp(10px, 0.95vw, 13px); line-height: 1.55; }
.run-row span:first-child { color: #899893; }
.run-row strong { font-weight: 750; font-variant-numeric: tabular-nums; }
#mute-button {
  position: absolute;
  top: 31%;
  right: 2.2%;
  pointer-events: auto;
  cursor: pointer;
  padding: 7px 12px;
  color: #b8f1d0;
  background: rgba(18, 46, 35, 0.9);
  border: 1px solid #64b88a;
  border-radius: 7px;
  font: 750 clamp(10px, 0.9vw, 13px)/1.1 inherit;
  z-index: 20;
}
#mute-button.muted { color: #ffb3b3; background: rgba(62, 24, 24, 0.92); border-color: #d86868; }
#passive-skills {
  position: absolute;
  top: 22%;
  left: 2.2%;
  display: flex;
  flex-wrap: wrap;
  max-width: 32vw;
  gap: 5px;
}
.skill-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 7px;
  border: 1px solid var(--skill-color, #aaa);
  border-radius: 999px;
  background: rgba(12, 15, 13, 0.82);
  color: var(--skill-color, #fff);
  font-size: clamp(9px, 0.82vw, 12px);
  font-weight: 700;
}
#hotbar {
  position: absolute;
  left: 50%;
  bottom: 3.2%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}
.hotbar-slot {
  position: relative;
  min-width: 64px;
  padding: 7px 9px 6px;
  text-align: center;
  background: rgba(21, 27, 24, 0.88);
  border: 1px solid rgba(232, 198, 119, 0.62);
  border-radius: 7px;
  box-shadow: 0 3px 12px rgba(0,0,0,0.3);
}
.hotbar-slot.cooldown { filter: saturate(0.35); }
.hotbar-icon { font-size: clamp(16px, 1.6vw, 23px); line-height: 1; }
.hotbar-key { margin-top: 3px; color: #aeb9b1; font-size: clamp(8px, 0.72vw, 10px); font-weight: 700; }
.hotbar-cooldown { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; background: rgba(0,0,0,0.58); border-radius: inherit; font-weight: 800; }
#boss-hud {
  position: absolute;
  left: 50%;
  bottom: 19%;
  width: min(72vw, 720px);
  transform: translateX(-50%);
  padding: 9px 12px 11px;
}
.boss-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 5px; font-size: clamp(11px, 1vw, 14px); }
#boss-name { color: #ffdca0; font-weight: 800; letter-spacing: 0.06em; }
#boss-state { margin-left: 7px; color: #ff9a8a; font-size: 0.82em; }
#boss-fill { background: linear-gradient(#ff8053, #b93018); }
#boss-hud.guard #boss-fill { background: linear-gradient(#75eaff, #2199b8); }
#boss-hud.enraged #boss-fill { background: linear-gradient(#ff5145, #a91010); }
#boss-warning, #boss-announce, #level-notice {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  font-weight: 850;
  text-shadow: 0 2px 5px #000, 0 0 14px rgba(0,0,0,0.9);
}
#boss-warning { bottom: 31%; color: #ff6464; font-size: clamp(15px, 1.8vw, 26px); }
#boss-announce { top: 33%; color: #ff6a5d; font-size: clamp(20px, 2.7vw, 38px); }
#level-notice { top: 43%; color: #ffe08a; font-size: clamp(20px, 2.2vw, 34px); }
#level-notice small { display: block; margin-top: 5px; color: #9affbd; font-size: 0.48em; font-weight: 700; }
.screen-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 4vh 5vw;
  background: rgba(4, 9, 7, 0.78);
  pointer-events: auto;
  z-index: 10;
}
.overlay-panel {
  width: min(90vw, 940px);
  max-height: 88vh;
  overflow: auto;
  padding: clamp(18px, 3vw, 34px);
  text-align: center;
  background: linear-gradient(145deg, rgba(27,38,41,0.97), rgba(12,14,17,0.97));
  border: 1px solid rgba(240, 214, 138, 0.55);
  border-radius: 14px;
  box-shadow: 0 18px 70px rgba(0,0,0,0.58);
}
.overlay-title { color: #f0d68a; font-size: clamp(25px, 4vw, 52px); line-height: 1.1; letter-spacing: 0.04em; }
.overlay-subtitle { margin-top: 12px; color: #bdcbbd; font-size: clamp(12px, 1.3vw, 18px); }
.overlay-help { margin-top: 18px; color: #819086; font-size: clamp(10px, 1vw, 14px); }
.ui-action {
  margin-top: 20px;
  padding: 10px 22px;
  color: #172014;
  background: #e7ca72;
  border: 0;
  border-radius: 8px;
  font: 800 clamp(12px, 1.2vw, 16px)/1 inherit;
  cursor: pointer;
}
#skill-cards { display: flex; justify-content: center; gap: clamp(10px, 2vw, 24px); margin-top: 24px; }
.html-skill-card {
  position: relative;
  width: min(25vw, 240px);
  min-height: 150px;
  padding: 20px 14px 16px;
  color: #eef4ee;
  background: rgba(12, 28, 22, 0.96);
  border: 2px solid var(--skill-color, #82978c);
  border-radius: 11px;
  font: inherit;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.html-skill-card.selected {
  transform: translateY(-5px);
  background: rgba(27, 52, 40, 0.98);
  box-shadow: 0 0 0 2px #fff1b4, 0 0 22px var(--skill-color, #fff);
}
.skill-card-name { color: #fff; font-size: clamp(16px, 1.8vw, 24px); font-weight: 850; }
.skill-card-desc { margin-top: 12px; color: #bdd0c0; font-size: clamp(11px, 1.05vw, 15px); }
.skill-card-count { margin-top: 14px; color: #8c9b90; font-size: clamp(10px, 0.9vw, 13px); }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 20px; }
.stat-card { padding: 10px; background: rgba(0,0,0,0.22); border-radius: 8px; }
.stat-card span { display: block; color: #829087; font-size: clamp(9px, 0.8vw, 12px); }
.stat-card strong { display: block; margin-top: 3px; color: #edf2e8; font-size: clamp(14px, 1.4vw, 20px); }
.status-columns { display: grid; grid-template-columns: 1fr; gap: 18px; margin-top: 20px; text-align: left; }
.status-section { padding: 14px; background: rgba(0,0,0,0.2); border-radius: 9px; }
.status-section h3 { margin-bottom: 9px; color: #e6c875; font-size: clamp(13px, 1.2vw, 17px); }
.status-row { display: flex; justify-content: space-between; gap: 18px; color: #aebbb2; font-size: clamp(11px, 1vw, 14px); line-height: 1.65; }
.status-row strong { color: #fff; }
.tag-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; margin-top: 12px; }
@media (hover: none) and (pointer: coarse) {
  #hotbar { display: none; }
  #mute-button { top: 3%; right: 2%; }
  #run-hud { right: 13%; }
  .overlay-panel { padding: 16px; }
  #skill-cards { margin-top: 14px; }
  .html-skill-card { min-height: 120px; padding: 12px 9px; }
}
#virtual-pad {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  display: none;
}
.vbtn {
  position: absolute;
  width: 64px;
  height: 64px;
  background: rgba(255, 255, 255, 0.18);
  border: 2px solid rgba(255, 255, 255, 0.38);
  border-radius: 50%;
  color: #fff;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}
.vbtn:active { background: rgba(255, 255, 255, 0.40); }
#vbtn-left   { bottom: 8%; left:  4%; }
#vbtn-right  { bottom: 8%; left: 17%; }
#vbtn-jump   { bottom: 24%; right: 6%; }
#vbtn-attack { bottom: 8%;  right: 19%; }
#vbtn-dash   { bottom: 8%;  right: 6%; }
@media (hover: none) and (pointer: coarse) {
  #controls { display: none; }
}
#portrait-warn {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  font-size: 1.2rem;
  align-items: center;
  justify-content: center;
  text-align: center;
  z-index: 99;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans JP', sans-serif;
}
@media (orientation: portrait) and (pointer: coarse) {
  #portrait-warn { display: flex; }
}
