/* うさタワーバトル — ピンクと そらいろ、まるくて ぷっくり */
:root {
  --ink: #4a3428;
  --ink-soft: #7a6355;
  --pink: #ff7aa8;
  --pink-deep: #e2477f;
  --pink-pale: #ffe9f1;
  --sky: #69b8ff;
  --sky-deep: #2f7fd1;
  --mint: #59cfa6;
  --mint-deep: #2a9c76;
  --butter: #ffd45e;
  --butter-deep: #d99a12;
  --p0: #ff6f9f;
  --p1: #5aa9ff;
  --card: rgba(255, 255, 255, 0.92);
  --font: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "BIZ UDPGothic", "Yu Gothic", sans-serif;
  --font-cute: "Hachi Maru Pop", "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", sans-serif;
  --st: env(safe-area-inset-top, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  --sl: env(safe-area-inset-left, 0px);
  --sr: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #cfeeff;
  color: var(--ink);
  font-family: var(--font);
  font-weight: 800;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
  word-break: auto-phrase;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  padding: 0;
  touch-action: manipulation;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid var(--sky-deep);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

/* ---------- ボタン ---------- */
.big-btn,
.mid-btn {
  --c: var(--pink);
  --d: var(--pink-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  padding: 10px 18px;
  border-radius: 22px;
  background: var(--c);
  color: #fff;
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  box-shadow: 0 5px 0 var(--d), 0 10px 22px rgba(120, 60, 90, 0.18);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.12);
  transition: transform 0.08s, box-shadow 0.08s;
}

.mid-btn {
  min-height: 48px;
  font-size: 1rem;
  border-radius: 18px;
}

.big-btn:active,
.mid-btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--d), 0 4px 10px rgba(120, 60, 90, 0.16);
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.ico-svg {
  flex: none;
  width: 30px;
  height: 30px;
  color: #fff;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.12));
}

.tile .ico-svg {
  width: 34px;
  height: 34px;
  margin-bottom: 2px;
}

.btn-sky .ico-svg {
  --eye: var(--sky);
}

.btn-butter .ico-svg {
  color: #fff8e0;
  filter: drop-shadow(0 2px 0 rgba(160, 110, 0, 0.25));
}

.ico-sm {
  width: 18px;
  height: 18px;
  margin-right: 5px;
  vertical-align: -3px;
  color: var(--pink);
}

.big-btn .ico {
  font-size: 1.35rem;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.1));
}

.btn-pink {
  --c: var(--pink);
  --d: var(--pink-deep);
}
.btn-sky {
  --c: var(--sky);
  --d: var(--sky-deep);
}
.btn-mint {
  --c: var(--mint);
  --d: var(--mint-deep);
}
.btn-butter {
  --c: var(--butter);
  --d: var(--butter-deep);
  color: #6b4a00;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

.big-btn:disabled,
.mid-btn:disabled {
  filter: grayscale(0.6) opacity(0.6);
  pointer-events: none;
}

.sm-btn {
  padding: 9px 16px;
  border-radius: 999px;
  background: #fff;
  color: var(--ink-soft);
  font-size: 0.92rem;
  box-shadow: 0 3px 0 #ecd9df, 0 6px 14px rgba(120, 60, 90, 0.12);
}

.sm-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #ecd9df;
}

.round-btn {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: 0 3px 0 #ecd9df, 0 6px 16px rgba(120, 60, 90, 0.16);
  pointer-events: auto;
}

.round-btn .bars,
.round-btn .bars::before,
.round-btn .bars::after {
  display: block;
  width: 20px;
  height: 3.5px;
  border-radius: 3px;
  background: var(--ink-soft);
  position: relative;
}
.round-btn .bars::before,
.round-btn .bars::after {
  content: "";
  position: absolute;
  left: 0;
}
.round-btn .bars::before {
  top: -7px;
}
.round-btn .bars::after {
  top: 7px;
}

