/* ==========================================================================
   style.css
   アイランド開拓タイクーン - スマホ全画面最適化＆モダンアーケードUI
   ========================================================================== */

:root {
  --bg-ocean: #1b4d7e;
  --glass-bg: rgba(15, 23, 42, 0.78);
  --glass-border: rgba(255, 255, 255, 0.18);
  --card-bg: #ffffff;
  --card-surface: #f8fafc;
  --text-main: #0f172a;
  --text-sub: #475569;
  --text-light: #f8fafc;
  --accent-gold: #f59e0b;
  --accent-gold-dark: #d97706;
  --accent-green: #10b981;
  --accent-green-dark: #059669;
  --accent-blue: #3b82f6;
  --accent-blue-dark: #2563eb;
  --accent-danger: #ef4444;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-ocean);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  color: var(--text-light);
  /* スワイプ時の画面スクロール・引っ張り更新（バウンス）を完全防止 */
  overscroll-behavior: none;
  touch-action: none;
  position: fixed;
  inset: 0;
}

/* メインゲームCanvas */
#gameCanvas {
  display: block;
  width: 100vw;
  height: 100vh;
  touch-action: none;
  cursor: grab;
}

#gameCanvas:active {
  cursor: grabbing;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   上部HUDオーバーレイ
   ========================================================================== */
#hud-top {
  position: fixed;
  top: calc(var(--safe-top) + 10px);
  left: calc(var(--safe-left) + 12px);
  right: calc(var(--safe-right) + 12px);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  pointer-events: none;
  z-index: 20;
}

.hud-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: calc(100% - 145px);
}

.island-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1.5px solid var(--glass-border);
  border-radius: 16px;
  padding: 6px 12px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  pointer-events: auto;
  width: fit-content;
}

.island-icon {
  font-size: 1.35rem;
  line-height: 1;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
}

.island-info {
  display: flex;
  flex-direction: column;
}

.island-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.island-sub {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fde047;
}

.dot-sep {
  color: rgba(255, 255, 255, 0.45);
}

#unlock-progress {
  color: #93c5fd;
}

/* リソースピル（コイン・スタック数） */
.resource-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1.5px solid var(--glass-border);
  border-radius: 999px;
  padding: 5px 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  pointer-events: auto;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.stat-pill.pulse {
  transform: scale(1.12);
}

.coin-pill {
  border-color: rgba(250, 204, 21, 0.45);
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.88), rgba(15, 23, 42, 0.88));
}

.stack-pill {
  border-color: rgba(148, 163, 184, 0.35);
}

.stack-pill.max-full {
  border-color: #f87171;
  background: linear-gradient(135deg, rgba(127, 29, 29, 0.85), rgba(69, 10, 10, 0.85));
}

.pill-icon {
  font-size: 1.05rem;
  line-height: 1;
}

.pill-value {
  font-size: 0.95rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.coin-pill .pill-value {
  color: #fde047;
}

.mini-action-btn {
  margin-left: 2px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.mini-action-btn:hover {
  background: rgba(239, 68, 68, 0.45);
}

.mini-action-btn:active {
  transform: scale(0.9);
}

/* 右側ボタン群 */
.hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.hud-btn {
  position: relative;
  border: 1.5px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #ffffff;
  border-radius: 14px;
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28);
  transition: transform 0.12s ease, background 0.15s ease;
}

.hud-btn:hover {
  background: rgba(30, 41, 59, 0.92);
}

.hud-btn:active {
  transform: scale(0.93);
}

.primary-hud-btn {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-color: #fde68a;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  box-shadow: 0 6px 16px rgba(217, 119, 6, 0.45);
}

.primary-hud-btn:hover {
  background: linear-gradient(135deg, #fbbf24, #d97706);
}

.icon-only-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 1.15rem;
}

.notify-dot {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ef4444;
  border: 2px solid #ffffff;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.8);
  animation: pulseDot 1.2s infinite ease-in-out;
}

@keyframes pulseDot {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.25); }
}

/* ==========================================================================
   次目標ガイドバナー ＆ 新エリア出航フローティングボタン
   ========================================================================== */
#objective-banner {
  position: fixed;
  top: calc(var(--safe-top) + 106px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 6px 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #e2e8f0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
  pointer-events: none;
  z-index: 15;
  max-width: 92vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.obj-icon {
  font-size: 0.9rem;
  flex-shrink: 0;
}

#objective-text {
  overflow: hidden;
  text-overflow: ellipsis;
}

.floating-prestige-btn {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 24px);
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #10b981, #059669);
  border: 2px solid #a7f3d0;
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 800;
  padding: 12px 24px;
  border-radius: 999px;
  box-shadow: 0 10px 25px rgba(5, 150, 105, 0.55);
  cursor: pointer;
  z-index: 22;
  white-space: nowrap;
  animation: floatBounce 1.8s infinite ease-in-out;
}

.floating-prestige-btn:active {
  transform: translateX(-50%) scale(0.95);
}

@keyframes floatBounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-5px); }
}

/* ==========================================================================
   トースト通知
   ========================================================================== */
#toast-container {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 84px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  z-index: 40;
  width: 90%;
  max-width: 380px;
}

.toast-item {
  background: rgba(15, 23, 42, 0.9);
  border: 1.5px solid rgba(250, 204, 21, 0.5);
  color: #ffffff;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  animation: toastInOut 2.6s ease forwards;
  text-align: center;
}

@keyframes toastInOut {
  0% { opacity: 0; transform: translateY(14px) scale(0.92); }
  12% { opacity: 1; transform: translateY(0) scale(1); }
  85% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-10px) scale(0.95); }
}

