/* Attack50 — 5×10 vertical board, mobile-first 60fps */
:root {
  --red: #c41e3a;
  --tier0: #aeb9c8;
  --tier1: #087fd0;
  --tier2: #27a44b;
  --tier3: #f2b500;
  --tier4: #da8500;
  --gap: 0px;
  --line: 2px;
}

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

html, body {
  background: #0a1520;
  color: #fff;
  font-family: "Roboto", "Hiragino Sans", sans-serif;
  min-height: 100%;
  -webkit-tap-highlight-color: transparent;
}

.crt {
  min-height: 100vh;
  position: relative;
  background:
    linear-gradient(180deg, rgba(0,0,0,0.55) 0%, rgba(0,20,40,0.62) 45%, rgba(0,0,0,0.7) 100%),
    url("bg-beach.jpg") center / cover no-repeat fixed;
  background-color: #0a1520;
}
.scanlines, .vignette { display: none; } /* 重いCRT演出は切る */

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 10px 10px 20px;
}

.header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}
.board-label {
  font-family: "DotGothic16", sans-serif;
  font-size: clamp(18px, 3.8vw, 26px);
  letter-spacing: 0.06em;
}
#remaining { font-weight: 700; }

.studio {
  background: transparent;
  padding: 0;
  border: none;
  /* filter禁止: 親のfilterは子（ご褒美）までボカして描画される */
}

.game-area {
  position: relative;
  width: min(100%, 480px);
  /* 5列×10行。各パネルを正方形にする */
  aspect-ratio: 1 / 2;
  margin: 0 auto;
  background: transparent;
  overflow: visible;
  contain: layout style;
  border-radius: 6px;
  box-shadow:
    0 2px 0 rgba(255,255,255,0.12),
    0 14px 40px rgba(0,0,0,0.55),
    0 40px 60px rgba(0,0,0,0.35);
  transform: translateZ(0);
}

.reward-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.reward-blur {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  /* ぼかしは生成済み画像側だけで行い、アプリでは加工しない */
  filter: none !important;
  transform: none;
  z-index: 0;
}
.clear-holes {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  overflow: hidden;
}
body.intro-active .clear-holes {
  /* 既解放のクリア panel だけはタイトルの上に出す */
  z-index: 40;
}
.clear-hole {
  position: absolute;
  overflow: hidden;
  background-repeat: no-repeat;
  background-color: transparent;
}
.clear-grid, .clear-tile, .panel-clear, .reward-clear, .blur-mask-svg { display: none !important; }


.grid {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(10, 1fr);
  gap: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  background: transparent;
  /* 商品画像のmultiplyを背面の元ブラー画像まで通す */
  isolation: auto;
  overflow: visible;
}

/* 常時表示の黒分割線（パネル枠ではなくオーバーレイ） */
.grid-lines {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(10, 1fr);
  gap: 0;
  padding: 0;
  pointer-events: none;
  box-sizing: border-box;
  border: var(--line) solid #000;
}
.grid-lines span {
  box-sizing: border-box;
  border-right: var(--line) solid #000;
  border-bottom: var(--line) solid #000;
  background: transparent;
}
.grid-lines span:nth-child(5n) { border-right: none; }
.grid-lines span:nth-child(n+46) { border-bottom: none; }

/* ホバー中は分割線をパネルの下へ（拡大パネルに黒線が乗らない） */
@media (hover: hover) and (pointer: fine) {
  .game-area:has(.panel:not(.opened):hover) .grid-lines {
    z-index: 8;
  }
  .game-area:has(.panel:not(.opened):hover) .grid {
    z-index: 40;
  }
}


.panel {
  --panel-color: var(--tier0);
  position: relative;
  /* アタック25風：パネル自体に枠線なし（分割線は .grid-lines） */
  border: none;
  box-shadow: none;
  border-radius: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  font: inherit;
  color: inherit;
  /* 単色アルファのパネル越しに背面のご褒美画像を見せる */
  background: color-mix(in srgb, var(--panel-color) 46%, transparent);
  overflow: hidden;
  contain: layout;
  transition: transform 0.2s cubic-bezier(0.2, 1.2, 0.3, 1), box-shadow 0.2s ease, background 0.15s ease;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}
