/* ドーンゾーン — 画面レイアウトと UI */
:root {
  --ink: #3b2a5c;
  --bg: #1f1545;
  --bg2: #2e1f66;
  --pink: #ff8fb8;
  --pink-d: #e0508a;
  --yellow: #ffe066;
  --mint: #7fffd4;
  --sky: #7fd4ff;
  --panel: #fff8fc;
  --font: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Hiragino Sans", "BIZ UDPGothic", "Yu Gothic UI", "Meiryo", "Noto Sans CJK JP", "Noto Sans JP", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 20%, var(--bg2), var(--bg) 70%);
  color: #fff;
  font-family: var(--font);
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#stage-wrap {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#screen {
  position: relative;
  line-height: 0;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08), 0 8px 30px rgba(0, 0, 0, 0.35);
}

#game {
  display: block;
  touch-action: none;
  background: #1c1a4a;
}

#corner {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 6px;
  z-index: 5;
}

.corner-btn {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.75);
  background: rgba(59, 42, 92, 0.55);
  color: #fff;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}

.corner-btn svg {
  width: 20px;
  height: 20px;
  fill: #fff;
  stroke: #fff;
}

.corner-btn .spk {
  stroke: none;
}

.corner-btn .wave,
.corner-btn .x {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
}

.corner-btn .x {
  display: none;
}

.corner-btn.muted .wave {
  display: none;
}

.corner-btn.muted .x {
  display: inline;
}

.corner-btn:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 2px;
}

/* ---------- タッチ操作パッド ---------- */
#pad {
  display: none;
}

#app.touch #pad {
  display: flex;
}

#app.touch.portrait #pad {
  position: relative;
  flex: 1 1 auto;
  min-height: 150px;
  background: linear-gradient(180deg, #34246f 0%, #241a52 100%);
  border-top: 2px solid rgba(255, 255, 255, 0.15);
}

#app.touch.landscape #pad {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

#stick-zone {
  position: relative;
  flex: 1 1 55%;
  touch-action: none;
  pointer-events: auto;
  overflow: hidden;
}

#app.touch.landscape #stick-zone {
  position: absolute;
  left: 0;
  top: 18%;
  bottom: 0;
  width: 46%;
}

.pad-label {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 15px;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 0 rgba(20, 10, 50, 0.7);
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 0.2s;
}

#app.touch.portrait #stick-zone::before {
  content: "";
  position: absolute;
  inset: 14px 10px;
  border: 2px dashed rgba(255, 255, 255, 0.3);
  border-radius: 22px;
  pointer-events: none;
}

#stick-base.on + .pad-label {
  opacity: 0;
}

#app.touch.landscape .pad-label {
  top: auto;
  bottom: 14px;
  left: 16px;
  transform: none;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

#app.touch.landscape #stick-zone.used .pad-label {
  opacity: 0;
  transition: opacity 0.6s;
}

#stick-base {
  position: absolute;
  left: 0;
  top: 0;
  width: 92px;
  height: 92px;
  margin: -46px 0 0 -46px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.55);
  background: radial-gradient(circle, rgba(255, 255, 255, 0.12), rgba(255, 143, 184, 0.18));
  opacity: 0;
  transition: opacity 0.12s;
  pointer-events: none;
}

#stick-base.on {
  opacity: 1;
}

#stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 35% 30%, #ffffff, #ffc2da 60%, #ff8fb8);
  border: 2px solid var(--ink);
}

#btn-zone {
  position: relative;
  flex: 1 1 45%;
  pointer-events: none;
}

#app.touch.landscape #btn-zone {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 44%;
  height: 72%;
}

.tbtn {
  position: absolute;
  display: grid;
  place-items: center;
  text-align: center;
  border-radius: 50%;
  font-weight: 900;
  color: #fff;
  line-height: 1.1;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
  border: 3px solid rgba(255, 255, 255, 0.85);
  pointer-events: auto;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  transition: transform 0.05s, filter 0.05s;
}

.tbtn.down {
  transform: scale(0.92);
  filter: brightness(1.25);
}

.tbtn.off {
  opacity: 0.35;
  filter: grayscale(0.8);
}