/* ==========================================================================
   モーダル共通（強化ショップ・出航・設定）
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
  animation: fadeIn 0.18s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  background: var(--card-bg);
  color: var(--text-main);
  border-radius: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: cardPop 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes cardPop {
  from { transform: scale(0.92) translateY(12px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: #ffffff;
}

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-title-icon {
  font-size: 1.75rem;
}

.modal-header h2 {
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.25;
}

.modal-subtitle {
  font-size: 0.8rem;
  color: #cbd5e1;
  margin-top: 2px;
}

.modal-subtitle strong {
  color: #fde047;
  font-size: 0.92rem;
}

.modal-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
}

.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.modal-close-btn:active {
  transform: scale(0.9);
}

/* モーダルタブ */
.modal-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #e2e8f0;
  padding: 6px;
  gap: 6px;
}

.tab-btn {
  border: none;
  background: transparent;
  color: #475569;
  font-size: 0.88rem;
  font-weight: 800;
  padding: 10px 8px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.tab-content {
  display: none;
  padding: 14px 16px 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.tab-content.active {
  display: block;
}

/* アップグレード＆アルバイト一覧 */
.worker-summary-banner {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.82rem;
  color: #1e3a8a;
}

.worker-hint {
  font-size: 0.74rem;
  color: #3b82f6;
}

.upgrade-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.upgrade-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--card-surface);
  border: 1.5px solid #e2e8f0;
  border-radius: 16px;
  padding: 12px 14px;
  transition: border-color 0.15s;
}

.upgrade-item.can-afford {
  border-color: #93c5fd;
  background: #f8fafc;
}

.upgrade-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.upgrade-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: #e0f2fe;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.upgrade-info {
  min-width: 0;
}

.upgrade-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.upgrade-name {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text-main);
}

.upgrade-lvl {
  font-size: 0.72rem;
  font-weight: 800;
  background: #dbeafe;
  color: #1d4ed8;
  padding: 2px 8px;
  border-radius: 999px;
}

.upgrade-desc {
  font-size: 0.76rem;
  color: var(--text-sub);
  margin-top: 3px;
}

.upgrade-buy-btn {
  flex-shrink: 0;
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  min-width: 104px;
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
  transition: transform 0.1s, filter 0.15s;
}

.upgrade-buy-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.upgrade-buy-btn:disabled {
  background: #cbd5e1;
  color: #64748b;
  box-shadow: none;
  cursor: not-allowed;
}

.buy-btn-label {
  font-size: 0.72rem;
  opacity: 0.92;
}

.buy-btn-cost {
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   新エリア出航（プレステージ）モーダル
   ========================================================================== */
.prestige-body {
  padding: 18px 20px 22px;
  overflow-y: auto;
  touch-action: pan-y;
}

.prestige-comparison {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.prestige-box {
  flex: 1;
  background: #f1f5f9;
  border: 1.5px solid #cbd5e1;
  border-radius: 16px;
  padding: 12px;
  text-align: center;
}

.prestige-box.next {
  background: #ecfdf5;
  border-color: #34d399;
}

.p-label {
  font-size: 0.74rem;
  font-weight: 700;
  color: #64748b;
}

.p-val {
  font-size: 0.95rem;
  font-weight: 800;
  color: #0f172a;
  margin: 4px 0;
}

.p-mult {
  font-size: 0.82rem;
  font-weight: 800;
  color: #475569;
}

.p-mult.highlight {
  color: #059669;
  font-size: 0.9rem;
}

.prestige-arrow {
  font-size: 1.4rem;
  color: #64748b;
}

.prestige-perks {
  list-style: none;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.82rem;
  color: #78350f;
  margin-bottom: 18px;
}

.prestige-actions {
  display: flex;
  justify-content: center;
}

.prestige-confirm-btn {
  width: 100%;
  border: none;
  border-radius: 16px;
  padding: 14px 20px;
  font-size: 1rem;
  font-weight: 800;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(217, 119, 6, 0.4);
  cursor: pointer;
  transition: transform 0.12s;
}

.prestige-confirm-btn:active {
  transform: scale(0.96);
}

/* ==========================================================================
   設定・統計モーダル
   ========================================================================== */
.settings-body {
  padding: 18px 20px 22px;
  overflow-y: auto;
  touch-action: pan-y;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 12px;
}

.stat-card-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #64748b;
}

.stat-card-value {
  font-size: 0.98rem;
  font-weight: 800;
  color: #0f172a;
  margin-top: 2px;
}

.controls-guide {
  background: #f1f5f9;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 0.8rem;
  color: #334155;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.controls-guide h3 {
  font-size: 0.88rem;
  color: #0f172a;
}

.controls-guide code {
  background: #e2e8f0;
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 700;
}

.settings-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.settings-action-btn {
  flex: 1;
  min-width: 140px;
  border: none;
  border-radius: 12px;
  padding: 12px;
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.1s;
}

.settings-action-btn:active {
  transform: scale(0.96);
}

.settings-action-btn.save {
  background: #3b82f6;
  color: #ffffff;
}

.settings-action-btn.danger {
  background: #fee2e2;
  color: #b91c1c;
}

/* ==========================================================================
   スマホ小画面対応レスポンシブ調整
   ========================================================================== */
@media (max-width: 520px) {
  .btn-label {
    display: none;
  }

  .primary-hud-btn {
    width: 40px;
    height: 40px;
    padding: 0;
  }

  .hud-left {
    max-width: calc(100% - 136px);
  }

  #objective-banner {
    top: calc(var(--safe-top) + 98px);
    font-size: 0.72rem;
    padding: 5px 12px;
  }

  .modal-card {
    max-height: 88vh;
    border-radius: 20px;
  }

  .upgrade-item {
    padding: 10px 12px;
  }

  .upgrade-buy-btn {
    min-width: 92px;
    padding: 8px 10px;
  }
}

