html,
body {
  height: 100%;
  overscroll-behavior: none;
}
body {
  background: #222;
  color: #fff;
  font-family: sans-serif;
  margin: 0;
  padding: 0 12px 24px;
  overflow: hidden;
  touch-action: manipulation;
}
body.screen-scrollable {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
.top-content {
  max-width: 680px;
  margin: 0 auto;
  padding-top: 16px;
}

.start-link {
  display: inline-block;
  margin-bottom: 16px;
  padding: 12px 18px;
  font-size: 24px;
  font-weight: bold;
  color: #fff;
  background: #4a6cf7;
  border-radius: 12px;
  text-decoration: none;
}

.start-link:hover {
  background: #6c87ff;
}

.site-footer {
  margin-top: 48px;
  padding-bottom: 16px;
}

.site-footer a {
  display: inline-block;
  margin-right: 12px;
}

.game {
  max-width: 520px;
  width: 100%;
  margin: 16px auto;
  background: #333;
  padding: 14px;
  border: 2px solid #666;
  border-radius: 12px;
  box-sizing: border-box;
  border: 2px solid #666;  position: relative;
}

@media (max-width: 768px) {
  .game {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    height: 100vh;
    overflow: hidden;
    margin: 0 auto;
  }

  body.screen-scrollable .game {
    position: static;
    top: auto;
    left: auto;
    transform: none;
    height: auto;
    overflow: visible;
    margin: 16px auto;
  }
}

.status {
  margin-bottom: 10px;
}

.log {
  height: 220px;
  background: #111;
  padding: 8px;
  overflow-y: auto;
  margin-bottom: 12px;
  font-size: 14px;
  border-radius: 8px;
}

#inventory {
  font-size: 14px;
}
.accessory-synthesis-modal-content {
  max-width: 420px;
  text-align: left;
}

.accessory-synthesis-section {
  margin-top: 12px;
}

.accessory-synthesis-label {
  font-size: 12px;
  color: #cfcfcf;
  margin-bottom: 6px;
}

.accessory-synthesis-name {
  font-size: 14px;
  margin-bottom: 6px;
}

.accessory-synthesis-list {
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
  font-size: 13px;
}

.accessory-synthesis-list li {
  margin-bottom: 4px;
}

#accessorySynthesisTargetSelect {
  width: 100%;
  margin: 6px 0 10px;
  padding: 8px;
  font-size: 14px;
  border-radius: 6px;
  background: #1a1a1a;
  color: #fff;
  border: 1px solid #444;
}

.accessory-synthesis-hint {
  font-size: 12px;
  color: #ddd;
}

.accessory-synthesis-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 12px;
}
.glowing-accessory {
  color: #ffd966;
  text-shadow: 0 0 6px rgba(255, 217, 102, 0.45);
}
.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;
  }
}
.start-link:hover {
  background: #6c87ff;
}

.game {
  max-width: 520px;
  width: 100%;
  margin: 16px auto;
  background: #333;
  padding: 14px;
  border: 2px solid #666;
  border-radius: 12px;
  box-sizing: border-box;
  border: 2px solid #666;
}

.status {
  margin-bottom: 10px;
}

.log {
  height: 220px;
  background: #111;
  padding: 8px;
  overflow-y: auto;
  margin-bottom: 12px;
  font-size: 14px;
  border-radius: 8px;
}

button {
  flex: 1;
  min-height:80px;
  padding: 12px 14px;
  font-size: 16px;
  border-radius: 10px;
  border: 1px solid #555;
  background: #444;
  color: #fff;
  touch-action: manipulation;
}
.row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

#statusScreen,
#discardWeakScreen,
#skillScreen {
  background: #333;
  color: #fff;
  padding: 14px;
  max-width: 520px;
  width: 100%;
  margin: 10px auto;
  border: 2px solid #666;
  border-radius: 12px;
  box-sizing: border-box;
}
.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.screen-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.status-version {
  font-size: 12px;
  color: #b6b6b6;
  margin-left: 6px;
}

.screen-header h3 {
  margin: 0;
  font-size: 18px;
}
.inventory-tabs {
  display: flex;
  gap: 8px;
  margin: 6px 0 12px;
}

.inventory-tab {
  flex: 1;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid #555;
  background: #1f1f1f;
  color: #e0e0e0;
  font-size: 14px;
}