/* ---------- 画面（重ねる もの） ---------- */
.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
}

.sheet {
  display: grid;
  place-items: center;
  padding: calc(16px + var(--st)) 16px calc(16px + var(--sb));
  background: rgba(255, 233, 241, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fade-in 0.18s ease-out;
  overflow-y: auto;
}

.panel {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  width: min(420px, 100%);
  padding: 24px 20px 20px;
  border-radius: 30px;
  background: var(--card);
  box-shadow: 0 18px 50px rgba(160, 70, 110, 0.22), inset 0 0 0 3px #fff;
  animation: pop-in 0.28s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.panel h2 {
  margin: 0 0 4px;
  text-align: center;
  font-family: var(--font-cute);
  font-weight: 400;
  font-size: 1.55rem;
  color: var(--pink-deep);
}

.panel .back {
  align-self: center;
  margin-top: 4px;
}

.small-note {
  margin: 0;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--ink-soft);
}

.err {
  min-height: 1.2em;
  margin: 0;
  text-align: center;
  color: #e0365f;
  font-size: 0.9rem;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes pop-in {
  from {
    transform: scale(0.85) translateY(14px);
    opacity: 0;
  }
}

/* ---------- タイトル ---------- */
.title {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: calc(28px + var(--st)) 18px calc(18px + var(--sb));
  pointer-events: none;
}

.title > * {
  pointer-events: auto;
}

.title-top {
  text-align: center;
  animation: drop-in 0.7s cubic-bezier(0.2, 1.5, 0.4, 1) both;
}

.logo {
  margin: 0;
  font-family: var(--font-cute);
  font-weight: 400;
  line-height: 1.05;
  font-size: clamp(2.6rem, 13vw, 4.4rem);
  letter-spacing: 0.02em;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 0.12em;
  filter: drop-shadow(0 6px 0 rgba(200, 80, 130, 0.25));
}

.logo span {
  -webkit-text-stroke: 0.16em #fff;
  paint-order: stroke fill;
  display: inline-block;
}

.logo-usa {
  color: var(--pink);
  animation: bob 2.4s ease-in-out infinite;
}
.logo-tower {
  color: var(--sky);
  animation: bob 2.4s ease-in-out 0.2s infinite;
}
.logo-battle {
  color: var(--butter-deep);
  width: 100%;
  font-size: 0.8em;
  animation: bob 2.4s ease-in-out 0.4s infinite;
}

.logo {
  position: relative;
}

.logo-mascot {
  position: absolute;
  right: -6px;
  bottom: -4px;
  width: clamp(48px, 13vw, 66px);
  height: auto;
  transform: rotate(9deg);
  filter: drop-shadow(0 4px 6px rgba(160, 70, 110, 0.25));
  animation: mascot 2.6s ease-in-out infinite;
}

@keyframes mascot {
  0%,
  100% {
    transform: rotate(9deg) translateY(0);
  }
  50% {
    transform: rotate(3deg) translateY(-6px);
  }
}

.logo-sub {
  margin: 8px 0 0;
  font-size: 0.95rem;
  color: var(--pink-deep);
  text-shadow: 0 0 6px #fff, 0 0 12px #fff;
}

@keyframes bob {
  50% {
    transform: translateY(-5px) rotate(-1.5deg);
  }
}

@keyframes drop-in {
  from {
    transform: translateY(-60px) scale(0.8);
    opacity: 0;
  }
}

.title-menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(400px, 100%);
  padding: 14px;
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 16px 40px rgba(120, 80, 140, 0.18);
  animation: rise-in 0.6s cubic-bezier(0.2, 1.3, 0.4, 1) 0.15s both;
}

@keyframes rise-in {
  from {
    transform: translateY(80px);
    opacity: 0;
  }
}

.mode-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 86px;
  padding: 8px 4px;
  border-radius: 20px;
  background: var(--c);
  color: #fff;
  font-size: 0.86rem;
  line-height: 1.25;
  font-weight: 900;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.12);
  box-shadow: 0 5px 0 var(--d), 0 10px 20px rgba(120, 60, 90, 0.16);
  transition: transform 0.08s, box-shadow 0.08s;
}

