html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: #222;
  color: #fff;
  font-family: sans-serif;
  margin: 0;
  padding: 0 12px 24px;
  overflow-y: auto;
  touch-action: manipulation;
}

.game {
  max-width: 520px;
  width: 100%;
  margin: 16px auto;
  background: #333;
  padding: 14px;
  border: 2px solid #666;
  border-radius: 12px;
  box-sizing: border-box;
  position: relative;
}

.status {
  margin-bottom: 10px;
}

.header-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 14px;
}

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


/* ヘッダー（階層表示）の転移ボタンは小さく表示 */
.floor-info #teleportBtn {
  flex: 0 0 auto;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 6px;
}

.exp-bar {
  height: 8px;
  background: #111;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.exp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #4a6cf7, #6c87ff);
  transition: width 0.3s;
}

.battle-status {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  font-size: 14px;
}

.player-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 2.4em;
}

.player-hp {
  /* 敵HP表示と同じ見た目にする（太字にしない） */
  display: block;
  min-height: 1.2em;
  line-height: 1.2em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: normal;
}

.player-gauges {
  font-size: 12px;
  line-height: 1.2em;
  min-height: 1.2em;
  opacity: 0.9;
}

.enemy-info {
  text-align: right;
  min-width: 170px;
  min-height: 2.4em;
}

