/* カートラッシュ！ スマホ縦画面専用のスタイル
   サイズは .app（ゲーム枠）基準の cqw / cqh を使う。PCでも中央の縦長枠に同じ見た目で表示される。 */

.app {
  background: #efe9dc;
}

#game,
#fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hidden {
  display: none !important;
}

/* ---------- 画面（メニュー類） ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  overflow-y: auto;
  touch-action: pan-y;
  background: rgba(255, 250, 240, 0.2);
  z-index: 10;
}
.screen.dim {
  background: rgba(43, 45, 66, 0.5);
}
.menu-panel {
  width: 100%;
  max-width: 400px;
  text-align: center;
  padding: 22px 18px;
}
/* タイトルはボタンを親指の届く下側に寄せる */
#screen-title {
  align-items: end;
  padding-bottom: max(28px, env(safe-area-inset-bottom));
}
.eyebrow {
  margin: 0;
  font-weight: 800;
  font-size: 13px;
  color: var(--primary-dark);
  letter-spacing: 0.2em;
}
.logo {
  margin: 2px 0 18px;
  font-size: min(54px, 14cqw);
  font-weight: 900;
  line-height: 1.05;
  color: var(--ink);
  text-shadow: 3px 3px 0 var(--accent);
}
.logo span {
  display: block;
  color: var(--primary);
  text-shadow: 3px 3px 0 var(--line);
}
.screen-title {
  margin: 2px 0 14px;
  font-size: 24px;
  font-weight: 900;
}
.btn-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.btn {
  min-height: 60px;
  font-size: 18px;
}
.row-links {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 14px;
}
.row-links .link {
  font-size: 13px;
}