.tile .ico {
  font-size: 1.6rem;
  line-height: 1.2;
}

.tile:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--d);
}

.tile.btn-butter {
  color: #6b4a00;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

.title-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.title-best {
  margin: 0;
  min-height: 1em;
  text-align: center;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.privacy {
  position: absolute;
  right: calc(10px + var(--sr));
  bottom: calc(6px + var(--sb));
  font-size: 0.68rem;
  font-weight: 500;
  color: rgba(74, 52, 40, 0.38);
  text-decoration: none;
}

.privacy.in-panel {
  position: static;
  align-self: center;
}

/* ---------- CPU ---------- */
.level-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.level-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-radius: 20px;
  background: #fff;
  box-shadow: inset 0 0 0 3px #ffd3e0, 0 4px 0 #f3c4d4;
  font-size: 1.15rem;
}

.level-btn small {
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.level-btn:active {
  transform: translateY(3px);
  box-shadow: inset 0 0 0 3px #ffd3e0;
}

#scr-solo .level-btn b {
  color: var(--butter-deep);
}

#scr-solo .level-btn.daily b {
  color: var(--pink-deep);
}

#scr-solo .level-btn small {
  text-align: right;
}

.level-btn[data-level="easy"] b {
  color: var(--mint-deep);
}
.level-btn[data-level="normal"] b {
  color: var(--sky-deep);
}
.level-btn[data-level="hard"] b {
  color: var(--pink-deep);
}

/* ---------- オンライン ---------- */
.me-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 20px;
  background: var(--pink-pale);
}

.me-icon {
  flex: none;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 0 0 3px #fff, 0 3px 0 4px #f3c4d4;
}

.me-icon img,
.pcard-ava img,
.wait-usa img,
.vs-side img,
.icon-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.me-name {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.me-name input,
.code-input {
  width: 100%;
  padding: 8px 12px;
  border: 0;
  border-radius: 12px;
  background: #fff;
  font: inherit;
  font-size: 1.1rem;
  color: var(--ink);
  box-shadow: inset 0 0 0 2px #ffd3e0;
  -webkit-user-select: text;
  user-select: text;
}

.code-input {
  font-size: 2.4rem;
  text-align: center;
  letter-spacing: 0.3em;
  padding: 10px;
  font-weight: 900;
}

.friend-box {
  padding: 12px;
  border-radius: 20px;
  background: #f1f8ff;
}

.friend-title {
  margin: 0 0 8px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--sky-deep);
}

.friend-row,
.share-row {
  display: flex;
  gap: 10px;
}

.wait-panel {
  align-items: center;
  text-align: center;
}

.wait-usa {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 0 0 4px #fff, 0 6px 0 6px #ffd3e0;
  animation: hop 0.9s ease-in-out infinite;
}

@keyframes hop {
  0%,
  100% {
    transform: translateY(0) rotate(-4deg);
  }
  50% {
    transform: translateY(-12px) rotate(4deg);
  }
}

.room-box {
  width: 100%;
  padding: 12px;
  border-radius: 20px;
  background: #fff7d6;
}

.room-code {
  margin: 0 0 10px;
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: 0.25em;
  color: var(--butter-deep);
  text-indent: 0.25em;
}

/* ---------- VS ---------- */
.vs-screen {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 4vw;
  background: linear-gradient(115deg, rgba(255, 111, 159, 0.85) 0 49.6%, rgba(90, 169, 255, 0.85) 50.4% 100%);
  animation: fade-in 0.2s;
}

.vs-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 1.15rem;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.15);
}

.vs-side img {
  width: min(32vw, 150px);
  height: min(32vw, 150px);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 5px #fff, 0 10px 30px rgba(0, 0, 0, 0.2);
}