/* 未購入でまだ開けられないパネルだけ暗くする。 */
.panel:not([data-purchased="1"]):not(.opened):not(.opening):not(.panel-falling) {
  background: color-mix(in srgb, var(--panel-color) 58%, transparent);
}
.panel.tier-0 { --panel-color: var(--tier0); }
.panel.tier-1 { --panel-color: var(--tier1); }
.panel.tier-2 { --panel-color: var(--tier2); }
.panel.tier-3 { --panel-color: var(--tier3); }
.panel.tier-4 {
  --panel-color: var(--tier4);
  /* 旧データ互換。現在の4色配分ではtier-3までを使用する */
  background: color-mix(in srgb, var(--tier4) 38%, transparent);
}
.panel.tier-4:hover:not(.opening):not(.opened) {
  background: color-mix(in srgb, var(--panel-color) 42%, transparent);
}

.panel-blur-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: transparent;
  filter: none;
}
.panel.tier-4 .panel-blur-bg {
  background: transparent;
}

.panel-thumb {
  position: absolute;
  inset: 3px;
  width: calc(100% - 6px);
  height: calc(100% - 6px);
  object-fit: contain;
  display: block;
  opacity: 0.78;
  mix-blend-mode: multiply;
  filter: none;
  pointer-events: none;
  z-index: 1;
}
.panel-sender-icon {
  position: absolute;
  inset: 9%;
  z-index: 3;
  width: 82%;
  height: 82%;
  border: 3px solid rgba(255,255,255,.92);
  border-radius: 50%;
  object-fit: cover;
  background: #111;
  box-shadow: 0 3px 14px rgba(0,0,0,.65);
  opacity: 0;
  transform: scale(.86);
  transition: opacity .45s ease, transform .45s ease;
  pointer-events: none;
}
.panel[data-has-sender="1"] .panel-thumb { transition: opacity .45s ease, transform .45s ease; }
.panel.show-sender .panel-thumb { opacity: 0; transform: scale(.86); }
.panel.show-sender .panel-sender-icon { opacity: 1; transform: scale(1); }
.panel-num {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: clamp(12px, 3.2vw, 32px);
  color: #fff;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000;
  pointer-events: none;
  line-height: 1;
}

/* hover：元サイズのまま色だけ強調 */
@media (hover: hover) and (pointer: fine) {
  .panel:hover:not(.opening):not(.opened) {
    transform: translateZ(0);
    z-index: 40 !important;
    border: none !important;
    outline: none !important;
    outline-width: 0 !important;
    background-color: color-mix(in srgb, var(--panel-color) 42%, transparent) !important;
    background-image: none !important;
    box-shadow:
      0 18px 40px rgba(0,0,0,0.55),
      0 0 0 0 transparent !important;
    transition: box-shadow 0.18s ease, background 0.18s ease;
  }
.panel:hover:not(.opening):not(.opened) .panel-blur-bg {
    background: transparent;
    filter: none;
  }
.panel:hover:not(.opening):not(.opened) .panel-thumb {
    display: none !important;
  }
}
.panel {
  outline: none !important;
}
.panel:focus, .panel:focus-visible {
  outline: none !important;
}

