* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  background: #1a2238;
  overflow: hidden;
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic UI", "Meiryo", "M PLUS Rounded 1c", sans-serif;
  -webkit-user-select: none; user-select: none;
  touch-action: none;
}

#wrap {
  position: absolute;
  width: 960px; height: 540px;
  left: 0; top: 0;
  transform-origin: 0 0;
}

#game { position: absolute; left: 0; top: 0; border-radius: 12px; }

.hidden { display: none !important; }

/* ===== HUD ===== */
#hud { position: absolute; left: 10px; top: 8px; pointer-events: none; }
#res-bar { display: flex; gap: 8px; }
.res {
  background: rgba(20, 28, 52, .82);
  border: 2px solid rgba(255,255,255,.18);
  border-radius: 20px;
  padding: 3px 12px 3px 8px;
  color: #fff; font-size: 15px; font-weight: bold;
  display: flex; align-items: center; gap: 5px;
  text-shadow: 0 1px 2px rgba(0,0,0,.5);
}
.res i { font-style: normal; font-size: 15px; }
.res em { font-style: normal; color: #ff9d9d; font-size: 12px; margin-left: 2px; }

#hint-bar {
  margin-top: 7px;
  background: rgba(255, 244, 214, .95);
  color: #6b4a12;
  border-radius: 14px;
  border: 2px solid #e8c66a;
  padding: 4px 12px;
  font-size: 13px; font-weight: bold;
  max-width: 560px;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
  animation: hintpop .4s ease;
}
@keyframes hintpop { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }

#btn-vol {
  position: absolute; right: 10px; top: 8px;
  background: rgba(20, 28, 52, .82);
  border: 3px solid rgba(255,255,255,.25);
  border-radius: 30px;
  color: #fff; font-size: 22px; font-weight: bold;
  padding: 10px 20px;
  cursor: pointer;
  z-index: 55; /* タイトル画面(z50)より上に置いてタイトルでも押せるように */
}
#btn-vol:hover { background: rgba(60, 72, 110, .9); }

#btn-title {
  position: absolute; right: 10px; top: 72px;
  background: rgba(20, 28, 52, .82);
  border: 3px solid rgba(255,255,255,.25);
  border-radius: 28px;
  color: #fff; font-size: 20px; font-weight: bold;
  padding: 9px 18px;
  cursor: pointer;
  z-index: 40;
}
#btn-title:hover { background: rgba(60, 72, 110, .9); }

/* ===== 下部ボタン ===== */
#bottom-bar {
  position: absolute; left: 0; right: 0; bottom: 10px;
  display: flex; justify-content: center; gap: 12px;
  pointer-events: none;
}
#bottom-bar button { pointer-events: auto; }
.big-btn {
  background: linear-gradient(#ff9a53, #f0653a);
  border: 3px solid #fff;
  border-radius: 36px;
  color: #fff; font-size: 26px; font-weight: bold;
  padding: 13px 48px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,.4), inset 0 -3px 0 rgba(0,0,0,.15);
  text-shadow: 0 2px 2px rgba(0,0,0,.25);
  transition: transform .08s;
}
.big-btn:hover { transform: scale(1.05); }
.big-btn:active { transform: scale(.97); }
.sub-btn {
  background: linear-gradient(#7ea6e0, #4a72b8);
  border: 3px solid #fff;
  border-radius: 32px;
  color: #fff; font-size: 21px; font-weight: bold;
  padding: 12px 30px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,.4), inset 0 -3px 0 rgba(0,0,0,.15);
  text-shadow: 0 1px 2px rgba(0,0,0,.3);
  transition: transform .08s;
}
.sub-btn:hover { transform: scale(1.05); }
.sub-btn:active { transform: scale(.97); }

/* ===== 討伐HUD ===== */
#hunt-hud { position: absolute; left: 0; top: 0; width: 100%; pointer-events: none; }
#hunt-count { display: none; }
#hunt-progress {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%);
  width: 340px; height: 14px;
  background: rgba(0,0,0,.45);
  border: 2px solid rgba(255,255,255,.5);
  border-radius: 10px;
}
#hunt-progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #6fd3ff, #b9ecff);
  border-radius: 8px;
  transition: width .2s linear;
}
#hunt-progress-icon { position: absolute; top: -7px; left: 0; font-size: 18px; transition: left .2s linear; }
#btn-retreat {
  position: absolute; right: 10px; top: 76px;
  pointer-events: auto;
  background: rgba(20,28,52,.8);
  border: 2px solid rgba(255,255,255,.3);
  border-radius: 18px;
  color: #fff; font-size: 13px; font-weight: bold;
  padding: 5px 12px; cursor: pointer;
}