.vs-left {
  animation: from-left 0.5s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.vs-right {
  animation: from-right 0.5s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.vs-mark {
  font-family: var(--font-cute);
  font-size: clamp(2.6rem, 12vw, 4.5rem);
  color: #fff;
  -webkit-text-stroke: 0.12em var(--butter-deep);
  paint-order: stroke fill;
  animation: vs-pop 0.6s cubic-bezier(0.2, 1.8, 0.4, 1) 0.25s both;
}

.vs-first {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(18% + var(--sb));
  margin: 0;
  text-align: center;
  color: #fff;
  font-size: 1.2rem;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
  animation: fade-in 0.4s 0.6s both;
}

@keyframes from-left {
  from {
    transform: translateX(-60vw);
  }
}
@keyframes from-right {
  from {
    transform: translateX(60vw);
  }
}
@keyframes vs-pop {
  from {
    transform: scale(3) rotate(-20deg);
    opacity: 0;
  }
}

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.hud-top {
  position: absolute;
  top: calc(10px + var(--st));
  left: calc(10px + var(--sl));
  right: calc(10px + var(--sr));
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.players {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
}

.pcard {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  max-width: 47%;
  padding: 3px 9px 3px 3px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: 0 4px 14px rgba(120, 60, 90, 0.14);
  transition: transform 0.25s, box-shadow 0.25s, opacity 0.25s;
  opacity: 0.72;
  transform: scale(0.94);
}

.pcard[data-seat="1"] {
  flex-direction: row-reverse;
  padding: 3px 3px 3px 9px;
  text-align: right;
}

.pcard.active {
  opacity: 1;
  transform: scale(1.04);
  box-shadow: 0 0 0 3px var(--pc), 0 6px 18px rgba(120, 60, 90, 0.22);
}

.pcard[data-seat="0"] {
  --pc: var(--p0);
}
.pcard[data-seat="1"] {
  --pc: var(--p1);
}

.pcard-ava {
  position: relative;
  flex: none;
  width: 40px;
  height: 40px;
}

.pcard-ava img {
  position: absolute;
  inset: 3px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #fff;
}

.pcard-ava .ring {
  position: absolute;
  inset: 0;
  width: 40px;
  height: 40px;
  transform: rotate(-90deg);
}

.pcard-ava .ring circle {
  fill: none;
  stroke: var(--pc);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 125.66;
  stroke-dashoffset: 125.66;
}

.pcard.active .ring circle {
  stroke-dashoffset: var(--ring, 0);
}

.pcard.away {
  filter: grayscale(1);
}

.pcard-txt {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.15;
}

.pcard-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 0.78rem;
}

.pcard-sub {
  font-size: 0.68rem;
  color: var(--ink-soft);
  white-space: nowrap;
}

.vs {
  flex: none;
  font-family: var(--font-cute);
  font-size: 0.95rem;
  color: #fff;
  -webkit-text-stroke: 0.18em var(--pink);
  paint-order: stroke fill;
}

.solo-score {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  text-shadow: 0 0 6px #fff, 0 0 12px #fff, 0 0 18px #fff;
}

.ss-count b {
  font-size: 2.6rem;
  font-weight: 900;
  color: var(--pink-deep);
}

.ss-count span {
  font-size: 1rem;
  color: var(--pink-deep);
}

.ss-h {
  margin-top: 4px;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.ss-h small {
  margin-left: 6px;
  color: var(--butter-deep);
}

.next {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 52px;
  transition: transform 0.2s;
  padding: 4px 4px 6px;
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 4px 14px rgba(120, 60, 90, 0.14);
  font-size: 0.66rem;
  color: var(--ink-soft);
}

.next img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.hud-top .round-btn {
  flex: none;
}

.turn-banner {
  position: absolute;
  top: calc(74px + var(--st));
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 18px;
  border-radius: 999px;
  background: var(--card);
  font-size: 0.95rem;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(120, 60, 90, 0.14);
  opacity: 0;
  transition: opacity 0.2s;
}

.turn-banner.show {
  opacity: 1;
  animation: banner-pop 0.4s cubic-bezier(0.2, 1.6, 0.4, 1);
}

@keyframes banner-pop {
  from {
    transform: translateX(-50%) scale(0.6);
  }
}

.timer {
  position: absolute;
  top: calc(112px + var(--st));
  left: 50%;
  transform: translateX(-50%);
  min-width: 44px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  text-align: center;
  font-size: 1.05rem;
  font-weight: 900;
  color: var(--ink-soft);
}

.timer.hurry {
  color: #fff;
  background: #ff5c7a;
  animation: pulse 0.5s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    transform: translateX(-50%) scale(1.15);
  }
}

.hud-bottom {
  position: absolute;
  left: calc(14px + var(--sl));
  right: calc(14px + var(--sr));
  bottom: calc(16px + var(--sb));
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 12px;
}

.hud-bottom > * {
  pointer-events: auto;
}

.rotate-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff 0, #ffe4ee 70%);
  color: var(--pink-deep);
  box-shadow: 0 5px 0 #f0b9cc, 0 10px 24px rgba(160, 60, 100, 0.25), inset 0 0 0 3px #fff;
  font-size: 0.78rem;
  transition: transform 0.08s;
}

.rotate-btn svg {
  width: 38px;
  height: 38px;
  margin-bottom: 1px;
}

.rotate-btn:active {
  transform: translateY(4px) rotate(20deg);
  box-shadow: 0 1px 0 #f0b9cc;
}

.rotate-btn:disabled,
.drop-btn:disabled {
  opacity: 0.45;
}

.drop-btn {
  min-width: 120px;
  height: 64px;
  padding: 0 22px;
  border-radius: 32px;
  background: var(--sky);
  color: #fff;
  font-size: 1.2rem;
  box-shadow: 0 5px 0 var(--sky-deep), 0 10px 24px rgba(40, 90, 160, 0.25);
}

.drop-btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--sky-deep);
}