@media (hover: hover) and (pointer: fine) {
  .panel.purchased-glow:hover:not(.opened):not(.opening) {
    outline: none !important;
    animation: none !important;
  }
  .panel.purchased-glow:hover:not(.opened):not(.opening)::before,
  .panel.purchased-glow:hover:not(.opened):not(.opening)::after {
    display: none !important;
  }
}
/* 購入済み：超派手レインボー枠＋外側ブルーム */
.panel.purchased-glow {
  z-index: 8;
  overflow: visible !important;
  contain: none !important;
  outline: 2px solid rgba(255,255,255,.82);
  outline-offset: -1px;
  animation: edgePulse 1.25s ease-in-out infinite alternate;
  box-shadow:
    0 0 6px rgba(255,255,255,.72),
    0 0 13px rgba(255,229,102,.48),
    0 0 21px rgba(255,79,216,.3),
    inset 0 0 7px rgba(255,255,255,.32) !important;
}
.panel.purchased-glow::before {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 4px;
  pointer-events: none;
  z-index: 5;
  background: radial-gradient(circle at 50% 50%,
    rgba(255,255,255,0.55) 0%,
    rgba(255,228,102,0.35) 35%,
    rgba(255,79,216,0.2) 55%,
    transparent 72%);
  animation: bloomPulse 0.55s ease-in-out infinite alternate;
}
.panel.purchased-glow::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 3px;
  pointer-events: none;
  z-index: 6;
  background: conic-gradient(from var(--glow-angle, 0deg),
    #fff 0deg,
    #ffe566 50deg,
    #ff4fd8 110deg,
    #7CFC00 170deg,
    #00e5ff 230deg,
    #ff6a00 290deg,
    #fff 360deg);
  opacity: .58;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  padding: 2px;
  animation: glowSpin 2.4s linear infinite;
  box-shadow: 0 0 8px rgba(255,255,255,.42);
}
@property --glow-angle {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}
@keyframes edgePulse {
  from {
    outline-color: rgba(255,255,255,.65);
    outline-width: 1px;
    box-shadow:
      0 0 4px rgba(255,255,255,.55),
      0 0 9px rgba(255,229,102,.35),
      0 0 15px rgba(255,79,216,.22),
      inset 0 0 5px rgba(255,255,255,.2);
  }
  to {
    outline-color: rgba(255,229,102,.82);
    outline-width: 2px;
    box-shadow:
      0 0 7px rgba(255,255,255,.72),
      0 0 15px rgba(255,229,102,.5),
      0 0 24px rgba(255,79,216,.28),
      inset 0 0 8px rgba(255,255,255,.34);
  }
}
@keyframes bloomPulse {
  from { opacity: 0.22; transform: scale(0.99); }
  to   { opacity: 0.48; transform: scale(1.02); }
}
@keyframes glowSpin {
  to { --glow-angle: 360deg; }
}

.panel.opened {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  cursor: pointer;
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
  outline: none !important;
  animation: none !important;
  overflow: visible !important;
  contain: none !important;
  z-index: 2;
}
.panel.opened::before,
.panel.opened::after {
  display: none !important;
}
.panel.opened .panel-num,
.panel.opened .panel-thumb,
.panel.opened .panel-sender-icon,
.panel.opened .panel-blur-bg,
.panel.opened .panel-clear {
  display: none !important;
}
body.intro-active .panel.opened {
  /* 解放済みは番号のタイミングで一瞬でクリアへ切り替える */
  transition: none !important;
  transform: none !important;
}

/* タイトル：赤背景＋ロゴ → アルファで消えてパネルへ */
.intro-logo {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: #c41e3a;
  opacity: 1;
  transition: opacity 0.9s ease;
  pointer-events: auto;
  user-select: none;
  cursor: default;
}
.intro-logo img {
  position: relative;
  z-index: 1;
  width: min(88%, 680px);
  height: auto;
  object-fit: contain;
  display: block;
}
/* タイトル上にもパネルと同じ5×10黒線 */
.intro-grid {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(10, 1fr);
  gap: 0;
  padding: 0;
  pointer-events: none;
  box-sizing: border-box;
  border: var(--line) solid #000;
}
.intro-grid span {
  box-sizing: border-box;
  border-right: var(--line) solid #000;
  border-bottom: var(--line) solid #000;
  background: transparent;
}
.intro-grid span:nth-child(5n) { border-right: none; }
.intro-grid span:nth-child(n+46) { border-bottom: none; }
body.booting .grid,
body.ready .grid { opacity: 1; }
body.booting .reward-layer,
body.ready .reward-layer { opacity: 1; visibility: visible; }
body.intro-active .grid,
body.intro-active .reset-btn {
  pointer-events: none !important;
}
body.intro-active .grid {
  z-index: 50;
}
body.intro-active .grid-lines {
  z-index: 60;
  opacity: 1;
}
body.intro-active .panel {
  visibility: visible !important;
  pointer-events: none !important;
}
body.intro-active .panel.pre-reveal {
  visibility: hidden !important;
}
body.intro-active .panel:not(.pre-reveal):not(.opened) {
  opacity: 1 !important;
  background: color-mix(in srgb, var(--panel-color) 30%, transparent) !important;
}

.controls { margin-top: 12px; text-align: center; }
.unlocked-items {
  width: min(100%, 480px);
  margin: 12px auto 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}
