* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: #0c1220; color: #e7edf7;
  font-family: "Hiragino Sans", "Yu Gothic", "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  user-select: none;
}
#app { min-height: 100%; display: flex; flex-direction: column; align-items: center; }

.screen { display: none; width: 100%; max-width: 820px; padding: 18px 14px 40px; flex-direction: column; align-items: center; }
.screen.on { display: flex; }

/* ===== タイトル ===== */
.logo { font-size: 2.4rem; letter-spacing: 2px; margin: 30px 0 4px; text-align: center; }
.logo span { color: #f97362; margin: 0 6px; }
.tag { color: #9fb0cc; margin: 0 0 26px; text-align: center; }
.menu-col { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 340px; }
.ver { color: #58698c; font-size: 0.75rem; margin-top: 30px; }

.btn {
  font-size: 1.05rem; padding: 14px 18px; border-radius: 14px; border: none;
  background: linear-gradient(180deg, #3a6bff, #2450e0); color: #fff; font-weight: 700;
  cursor: pointer; box-shadow: 0 4px 0 #1734a0;
}
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #1734a0; }
.btn.big { font-size: 1.15rem; padding: 16px 18px; }
.btn.ghost { background: transparent; color: #b7c3dd; box-shadow: none; border: 1px solid #35405c; }
.btn.ghost:active { transform: translateY(1px); }
.btn.small { font-size: 0.85rem; padding: 8px 14px; border-radius: 10px; }
.btn.danger { background: linear-gradient(180deg, #ff5b5b, #d93838); box-shadow: 0 4px 0 #921f1f; }
.btn.tiny { position: fixed; top: 10px; right: 10px; font-size: 0.75rem; padding: 6px 10px; z-index: 20; }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.hero {
  font-size: 1.25rem; padding: 20px 18px; border-radius: 16px;
  background: linear-gradient(180deg, #ffb84d, #f97362); box-shadow: 0 5px 0 #b6431f;
}
.btn.hero:active { transform: translateY(2px); box-shadow: 0 3px 0 #b6431f; }
.logo.small { font-size: 1.7rem; margin: 6px 0 22px; }

/* ===== あそびかた ===== */
.help-box { background: #131c30; border-radius: 16px; padding: 18px 20px; width: 100%; max-width: 560px; line-height: 1.7; }
.help-box h3 { margin-top: 0; }
.help-box ul { padding-left: 20px; margin: 6px 0; }
.help-box p { color: #c6d1e8; }

/* ===== 役割/難易度選択 ===== */
h2 { margin: 20px 0 6px; }
.sub { color: #9fb0cc; margin: 6px 0 14px; text-align: center; }
.role-pick { display: flex; gap: 14px; width: 100%; max-width: 420px; margin-bottom: 6px; }
.role-card {
  flex: 1; background: #131c30; border: 2px solid #263252; border-radius: 16px; padding: 18px 8px;
  color: #e7edf7; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.role-card.sel { border-color: #3a6bff; background: #16213d; }
.ricon { font-size: 2rem; }
.rname { font-weight: 700; }
.rdesc { font-size: 0.8rem; color: #9fb0cc; }
.level-pick { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; max-width: 420px; margin-bottom: 20px; }
.level-btn {
  padding: 10px 16px; border-radius: 12px; border: 2px solid #263252; background: #131c30; color: #e7edf7; cursor: pointer;
}
.level-btn.sel { border-color: #f97362; background: #2a1c1c; }

/* ===== オンライン ===== */
.online-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab-btn { padding: 10px 18px; border-radius: 12px 12px 0 0; border: none; background: #131c30; color: #9fb0cc; cursor: pointer; }
.tab-btn.on { background: #1b2745; color: #fff; }
.online-pane { display: flex; flex-direction: column; align-items: center; width: 100%; max-width: 420px; }
.room-wait { margin-top: 18px; text-align: center; }
.room-code { font-size: 2.4rem; letter-spacing: 8px; font-weight: 800; background: #131c30; border-radius: 14px; padding: 14px 20px; margin: 10px 0; }
.waiting-msg { color: #9fb0cc; }
.code-input {
  font-size: 1.8rem; letter-spacing: 8px; text-align: center; width: 100%; max-width: 260px;
  padding: 12px; border-radius: 12px; border: 2px solid #263252; background: #131c30; color: #fff; margin-bottom: 14px;
  text-transform: uppercase;
}
.join-status { color: #f97362; min-height: 1.4em; }
.loadout-note {
  font-size: 0.82rem; color: #9fb0cc; text-align: center; margin: 4px 0 14px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}

/* ===== 対戦画面 ===== */
#s-game { padding: 8px 8px 16px; max-width: 900px; }
.hud-top {
  display: flex; align-items: center; gap: 14px; width: 100%; max-width: 800px;
  background: #131c30; border-radius: 12px; padding: 8px 14px; margin-bottom: 8px; flex-wrap: wrap;
}
.hud-item { display: flex; align-items: center; gap: 6px; font-size: 0.9rem; }
.hud-item.timer { font-weight: 700; }
.hud-item.hp { flex: 1; min-width: 160px; }
.bar { width: 100px; height: 10px; background: #263252; border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #4ade80, #22c55e); transition: width 0.2s; }
.role-tag { background: #1b2745; padding: 3px 10px; border-radius: 10px; font-weight: 700; }
.net-status { font-size: 0.8rem; color: #9fb0cc; }
.speed-ctrl { gap: 4px; }
.speed-btn {
  font-size: 0.78rem; padding: 5px 9px; border-radius: 8px; border: 1px solid #263252;
  background: #131c30; color: #9fb0cc; cursor: pointer;
}
.speed-btn.sel { background: #3a6bff; border-color: #3a6bff; color: #fff; font-weight: 700; }
.speed-ctrl.readonly .speed-btn { cursor: default; opacity: 0.55; pointer-events: none; }
.speed-ctrl.readonly .speed-btn.sel { opacity: 0.9; }

.board-wrap { position: relative; width: 100%; max-width: 800px; touch-action: none; }
#board { width: 100%; height: auto; display: block; background: #0f1830; border-radius: 10px; border: 2px solid #1e2a4a; }
.place-hint {
  position: absolute; top: 6px; left: 6px; background: rgba(0,0,0,0.65); color: #fff; padding: 6px 10px;
  border-radius: 8px; font-size: 0.82rem; pointer-events: none;
}

.hud-bottom { width: 100%; max-width: 800px; margin-top: 8px; }
.resource-line { display: flex; justify-content: space-between; padding: 0 4px 6px; font-weight: 700; }
.shop-row { display: flex; gap: 8px; }
.shop-btn {
  flex: 1; background: #131c30; border: 2px solid #263252; border-radius: 12px; padding: 10px 4px;
  color: #e7edf7; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 0.8rem;
}
.shop-btn .sb-icon { font-size: 1.4rem; }
.shop-btn .sb-cost { color: #facc15; font-weight: 700; }
.shop-btn.sel { border-color: #3a6bff; background: #16213d; }
.shop-btn:disabled { opacity: 0.35; }
.sell-panel {
  display: flex; align-items: center; justify-content: center; gap: 10px; background: #1b2745; border-radius: 12px;
  padding: 10px; margin-top: 8px;
}

/* ===== 結果 ===== */
#result-title { font-size: 1.8rem; }

@media (max-width: 480px) {
  .logo { font-size: 1.9rem; }
  .room-code { font-size: 1.9rem; letter-spacing: 5px; }
}

/* ===== キャンペーン共通 ===== */
.camp-topbar { display: flex; justify-content: space-between; align-items: center; width: 100%; max-width: 800px; margin-bottom: 6px; }
.coin-badge { background: #1b2745; padding: 6px 14px; border-radius: 12px; font-weight: 700; color: #facc15; }

/* ステージ選択 */
.stage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; width: 100%; max-width: 720px; }
.stage-card {
  background: #131c30; border: 2px solid #263252; border-radius: 16px; padding: 16px 8px; color: #e7edf7;
  cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.stage-card.locked { opacity: 0.5; cursor: default; }
.stage-emoji { font-size: 2rem; }
.stage-name { font-weight: 700; font-size: 0.85rem; text-align: center; }
.stage-badges { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; min-height: 18px; }
.clear-badge { font-size: 0.65rem; padding: 2px 6px; border-radius: 8px; background: #16213d; }
.clear-badge.easy { color: #4ade80; }
.clear-badge.normal { color: #facc15; }
.clear-badge.hard { color: #f87171; }
.stage-detail {
  margin-top: 18px; background: #131c30; border-radius: 16px; padding: 18px; width: 100%; max-width: 420px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.diff-pick { display: flex; gap: 8px; }
.diff-btn {
  padding: 10px 14px; border-radius: 12px; border: 2px solid var(--dc, #263252); background: #16213d; color: #e7edf7; cursor: pointer;
}
.diff-btn.sel { background: var(--dc, #3a6bff); color: #0c1220; font-weight: 700; }

/* キャラ編成 */
.char-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; width: 100%; max-width: 760px; }
.char-card {
  background: #131c30; border: 2px solid var(--rc, #263252); border-radius: 14px; padding: 12px 8px; color: #e7edf7;
  cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center;
}
.char-card.sel { background: #1b2745; box-shadow: 0 0 0 2px var(--rc, #3a6bff) inset; }
.char-card.locked { opacity: 0.4; cursor: default; }
.char-card.warn { animation: warnshake 0.3s; }
@keyframes warnshake { 0%,100%{transform:translateX(0);} 25%{transform:translateX(-4px);} 75%{transform:translateX(4px);} }
.char-emoji { font-size: 1.8rem; }
.char-name { font-weight: 700; font-size: 0.82rem; }
.char-rarity { font-size: 0.72rem; color: var(--rc, #9fb0cc); font-weight: 700; }
.char-desc { font-size: 0.68rem; color: #9fb0cc; line-height: 1.3; }

/* ガチャ */
.gacha-btns { display: flex; gap: 12px; margin-top: 10px; flex-wrap: wrap; justify-content: center; }
.gacha-btns .btn small { display: block; font-size: 0.7rem; font-weight: 400; opacity: 0.85; }
.gacha-result { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 22px; max-width: 760px; }
.gacha-card {
  background: #131c30; border: 2px solid var(--rc, #263252); border-radius: 14px; padding: 14px 10px; width: 110px;
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  box-shadow: 0 0 14px 0 color-mix(in srgb, var(--rc, #3a6bff) 45%, transparent);
  animation: gachaPop 0.35s ease-out;
}
@keyframes gachaPop { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.gc-emoji { font-size: 2rem; }
.gc-name { font-weight: 700; font-size: 0.78rem; }
.gc-rarity { font-size: 0.72rem; color: var(--rc, #9fb0cc); font-weight: 700; }
.gc-tag { font-size: 0.68rem; color: #facc15; font-weight: 700; }

/* バトル(キャンペーン) */
.wave-tag { background: #1b2745; padding: 3px 12px; border-radius: 10px; font-weight: 700; }
.autoskip-btn {
  background: #1b2745; border: 1px solid #35405c; color: #9fb0cc; padding: 3px 10px;
  border-radius: 10px; font-size: 0.78rem; font-weight: 700; cursor: pointer;
}
.autoskip-btn.on { background: #22c55e; border-color: #22c55e; color: #06280f; }
.camp-prep { gap: 8px; margin-left: auto; }
#camp-prep-text { font-size: 0.85rem; color: #facc15; }

/* 結果(キャンペーン) */
.coin-earn { background: #1b2745; padding: 10px 18px; border-radius: 12px; font-weight: 700; color: #facc15; margin: 10px 0 24px; text-align: center; }

/* ===== デイリー要素(ホーム画面の3ボタン) ===== */
.daily-row { display: flex; gap: 10px; width: 100%; max-width: 340px; margin: 14px 0; }
.daily-btn {
  flex: 1; position: relative; background: #131c30; border: 1px solid #263252; border-radius: 14px;
  padding: 12px 6px; color: #e7edf7; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.db-icon { font-size: 1.5rem; }
.db-label { font-size: 0.72rem; color: #9fb0cc; }
.db-badge {
  position: absolute; top: -6px; right: -6px; background: #ef4444; color: #fff; font-size: 0.7rem; font-weight: 800;
  width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
}

/* デイリーボーナス */
.bonus-calendar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; max-width: 620px; margin: 16px 0 26px; }
.bonus-day {
  width: 78px; padding: 12px 6px; border-radius: 12px; background: #131c30; border: 2px solid #263252;
  text-align: center; opacity: 0.55;
}
.bonus-day.today { border-color: #facc15; opacity: 1; box-shadow: 0 0 12px 0 rgba(250,204,21,0.35); }
.bonus-day.done { opacity: 0.85; border-color: #4ade80; }
.bd-day { font-size: 0.72rem; color: #9fb0cc; }
.bd-coin { font-weight: 700; margin-top: 4px; }

/* デイリーミッション */
.mission-list { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 560px; }
.mission-card { background: #131c30; border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.mission-card.claimed { opacity: 0.55; }
.mission-desc { font-weight: 700; }
.mission-bar-wrap { height: 8px; background: #263252; border-radius: 5px; overflow: hidden; }
.mission-bar { height: 100%; background: linear-gradient(90deg, #4ade80, #22c55e); }
.mission-foot { display: flex; justify-content: space-between; align-items: center; font-size: 0.85rem; color: #9fb0cc; }
.mission-reward { color: #facc15; font-weight: 700; }

/* デイリーステージ */
.daily-stage-card {
  background: #131c30; border-radius: 16px; padding: 22px; width: 100%; max-width: 420px;
  display: flex; flex-direction: column; align-items: center; gap: 4px; margin-bottom: 18px; text-align: center;
}