.stamp-btn {
  margin-right: auto;
  width: 54px;
  height: 54px;
  font-size: 1.5rem;
}

.stamps {
  position: absolute;
  left: 0;
  bottom: 66px;
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 8px;
  padding: 10px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 10px 30px rgba(120, 60, 90, 0.2);
  animation: pop-in 0.2s;
}

.stamps button {
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--pink-pale);
  font-size: 0.9rem;
  white-space: nowrap;
}

.bubbles {
  position: absolute;
  inset: 0;
}

.bubble {
  position: absolute;
  top: calc(64px + var(--st));
  padding: 8px 14px;
  border-radius: 18px;
  background: #fff;
  font-size: 1rem;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(120, 60, 90, 0.2);
  animation: bubble 2.4s ease-out forwards;
}

.bubble.left {
  left: calc(16px + var(--sl));
}
.bubble.right {
  right: calc(16px + var(--sr));
}

@keyframes bubble {
  0% {
    transform: scale(0.4) translateY(-6px);
    opacity: 0;
  }
  10% {
    transform: scale(1.08);
    opacity: 1;
  }
  16% {
    transform: scale(1);
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(8px);
  }
}

.hint {
  position: absolute;
  left: 50%;
  bottom: calc(118px + var(--sb));
  transform: translateX(-50%);
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(74, 52, 40, 0.62);
  color: #fff;
  font-size: 0.82rem;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s;
}

.hint.show {
  opacity: 1;
}

/* ---------- けっか ---------- */
.result-screen {
  background: rgba(255, 233, 241, 0.25);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  align-items: end;
}

.result-panel {
  text-align: center;
  align-items: center;
}