.unlocked-items[hidden] { display: none !important; }
.unlocked-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.82);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 5px 14px rgba(0,0,0,0.34);
}
.unlocked-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.unlocked-item-num {
  position: absolute;
  right: 3px;
  bottom: 3px;
  min-width: 1.65em;
  padding: 2px 4px;
  border-radius: 999px;
  background: rgba(0,0,0,0.78);
  color: #fff;
  font-size: clamp(10px, 2.5vw, 13px);
  line-height: 1.2;
  text-align: center;
}

@media (min-width: 901px) and (orientation: landscape) {
  .container {
    max-width: 1120px;
  }
  .studio {
    display: grid;
    grid-template-columns: minmax(0, 480px) minmax(240px, 1fr);
    align-items: start;
    justify-content: center;
    gap: 18px;
  }
  .game-area {
    width: 480px;
    margin: 0;
  }
  .unlocked-items {
    width: 100%;
    margin: 0;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-content: start;
  }
  .unlocked-item-num {
    font-size: 13px;
  }
}
.reset-btn {
  font-family: inherit;
  font-weight: 700;
  padding: 8px 18px;
  border: 2px solid #000;
  background: #c41e3a;
  color: #fff;
  cursor: pointer;
}

/* modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0,0,0,0.55);
  opacity: 0;
  transition: opacity 0.22s ease;
}
.modal-overlay.is-open {
  opacity: 1;
}
.modal-overlay[hidden] { display: none !important; }
.modal {
  position: relative;
  width: min(520px, 94vw);
  max-height: min(88vh, 900px);
  overflow: auto;
  background: #fff;
  color: #111;
  border: none;
  border-radius: 12px;
  padding: 22px 22px 20px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.45);
  transform: scale(0.55);
  opacity: 0;
  transition: transform 0.34s cubic-bezier(0.2, 1.35, 0.3, 1), opacity 0.22s ease;
}
.modal-overlay.is-open .modal {
  transform: scale(1);
  opacity: 1;
}
.modal-close {
  position: absolute; top: 8px; right: 10px;
  border: 0; background: transparent; color: #333;
  font-size: 28px; line-height: 1; cursor: pointer; padding: 4px 8px;
}
.modal-image {
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  background: #f3f3f3;
  border: none;
  border-radius: 8px;
  margin-bottom: 12px;
}
.modal-num { font-size: 12px; color: #666; margin-bottom: 4px; }
.modal-title { font-size: 16px; text-align: left; margin: 0 0 8px; line-height: 1.35; color: #111; }
.modal-price { font-size: 24px; font-weight: 700; color: #c41e3a; margin: 0 0 12px; }
.modal-senders { display: grid; gap: 8px; margin: 0 0 14px; }
.modal-sender { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 10px; background: #f2f4f7; color: #111; text-decoration: none; }
.modal-sender[href]:hover { background: #e5f2ff; }
.modal-sender img { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; background: #ddd; }
.modal-sender span { display: grid; min-width: 0; text-align: left; }
.modal-sender strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-sender small { color: #536471; }
.modal-link {
  display: inline-block;
  padding: 10px 16px;
  background: #c41e3a;
  color: #fff !important;
  text-decoration: none;
  font-weight: 700;
  border-radius: 8px;
  border: none;
}
body.modal-open { overflow: hidden; }

/* stars — transform/opacity only */
.star-particle {
  position: fixed;
  z-index: 220;
  pointer-events: none;
  margin-left: -0.5em;
  margin-top: -0.5em;
  line-height: 1;
  animation: starFly linear forwards;
  will-change: transform, opacity;
}

.birthday-balloon {
  position: fixed;
  z-index: 900;
  bottom: -90px;
  width: clamp(34px, 7vw, 58px);
  aspect-ratio: 0.82;
  border-radius: 52% 48% 48% 52%;
  background: radial-gradient(circle at 32% 25%, #fff 0 5%, var(--balloon-color) 18% 100%);
  box-shadow: inset -8px -10px 12px rgba(0, 0, 0, 0.18), 0 5px 16px rgba(0, 0, 0, 0.24);
  pointer-events: none;
  animation: balloonRise linear forwards;
}
.birthday-balloon::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -9px;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 10px solid var(--balloon-color);
  transform: translateX(-50%);
}
.birthday-balloon::after {
  content: '';
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  width: 1px;
  height: 65px;
  background: rgba(255, 255, 255, 0.72);
}
@keyframes balloonRise {
  0% { transform: translate3d(0, 0, 0) rotate(-4deg); }
  45% { transform: translate3d(calc(var(--balloon-drift) * 0.55), -58vh, 0) rotate(5deg); }
  100% { transform: translate3d(var(--balloon-drift), -125vh, 0) rotate(-3deg); }
}