.enemy-name, .enemy-hp {
  display: block;
  min-height: 1.2em;
  line-height: 1.2em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.enemy-name {
  color: #ffffff;
  font-weight: bold;
}

.log {
  height: 220px;
  background: #111;
  padding: 8px;
  overflow-y: auto;
  scrollbar-gutter: stable;
  margin-bottom: 12px;
  font-size: 14px;
  border-radius: 8px;
}



.rare-popup {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 30;
}

.rare-popup.is-visible {
  display: flex;
  opacity: 1;
  pointer-events: auto;
}

.rare-popup-content {
  min-width: 220px;
  padding: 16px 20px;
  background: linear-gradient(135deg, #ffde73, #ffb347);
  color: #1c1c1c;
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  border: 2px solid #ffd24d;
  animation: rare-pop 0.25s ease-out;
}

.rare-popup-title {
  font-weight: bold;
  font-size: 18px;
  margin-bottom: 6px;
}

.rare-popup-name {
  font-size: 16px;
  margin-bottom: 6px;
}

.rare-popup-hint {
  font-size: 12px;
  opacity: 0.7;
}

.rare-popup-close {
  margin-top: 10px;
  padding: 6px 16px;
  border-radius: 999px;
  border: none;
  background: #1c1c1c;
  color: #fff;
  font-size: 13px;
  cursor: pointer;
}

.rare-popup-close:hover {
  background: #333;
}

@keyframes rare-pop {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.log div {
  margin-bottom: 4px;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.row > button {
  width: 100%;
  min-width: 0;
}


/* 戦闘UI：スキルボタン内に装備スキル名（小さめ表示） */
.skill-cell {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.skill-cell button {
  flex: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 12px 10px;
}

.skill-button-main {
  font-size: 16px;
  font-weight: bold;
  line-height: 1.1;
}

.skill-button-sub {
  font-size: 11px;
  font-weight: normal;
  opacity: 0.85;
  line-height: 1.15;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

button {
  flex: 1;
  padding: 16px 12px;
  font-size: 16px;
  font-weight: bold;
  color: #fff;
  background: #4a6cf7;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

button:hover {
  background: #6c87ff;
}

button:active {
  background: #3a5ce7;
}

.escape-btn {
  background: #e74c3c;
}

.escape-btn:hover {
  background: #ff6b6b;
}

.screen-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid #555;
}

.screen-header h3 {
  margin: 0;
  font-size: 18px;
}

.back-button {
  padding: 8px 16px;
  font-size: 14px;
  background: #555;
}

.back-button:hover {
  background: #666;
}

.inventory-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

/* バッグ（装備品タブ）上部の操作ボタン */
.bag-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 6px 0 10px;
}

.danger-btn {
  background: #6b2b2b;
}

.danger-btn:hover {
  background: #7a3333;
}

.bag-actions-stack {
  flex-direction: column;
  align-items: stretch;
}


.effect-sort-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.effect-sort-btn.is-active {
  background: #4a6fa5;
}

.auto-sell-modal-content {
  max-width: 560px;
}

.auto-sell-grid {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.auto-sell-grid label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.auto-sell-grid input {
  width: 72px;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(0,0,0,0.25);
  color: inherit;
}

.auto-sell-rarity-filter {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.auto-sell-rarity-filter > label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inventory-tab {
  flex: 1;
  padding: 10px;
  font-size: 14px;
  background: #444;
  border-radius: 6px;
}

.inventory-tab.is-active {
  background: #4a6cf7;
}

.sub-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.sub-tab {
  flex: 1;
  padding: 8px;
  font-size: 13px;
  background: #444;
  border-radius: 6px;
}

.sub-tab.is-active {
  background: #555;
}

.inventory-footer {
  margin-top: 16px;
}

.scroll-top-button {
  width: 100%;
  padding: 12px;
  background: #555;
}

.status-section {
  margin-bottom: 20px;
  padding: 12px;
  background: #2a2a2a;
  border-radius: 8px;
}

.status-section h4 {
  margin: 0 0 12px 0;
  font-size: 15px;
  color: #aaa;
}

.job-display {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.job-progress {
  font-size: 12px;
  color: #aaa;
  padding: 6px;
  background: #222;
  border-radius: 4px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  padding: 8px;
  background: #222;
  border-radius: 6px;
}

.stat-name {
  font-size: 13px;
}

.stat-value {
  font-size: 14px;
  font-weight: bold;
  color: #4a6cf7;
}

.stat-points-display,
.skill-points-display {
  padding: 8px;
  background: #222;
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.small-btn {
  padding: 6px 12px;
  font-size: 13px;
  flex: none;
}

.full-btn {
  width: 100%;
  padding: 10px;
  margin-top: 8px;
}

.equipped-slots {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.equip-slot {
  padding: 10px;
  background: #222;
  border-radius: 6px;
  border: 2px dashed #444;
  font-size: 13px;
}

.equip-slot.filled {
  border-style: solid;
  border-color: #4a6cf7;
}

.equip-note {
  margin-top: 6px;
  font-size: 12px;
  color: #bbb;
  line-height: 1.4;
}

.calc-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  font-size: 13px;
}

.calc-stats div {
  padding: 6px;
  background: #222;
  border-radius: 4px;
}

.equipped-skill {
  padding: 8px;
  background: #222;
  border-radius: 6px;
  margin-top: 8px;
  font-size: 13px;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #333;
  padding: 20px;
  border-radius: 12px;
  max-width: 480px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  border: 2px solid #666;
}

.modal-content h2 {
  margin: 0 0 16px 0;
  font-size: 18px;
}

.modal-content button {
  margin-top: 12px;
}

.job-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.job-card {
  padding: 12px;
  background: #2a2a2a;
  border: 2px solid #444;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.job-card:hover {
  border-color: #4a6cf7;
}

.job-card.selected {
  border-color: #4a6cf7;
  background: #1a3a7f;
}

.job-card h4 {
  margin: 0 0 6px 0;
  font-size: 15px;
}

.job-card p {
  margin: 0;
  font-size: 12px;
  color: #aaa;
}

.job-card.locked {
  opacity: 0.55;
  cursor: not-allowed;
  border-style: dashed;
}

.job-card.locked:hover {
  border-color: #444;
}

.job-section-title {
  grid-column: 1 / -1;
  margin: 6px 0 2px 0;
  font-weight: 700;
  font-size: 13px;
  color: #ddd;
}

/* 上級職を基礎職ごとにまとめる見出し */
.job-group-title {
  grid-column: 1 / -1;
  margin: 10px 0 0 0;
  padding-top: 2px;
  font-weight: 700;
  font-size: 12px;
  color: #cfcfcf;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.job-req {
  margin-top: 6px;
  font-size: 11px;
  color: #bbb;
}

.job-adv-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 10px;
  border-radius: 999px;
  background: #444;
  color: #eee;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.modal-actions button {
  flex: 1;
  margin: 0;
}

.equip-compare-wrap {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.equip-compare-wrap.single {
  grid-template-columns: 1fr;
}

.equip-compare-card {
  background: #262626;
  border: 1px solid #4a4a4a;
  border-radius: 8px;
  padding: 8px;
  font-size: 12px;
  line-height: 1.45;
}

.equip-compare-card.hidden {
  display: none;
}

.equip-compare-title {
  font-weight: 700;
  margin-bottom: 6px;
}

.equip-compare-current {
  color: #d7d7d7;
}

.equip-compare-stats {
  margin-top: 6px;
}

.equip-stat-up {
  color: #7fb9ff;
  font-weight: 700;
}

.equip-stat-down {
  color: #ff8c8c;
  font-weight: 700;
}

.equip-compare-effects {
  margin-top: 6px;
  color: #9ad3ff;
}

/* 転移モーダル */
.teleport-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
}

.teleport-row label {
  font-size: 13px;
  color: #ddd;
  min-width: 56px;
}

.teleport-select {
  flex: 1;
  padding: 10px;
  font-size: 16px;
  border-radius: 8px;
  border: 1px solid #666;
  background: #222;
  color: #fff;
}

.teleport-stay-row {
  margin: 8px 0 12px;
}

.teleport-stay-row.hidden {
  display: none;
}

.teleport-stay-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #ddd;
}

.teleport-stay-label input {
  width: 16px;
  height: 16px;
}

.stat-alloc-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  background: #2a2a2a;
  border-radius: 6px;
  margin-bottom: 8px;
}

.stat-alloc-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.stat-alloc-controls button {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 18px;
  margin: 0;
}

.stat-alloc-value {
  min-width: 30px;
  text-align: center;
  font-weight: bold;
}

.stat-step-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.stat-step-row input {
  width: 90px;
  height: 32px;
  padding: 4px 8px;
  border: 1px solid #666;
  border-radius: 6px;
  background: #222;
  color: #fff;
}

.item-card {
  padding: 10px;
  background: #2a2a2a;
  border: 2px solid #444;
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.item-card:hover {
  border-color: #4a6cf7;
}

.item-card.equipped {
  border-color: #4caf50;
  background: #1a3d1a;
  border-left: 4px solid #4caf50;
}

.item-card.locked {
  border-style: dashed;
}

.item-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.item-main {
  flex: 1;
  min-width: 0;
}

.item-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}

button.item-action-btn {
  flex: 0 0 auto;
  width: 40px;
  height: 36px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  background: #555;
}

button.item-action-btn:hover {
  background: #666;
}

button.item-action-btn.discard {
  background: #6b2b2b;
}

button.item-action-btn.discard:hover {
  background: #7a3333;
}

button.item-action-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}


button.item-action-btn.item-action-btn-text {
  width: auto;
  min-width: 88px;
  padding: 0 12px;
  white-space: nowrap;
  font-size: 13px;
}

.locked-label {
  color: #ffcc66;
  font-weight: bold;
  margin-top: 4px;
  font-size: 12px;
}

.item-card:not(.equipped).cat-weapon { border-left: 4px solid #e74c3c; }
.item-card:not(.equipped).cat-armor { border-left: 4px solid #4a6cf7; }

.item-name {
  font-weight: bold;
  margin-bottom: 4px;
  font-size: 14px;
}

.item-name.rarity-rare {
  color: #4aa3ff;
}

.item-name.rarity-epic {
  color: #ffd54a;
}

.item-name.rarity-legendary {
  color: #ff5a5a;
}

.item-stats {
  font-size: 12px;
  color: #aaa;
}

.item-effects {
  margin-top: 6px;
  display: grid;
  gap: 6px;
}

.effect-title {
  font-size: 11px;
  font-weight: bold;
  color: #ddd;
  margin-bottom: 2px;
}

.effect-list {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  color: #aaa;
}

.effect-list li {
  margin: 0;
}

.effect-none {
  font-size: 12px;
  color: #666;
}


.equipped-label {
  color: #4caf50;
  font-weight: bold;
  margin-top: 4px;
  font-size: 12px;
}

.equipped-label {
  color: #4caf50;
  font-weight: bold;
  margin-top: 4px;
  font-size: 12px;
}

.skill-item {
  padding: 10px;
  background: #2a2a2a;
  border-radius: 8px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.skill-info {
  flex: 1;
}

.skill-name {
  font-weight: bold;
  font-size: 14px;
  margin-bottom: 4px;
}

.skill-desc {
  font-size: 12px;
  color: #aaa;
}

.skill-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}

.skill-action-row {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.skill-level {
  background: #4a6cf7;
  padding: 6px 12px;
  border-radius: 6px;
  font-weight: bold;
  font-size: 13px;
}

@media (max-width: 768px) {
  .game {
    margin: 16px auto;
    height: auto;
  }
}


/* Status tabs */
.status-tabs{
  display:flex;
  gap:8px;
  padding:8px 12px;
  border-bottom:1px solid rgba(255,255,255,0.08);
}
.status-tab-btn{
  flex:1;
  padding:8px 10px;
  border-radius:10px;
  border:1px solid rgba(255,255,255,0.12);
  background:rgba(255,255,255,0.06);
  color:inherit;
  cursor:pointer;
  font-weight:600;

  /* スマホで「ステータス」などが折り返されないようにする */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status-tab-btn.is-active{
  background:rgba(255,255,255,0.16);
}

@media (max-width: 420px) {
  .status-tabs{
    gap:6px;
    padding:8px 10px;
  }
  .status-tab-btn{
    padding:8px 6px;
    font-size: 13px;
  }
  .stat-value {
    font-size: 12px;
  }
}


/* バージョン表示（記録タブ横など） */
.status-version{
  margin-left: 6px;
  font-size: 11px;
  opacity: 0.75;
  font-weight: 500;
}

.options-tabs{
  display:flex;
  gap:8px;
  padding:8px 12px;
  border-bottom:1px solid rgba(255,255,255,0.08);
}
.update-history-list{
  display:flex;
  flex-direction:column;
  gap:10px;
}
.update-history-item{
  padding:10px 12px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,0.10);
  background:rgba(255,255,255,0.04);
}
.update-history-item h5{
  margin:0 0 8px;
  font-size:14px;
}
.update-history-item ul{
  margin:0;
  padding-left:18px;
}
.options-row{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}
.serial-row{
  align-items:center;
}
.serial-input{
  flex:1;
  min-width:220px;
  padding:8px 10px;
  border-radius:10px;
  border:1px solid rgba(255,255,255,0.12);
  background:rgba(255,255,255,0.06);
  color:inherit;
}
.serial-input:disabled{
  opacity:0.6;
}
.option-check{
  display:flex;
  align-items:center;
  gap:8px;
}
.author-links{
  display:flex;
  flex-direction:column;
  gap:8px;
}
.author-links a{
  color:#86c5ff;
  text-decoration:underline;
  text-underline-offset:2px;
  width:fit-content;
}
.author-links a:hover{
  opacity:0.9;
}
.achievements-list{
  display:flex;
  flex-direction:column;
  gap:8px;
}
.achievement-card{
  padding:10px 12px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,0.10);
  background:rgba(255,255,255,0.04);
}
.achievement-card .small{
  margin-top:4px;
  opacity:0.85;
  font-size:12px;
}

.record-list{
  display:flex;
  flex-direction:column;
  gap:8px;
}
.record-item{
  padding:10px 12px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,0.10);
  background:rgba(255,255,255,0.04);
}

.records-header{
  display:flex;
  align-items:center;
  gap:8px;
}

.record-post-btn{
  margin-left:auto;
  flex-shrink:0;
  border:1px solid rgba(255,255,255,0.18);
  background:rgba(255,255,255,0.08);
  color:inherit;
  border-radius:999px;
  padding:6px 10px;
  font-size:12px;
  font-weight:700;
  cursor:pointer;
}

.record-post-btn:hover{
  background:rgba(255,255,255,0.16);
}


/* ===================
   状態異常バッジ
   =================== */
.status-effects {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0;
  min-height: 18px;
}

.status-badge {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.15);
  line-height: 1.4;
}

/* =========================
   操作ボタンのUI揺れ対策
   ========================= */

/* 探索/戦闘でボタンの高さが変わらないようにする */
#exploreButtons button,
#battleButtons button {
  min-height: 64px;
  box-sizing: border-box;
}

/* 戦闘：左ボタン（たたかう/防御）もスキルボタンと同じ余白にして見た目を揃える */
#battleButtons .row > button {
  padding: 12px 10px;
}

/* 戦闘：左右セルの横幅がテキストで変わらないようにする */
#battleButtons .row > button,
#battleButtons .skill-cell {
  flex: 1 1 0;
  min-width: 0;
}

#battleButtons .skill-cell button {
  min-height: 64px;
  box-sizing: border-box;
}

/* 戦闘：ボタン内テキストが折り返して高さが変わるのを防ぐ */
.skill-button-main,
.skill-button-sub {
  width: 100%;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.skill-button-main {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 無効化ボタンがブラウザ既定スタイルで見た目が変わらないようにする */
#battleButtons button:disabled {
  opacity: 0.6;
}