.res-kicker {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.res-title {
  font-size: 2.3rem !important;
}

.res-title.win {
  color: var(--pink-deep) !important;
  animation: win-pop 0.8s cubic-bezier(0.2, 1.8, 0.4, 1);
}

.res-title.lose {
  color: var(--sky-deep) !important;
}

@keyframes win-pop {
  from {
    transform: scale(0.3) rotate(-10deg);
  }
}

.res-stats {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.stat {
  min-width: 92px;
  padding: 10px 12px;
  border-radius: 18px;
  background: var(--pink-pale);
}

.stat small {
  display: block;
  font-size: 0.72rem;
  color: var(--ink-soft);
}

.stat b {
  font-size: 1.5rem;
}

.res-new {
  margin: 0;
  padding: 4px 14px;
  border-radius: 999px;
  background: var(--butter);
  color: #6b4a00;
  animation: pulse-s 0.8s ease-in-out infinite;
}

@keyframes pulse-s {
  50% {
    transform: scale(1.08);
  }
}

.res-btns {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  margin-top: 4px;
}

/* ---------- あそびかた・せってい ---------- */
.howto-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  counter-reset: h;
}

.howto-list li {
  position: relative;
  padding: 10px 12px 10px 46px;
  border-radius: 16px;
  background: var(--pink-pale);
  counter-increment: h;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.howto-list li::before {
  content: counter(h);
  position: absolute;
  left: 12px;
  top: 10px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--pink);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
}

.howto-list span {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink-soft);
}

.set-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 16px;
  background: var(--pink-pale);
  cursor: pointer;
}

.set-row span {
  display: flex;
  flex-direction: column;
  font-size: 0.95rem;
}

.set-row small {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--ink-soft);
}

.toggle {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  position: relative;
  width: 54px;
  height: 32px;
  margin: 0;
  border-radius: 999px;
  background: #e3cfd6;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s;
}

.toggle:checked {
  background: var(--pink);
}

.toggle:checked::after {
  transform: translateX(22px);
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.icon-grid button {
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 0 0 3px #ffe0ea;
}

.icon-grid button[aria-pressed="true"] {
  box-shadow: 0 0 0 4px var(--pink);
}

/* ---------- よみこみ・おしらせ ---------- */
.loading {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: linear-gradient(#bfe8ff, #fff1f6);
  z-index: 50;
}

.load-usa {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 0 0 6px #ffd3e0;
  animation: hop 0.8s ease-in-out infinite;
}

.load-usa img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.load-txt {
  margin: 0;
  color: var(--pink-deep);
}

.toast {
  position: absolute;
  left: 50%;
  top: calc(18px + var(--st));
  z-index: 60;
  max-width: calc(100% - 32px);
  padding: 10px 18px;
  border-radius: 18px;
  background: rgba(74, 52, 40, 0.86);
  color: #fff;
  font-size: 0.9rem;
  text-align: center;
  transform: translate(-50%, -140%);
  transition: transform 0.3s cubic-bezier(0.2, 1.4, 0.4, 1);
  pointer-events: none;
}

.toast.show {
  transform: translate(-50%, 0);
}

.banner {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(118px + var(--st));
  z-index: 8;
  text-align: center;
  font-family: var(--font-cute);
  font-size: clamp(1.6rem, 8vw, 2.6rem);
  color: #fff;
  -webkit-text-stroke: 0.14em var(--pink-deep);
  paint-order: stroke fill;
  pointer-events: none;
  opacity: 0;
}

.banner.show {
  animation: banner 1.6s cubic-bezier(0.2, 1.4, 0.4, 1) forwards;
}

@keyframes banner {
  0% {
    opacity: 0;
    transform: scale(0.4);
  }
  15% {
    opacity: 1;
    transform: scale(1.1);
  }
  25% {
    transform: scale(1);
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-30px);
  }
}

@media (min-width: 760px) {
  .hud-top {
    left: calc(50% - 360px);
    right: calc(50% - 360px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ---------- さがし中（CPU と あそびながら） ---------- */
.search-badge {
  position: absolute;
  bottom: calc(26px + var(--sb));
  left: calc(14px + var(--sl));
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 12px;
  border-radius: 999px;
  background: rgba(74, 52, 40, 0.75);
  color: #fff;
  font-size: 0.8rem;
  white-space: nowrap;
  pointer-events: auto;
}

.search-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #7dffb2;
  animation: blink 1s ease-in-out infinite;
}

.search-badge button {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
}

@keyframes blink {
  50% {
    opacity: 0.25;
  }
}

/* ---------- はじめての 人むけ：ゆびの お手本 ---------- */
.tutor {
  position: absolute;
  left: 0;
  right: 0;
  top: 42%;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.tutor-hand {
  font-size: 3rem;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.25));
  animation: swipe 2.4s ease-in-out infinite;
}

.tutor-txt {
  margin: 6px 0 0;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(74, 52, 40, 0.7);
  color: #fff;
  font-size: 0.88rem;
  text-align: center;
}

@keyframes swipe {
  0% {
    transform: translateX(0) translateY(0);
  }
  25% {
    transform: translateX(-60px) translateY(0);
  }
  55% {
    transform: translateX(60px) translateY(0);
  }
  75% {
    transform: translateX(0) translateY(0);
  }
  85% {
    transform: translateX(0) translateY(-14px) scale(0.92);
    opacity: 0.6;
  }
  100% {
    transform: translateX(0) translateY(0);
  }
}

/* ---------- うさ ずかん ---------- */
.dex-panel {
  width: min(520px, 100%);
}

.dex-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-height: min(56vh, 520px);
  overflow-y: auto;
  padding: 4px;
}

.dex-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px 8px;
  border-radius: 18px;
  background: var(--pink-pale);
}