.line-clear-flash {
  position: fixed;
  inset: 0;
  z-index: 880;
  pointer-events: none;
  background: #fff8b5;
  animation: lineClearFlash 0.7s ease-out forwards;
}
.row-lightning {
  position: fixed;
  z-index: 889;
  pointer-events: none;
  overflow: visible;
  filter: drop-shadow(0 0 7px #40d9ff) drop-shadow(0 0 15px #fff);
  animation: lightningHost 1.05s steps(5, end) forwards;
}
.row-lightning svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.row-lightning polyline {
  fill: none;
  stroke-linecap: square;
  stroke-linejoin: bevel;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: lightningStrike 0.28s linear forwards;
}
.row-lightning .lightning-glow {
  stroke: #00a8ff;
  stroke-width: 11px;
  opacity: 0.72;
}
.row-lightning .lightning-core {
  stroke: #fff;
  stroke-width: 3px;
}
@keyframes lightningStrike {
  0% { stroke-dashoffset: 1; opacity: 0; }
  12% { opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 1; }
}
@keyframes lightningHost {
  0%, 24%, 42%, 62% { opacity: 1; }
  16%, 34%, 52%, 74% { opacity: 0.18; }
  100% { opacity: 0; }
}
.combo-cutin {
  position: fixed;
  inset: 0;
  z-index: 890;
  display: grid;
  place-items: center;
  overflow: hidden;
  pointer-events: none;
  isolation: isolate;
}
.combo-cutin::before {
  content: "";
  position: absolute;
  left: -20vw;
  top: 50%;
  z-index: -1;
  width: 140vw;
  height: min(56vw, 520px);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.9) 48%, transparent);
  filter: blur(10px);
  transform: translateY(-50%) skewX(-14deg) scaleY(0.08);
  animation: comboCutinSlash 1.24s ease-out forwards;
}
.combo-cutin img {
  display: block;
  width: min(1120px, 112vw);
  height: auto;
  max-width: none;
  filter: drop-shadow(0 0 8px #fff) drop-shadow(0 12px 34px rgba(0,0,0,0.8));
  animation: comboCutinImage 1.24s cubic-bezier(0.18, 0.88, 0.24, 1) forwards;
}
.combo-cutin strong {
  position: absolute;
  left: 50%;
  bottom: 14%;
  color: #fff;
  font-size: clamp(42px, 12vw, 104px);
  font-weight: 1000;
  font-style: italic;
  white-space: nowrap;
  text-shadow: 0 5px 0 #7b1300, 0 0 20px #ffcf33, 0 10px 34px #000;
  transform: translateX(-50%) rotate(-5deg);
  animation: comboBadge 1.24s ease-out forwards;
}
body.combo-impact .studio {
  animation: comboImpact 0.42s steps(2, end);
}
.panel.row-complete {
  z-index: 230 !important;
  animation: rowCompletePulse 0.9s ease-out !important;
  box-shadow: inset 0 0 24px #fff, 0 0 28px #ffd400 !important;
}
@keyframes lineClearFlash {
  0% { opacity: 0; }
  12% { opacity: 0.88; }
  100% { opacity: 0; }
}
@keyframes comboCutinImage {
  0% { opacity: 0; transform: translateX(-125vw) skewX(-12deg) scale(0.86); }
  15% { opacity: 1; transform: translateX(3vw) skewX(2deg) scale(1.06); }
  23%, 72% { opacity: 1; transform: translateX(0) skewX(0) scale(1); }
  100% { opacity: 0; transform: translateX(125vw) skewX(12deg) scale(0.94); }
}
@keyframes comboCutinSlash {
  0% { opacity: 0; transform: translate(-100vw, -50%) skewX(-14deg) scaleY(0.04); }
  14% { opacity: 0.9; transform: translate(0, -50%) skewX(-14deg) scaleY(1); }
  72% { opacity: 0.65; transform: translate(0, -50%) skewX(-14deg) scaleY(1); }
  100% { opacity: 0; transform: translate(100vw, -50%) skewX(-14deg) scaleY(0.05); }
}
@keyframes comboBadge {
  0%, 18% { opacity: 0; transform: translateX(-50%) rotate(-5deg) scale(2); }
  26%, 72% { opacity: 1; transform: translateX(-50%) rotate(-5deg) scale(1); }
  100% { opacity: 0; transform: translateX(40vw) rotate(6deg) scale(0.9); }
}
@keyframes comboImpact {
  0%, 100% { transform: translate(0); }
  25% { transform: translate(-5px, 3px); }
  50% { transform: translate(5px, -2px); }
  75% { transform: translate(-3px, -2px); }
}
@keyframes rowCompletePulse {
  0%, 100% { filter: brightness(1); }
  35% { filter: brightness(2.2) saturate(1.7); }
}
@keyframes starFly {
  from { transform: translate(0,0) rotate(0) scale(0.5); opacity: 1; }
  to { transform: translate(var(--stx), var(--sty)) rotate(var(--srot)) scale(1); opacity: 0; }
}
.panel-falling {
  opacity: 1 !important;
  background: var(--panel-color) !important;
  box-shadow: 0 8px 20px rgba(0,0,0,0.4);
  overflow: hidden;
  contain: none !important;
  transition: none !important;
}
.panel-falling .panel-thumb {
  opacity: 1 !important;
  mix-blend-mode: normal;
}
.panel-falling .panel-blur-bg {
  display: none !important;
}

.panel-release-flash {
  position: fixed;
  z-index: 239;
  overflow: visible;
  pointer-events: none;
  background: #fff;
  box-shadow: 0 0 18px 8px #fff, 0 0 38px 14px rgba(170, 235, 255, 0.95);
  animation: panelWhiteMelt 0.82s steps(10, end) forwards;
}
.panel-release-flash i {
  position: absolute;
  width: clamp(3px, 1vw, 7px);
  aspect-ratio: 1;
  background: #fff;
  box-shadow: 0 0 8px #fff;
  animation: panelWhitePixel 0.7s ease-out forwards;
}
@keyframes panelWhiteMelt {
  0% { opacity: 0; transform: scale(0.9); }
  8% { opacity: 1; transform: scale(1.04); }
  28% { opacity: 0.96; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.08) translateY(9px); }
}
@keyframes panelWhitePixel {
  0%, 20% { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--melt-x), var(--melt-y)) scale(0.2); }
}