.inventory-tab.is-active {
  background: #6c87ff;
  border-color: #6c87ff;
  color: #fff;
}

.back-button {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 6px 12px;
  font-size: 14px;
}

.discard-button {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 6px 12px;
  font-size: 14px;
}
.discard-weak-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.discard-weak-note {
  margin: 0;
  font-size: 13px;
  opacity: 0.85;
}

.discard-weak-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
status-actions {
  margin-top: 12px;
}
.status-point-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: 6px 0 10px;
}

.status-point-label {
  font-size: 12px;
  color: #cfcfcf;
}

.status-point-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  width: 100%;
}

.status-point-buttons button {
  min-width: 48px;
  height: 32px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 14px;
}

.status-point-buttons button.is-active {
  background: #6c87ff;
  color: #fff;
  border-color: #6c87ff;
}

.status-step-note {
  margin-top: 6px;
  font-size: 12px;
  opacity: 0.8;
}
.status-action-button {
  width: 100%;
  min-height: 48px;
}

.skill-points {
  margin-bottom: 12px;
  font-weight: bold;
}

.skill-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.skill-footer .scroll-top-button {
  flex: 0 0 auto !important;
  margin: 5%;
  padding: 0;
}
.skill-card {
  background: #2b2b2b;
  border: 1px solid #555;
  border-radius: 10px;
  padding: 12px;
}

.skill-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.skill-title {
  font-weight: bold;
  flex: 1;
}

.skill-level {
  font-size: 13px;
  opacity: 0.8;
}

.skill-description {
  font-size: 13px;
  opacity: 0.9;
  margin-bottom: 10px;
}
.skill-requirement {
  font-size: 12px;
  opacity: 0.75;
  margin-bottom: 10px;
}
.skill-required-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.skill-required {
  font-size: 12px;
  opacity: 0.8;
  margin-bottom: 10px;
  margin: 0;
}

.skill-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.skill-button {
  min-height: 44px;
  padding: 6px 12px;
  font-size: 14px;
  flex: 0 0 auto;
}

.discard-weak-row label {
  flex: 0 0 auto;
  font-size: 14px;
}

.discard-weak-row input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #555;
  background: #222;
  color: #fff;
  font-size: 14px;
}
.discard-weak-row input[type="checkbox"] {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  padding: 0;
}
.status {
  background: #222;
  padding: 10px;
  margin-bottom: 10px;
  font-size: 14px;
  border-radius: 8px;
  min-height: 60px;
}

.header-row {
  display: flex;
  align-items: center;
  gap: 6px;          /* 要素間の余白 */
  margin: 4px 0;
}
.header-row div {

  flex: 1;
  min-width: 0;
}
.floor-info {
  display: flex;
  align-items: center;
  gap: 6px;
}

.teleport-button {
  flex: 0 0 auto;
  min-height: 28px;
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 8px;
}
.battle-status {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 4px 0;
}

.player-hp {
  align-self: flex-start;
}

.enemy-info {
  align-self: flex-end;
  max-width: 100%;
  text-align: right;
}

.enemy-name,
.enemy-hp {
  line-height: 1.2;
  min-height: 1.2em;
}
#enemyName,
#enemyHp {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 6px;          /* 要素間の余白 */
  margin: 4px 0;
}
.skill-toggle-button.is-active {
  background: #6c87ff;
  color: #fff;
  border-color: #6c87ff;
}
/* 経験値バー */
.exp-bar {
  width: 100%;
  height: 6px;
  background: #111;
  border-radius: 999px;
  overflow: hidden;
  margin: 4px 0 6px;
  border: 1px solid #444;
}
.status-point-buttons{
  font-size: 12px;
}
.exp-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #6c87ff, #8fa2ff);
  transition: width 0.25s ease;
}
.status-row div {
  width: 48%;
}
.status-controls {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.status-controls button {
  width: 32px;
  height: 32px;
  padding: 0;
  flex: 0 0 auto;
  font-size: 18px;
  border-radius: 6px;
}

.status-note {
  font-size: 12px;
  color: #bbb;
  margin-bottom: 6px;
}
/* スキル割り振り用 行 */
.skill-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* スキル割り振り用 ボタン（強制的に小さくする） */
.skill-row button {
  width: 32px !important;
  height: 32px !important;
  padding: 0 !important;
  flex: 0 0 auto !important;
  font-size: 18px;
  border-radius: 6px;
}

@media (max-width: 480px) {
  body {
    padding: 0 10px 20px;
  }

  .game,
  #inventory,
  #statusScreen,
  #discardWeakScreen {
    margin: 12px auto;
    padding: 12px;
  }

  .log {
    height: 240px;
  }
  #inventory button,
  #skillScreen button,
  #statusScreen button,
  #discardWeakScreen button {
    min-height: 44px;
    padding: 6px 10px;
    font-size: 14px;
  }
}
/* --- Skill UI 改善 --- */

