/* 神綺の魔界ブロックおとし — 魔界の夜とレトロな升目 */
:root {
  --smb-bg: #160c2e;
  --smb-bg2: #2a1458;
  --smb-panel: rgba(18, 10, 42, 0.86);
  --smb-line: #6b4fc4;
  --smb-text: #f4efff;
  --smb-dim: #c9bdf0;
  --smb-gold: #ffd75a;
  --smb-red: #d23a4a;
  --smb-key: #3a2380;
  --smb-key-on: #5b3cc0;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--smb-bg); overflow: hidden; }
body {
  color: var(--smb-text);
  font-family: "BIZ UDPGothic", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; }

.smb {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  height: 100dvh;
  /* --smb-in*：WordPress の親ページが測った、画面に固定の広告が重なる幅（wordpress/embed.js）。ふだんは0 */
  padding: calc(max(6px, env(safe-area-inset-top)) + var(--smb-int, 0px)) calc(max(8px, env(safe-area-inset-right)) + var(--smb-inr, 0px)) calc(max(6px, env(safe-area-inset-bottom)) + var(--smb-inb, 0px)) calc(max(8px, env(safe-area-inset-left)) + var(--smb-inl, 0px));
  background:
    radial-gradient(ellipse at 50% -10%, rgba(255, 90, 140, 0.25), transparent 55%),
    linear-gradient(180deg, var(--smb-bg2), var(--smb-bg) 70%);
  overflow: hidden;
}
/* 遠くにちらばる升目のひし形（カードの模様に合わせる） */
.smb-bg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(14, 6, 32, 0.35), rgba(14, 6, 32, 0.6)); }
.smb::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0.18;
  background-image:
    linear-gradient(45deg, transparent 46%, #7d9cff 46% 54%, transparent 54%),
    linear-gradient(-45deg, transparent 46%, #7d9cff 46% 54%, transparent 54%);
  background-size: 46px 46px;
}

.smb-top { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex: none; margin-bottom: 6px; }
.smb-title { margin: 0; font-size: clamp(15px, 2.4vw, 22px); letter-spacing: 0.04em; text-shadow: 0 2px 0 #000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.smb-top-btns { display: flex; gap: 6px; flex: none; }
.smb-chip {
  border: 1px solid var(--smb-line); background: var(--smb-panel); border-radius: 999px;
  padding: 5px 12px; font-size: 13px; cursor: pointer;
}
.smb-chip:hover { background: var(--smb-key-on); }

.smb-stage {
  position: relative; flex: 1 1 auto; min-height: 0;
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: start;
}
.smb-side { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.smb-left { align-items: flex-end; }
.smb-right { align-items: flex-start; }
.smb-box {
  width: 100%; max-width: 190px;
  background: var(--smb-panel); border: 2px solid var(--smb-line); border-radius: 10px;
  padding: 6px 8px 8px;
}
.smb-box h2 { margin: 0 0 4px; font-size: 12px; letter-spacing: 0.1em; color: var(--smb-gold); }
.smb-mini { display: block; width: 100%; }
.smb-stats div { display: flex; align-items: baseline; justify-content: space-between; gap: 4px; flex-wrap: wrap; padding: 2px 0; }
.smb-stats span { font-size: 12px; color: var(--smb-dim); }
.smb-stats b { font-size: 18px; font-variant-numeric: tabular-nums; }
.smb-stats small { font-size: 11px; color: var(--smb-dim); }
.smb-keys dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 8px; margin: 0; font-size: 12px; line-height: 1.35; }
.smb-keys dt { color: #fff; font-weight: bold; white-space: nowrap; }
.smb-keys dd { margin: 0; color: var(--smb-dim); }
/* スマホは画面下のボタンで動かすので、キーの説明は出さない */
.smb-touch .smb-keys, .smb-narrow .smb-keys, .smb-land .smb-keys { display: none; }
.smb-talk { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.smb-talk img { width: 64px; height: 64px; border-radius: 10px; border: 2px solid var(--smb-gold); object-fit: cover; }
.smb-talk p { margin: 0; font-size: 13px; line-height: 1.45; text-align: center; min-height: 3.6em; }
.smb-talk.smb-pop img { animation: smb-bob 0.45s ease; }
@keyframes smb-bob { 0% { transform: scale(1); } 40% { transform: scale(1.18) rotate(-6deg); } 100% { transform: scale(1); } }

.smb-well { position: relative; }
#smbBoard {
  display: block; border: 3px solid var(--smb-line); border-radius: 6px;
  background: #0b0619; box-shadow: 0 0 0 3px #0b0619, 0 0 26px rgba(120, 90, 255, 0.45);
  touch-action: none;
}
.smb-popup {
  position: absolute; left: 0; right: 0; top: 34%; text-align: center; pointer-events: none;
  font-weight: 900; font-size: clamp(20px, 4.2vh, 34px); color: var(--smb-gold);
  text-shadow: 0 3px 0 #5a1a3a, 0 0 12px rgba(0, 0, 0, 0.8); opacity: 0;
}
.smb-popup small { display: block; font-size: 0.55em; color: #fff; }
.smb-popup.smb-show { animation: smb-popup 1.1s ease forwards; }
@keyframes smb-popup { 0% { opacity: 0; transform: scale(0.6); } 15% { opacity: 1; transform: scale(1.1); } 30% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-24px); } }

/* スマホのボタン */
.smb-pad { display: none; flex: none; position: relative; margin-top: 6px; gap: 12px 6px; grid-template-columns: repeat(4, 1fr); grid-template-rows: 50px 56px; }
.smb-touch .smb-pad { display: grid; }
.smb-key {
  border: 2px solid var(--smb-line); border-radius: 12px; background: var(--smb-key);
  font-size: 24px; line-height: 1; cursor: pointer; touch-action: none;
}
.smb-key-s { font-size: 13px; line-height: 1.2; }
.smb-key.smb-on { background: var(--smb-key-on); transform: translateY(1px); }
/* ★2026-10-12 本人「右に移動を押すと、その上の『一気に落とす』になりやすい」。
   一気に落とすは ▼（速く落とす）の上へ。▶ の上は右回転、◀ の上は左回転にし、2段のすき間も広げた。 */
.smb-pad [data-act="rotL"] { grid-row: 1; grid-column: 1; }
.smb-pad [data-act="hold"] { grid-row: 1; grid-column: 2; }
.smb-pad [data-act="hard"] { grid-row: 1; grid-column: 3; }
.smb-pad [data-act="rotR"] { grid-row: 1; grid-column: 4; }
.smb-pad [data-act="left"] { grid-row: 2; grid-column: 1; }
.smb-pad [data-act="soft"] { grid-row: 2; grid-column: 2 / span 2; }
.smb-pad [data-act="right"] { grid-row: 2; grid-column: 4; }

/* スマホのたて画面では、横の欄をせまくする */
.smb-narrow .smb-stage { gap: 6px; }
.smb-narrow .smb-box { padding: 4px 5px 6px; border-radius: 8px; }
.smb-narrow .smb-box h2 { font-size: 10px; letter-spacing: 0; }
.smb-narrow .smb-stats b { font-size: 14px; }
.smb-narrow .smb-stats span, .smb-narrow .smb-stats small { font-size: 10px; }
.smb > .smb-talk { flex: none; position: relative; max-width: none; flex-direction: row; justify-content: center; margin-top: 6px; padding: 6px 10px; }
.smb > .smb-talk img { width: 48px; height: 48px; flex: none; }
.smb > .smb-talk p { font-size: 14px; min-height: 0; text-align: left; }

/* スマホのよこ画面：ボタンを盤の左右の下に分けて置き、盤を高くする */
.smb-land .smb-top { margin-bottom: 2px; }
.smb-land .smb-title { font-size: 14px; }
.smb-land .smb-chip { padding: 3px 10px; font-size: 12px; }
.smb-land .smb-talk { display: none; }
.smb-land .smb-side { max-height: calc(100% - 112px); overflow: hidden; }
.smb-land .smb-box { max-width: 160px; padding: 4px 6px 6px; }
.smb-land .smb-stats b { font-size: 14px; }
.smb-touch.smb-land .smb-pad {
  position: absolute; left: calc(max(8px, env(safe-area-inset-left)) + var(--smb-inl, 0px)); right: calc(max(8px, env(safe-area-inset-right)) + var(--smb-inr, 0px)); bottom: calc(max(6px, env(safe-area-inset-bottom)) + var(--smb-inb, 0px));
  margin: 0; pointer-events: none;
  grid-template-columns: repeat(3, 56px) 1fr repeat(2, 64px); grid-template-rows: 46px 50px;
}
.smb-land .smb-key { pointer-events: auto; }
.smb-land .smb-pad [data-act="hold"] { grid-row: 1; grid-column: 1 / span 2; }
.smb-land .smb-pad [data-act="left"] { grid-row: 2; grid-column: 1; }
.smb-land .smb-pad [data-act="soft"] { grid-row: 2; grid-column: 2; }
.smb-land .smb-pad [data-act="right"] { grid-row: 2; grid-column: 3; }
.smb-land .smb-pad [data-act="rotL"] { grid-row: 1; grid-column: 5; }
.smb-land .smb-pad [data-act="rotR"] { grid-row: 1; grid-column: 6; }
.smb-land .smb-pad [data-act="hard"] { grid-row: 2; grid-column: 5 / span 2; }

/* 面ごとの背景（幻想郷人物録の風景）。2枚を重ねて、レベルが上がるとふわっと入れかえる */
.smb-bg {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background-size: cover; background-position: center; opacity: 0;
  transition: opacity 1.4s ease;
}
.smb-bg.smb-on { opacity: 1; }

/* 4列消し・Tスピン・レベルが上がったときに横から飛び出す人物 */
.smb-cutin {
  position: absolute; z-index: 8; left: var(--smb-inl, 0px); right: var(--smb-inr, 0px); top: 54%; height: 150px; pointer-events: none;
  display: flex; align-items: center; justify-content: center; gap: 14px; opacity: 0;
  background: linear-gradient(90deg, transparent, rgba(20, 8, 50, 0.88) 18%, rgba(20, 8, 50, 0.88) 82%, transparent);
}
.smb-cutin img { height: 140px; width: 105px; object-fit: cover; object-position: top; border-radius: 12px; border: 3px solid var(--smb-gold); background: linear-gradient(180deg, #4a2590, #1f0f48); }
.smb-cutin p { margin: 0; font-size: 26px; font-weight: 900; color: var(--smb-gold); text-shadow: 0 3px 0 #5a1a3a; white-space: nowrap; }
.smb-cutin.smb-go { animation: smb-cutin 1.25s ease forwards; }
.smb-cutin.smb-go img { animation: smb-cutin-img 1.25s ease forwards; }
@keyframes smb-cutin { 0% { opacity: 0; } 12% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; } }
@keyframes smb-cutin-img { 0% { transform: translateX(120px) rotate(6deg); } 18% { transform: translateX(0) rotate(-3deg); } 30% { transform: rotate(0); } 100% { transform: translateX(-30px); } }
.smb-narrow .smb-cutin { height: 110px; }
.smb-narrow .smb-cutin img { height: 100px; width: 75px; }
.smb-narrow .smb-cutin p { font-size: 20px; }

.smb-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.smb-kv { display: block; width: 100%; max-height: 46vh; object-fit: contain; border-radius: 10px; border: 2px solid var(--smb-gold); background: #1a0d3d; }

/* 重ねる画面 */
.smb-layer {
  position: absolute; inset: var(--smb-int, 0px) var(--smb-inr, 0px) var(--smb-inb, 0px) var(--smb-inl, 0px); z-index: 10;
  display: flex; align-items: center; justify-content: center;
  padding: 12px; background: rgba(8, 4, 20, 0.78);
  overflow-y: auto;
}
.smb-layer[hidden] { display: none; }
.smb-card {
  position: relative; width: min(560px, 100%); margin: auto;
  background: linear-gradient(180deg, #2c1763, #1a0d3d); border: 3px solid var(--smb-line); border-radius: 16px;
  padding: 16px 18px; text-align: center; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}
.smb-small { width: min(380px, 100%); }
.smb-hero { width: 100%; max-height: 32vh; object-fit: cover; object-position: 30% 30%; border-radius: 10px; display: block; border: 2px solid var(--smb-gold); }
.smb-big { margin: 10px 0 2px; font-size: clamp(22px, 5vw, 30px); color: var(--smb-gold); text-shadow: 0 3px 0 #5a1a3a; }
.smb-sub { margin: 0 0 6px; color: var(--smb-dim); font-weight: bold; }
.smb-kicker { margin: 0; color: #fff; letter-spacing: 0.3em; font-weight: bold; }
.smb-lead { margin: 8px 0; line-height: 1.6; font-size: 15px; }
.smb-lead b { color: var(--smb-gold); }
.smb-cast { list-style: none; margin: 10px 0; padding: 0; display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.smb-cast li { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; }
.smb-cast canvas { width: 100%; max-width: 64px; }
.smb-cast span { white-space: nowrap; }
.smb-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.smb-col { flex-direction: column; align-items: stretch; }
.smb-btn {
  min-width: 130px; padding: 11px 18px; border-radius: 999px; cursor: pointer;
  border: 2px solid var(--smb-line); background: var(--smb-key); font-size: 16px; font-weight: bold;
}
.smb-btn:hover { background: var(--smb-key-on); }
.smb-btn-main { background: linear-gradient(180deg, #ff6f8e, var(--smb-red)); border-color: #ffb3c2; color: #fff; text-shadow: 0 1px 0 #7a1020; }
.smb-btn-main:hover { background: linear-gradient(180deg, #ff86a1, #e04456); }
.smb-best { margin: 10px 0 0; color: var(--smb-gold); font-weight: bold; min-height: 1.2em; }
.smb-note { margin: 8px 0 0; font-size: 11px; color: var(--smb-dim); line-height: 1.5; }
.smb-how { text-align: left; }
.smb-how h2 { text-align: center; }
.smb-how h3 { margin: 12px 0 4px; font-size: 15px; color: var(--smb-gold); }
.smb-how p { margin: 4px 0; line-height: 1.6; font-size: 14px; }
.smb-how table { border-collapse: collapse; width: 100%; font-size: 14px; }
.smb-how th { text-align: left; white-space: nowrap; padding: 3px 12px 3px 0; color: #fff; }
.smb-how td { padding: 3px 0; color: var(--smb-dim); }
.smb-result { display: grid; grid-template-columns: auto auto; justify-content: center; gap: 4px 18px; margin: 10px 0 0; font-size: 15px; }
.smb-result dt { color: var(--smb-dim); text-align: left; }
.smb-result dd { margin: 0; text-align: right; font-weight: bold; font-variant-numeric: tabular-nums; }
.smb-result .smb-new { color: var(--smb-gold); }
.smb-overface { display: flex; align-items: center; gap: 10px; justify-content: center; margin-top: 8px; }
.smb-overface img { width: 84px; height: 112px; object-fit: cover; object-position: top; border-radius: 10px; border: 2px solid var(--smb-gold); background: linear-gradient(180deg, #4a2590, #1f0f48); }
.smb-stand { display: block; height: min(34vh, 260px); margin: -6px auto 0; filter: drop-shadow(0 6px 14px rgba(0,0,0,0.5)); }
.smb-overface p { margin: 0; text-align: left; line-height: 1.5; font-size: 14px; }

.smb-parade { display: flex; justify-content: center; gap: 6px; margin: 8px 0 10px; }
.smb-parade img { width: 13%; max-width: 62px; border-radius: 10px; border: 2px solid var(--smb-gold); animation: smb-jump 0.9s ease-in-out infinite; }
@keyframes smb-jump { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px) rotate(4deg); } }
.smb-ending .smb-card { overflow: hidden; }
.smb-confetti { position: absolute; top: -12px; width: 10px; height: 10px; pointer-events: none; animation: smb-fall linear forwards; }
@keyframes smb-fall { to { transform: translateY(110vh) rotate(720deg); } }

@media (prefers-reduced-motion: reduce) {
  .smb-parade img, .smb-talk.smb-pop img { animation: none; }
}