.item-speech-bubble {
  position: fixed;
  z-index: 950;
  width: min(320px, calc(100vw - 34px));
  padding: 14px 16px;
  border: 4px solid #111;
  background: rgba(255, 255, 255, 0.82);
  color: #111;
  box-shadow: 4px 5px 0 rgba(0, 0, 0, 0.48);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.18);
  transform-origin: center;
  pointer-events: none;
}
.item-speech-bubble.is-visible {
  animation: speechBubbleBig 0.28s steps(5, end) forwards;
}
.item-speech-bubble.is-closing {
  animation: speechBubbleClose 0.25s steps(5, end) forwards;
}
.item-speech-bubble strong {
  display: block;
  max-height: 3.8em;
  overflow: hidden;
  font-size: clamp(14px, 3.8vw, 20px);
  line-height: 1.25;
}
.item-speech-bubble span {
  display: block;
  margin-top: 5px;
  color: #c41e3a;
  font-size: clamp(22px, 6vw, 34px);
  font-weight: 900;
}
@keyframes speechBubbleBig {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.18); }
  70% { opacity: 1; transform: translate(-50%, -50%) scale(1.12); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes speechBubbleClose {
  from { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  to { opacity: 0; transform: translate(-50%, -50%) scale(0.18); }
}
/* 落ちたプレゼントを受け止めて画面外へ運ぶバスケット */
.basket-catcher {
  position: fixed;
  z-index: 220;
  pointer-events: none;
  opacity: 0;
  transform: translate(var(--approach-x, -120vw), 18px) rotate(-5deg);
  will-change: transform, opacity;
}
.basket-front-lip {
  position: fixed;
  z-index: 223;
  pointer-events: none;
  opacity: 0;
  transform: translate(var(--approach-x, -120vw), 18px) rotate(-5deg);
  will-change: transform, opacity;
}
.basket-front-lip::after {
  content: '';
  position: absolute;
  left: 3%;
  right: 3%;
  bottom: 0;
  height: 43%;
  border: 4px solid #75451f;
  border-radius: 5px 5px 22px 22px;
  background: repeating-linear-gradient(90deg, rgba(255, 226, 157, 0.92) 0 7px, rgba(135, 72, 28, 0.9) 7px 12px);
  box-shadow: inset 0 5px 0 rgba(255, 245, 204, 0.78), 0 5px 10px rgba(0, 0, 0, 0.32);
  clip-path: polygon(3% 0, 97% 0, 100% 100%, 0 100%);
}
.basket-catcher::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: 0;
  left: 16%;
  width: 68%;
  height: 43%;
  border: 5px solid #8b542b;
  border-bottom: 0;
  border-radius: 50% 50% 0 0;
  box-shadow: 0 0 0 2px rgba(255, 221, 145, 0.8);
}
.basket-catcher::after {
  content: "";
  position: absolute;
  z-index: 1;
  left: 0;
  right: 0;
  bottom: 0;
  height: 72%;
  border: 4px solid #8b542b;
  border-radius: 10px 10px 24px 24px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 226, 157, 0.7) 0 7px, rgba(157, 91, 39, 0.62) 7px 12px),
    linear-gradient(180deg, #d89b55, #995b2d);
  box-shadow:
    inset 0 5px 0 rgba(255, 239, 185, 0.68),
    0 8px 18px rgba(0, 0, 0, 0.42);
  clip-path: polygon(7% 0, 93% 0, 100% 100%, 0 100%);
}
.basket-catcher.is-visible,
.basket-front-lip.is-visible {
  animation: basketEnter 0.45s cubic-bezier(0.2, 1.1, 0.3, 1) forwards;
}
.basket-catcher.is-catching,
.basket-front-lip.is-catching {
  opacity: 1;
  animation: basketCatch 0.18s ease-in-out forwards;
}
.basket-catcher.carrying,
.basket-front-lip.carrying {
  animation: basketCarry 0.78s cubic-bezier(0.4, 0, 1, 1) forwards;
}
.panel-falling.in-basket {
  animation: panelCarry 0.78s cubic-bezier(0.4, 0, 1, 1) forwards;
}
@keyframes basketEnter {
  from { opacity: 0; transform: translate(var(--approach-x), 18px) rotate(-5deg); }
  70%  { opacity: 1; transform: translate(-8px, -4px) rotate(2deg); }
  to   { opacity: 1; transform: translate(0, 0) rotate(-2deg); }
}
@keyframes basketCatch {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50%      { transform: translateY(-8px) rotate(2deg); }
}
@keyframes basketCarry {
  from { opacity: 1; transform: translateX(0) rotate(-2deg); }
  to   { opacity: 1; transform: translateX(var(--carry-x)) rotate(8deg); }
}
@keyframes panelCarry {
  from {
    opacity: 1;
    transform: translate(var(--catch-x), var(--catch-y)) rotate(0deg);
  }
  to {
    opacity: 1;
    transform: translate(calc(var(--catch-x) + var(--carry-x)), calc(var(--catch-y) - 18px)) rotate(8deg);
  }
}

