/* VOXEL DUNGEON B10F - スマホ縦画面(9:16)最適化スタイルシート */

:root {
  --bg-deep: #0b0914;
  --bg-panel: #161224;
  --bg-card: #211b36;
  --border-subtle: rgba(255, 255, 255, 0.12);
  --text-main: #f4f1ff;
  --text-muted: #a69ec4;
  --accent-gold: #ffd147;
  --accent-red: #ff4d6d;
  --accent-green: #38d399;
  --accent-blue: #4ea8ff;
  --accent-purple: #b565ff;
}

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

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #05040a;
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
}

.hidden {
  display: none !important;
}

/* スマホ9:16縦画面コンテナ（PCブラウザでも中央にスマホ比率で表示） */
.app-shell {
  position: relative;
  width: 100%;
  max-width: 430px;
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg-deep);
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.85);
}

.btn-mute {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 60;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(16, 13, 28, 0.82);
  color: #fff;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-primary {
  width: 100%;
  padding: 13px 16px;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #160e05;
  background: linear-gradient(135deg, #ffe074 0%, #ff9f2e 100%);
  box-shadow: 0 4px 16px rgba(255, 165, 50, 0.35);
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease;
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-primary:disabled {
  opacity: 0.4;
  background: #403a57;
  color: #9e96ba;
  box-shadow: none;
  cursor: not-allowed;
}

/* --- 画面共通 --- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
}

.screen.active {
  display: flex;
}

/* --- タイトル＆職業選択画面 --- */
.screen-title {
  background: #0b0914;
}

.title-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0.45;
  filter: saturate(1.1);
}

.title-overlay {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 16px 14px 18px;
  background: linear-gradient(180deg, rgba(11, 9, 20, 0.75) 0%, rgba(11, 9, 20, 0.45) 45%, rgba(11, 9, 20, 0.94) 100%);
}

.title-header {
  text-align: center;
  margin-top: 8px;
  margin-bottom: 10px;
}

.title-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent-gold);
  background: rgba(255, 209, 71, 0.14);
  border: 1px solid rgba(255, 209, 71, 0.35);
  padding: 3px 10px;
  border-radius: 999px;
}

.title-logo {
  margin: 6px 0 4px;
  font-size: 26px;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: 0.03em;
  text-shadow: 0 3px 14px rgba(0, 0, 0, 0.9);
}

.title-logo span {
  display: inline-block;
  margin-left: 6px;
  color: var(--accent-gold);
}

.title-sub {
  margin: 0;
  font-size: 11px;
  color: var(--text-muted);
}

.job-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.section-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-gold);
  margin-bottom: 6px;
}

.job-list {
  flex: 1;
  overflow-y: auto;
  touch-action: pan-y;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 2px;
}

.job-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(25, 20, 42, 0.88);
  border: 2px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.job-card.selected {
  border-color: var(--accent-gold);
  background: rgba(54, 41, 88, 0.95);
  box-shadow: 0 0 14px rgba(255, 209, 71, 0.25);
}

.job-card img {
  width: 58px;
  height: 58px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

.job-meta {
  flex: 1;
  min-width: 0;
}

.job-name-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}

.job-name {
  font-size: 14px;
  font-weight: 800;
}

.job-stats-text {
  font-size: 10px;
  color: var(--accent-gold);
  font-weight: 700;
}

.job-passive {
  margin-top: 3px;
  font-size: 11px;
  color: #d6cff2;
  line-height: 1.3;
}

.title-footer {
  padding-top: 10px;
}

/* --- バトル画面（45% / 15% / 40%） --- */
.battle-top {
  position: relative;
  height: 45%;
  width: 100%;
  background: #0c0a14;
  overflow: hidden;
  border-bottom: 1px solid var(--border-subtle);
}

.voxel-stage {
  position: absolute;
  inset: 0;
}

.stage-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #251d42 0%, #0c0a14 100%);
  color: var(--text-muted);
  font-size: 13px;
}

.top-hud {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  z-index: 5;
}

.floor-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.floor-badge {
  background: rgba(12, 10, 22, 0.85);
  border: 1px solid rgba(255, 209, 71, 0.45);
  color: var(--accent-gold);
  font-weight: 900;
  font-size: 13px;
  padding: 3px 10px;
  border-radius: 8px;
}