.tbtn.shot {
  width: 96px;
  height: 96px;
  right: 18px;
  bottom: 26%;
  font-size: 16px;
  background: radial-gradient(circle at 35% 30%, #ffb3d1, #ff5c9a 70%);
  box-shadow: 0 4px 0 #b8246a;
}

.tbtn.bomb {
  width: 74px;
  height: 74px;
  right: 124px;
  bottom: 12%;
  font-size: 15px;
  white-space: pre-line;
  background: radial-gradient(circle at 35% 30%, #bfe4ff, #4a7ae0 70%);
  box-shadow: 0 4px 0 #2a4a9e;
}

.tbtn.swap {
  width: 52px;
  height: 52px;
  right: 138px;
  bottom: calc(12% + 90px);
  font-size: 11px;
  background: radial-gradient(circle at 35% 30%, #fff3b0, #e8a820 75%);
  box-shadow: 0 3px 0 #a8660f;
}

#app.touch.landscape .tbtn {
  opacity: 0.78;
}

#app.touch.landscape .tbtn.off {
  opacity: 0.3;
}

/* メニュー表示中はタッチパッドを隠す */
#app.menu-open #pad .tbtn,
#app.menu-open #pad .pad-label,
#app.menu-open #stick-base,
#app.menu-open #stick-zone::before {
  visibility: hidden;
}

#app.touch.landscape.menu-open #pad {
  display: none;
}

#app.touch.landscape .tbtn.shot {
  width: 84px;
  height: 84px;
  right: 16px;
  bottom: 24px;
}

#app.touch.landscape .tbtn.bomb {
  width: 64px;
  height: 64px;
  right: 110px;
  bottom: 14px;
}

#app.touch.landscape .tbtn.swap {
  width: 46px;
  height: 46px;
  right: 116px;
  bottom: 92px;
}

/* ---------- オーバーレイ共通 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  touch-action: manipulation;
}

.overlay[hidden] {
  display: none !important;
}

.overlay.dim {
  background: rgba(24, 12, 54, 0.62);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.overlay.behind {
  visibility: hidden;
}

.panel {
  background: linear-gradient(180deg, #fffafd, #ffeef7);
  color: var(--ink);
  border-radius: 22px;
  border: 3px solid #ffffff;
  box-shadow: 0 0 0 3px var(--pink), 0 14px 40px rgba(0, 0, 0, 0.4);
  padding: 18px 20px;
  width: min(420px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.panel.small {
  width: min(340px, 100%);
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 22px;
  color: var(--pink-d);
  letter-spacing: 0.08em;
}

.panel h2.big {
  font-size: 30px;
  letter-spacing: 0.06em;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 9px;
  width: 100%;
  max-width: 300px;
  margin: 6px 0;
}

.menu.row {
  flex-direction: row;
  justify-content: center;
  max-width: none;
}

.btn {
  font-family: var(--font);
  font-weight: 800;
  font-size: 16px;
  color: var(--ink);
  background: linear-gradient(180deg, #ffffff, #f1e8ff);
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 10px 16px;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--ink);
  touch-action: manipulation;
  transition: transform 0.06s;
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ink);
}

.btn.primary {
  background: linear-gradient(180deg, #ffd0e4, #ff8fb8);
}

.btn.warn {
  background: linear-gradient(180deg, #fff3d6, #ffc98a);
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn:focus-visible,
.tab:focus-visible,
.card:focus-visible {
  outline: 4px solid var(--yellow);
  outline-offset: 2px;
}

.btn:focus:not(:focus-visible) {
  outline: none;
}

.keys-hint {
  font-size: 12px;
  opacity: 0.75;
  margin: 8px 0 0;
}

#app.touch .keys-hint {
  display: none;
}

.rotate-hint {
  display: none;
  font-size: 12px;
  margin: 8px 0 0;
  color: #fff3b0;
}

#app.touch.portrait .rotate-hint {
  display: block;
}

.note,
.status {
  font-size: 12px;
  opacity: 0.8;
  margin: 8px 0 0;
}

.ask {
  font-size: 17px;
  font-weight: 800;
  margin: 4px 0 14px;
}

/* ---------- タイトル ---------- */
.overlay.title {
  flex-direction: column;
  background: linear-gradient(180deg, rgba(40, 20, 90, 0.05) 0%, rgba(40, 20, 90, 0.25) 55%, rgba(30, 14, 70, 0.72) 100%);
}

.title-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-height: 100%;
  overflow: auto;
  touch-action: pan-y;
  padding: 4px;
}

.kicker {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #fff;
  background: rgba(59, 42, 92, 0.55);
  padding: 3px 12px;
  border-radius: 999px;
}