/* ===== タイトル ===== */
#title-screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 26px;
  z-index: 50;
}
#title-logo { text-align: center; animation: floaty 3s ease-in-out infinite; }
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
#title-main {
  font-size: 88px; font-weight: 900;
  color: #fff;
  letter-spacing: 4px;
  text-shadow:
    0 0 0 #fff,
    4px 4px 0 #5a8fd0,
    8px 8px 0 rgba(30,60,110,.45),
    0 0 30px rgba(160,220,255,.8);
  -webkit-text-stroke: 2px #3a6ab0;
}
#title-sub {
  margin-top: 6px;
  font-size: 20px; font-weight: bold;
  color: #dff1ff;
  text-shadow: 0 2px 4px rgba(0,0,0,.5);
}
.title-btn {
  display: block;
  width: 260px;
  margin: 6px auto;
  background: linear-gradient(#ffd76e, #f5a63b);
  border: 3px solid #fff;
  border-radius: 30px;
  color: #6b4310; font-size: 21px; font-weight: bold;
  padding: 12px;
  cursor: pointer;
  box-shadow: 0 5px 12px rgba(0,0,0,.4), inset 0 -3px 0 rgba(0,0,0,.12);
  transition: transform .08s;
}
.title-btn:hover { transform: scale(1.06); }
#title-note { color: #b9d4ee; font-size: 13px; text-shadow: 0 1px 2px rgba(0,0,0,.5); }

.share-btn {
  display: block;
  width: 190px;
  margin: 14px auto 0;
  background: #0f1419;
  border: 2px solid #536878;
  border-radius: 24px;
  color: #fff; font-size: 16px; font-weight: bold;
  padding: 9px;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0,0,0,.4);
  transition: transform .08s;
}
.share-btn:hover { transform: scale(1.05); background: #1c2733; }

#title-disclaimer {
  position: absolute;
  left: 0; right: 0; bottom: 6px;
  text-align: center;
  font-size: 10px;
  line-height: 1.55;
  color: rgba(255, 255, 255, .68);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
  pointer-events: none;
}
body.portrait #title-disclaimer { font-size: 9px; padding: 0 8px; }