.legend, .footer { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  .panel, .intro-logo, .star-particle, .panel.purchased-glow, .basket-catcher, .panel-falling, .combo-cutin img, .combo-cutin::before, .combo-cutin strong { animation: none !important; transition: none !important; }
}

/* hover ring removed — Attack25: no edge on hover */
.container {
  position: relative;
  z-index: 1;
}
.header .board-label {
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}

/* birthday countdown — large */
.countdown {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  bottom: auto;
  z-index: 240;
  width: max-content;
  max-width: calc(100vw - 16px);
  text-align: center;
  margin: 0;
  padding: 3px 10px 5px;
  background: rgba(10, 21, 32, 0.38);
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
  pointer-events: none;
  transform: translateX(-50%);
  text-shadow: 0 3px 12px rgba(0,0,0,0.85);
}
.countdown-label {
  font-family: "DotGothic16", "Hiragino Sans", sans-serif;
  font-size: clamp(10px, 2.4vw, 14px);
  letter-spacing: 0.2em;
  opacity: 0.9;
  margin-bottom: 1px;
}
.countdown-time {
  font-family: "Roboto", "Helvetica Neue", monospace;
  font-weight: 700;
  font-size: clamp(22px, 6vw, 44px);
  line-height: 1.05;
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow:
    0 0 18px rgba(245, 196, 0, 0.55),
    0 4px 0 #000,
    0 8px 24px rgba(0,0,0,0.7);
}
.countdown.done .countdown-label { color: #f5c400; }
.countdown.done .countdown-time {
  color: #f5c400;
  font-size: clamp(28px, 8vw, 56px);
}

.serve-hint {
  margin-top: 10px;
  font-size: 12px;
  opacity: 0.85;
  text-shadow: 0 1px 4px #000;
}
.serve-hint code {
  background: rgba(0,0,0,0.35);
  padding: 2px 6px;
  border-radius: 4px;
}


/* ===== responsive (phone portrait etc.) ===== */
.container {
  max-width: min(720px, 100%);
  padding: 8px 8px 16px;
}

@media (max-width: 700px), (orientation: portrait) and (max-width: 900px) {
  .header {
    margin-bottom: 4px;
  }
  .board-label {
    font-size: clamp(20px, 6vw, 30px);
  }
  .countdown {
    margin: 0;
    padding: 3px 8px 5px;
    top: calc(env(safe-area-inset-top, 0px) + 6px);
  }
  .countdown-label {
    font-size: clamp(12px, 3.2vw, 16px);
    letter-spacing: 0.12em;
  }
  .countdown-time {
    font-size: clamp(24px, 7vw, 38px);
  }
  .studio {
    width: 100%;
  }
  .game-area {
    width: 100%;
    max-width: 100%;
    aspect-ratio: 1 / 2;
    margin: 0 auto;
  }
  .panel {
    border-width: 1px;
  }
  .panel-num {
    font-size: clamp(20px, 5.6vw, 28px);
    text-shadow:
      -1px -1px 0 #fff,
      1px -1px 0 #fff,
      -1px 1px 0 #fff,
      1px 1px 0 #fff,
      0 3px 5px rgba(0, 0, 0, 0.9);
  }
  .panel-thumb { opacity: 0.78; }
  /* スマホはホバー拡大なし（誤爆防止）—既存mediaで制御 */
  .controls {
    margin-top: 10px;
  }
  .modal {
    width: min(96vw, 380px);
    padding: 12px;
  }
  .modal-image {
    max-height: 40vh;
  }
  .intro-logo img {
    width: min(92%, 520px);
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  /* 横向きスマホ：カウントダウン小さく、盤面を高さに合わせる */
  .countdown-time { font-size: clamp(18px, 6vh, 32px); }
  .countdown-label { font-size: 11px; }
  .game-area {
    width: min(100%, 70vh);
    margin: 0 auto;
  }
  .header { margin-bottom: 2px; }
}

@supports (height: 100dvh) {
  .crt { min-height: 100dvh; }
}



/* 通常表示：サムネ+番号が見える */
/* 開いたマスの上には数字なし */
.panel.opened .panel-num { display: none !important; }

/* D+Oホールド中：debug-dim（サムネ非表示、blur+番号のみ、開いたパネルは番号なし） */
body.debug-dim .panel-thumb { display: none !important; }
body.debug-dim .panel:not(.opened) {
  background: color-mix(in srgb, var(--panel-color) 38%, transparent) !important;
}
body.debug-dim .panel:hover:not(.opening):not(.opened) .panel-thumb { display: none !important; }
body.debug-dim .panel.opened .panel-num { display: none !important; }

/* タイトル後：1〜50をランダム順でポップイン（半透明フェードなし） */
.panel.pre-reveal {
  opacity: 1 !important;
  visibility: hidden !important;
  transform: scale(0.35);
  pointer-events: none !important;
}
.panel.pre-reveal .panel-thumb,
.panel.pre-reveal .panel-sender-icon,
.panel.pre-reveal .panel-num {
  opacity: 1;
  visibility: hidden;
}
.panel.product-reveal {
  animation: productPopIn 0.22s cubic-bezier(0.2, 1.4, 0.3, 1) both;
}
.panel.product-reveal .panel-thumb,
.panel.product-reveal .panel-sender-icon,
.panel.product-reveal .panel-num {
  visibility: visible;
  animation: productPopIn 0.22s cubic-bezier(0.2, 1.4, 0.3, 1) both;
}
@keyframes productPopIn {
  from { opacity: 1; transform: scale(0.35); }
  to   { opacity: 1; transform: scale(1); }
}