/* ステージ選択 */
.stage-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}
.stage-card {
  display: flex;
  align-items: stretch;
  min-height: 112px;
  text-align: left;
  border: 3px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  touch-action: manipulation;
}
.stage-card:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--line);
}
.stage-thumb {
  flex: 0 0 84px;
  display: grid;
  place-items: end center;
  padding: 8px;
  border-right: 3px solid var(--line);
}
.stage-thumb span {
  background: var(--line);
  color: #fff;
  font-weight: 900;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.stage-market .stage-thumb {
  background:
    linear-gradient(90deg, transparent 0 30%, #e1dbce 30% 70%, transparent 70%),
    repeating-linear-gradient(#aeb7bf 0 4px, #6cc070 4px 14px, #aeb7bf 14px 18px, #ec6f6f 18px 28px, #aeb7bf 28px 32px, #f3b740 32px 42px);
}
.stage-home .stage-thumb {
  background:
    linear-gradient(90deg, #84c55f 0 22%, #d4d0c6 22% 28%, #5a6068 28% 72%, #d4d0c6 72% 78%, #84c55f 78%) bottom / 100% 55% no-repeat,
    #9fd6f5;
}
.stage-rush .stage-thumb {
  background:
    linear-gradient(90deg, #8a6a7a 0 18%, #6f747b 18% 24%, #4d5259 24% 76%, #6f747b 76% 82%, #8a6a7a 82%) bottom / 100% 55% no-repeat,
    linear-gradient(#4a3a78, #ff9a5a);
}
.stars {
  color: #ff8c1a;
  letter-spacing: 1px;
  font-size: 13px;
}
.stage-info {
  padding: 10px 12px;
}
.stage-info h3 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 900;
}
.stage-info h3 .tag {
  font-style: normal;
  background: var(--good);
  color: #fff;
  vertical-align: middle;
}
.stage-info p {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink-soft);
}
.stage-info .best {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
}

/* あそびかた */
.howto {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}
.howto-block {
  background: var(--paper-2);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
}
.howto h3 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 900;
}
.howto ul {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.7;
}
.pad-mark {
  display: inline-block;
  padding: 0 6px;
  border-radius: 4px;
  background: #2b2d42;
  color: #ffd23f;
}

/* 結果 */
.result-head {
  margin: 4px 0 2px;
  font-size: min(36px, 10cqw);
  font-weight: 900;
}
.result-head.clear {
  color: var(--primary);
  text-shadow: 3px 3px 0 var(--accent);
}
.result-head.fail {
  color: var(--ink);
}
.result-sub {
  margin: 0 0 12px;
  color: var(--ink-soft);
  font-weight: 800;
  font-size: 14px;
}
.result-rows {
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 4px 12px;
  margin-bottom: 14px;
}
.result-rows .row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px dashed #d9d2c2;
  font-size: 14px;
}
.result-rows .row:last-child {
  border-bottom: none;
}
.result-rows .row.total {
  font-size: 18px;
  color: var(--primary-dark);
}
.badge {
  display: inline-block;
  background: var(--accent);
  border: 3px solid var(--line);
  border-radius: 999px;
  padding: 2px 14px;
  font-weight: 900;
  transform: rotate(-4deg);
  animation: pop 0.6s ease infinite alternate;
}
@keyframes pop {
  to {
    transform: rotate(3deg) scale(1.08);
  }
}

/* ---------- HUD（プレイ中の表示） ---------- */
.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  padding: max(10px, env(safe-area-inset-top)) 10px 10px;
}
.hud-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 6px;
}
.hud-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}
.hud-right {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
}
.chip {
  display: inline-block;
  background: rgba(255, 255, 255, 0.92);
  border: 3px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
  font-weight: 800;
  font-size: 12px;
  box-shadow: 0 3px 0 var(--line);
  white-space: nowrap;
}
.chip b {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.hearts {
  display: flex;
  gap: 2px;
}
.heart {
  font-size: 24px;
  line-height: 1;
  color: rgba(43, 45, 66, 0.25);
  -webkit-text-stroke: 2px var(--line);
}
.heart.full {
  color: var(--danger);
  animation: beat 1s ease infinite;
}
@keyframes beat {
  50% {
    transform: scale(1.12);
  }
}
.hud-center {
  position: relative;
  text-align: center;
  background: rgba(255, 255, 255, 0.92);
  border: 3px solid var(--line);
  border-radius: 14px;
  padding: 1px 10px 3px;
  box-shadow: 0 4px 0 var(--line);
}
.timer-label {
  font-size: 10px;
  font-weight: 800;
  color: var(--ink-soft);
}
.timer {
  font-size: 24px;
  font-weight: 900;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.time-pop {
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  margin-top: 4px;
  font-size: 15px;
  font-weight: 900;
  color: rgba(239, 71, 111, 0.6);
  white-space: nowrap;
  opacity: 0;
}
.time-pop.show {
  animation: time-pop 1s ease-out;
}
@keyframes time-pop {
  0% {
    opacity: 1;
    transform: translate(-50%, -4px);
  }
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
}
.timer.warn {
  color: var(--danger);
  animation: blink 0.5s steps(2) infinite;
}
@keyframes blink {
  50% {
    opacity: 0.45;
  }
}
.icon-btn {
  pointer-events: auto;
  width: 40px;
  height: 40px;
  border: 3px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 3px 0 var(--line);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
}
.icon-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--line);
}