.logo {
  margin: 6px 0 0;
  line-height: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.logo-main {
  font-size: clamp(38px, 9vw, 78px);
  font-weight: 900;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, #fffbe0 0%, #ffe066 35%, #ff9f43 60%, #ff5c9a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 2px var(--ink);
  filter: drop-shadow(0 4px 0 var(--ink)) drop-shadow(0 8px 12px rgba(0, 0, 0, 0.35));
}

.logo-en {
  margin-top: 4px;
  font-size: clamp(13px, 2.6vw, 20px);
  font-weight: 900;
  letter-spacing: 0.5em;
  color: #bff4ff;
  text-shadow: 0 2px 0 var(--ink);
}

.subtitle {
  margin: 8px 0 10px;
  font-size: clamp(14px, 3vw, 20px);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 0 var(--ink), 0 0 10px rgba(255, 143, 184, 0.8);
}

.title .menu {
  max-width: 260px;
}

.hiscore {
  margin: 8px 0 0;
  font-weight: 900;
  color: var(--yellow);
  text-shadow: 0 2px 0 var(--ink);
}

.disclaimer {
  position: absolute;
  left: 50%;
  bottom: max(6px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: max-content;
  max-width: min(94%, 680px);
  margin: 0;
  padding: 3px 12px;
  border-radius: 12px;
  background: rgba(24, 12, 56, 0.62);
  font-size: 11.5px;
  line-height: 1.45;
  text-align: center;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.6);
}

@media (max-height: 520px) {
  .title .menu {
    display: grid;
    grid-template-columns: 1fr 1fr;
    max-width: 440px;
  }
  .subtitle {
    margin: 4px 0 6px;
  }
  .disclaimer {
    font-size: 10.5px;
    padding: 2px 10px;
  }
}

/* ---------- あそびかた ---------- */
.panel.howto {
  width: min(640px, 100%);
  height: min(640px, 100%);
}

.howto-scroll {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
  text-align: left;
  width: 100%;
  flex: 1 1 auto;
  padding: 0 6px;
  font-size: 14px;
  line-height: 1.6;
}

.howto-scroll h3 {
  margin: 14px 0 4px;
  font-size: 15px;
  color: #7a3aa0;
  border-left: 5px solid var(--pink);
  padding-left: 8px;
}

.howto-scroll ul {
  margin: 0;
  padding-left: 1.2em;
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 5px;
  margin: 0 1px;
  border-radius: 6px;
  border: 2px solid var(--ink);
  background: #fff;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  line-height: 1.5;
}

.art-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 2px 0 6px;
}