.skill-top {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}
.skill-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.skill-preset-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.skill-preset-button.is-empty {
  opacity: 0.6;
}
.skill-preset-button.is-filled {
  border-color: #7a7a7a;
}
.skill-preset-dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.skill-preset-dialog {
  background: #1f1f1f;
  border: 1px solid #444;
  border-radius: 12px;
  padding: 16px;
  width: min(90vw, 360px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.skill-preset-dialog-title {
  font-weight: bold;
  margin-bottom: 6px;
}
.skill-preset-dialog-body {
  font-size: 13px;
  opacity: 0.9;
  margin-bottom: 12px;
}
.skill-preset-dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.skill-reset-button {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
}
.skill-reset-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.skill-summary {
  background: #262626;
  border: 1px solid #444;
  border-radius: 10px;
  padding: 10px;
}

.skill-summary-title {
  font-weight: bold;
  font-size: 13px;
  margin-bottom: 6px;
  opacity: 0.9;
}

.skill-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
  font-size: 12px;
  opacity: 0.9;
}

.skill-card {
  position: relative;
}

.skill-card.is-affordable {
  border-color: #6c87ff;
}

.skill-card.is-max {
  opacity: 0.92;
}

.skill-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.skill-badge {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid #555;
  background: #222;
  opacity: 0.9;
}


/* 下段：左に状態、右に + / - */
.skill-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.skill-hint {
  font-size: 12px;
  opacity: 0.8;
}

/* ★ここが肝：グローバル button をスキル用だけ上書き */
.skill-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.skill-btn {
  width: 34px !important;
  height: 34px !important;
  min-height: 34px !important;     /* button { min-height:80px } を潰す */
  padding: 0 !important;
  flex: 0 0 auto !important;        /* button { flex:1 } を潰す */
  font-size: 14px;
  border-radius: 8px;
}

.skill-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #111;
  color: #fff;
  padding: 20px 24px;
  border-radius: 10px;
  text-align: center;
  max-width: 320px;
}

.modal-content button {
  margin-top: 16px;
  padding: 6px 16px;
  font-size: 16px;
}

.teleport-modal-content select {
  width: 100%;
  margin-top: 12px;
  padding: 8px;
  font-size: 18px;
  border-radius: 6px;
  background: #1a1a1a;
  color: #fff;
  border: 1px solid #444;
}

.teleport-stay-option {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 14px;
}

.teleport-stay-option input {
  width: 18px;
  height: 18px;
}
@media (max-width: 480px) {
  .teleport-modal-content select {
    font-size: 22px;
    padding: 12px;
  }
}

.teleport-modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.teleport-modal-actions button {
  margin-top: 16px;
}

/* --- Save Data (Import / Export) --- */
.status-save {
  margin-top: 6px;
}

.status-save-label {
  font-size: 12px;
  color: #cfcfcf;
  margin-bottom: 6px;
}

.status-save-actions {
  display: flex;
  gap: 10px;
}

.status-save-button {
  flex: 1;
  min-height: 44px; /* button { min-height:80px } を潰す */
  padding: 6px 12px;
  font-size: 14px;
}

.status-save-note {
  margin-top: 6px;
  font-size: 12px;
  opacity: 0.8;
}


.status-serial {
  margin-top: 12px;
}

.status-serial-label {
  font-size: 12px;
  color: #cfcfcf;
  margin-bottom: 6px;
}

.status-serial-input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #444;
  background: #1a1a1a;
  color: #fff;
  font-size: 14px;
}

.status-serial-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.status-serial-actions .status-serial-input {
  flex: 1;
}

.status-serial-button {
  min-height: 44px;
  padding: 6px 12px;
  font-size: 14px;
}

.status-serial-input:disabled {
  opacity: 0.6;
}