.dex-cell img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  filter: drop-shadow(0 3px 4px rgba(150, 80, 110, 0.2));
}

.dex-cell.locked img {
  filter: brightness(0) opacity(0.14);
}

.dex-cell b {
  font-size: 0.82rem;
}

.dex-cell small {
  font-size: 0.68rem;
  color: var(--ink-soft);
}

.dex-cell .new {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--pink);
  color: #fff;
  font-size: 0.62rem;
}

.dot-new {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 4px;
  border-radius: 50%;
  background: #ff5c7a;
  vertical-align: 2px;
}

.title-row .sm-btn {
  padding: 8px 11px;
  font-size: 0.84rem;
  white-space: nowrap;
}

.title-row {
  flex-wrap: nowrap;
  gap: 8px;
}

/* たいせんの ときは「つぎ」を 名前の 下へ（名前を 長く 出せるように） */
.hud.versus .next {
  position: absolute;
  top: 58px;
  right: 0;
  width: 46px;
  padding: 3px 3px 5px;
}

.hud.versus .next img {
  width: 36px;
  height: 36px;
}

.hud.versus .pcard {
  max-width: 48%;
}

/* ---------- リプレイ ---------- */
.replay-badge {
  position: absolute;
  top: calc(118px + var(--st));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 6px 5px 14px;
  border-radius: 999px;
  background: rgba(74, 52, 40, 0.78);
  color: #fff;
  font-size: 0.85rem;
  pointer-events: auto;
}

.replay-badge button {
  padding: 4px 12px;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 0.8rem;
}

.hud.replaying .rotate-btn,
.hud.replaying .stamp-btn,
.hud.replaying .drop-btn,
.hud.replaying .turn-banner,
.hud.replaying .timer {
  visibility: hidden;
}

/* 文字が 長い ボタンの 折り返しを ととのえる */
.share-row .mid-btn,
.friend-row .mid-btn {
  min-height: 52px;
  padding: 8px 8px;
  font-size: 0.9rem;
  line-height: 1.25;
  white-space: nowrap;
}

#scr-solo .level-btn {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

#scr-solo .level-btn small {
  text-align: left;
}