.art {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(180deg, #bfeaff, #ffe3f3);
  border-radius: 12px;
  padding: 4px 8px;
  border: 2px solid #fff;
}

.art figcaption {
  font-size: 11px;
  font-weight: 800;
}

/* ---------- ショップ ---------- */
.overlay.shop {
  background: radial-gradient(ellipse at 50% 0%, rgba(255, 200, 225, 0.35), rgba(30, 14, 70, 0.8) 70%);
}

.shop-panel {
  width: min(860px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #fffafd, #fff0f7);
  color: var(--ink);
  border-radius: 22px;
  border: 3px solid #fff;
  box-shadow: 0 0 0 3px #ff4d5e, 0 14px 40px rgba(0, 0, 0, 0.45);
  padding: 10px 14px 10px;
  overflow: hidden;
}

.shop-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.shop-keeper {
  flex: 0 0 auto;
}

.shop-title {
  flex: 1 1 auto;
  min-width: 0;
}

.shop-title h2 {
  margin: 0;
  font-size: 20px;
  color: #e0304f;
}

.shop-say {
  margin: 2px 0 0;
  font-size: 13px;
  font-weight: 700;
  background: #fff;
  border: 2px solid #ffc2cc;
  border-radius: 12px;
  padding: 3px 10px;
  display: inline-block;
}

.shop-coins {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 22px;
  font-weight: 900;
  color: #a86a00;
  background: #fff6c8;
  border: 3px solid #ffd23f;
  border-radius: 14px;
  padding: 4px 12px;
}

.coin-ico {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fffbe0, #ffcf40 60%, #d89a00);
  border: 2px solid #8f6100;
}

.shop-tabs {
  display: flex;
  gap: 8px;
  margin: 8px 0 6px;
}

.tab {
  font-family: var(--font);
  font-size: 16px;
  font-weight: 900;
  padding: 6px 22px;
  border-radius: 12px 12px 4px 4px;
  border: 3px solid var(--ink);
  background: #eadcff;
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
}

.tab.on {
  background: linear-gradient(180deg, #ffd0e4, #ff8fb8);
}

.shop-body {
  display: flex;
  gap: 10px;
  min-height: 0;
  flex: 1 1 auto;
}

.shop-grid {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 6px;
  align-content: start;
  overflow-y: auto;
  touch-action: pan-y;
  overscroll-behavior: contain;
  padding: 4px;
  min-height: 0;
}

.shop-grid .cat {
  grid-column: 1 / -1;
  font-size: 12px;
  font-weight: 900;
  color: #7a3aa0;
  margin-top: 4px;
}

.card {
  position: relative;
  display: grid;
  grid-template-columns: 30px 1fr;
  grid-template-rows: auto auto;
  column-gap: 6px;
  align-items: center;
  text-align: left;
  font-family: var(--font);
  color: var(--ink);
  background: #fff;
  border: 2px solid #d9c8f0;
  border-radius: 12px;
  padding: 5px 6px;
  cursor: pointer;
  touch-action: manipulation;
  min-height: 48px;
}

.card .ico {
  grid-row: 1 / 3;
}

.cname {
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
}

.cprice {
  font-size: 13px;
  font-weight: 900;
  color: #a86a00;
}

.cprice.short {
  color: #d0305a;
}

.cprice.plus {
  color: #1a9a6a;
}

.card.dim {
  background: #f4eef8;
  opacity: 0.75;
}

.card.sel {
  border-color: var(--pink-d);
  box-shadow: 0 0 0 3px #ffc2da;
  background: #fff4fa;
}

.badge {
  position: absolute;
  top: -6px;
  right: -4px;
  font-size: 9.5px;
  font-weight: 900;
  color: #fff;
  background: #1a9a6a;
  border-radius: 8px;
  padding: 1px 5px;
}

.empty {
  grid-column: 1 / -1;
  font-size: 13px;
  opacity: 0.8;
}

.shop-detail {
  flex: 0 0 220px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #fff;
  border: 2px solid #ffc2da;
  border-radius: 14px;
  padding: 10px;
}

.detail-name {
  font-size: 16px;
  font-weight: 900;
  color: var(--pink-d);
}

.detail-desc {
  font-size: 13px;
  line-height: 1.45;
  flex: 1 1 auto;
}

.detail-price {
  font-size: 13px;
  font-weight: 900;
  color: #a86a00;
}

.deal {
  width: 100%;
}

.shop-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.equip {
  flex: 1 1 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 11.5px;
  font-weight: 700;
  opacity: 0.9;
}

.btn.exit {
  flex: 0 0 auto;
  background: linear-gradient(180deg, #d6f7ff, #7fd4ff);
}

.shop-panel .keys-hint {
  text-align: center;
  margin-top: 6px;
}

@media (max-width: 640px), (max-height: 480px) {
  .shop-panel {
    padding: 8px 8px;
    border-radius: 16px;
  }
  .shop-keeper {
    display: none;
  }
  .shop-title h2 {
    font-size: 16px;
  }
  .shop-say {
    font-size: 11.5px;
  }
  .shop-coins {
    font-size: 18px;
    padding: 2px 8px;
  }
  .shop-body {
    flex-direction: column;
  }
  .shop-grid {
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  }
  .shop-detail {
    flex: 0 0 auto;
    padding: 6px 8px;
    gap: 3px;
  }
  .detail-desc {
    font-size: 12px;
  }
  .equip {
    font-size: 10.5px;
  }
}

@media (orientation: landscape) and (max-height: 480px) {
  .shop-body {
    flex-direction: row;
  }
  .shop-detail {
    flex: 0 0 180px;
  }
}

/* ---------- 結果 ---------- */
.result {
  font-weight: 800;
  margin: 0 0 8px;
}

.results {
  display: grid;
  grid-template-columns: auto auto;
  gap: 2px 16px;
  margin: 10px 0;
  font-size: 14px;
}

.results dt {
  text-align: right;
  opacity: 0.8;
}

.results dd {
  margin: 0;
  text-align: left;
  font-weight: 900;
}

.credit {
  font-size: 11px;
  opacity: 0.75;
  margin: 10px 0 0;
}

.noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
}