.boss-badge {
  background: linear-gradient(135deg, #ff3355, #b5179e);
  color: #fff;
  font-weight: 900;
  font-size: 10px;
  padding: 3px 7px;
  border-radius: 6px;
  letter-spacing: 0.08em;
}

.deck-group {
  display: flex;
  gap: 6px;
}

.deck-pill {
  background: rgba(12, 10, 22, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 10px;
  padding: 3px 7px;
  border-radius: 6px;
  color: var(--text-muted);
}

.deck-pill b {
  color: var(--text-main);
}

.enemy-hud {
  position: absolute;
  top: 44px;
  left: 12px;
  right: 12px;
  z-index: 5;
  pointer-events: none;
}

.enemy-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 800;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9);
  margin-bottom: 3px;
}

.enemy-atk {
  font-size: 11px;
  color: #ff99a8;
  background: rgba(30, 12, 20, 0.78);
  padding: 1px 7px;
  border-radius: 6px;
}

.hp-bar-wrap {
  position: relative;
  height: 15px;
  border-radius: 8px;
  background: rgba(10, 8, 18, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.18);
  overflow: hidden;
}

.hp-bar-fill {
  height: 100%;
  transition: width 0.25s ease;
}

.enemy-hp-fill {
  background: linear-gradient(90deg, #ff3355, #ff7043);
}

.player-hp-fill {
  background: linear-gradient(90deg, #10b981, #34d399);
}

.hp-bar-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  text-shadow: 0 1px 3px #000;
}

.status-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 3px;
}