/* ===== モーダル ===== */
#modal-layer {
  position: absolute; inset: 0;
  background: rgba(8, 12, 26, .55);
  display: flex; align-items: center; justify-content: center;
  z-index: 60;
}
#modal-box {
  background: linear-gradient(#fdfaf2, #f2ecdc);
  border: 4px solid #8a6b3f;
  border-radius: 18px;
  min-width: 420px; max-width: 660px;
  max-height: 480px;
  overflow-y: auto;
  padding: 18px 22px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  color: #4a3a20;
  position: relative;
}
#modal-box h2 { font-size: 22px; margin-bottom: 6px; color: #5a431d; }
#modal-box h2 small { font-size: 13px; color: #97815a; font-weight: normal; margin-left: 8px; }
#modal-box .desc { font-size: 13px; color: #7a6844; margin-bottom: 10px; line-height: 1.5; }
.modal-close {
  position: absolute; right: 8px; top: 8px;
  background: #d96b5a; color: #fff;
  border: 3px solid #fff; border-radius: 50%;
  width: 56px; height: 56px;
  font-size: 26px; font-weight: bold;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
#modal-box h2 { padding-right: 60px; }

.cost-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.cost-item {
  display: inline-block;
  background: #fff; border: 2px solid #d8c9a5; border-radius: 14px;
  padding: 2px 10px; font-size: 13px; font-weight: bold;
}
/* アイテム行内の素材コスト (折り返しても重ならない) */
.row-costs {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-top: 5px;
}
.row-costs .cost-item { font-size: 12px; padding: 1px 8px; }
.cost-item.ng { color: #d43f3f; border-color: #e8a0a0; background: #fdeaea; }
.cost-item.ok { color: #3d7a2f; }

.action-btn {
  background: linear-gradient(#8ed06a, #55a83c);
  border: 3px solid #fff; border-radius: 24px;
  color: #fff; font-size: 17px; font-weight: bold;
  padding: 8px 28px;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0,0,0,.3), inset 0 -3px 0 rgba(0,0,0,.15);
  text-shadow: 0 1px 2px rgba(0,0,0,.3);
  margin-top: 4px;
}
.action-btn:hover { filter: brightness(1.08); }
.action-btn:disabled {
  background: #b6b0a2; cursor: default; filter: none;
  box-shadow: none;
}
.action-btn.orange { background: linear-gradient(#ffb058, #ef7f34); }

.item-row {
  display: flex; align-items: center; gap: 8px;
  background: #fff;
  border: 2px solid #e2d6b8;
  border-radius: 12px;
  padding: 6px 10px;
  margin-bottom: 6px;
  font-size: 14px;
}
.item-row .chip { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(0,0,0,.15); flex: none; }
.item-row .iname { font-weight: bold; flex: 1; }
.item-row .iname small { display: block; font-size: 11px; color: #9a8a66; font-weight: normal; }
.item-row .icount { font-weight: bold; color: #5a6ab0; min-width: 48px; text-align: right; }
.item-row .sellbtns { display: flex; gap: 4px; }
.item-row .sellbtns button, .mini-btn {
  background: #f5c95c; border: 2px solid #caa23a; border-radius: 10px;
  font-size: 12px; font-weight: bold; color: #6b4a10;
  padding: 2px 8px; cursor: pointer;
}
.item-row .sellbtns button:hover, .mini-btn:hover { filter: brightness(1.1); }
.item-row .sellbtns button:disabled { opacity: .4; cursor: default; }
.auto-toggle { font-size: 11px; }
.auto-toggle input { vertical-align: middle; }

.weapon-row.equipped { border-color: #f0a53a; background: #fff6e2; box-shadow: 0 0 0 2px rgba(240,165,58,.35); }
.watk { color: #d4572f; font-weight: bold; font-size: 15px; min-width: 62px; }

.stage-card {
  border: 3px solid #cbe3f5; border-radius: 14px;
  background: linear-gradient(#ffffff, #eef7ff);
  padding: 10px 14px; margin-bottom: 8px;
  display: flex; align-items: center; gap: 12px;
  cursor: pointer;
  transition: transform .07s;
}
.stage-card:hover { transform: scale(1.02); border-color: #7db8e8; }
.stage-card.locked { opacity: .55; cursor: default; background: #eee; }
.stage-card.locked:hover { transform: none; border-color: #cbe3f5; }
.stage-card .semoji { font-size: 30px; }
.stage-card .sinfo { flex: 1; }
.stage-card .sname { font-weight: bold; font-size: 16px; }
.stage-card .sdesc { font-size: 12px; color: #7a8aa0; }
.stage-card .spower { font-size: 12px; font-weight: bold; text-align: right; }
.stage-card .spower.over { color: #3d9a2f; }
.stage-card .spower.under { color: #d4572f; }
.stage-card .cleared { color: #f0a53a; font-size: 13px; }

/* 討伐リザルトの説明文は大きめに */
#modal-box .result-body .desc { font-size: 20px; line-height: 1.65; }
#modal-box .result-body h2 { font-size: 26px; }
#modal-box .result-body .loot-chip { font-size: 16px; }

.result-loot { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.loot-chip {
  display: flex; align-items: center; gap: 5px;
  background: #fff; border: 2px solid #e0d4b4; border-radius: 14px;
  padding: 3px 10px; font-size: 13px; font-weight: bold;
}
.loot-chip .chip { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(0,0,0,.15); }

.center { text-align: center; }
.big-emoji { font-size: 52px; text-align: center; margin: 6px 0; }

/* ===== バナー・トースト ===== */
#banner-layer { position: absolute; left: 0; right: 0; top: 130px; pointer-events: none; z-index: 55; text-align: center; }
.banner {
  display: inline-block;
  background: rgba(20, 28, 52, .88);
  border: 3px solid #ffd76e;
  color: #fff; font-size: 26px; font-weight: bold;
  border-radius: 16px;
  padding: 10px 34px;
  text-shadow: 0 2px 4px rgba(0,0,0,.6);
  animation: bannerin 2.6s ease forwards;
}
@keyframes bannerin {
  0% { transform: scale(.4); opacity: 0; }
  12% { transform: scale(1.08); opacity: 1; }
  18% { transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}
#toast-layer {
  position: absolute; right: 12px; bottom: 70px;
  display: flex; flex-direction: column-reverse; gap: 6px;
  pointer-events: none; z-index: 55;
}
.toast {
  background: rgba(255, 252, 240, .95);
  border: 2px solid #caa23a;
  color: #5a431d; font-size: 13px; font-weight: bold;
  border-radius: 14px;
  padding: 5px 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
  animation: toastin 3s ease forwards;
}
@keyframes toastin {
  0% { transform: translateX(40px); opacity: 0; }
  10% { transform: none; opacity: 1; }
  85% { opacity: 1; }
  100% { opacity: 0; }
}

/* エンディング */
#ending-overlay {
  position: absolute; inset: 0; z-index: 70;
  background: linear-gradient(#0c1430, #23345c);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #fff; text-align: center;
}
#ending-overlay h1 { font-size: 40px; margin-bottom: 14px; text-shadow: 0 0 20px #9fd8ff; }
#ending-overlay p { font-size: 16px; line-height: 2; color: #cfe6ff; }

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-thumb { background: #c9b98f; border-radius: 5px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,.06); }

/* ===== 縦持ち (スマホ) ===== */
body.portrait #title-main { font-size: 58px; letter-spacing: 2px; }
body.portrait #title-sub { font-size: 15px; }
body.portrait .title-btn { width: 230px; font-size: 19px; }
body.portrait .big-btn { font-size: 30px; padding: 15px 34px; }
body.portrait .sub-btn { font-size: 24px; padding: 14px 18px; }
body.portrait #bottom-bar { gap: 8px; }
body.portrait #hint-bar { max-width: 430px; font-size: 12px; }
body.portrait #modal-box { min-width: 330px; max-width: 500px; max-height: 780px; }
body.portrait #hunt-progress { width: 270px; }
body.portrait #ending-overlay h1 { font-size: 30px; }