.zone-label {
  position: absolute;
  left: 50%;
  top: calc(max(10px, env(safe-area-inset-top)) + 96px);
  transform: translateX(-50%);
  background: var(--line);
  color: #fff;
  font-weight: 900;
  font-size: 14px;
  padding: 5px 16px;
  border-radius: 999px;
  opacity: 0;
  white-space: nowrap;
}
.zone-label.show {
  animation: zone 2.6s ease forwards;
}
@keyframes zone {
  0% {
    opacity: 0;
    transform: translate(-50%, -10px);
  }
  12%,
  80% {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  100% {
    opacity: 0;
  }
}

.banner {
  position: absolute;
  left: 50%;
  top: 30%;
  width: 100%;
  transform: translate(-50%, -50%) scale(0.6);
  text-align: center;
  opacity: 0;
  pointer-events: none;
}
.banner.show {
  animation: banner 0.35s cubic-bezier(0.2, 1.6, 0.4, 1) forwards;
}
@keyframes banner {
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}
.banner-main {
  font-size: min(64px, 13cqw);
  font-weight: 900;
  color: #fff;
  -webkit-text-stroke: 3px var(--line);
  paint-order: stroke fill;
  text-shadow: 0 5px 0 var(--line);
  white-space: nowrap;
}
.banner-sub {
  display: inline-block;
  margin-top: 6px;
  background: #fff;
  border: 3px solid var(--line);
  border-radius: 999px;
  padding: 3px 14px;
  font-size: 15px;
  font-weight: 900;
  white-space: nowrap;
}
.banner.cp {
  top: 19%;
}
.banner.cp .banner-main {
  color: #ff8c42;
  font-size: min(34px, 8cqw);
  -webkit-text-stroke-width: 2px;
  text-shadow: 0 3px 0 var(--line);
}
.banner.cp .banner-sub {
  font-size: 12px;
  margin-top: 2px;
  padding: 1px 10px;
}
.banner.goal .banner-main {
  color: var(--primary);
}
.banner.go .banner-main {
  color: var(--accent);
}
.banner.over .banner-main {
  color: #9aa1b5;
}

/* 操作ガイド（カウントダウン中に表示） */
.drag-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8%;
  text-align: center;
  font-weight: 900;
  color: var(--ink);
}
.drag-hint p {
  display: inline-block;
  margin: 6px 0 0;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.92);
  border: 3px solid var(--line);
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.4;
}
.drag-hint p.sub {
  display: block;
  width: fit-content;
  margin: 6px auto 0;
  font-size: 11px;
  padding: 2px 10px;
  border-width: 2px;
}
.drag-track {
  position: relative;
  width: 60%;
  height: 46px;
  margin: 0 auto;
  border-bottom: 4px dashed rgba(43, 45, 66, 0.4);
}
.drag-finger {
  position: absolute;
  left: 50%;
  bottom: -14px;
  font-size: 40px;
  animation: swipe 1.4s ease-in-out infinite;
}
@keyframes swipe {
  0%,
  100% {
    transform: translateX(-130%);
  }
  50% {
    transform: translateX(30%);
  }
}

/* 加速中は画面のふちがオレンジに光る */
.boost-fx {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: radial-gradient(ellipse at 50% 60%, transparent 55%, rgba(255, 140, 26, 0.55));
  transition: opacity 0.2s;
}
.app.boosting .boost-fx {
  opacity: 1;
  animation: boost-pulse 0.25s ease-in-out infinite alternate;
}
@keyframes boost-pulse {
  to {
    opacity: 0.6;
  }
}

.flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, transparent 40%, rgba(239, 71, 111, 0.55));
  opacity: 0;
}
.flash.on {
  animation: flash 0.45s ease-out;
}
@keyframes flash {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

/* ---------- セールゲージ / タイムセール ---------- */
.gauge {
  position: relative;
  width: 108px;
  height: 16px;
  border: 3px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  overflow: hidden;
  box-shadow: 0 3px 0 var(--line);
}
.gauge span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.15em;
  color: var(--ink);
}
.gauge-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #ffd166, #ff8c1a);
  transition: width 0.15s;
}
.gauge.full .gauge-fill,
.gauge.active .gauge-fill {
  background: linear-gradient(90deg, #ff8c1a, #ef476f, #ffd166, #ff8c1a);
  background-size: 200% 100%;
  animation: gauge-flow 0.6s linear infinite;
}
@keyframes gauge-flow {
  to {
    background-position: -200% 0;
  }
}
.btn-sale {
  position: absolute;
  right: 14px;
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 24px);
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: 4px solid var(--line);
  background: radial-gradient(circle at 35% 30%, #ffe08a, #ff8c1a 60%, #ef476f);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 900;
  line-height: 1.15;
  -webkit-text-stroke: 1px var(--line);
  box-shadow: 0 5px 0 var(--line);
  pointer-events: auto;
  touch-action: manipulation;
  animation: sale-pulse 0.7s ease-in-out infinite alternate;
}
.btn-sale:active {
  transform: translateY(3px) scale(0.97);
  box-shadow: 0 2px 0 var(--line);
}
@keyframes sale-pulse {
  to {
    transform: scale(1.08);
  }
}
.app.sale .boost-fx {
  opacity: 1;
  background: radial-gradient(ellipse at 50% 60%, transparent 50%, rgba(255, 209, 102, 0.6));
  animation: boost-pulse 0.18s ease-in-out infinite alternate;
}
.zone-label {
  top: calc(max(10px, env(safe-area-inset-top)) + 100px);
}

/* ---------- 設定・昼夜 ---------- */
.seg {
  display: flex;
  border: 3px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 3px 0 var(--line);
}
.seg button {
  flex: 1;
  min-height: 44px;
  border: none;
  border-left: 2px solid var(--line);
  background: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 900;
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
}
.seg button:first-child {
  border-left: none;
}
.seg button.on {
  background: var(--secondary);
  color: #fff;
}
.time-seg {
  margin: -4px auto 14px;
  max-width: 240px;
}
.setting {
  text-align: left;
  margin-bottom: 16px;
}
.setting h3 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 900;
}
.note {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--ink-soft);
}
.stage-thumb.night {
  filter: brightness(0.55) saturate(1.3) hue-rotate(200deg);
}
.route {
  margin-left: 8px;
  color: var(--ink-soft);
  font-weight: 800;
}
.share-img {
  display: block;
  width: 100%;
  max-height: 52cqh;
  object-fit: contain;
  border: 3px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

/* ---------- 小さい画面でもスクロールせずに収まるように（ステージ選択・結果） ---------- */
#screen-stage .menu-panel,
#screen-result .menu-panel {
  padding: 14px 14px 16px;
}
#screen-stage .screen-title {
  font-size: 20px;
  margin: 0 0 8px;
}
.time-seg {
  margin: 0 auto 10px;
}
.time-seg button {
  min-height: 36px;
}
.stage-list {
  gap: 8px;
  margin-bottom: 10px;
}
.stage-card {
  min-height: 0;
}
.stage-thumb {
  flex-basis: 58px;
  padding: 5px;
}
.stage-thumb span {
  font-size: 10px;
  padding: 1px 6px;
}
.stage-info {
  padding: 7px 10px;
}
.stage-info h3 {
  font-size: 16px;
  margin: 0 0 2px;
}
.stage-info .desc {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 11px;
}
.stage-info .best {
  margin-top: 2px;
  font-size: 12px;
}
#screen-stage .btn,
#screen-result .btn {
  min-height: 46px;
  font-size: 16px;
  padding: 8px 12px;
}
.badge {
  font-size: 13px;
  padding: 1px 12px;
}
.result-head {
  font-size: min(30px, 9cqw);
  margin: 2px 0 0;
}
.result-sub {
  margin: 0 0 8px;
  font-size: 12px;
}
.result-rows {
  padding: 2px 12px;
  margin-bottom: 10px;
}
.result-rows .row {
  padding: 3px 0;
  font-size: 12.5px;
}
.result-rows .row.total {
  font-size: 16px;
}
.btn-col.tight {
  gap: 8px;
}
.btn-row {
  display: flex;
  gap: 8px;
}
.btn-row .btn {
  flex: 1;
}
#screen-result .btn-small {
  min-height: 38px;
  font-size: 13px;
}
@media (max-height: 640px) {
  #screen-stage,
  #screen-result {
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
  .stage-info .desc {
    display: none;
  }
  .result-rows .row {
    padding: 2px 0;
    font-size: 12px;
  }
  .result-head {
    font-size: 26px;
  }
}
.btn-row .btn {
  white-space: nowrap;
  font-size: 15px;
}

/* ---------- 結果: 被害額（寿司打のようにシンプルに） ---------- */
.result-rows {
  text-align: center;
  padding: 10px 12px 12px;
}
.dmg-label {
  font-size: 13px;
  font-weight: 800;
  color: var(--ink-soft);
}
.dmg-yen {
  font-size: min(42px, 9cqw); /* 億単位でも1行に収まる大きさ */
  white-space: nowrap;
  font-weight: 900;
  color: var(--primary-dark);
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}
.dmg-rank {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 12px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--accent);
  font-size: 14px;
  font-weight: 900;
}
.dmg-line {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
}