.status-chip {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(30, 26, 52, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.charge-banner {
  position: absolute;
  bottom: 38px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(220, 38, 38, 0.9);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid #ffd166;
  z-index: 6;
  animation: pulseWarn 0.8s infinite alternate;
}

@keyframes pulseWarn {
  from { transform: translateX(-50%) scale(1); }
  to { transform: translateX(-50%) scale(1.06); }
}

.damage-popup-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.dmg-pop {
  position: absolute;
  left: 50%;
  top: 52%;
  transform: translate(-50%, -50%);
  font-size: 26px;
  font-weight: 900;
  color: #ffe066;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.95), 0 0 12px rgba(255, 80, 50, 0.7);
  animation: popRise 0.85s ease forwards;
}

.dmg-pop.heal {
  color: #5ef2a8;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.95), 0 0 12px rgba(40, 220, 140, 0.7);
}

.dmg-pop.player-hit {
  top: 78%;
  color: #ff4d6d;
}

@keyframes popRise {
  0% { opacity: 0; transform: translate(-50%, -20%) scale(0.7); }
  20% { opacity: 1; transform: translate(-50%, -65%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -140%) scale(0.95); }
}

.battle-log {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 6px 10px;
  background: rgba(10, 8, 18, 0.84);
  font-size: 11px;
  font-weight: 700;
  color: #ebe6ff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 6;
}

/* --- 中部15% --- */
.battle-mid {
  height: 15%;
  padding: 6px 10px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.player-info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-avatar {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  border: 2px solid rgba(255, 209, 71, 0.5);
  flex-shrink: 0;
}

.player-stats {
  flex: 1;
  min-width: 0;
}

.player-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  margin-bottom: 3px;
}

.player-lv {
  color: var(--accent-gold);
}

.player-atk {
  color: #ff9f43;
  margin-left: auto;
}

.selected-slots {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.slot-box {
  width: 38px;
  height: 50px;
  border-radius: 7px;
  border: 1.5px dashed rgba(255, 255, 255, 0.25);
  background: rgba(11, 9, 20, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  color: var(--text-muted);
  text-align: center;
  padding: 2px;
  overflow: hidden;
  cursor: pointer;
}

.slot-box.filled {
  border-style: solid;
  border-color: var(--accent-gold);
  color: #fff;
  font-size: 8.5px;
  line-height: 1.1;
  background: rgba(65, 48, 105, 0.9);
}

/* --- 下部40%: 横スクロール手札 --- */
.battle-bottom {
  height: 40%;
  padding: 8px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: linear-gradient(180deg, #130f21 0%, #0b0914 100%);
}

.hand-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
}

.synergy-hint {
  color: var(--accent-gold);
  font-size: 10px;
}

.hand-scroll {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  touch-action: pan-x;
  padding: 4px 2px;
  scroll-snap-type: x proximity;
}

.hand-scroll::-webkit-scrollbar {
  height: 4px;
}

.hand-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 999px;
}

.hand-card {
  flex: 0 0 108px;
  height: 100%;
  border-radius: 11px;
  padding: 7px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--bg-card);
  border: 2px solid rgba(255, 255, 255, 0.16);
  position: relative;
  cursor: pointer;
  scroll-snap-align: start;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}

.hand-card.cat-attack {
  border-color: rgba(255, 77, 109, 0.7);
  background: linear-gradient(180deg, #321625 0%, #1d121d 100%);
}

.hand-card.cat-heal {
  border-color: rgba(56, 211, 153, 0.7);
  background: linear-gradient(180deg, #143229 0%, #101f1b 100%);
}

.hand-card.cat-support {
  border-color: rgba(78, 168, 255, 0.7);
  background: linear-gradient(180deg, #152942 0%, #101829 100%);
}

.hand-card.cat-monster {
  border-color: #d977ff;
  background: linear-gradient(145deg, #2d164a 0%, #4b1d52 48%, #1d2852 100%);
  box-shadow: inset 0 0 12px rgba(217, 119, 255, 0.35);
}

.hand-card.selected {
  transform: translateY(-5px);
  box-shadow: 0 0 0 2px var(--accent-gold), 0 8px 18px rgba(255, 209, 71, 0.38);
}

.card-order-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-gold);
  color: #1a1004;
  font-size: 12px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

.card-cat-tag {
  font-size: 9px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 4px;
  align-self: flex-start;
  background: rgba(0, 0, 0, 0.4);
}

.card-thumb {
  width: 100%;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
  margin: 3px 0;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.card-name {
  font-size: 11.5px;
  font-weight: 800;
  line-height: 1.2;
  margin-top: 2px;
}

.card-desc {
  font-size: 9.5px;
  color: #d7d0ee;
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}

.action-bar {
  padding-top: 2px;
}

/* --- 一筆書きパズルオーバーレイ --- */
.puzzle-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 68%;
  background: linear-gradient(180deg, #1b1530 0%, #0d0a18 100%);
  border-top: 2px solid var(--accent-gold);
  border-radius: 18px 18px 0 0;
  z-index: 30;
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  transform: translateY(105%);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.8);
}

.puzzle-overlay.open {
  transform: translateY(0);
}

.puzzle-header {
  margin-bottom: 6px;
}

.puzzle-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.puzzle-title {
  font-size: 14px;
  font-weight: 900;
  color: var(--accent-gold);
}

.puzzle-steps {
  font-size: 13px;
  font-weight: 800;
  background: rgba(255, 209, 71, 0.16);
  border: 1px solid rgba(255, 209, 71, 0.45);
  padding: 2px 10px;
  border-radius: 999px;
}

.puzzle-steps b {
  color: var(--accent-gold);
  font-size: 16px;
}

.puzzle-effects {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0 2px;
}

.puzzle-effect-tag {
  font-size: 9.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(78, 168, 255, 0.22);
  border: 1px solid rgba(78, 168, 255, 0.55);
  color: #c7e2ff;
}

.puzzle-effect-tag.muted {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--text-muted);
}

.puzzle-guide {
  font-size: 10px;
  color: var(--text-muted);
}

.puzzle-board-wrap {
  position: relative;
  width: 100%;
  max-width: 360px;
  aspect-ratio: 1 / 1;
  margin: auto;
  touch-action: none;
}

.puzzle-grid {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 3px;
  touch-action: none;
}

.puzzle-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

.puzzle-cell {
  position: relative;
  border-radius: 6px;
  background: #241e3d;
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 16px;
  color: #f1eeff;
  transition: transform 0.1s ease, background 0.12s ease;
}

.puzzle-cell.is-high .cell-num {
  color: #7ee8ff;
}

.puzzle-cell.is-critical {
  border-color: #ffd147;
  background: linear-gradient(135deg, #3c2e16 0%, #2b213a 100%);
  box-shadow: inset 0 0 8px rgba(255, 209, 71, 0.45);
}

.puzzle-cell.is-critical .cell-num {
  color: #ffe066;
}

.puzzle-cell.is-selected {
  background: #4f3b8f;
  border-color: #ffd147;
  transform: scale(0.95);
}

.puzzle-cell.is-revisit {
  background: #352b4f;
  opacity: 0.85;
}

.puzzle-cell.is-head {
  box-shadow: 0 0 10px rgba(255, 209, 71, 0.85);
}

.puzzle-cell.is-flashing {
  background: #ffcf48 !important;
  color: #191003 !important;
  transform: scale(1.08);
  z-index: 4;
  box-shadow: 0 0 16px #ffe066;
}

.puzzle-cell.is-flashing .cell-num {
  color: #191003 !important;
}

.puzzle-cell.is-crit-triggered {
  background: linear-gradient(135deg, #ffea75, #ff8811) !important;
}

.cell-badge {
  position: absolute;
  bottom: 1px;
  right: 2px;
  font-size: 8px;
  font-weight: 800;
  color: #ffd147;
  line-height: 1;
}

.puzzle-crit-popup {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%) scale(0.6);
  background: linear-gradient(135deg, #ffe066, #ff6b2b);
  color: #1a0b04;
  font-size: 22px;
  font-weight: 900;
  padding: 6px 16px;
  border-radius: 12px;
  border: 2px solid #fff;
  box-shadow: 0 6px 24px rgba(255, 140, 40, 0.7);
  opacity: 0;
  pointer-events: none;
  z-index: 15;
}

.puzzle-crit-popup.show {
  animation: critBurst 0.65s ease forwards;
}

@keyframes critBurst {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  25% { opacity: 1; transform: translate(-50%, -55%) scale(1.18); }
  100% { opacity: 0; transform: translate(-50%, -80%) scale(1); }
}

/* --- モーダル --- */
.modal {
  position: absolute;
  inset: 0;
  background: rgba(8, 6, 15, 0.84);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  width: 100%;
  background: linear-gradient(180deg, #241d3d 0%, #151126 100%);
  border: 2px solid rgba(255, 209, 71, 0.45);
  border-radius: 16px;
  padding: 18px 16px;
  text-align: center;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.8);
}

.modal-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: var(--accent-gold);
  background: rgba(255, 209, 71, 0.15);
  padding: 3px 10px;
  border-radius: 999px;
}

.modal-title {
  margin: 8px 0;
  font-size: 20px;
  font-weight: 900;
}

.vic-levelup {
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(52, 211, 153, 0.4);
  border-radius: 10px;
  padding: 8px;
  font-size: 13px;
  font-weight: 800;
  color: #6ee7b7;
  margin-bottom: 12px;
}

.vic-stats {
  font-size: 11px;
  color: var(--text-main);
  margin-top: 3px;
}

.drop-box {
  background: rgba(181, 101, 255, 0.12);
  border: 1.5px solid rgba(217, 119, 255, 0.55);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 14px;
}

.drop-label {
  font-size: 12px;
  font-weight: 800;
  color: #f3c4ff;
  margin-bottom: 8px;
}

.drop-card-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.drop-card-preview img {
  width: 74px;
  height: 74px;
  border-radius: 10px;
  object-fit: cover;
  border: 2px solid #ffd147;
  flex-shrink: 0;
}

.rare-pill {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 900;
  color: #1d1004;
  background: linear-gradient(135deg, #ffe066, #d977ff);
  padding: 2px 7px;
  border-radius: 5px;
  margin-bottom: 4px;
}

.drop-card-name {
  font-size: 14px;
  font-weight: 900;
}

.drop-card-desc {
  font-size: 11px;
  color: #dfd7f7;
  margin-top: 2px;
}

.modal-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin: 8px 0 12px;
}

.end-summary {
  background: rgba(0, 0, 0, 0.35);
  border-radius: 10px;
  padding: 10px;
  font-size: 12px;
  line-height: 1.6;
  margin-bottom: 14px;
}
