:root {
  --ink: #232838;
  --ink-soft: #5d6478;
  --bg: #eef0f5;
  --paper: #ffffff;
  --line: #d6dae5;
  --primary: #3a5bd0;
  --primary-dark: #263f9c;
  --board: #24304a;
  --well: #2f3d5c;
  --gold: #f4c24f;
  --k1: #f4b63f;
  --k2: #3fbfae;
  --k3: #ef6f5e;
  --k4: #f08d3c;
  --k5: #5b8def;
  --k6: #6cc04a;
  --k7: #e55ea0;
  --k8: #9b6bd6;
  --k9: #2fa6d9;
  --k10: #8a8fa3;
  --font: "Zen Kaku Gothic New", system-ui, sans-serif;
  --num: "Martian Mono", ui-monospace, "Zen Kaku Gothic New", monospace;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-weight: 500; line-height: 1.7; line-break: strict; }
.hidden { display: none !important; }
.nw { white-space: nowrap; }

.g-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; max-width: 520px; margin: 0 auto; font-size: 13px; font-weight: 900; }
.g-brand { color: var(--ink-soft); text-decoration: none; white-space: nowrap; }
.g-title { flex: 1; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-head [data-mg-account] a { color: var(--primary-dark); text-decoration: none; }

main { max-width: 520px; margin: 0 auto; padding: 0 12px 24px; }
.play { position: relative; user-select: none; -webkit-user-select: none; }

/* 点数・のこり・連続 */
.bar { display: grid; grid-template-columns: 1.3fr 1fr 1fr 44px; gap: 6px; margin: 0 auto 8px; max-width: 420px; }
.box { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 3px 6px; text-align: center; min-width: 0; position: relative; }
.lbl { font-size: 11px; line-height: 1.5; font-weight: 900; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.val { font: 700 20px/1.2 var(--num); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar .tool { justify-content: center; padding: 0; }
.val.bump { animation: bump 0.35s ease-out; }
@keyframes bump { 30% { transform: scale(1.18); color: var(--primary); } }
.combo .keep { display: flex; justify-content: center; gap: 4px; margin-top: 1px; height: 6px; }
.combo .keep i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.combo .keep i.on { background: var(--k7); }
.combo.live { border-color: var(--k7); background: #fff2f8; }
.combo.live .val { color: #c2397c; }

/* 盤 */
/* 背の低い画面でも、盤と下の3つが1画面に収まるよう、盤の大きさを画面の高さでも決める */
.board-wrap { position: relative; width: 100%; max-width: min(420px, calc(100svh - 230px)); min-width: 240px; margin: 0 auto; }
.board { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; padding: 6px; background: var(--board); border-radius: 16px; box-shadow: 0 10px 28px rgba(36, 48, 74, 0.28); aspect-ratio: 1 / 1; }
.board.shake { animation: shake 0.3s ease-out; }
@keyframes shake { 20% { transform: translate(-3px, 1px); } 45% { transform: translate(3px, -1px); } 70% { transform: translate(-2px, 0); } }
.cell { border-radius: 5px; background: var(--well); position: relative; }
.cell.k1, .pc.k1 { background: var(--k1); }
.cell.k2, .pc.k2 { background: var(--k2); }
.cell.k3, .pc.k3 { background: var(--k3); }
.cell.k4, .pc.k4 { background: var(--k4); }
.cell.k5, .pc.k5 { background: var(--k5); }
.cell.k6, .pc.k6 { background: var(--k6); }
.cell.k7, .pc.k7 { background: var(--k7); }
.cell.k8, .pc.k8 { background: var(--k8); }
.cell.k9, .pc.k9 { background: var(--k9); }
.cell.k10 { background: var(--k10); }
/* ブロックの立体感（上が明るく下が暗い） */
.cell[class*=" k"], .pc { box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.35), inset 0 -3px 0 rgba(0, 0, 0, 0.22); }
.cell.k10 { box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25); background-image: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.12) 0 3px, transparent 3px 7px); }
.cell.land { animation: land 0.22s ease-out; }
@keyframes land { 0% { transform: scale(0.82); } 60% { transform: scale(1.06); } }
/* 置く前の影と、消える列の予告 */
.cell.sh { background: rgba(255, 255, 255, 0.38); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.75); }
.cell.will { filter: brightness(1.35); box-shadow: inset 0 0 0 2px #fff; }
.cell.will:not([class*=" k"]) { background: rgba(255, 255, 255, 0.5); }

/* 演出（消える列・点数の文字） */
.fx { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.pop { position: absolute; border-radius: 5px; animation: pop 0.42s ease-out forwards; }
@keyframes pop { 0% { transform: scale(1); filter: brightness(1.6); } 40% { transform: scale(1.18); filter: brightness(2); opacity: 1; } 100% { transform: scale(0.2); opacity: 0; } }
.float { position: absolute; transform: translate(-50%, -50%); font: 900 22px/1.15 var(--font); color: #fff; text-align: center; white-space: nowrap; text-shadow: 0 0 3px rgba(20, 26, 44, 0.85), 0 2px 0 rgba(20, 26, 44, 0.6), 0 0 14px rgba(20, 26, 44, 0.45); animation: rise 0.95s ease-out forwards; }
.float small { display: block; font-size: 0.62em; }
.float.plain { font-size: 16px; }
/* 段階 t1〜t5（同時に消した列の数と倍率）。上がるほど大きく・色が強く・長く残る */
.float em { display: block; font-style: normal; font-size: 0.7em; letter-spacing: 0.08em; }
.float.t1 { font-size: 20px; }
.float.t2 { font-size: 25px; color: #ffe08a; }
.float.t3 { font-size: 30px; color: #ffb37a; }
.float.t4 { font-size: 36px; color: #ff9fd0; animation-duration: 1.4s; }
.float.t5 { font-size: 42px; color: #fff; animation-duration: 1.4s; text-shadow: 0 0 3px #7a1f5c, 0 2px 0 #7a1f5c, 0 0 18px #ff5fb0, 0 0 30px #ffd45f; }
.float.all { color: var(--gold); font-size: 34px; animation-duration: 1.4s; }
.float.broke { font-size: 18px; color: #c9cfdf; animation-duration: 1.4s; }
.float.end { font-size: 26px; animation: endin 2.5s ease-out forwards; }
.float.end.won { color: var(--gold); font-size: 30px; }
@keyframes endin { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); } 25% { transform: translate(-50%, -50%) scale(1); } 85% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -50%); } }
.board.shake2 { animation: shake2 0.45s ease-out; }
@keyframes shake2 { 15% { transform: translate(-6px, 2px) rotate(-0.6deg); } 35% { transform: translate(6px, -2px) rotate(0.6deg); } 55% { transform: translate(-4px, 1px); } 75% { transform: translate(3px, 0); } }
.board.flash { box-shadow: 0 0 0 4px #fff, 0 0 40px rgba(255, 210, 120, 0.9), 0 10px 28px rgba(36, 48, 74, 0.28); transition: box-shadow 0.1s; }
/* 終わる場面: 置き切り＝端から光る、置けなくなった＝端から灰色に沈む（--d はマスごとの遅れ） */
.board.won .cell { animation: wave 0.7s ease-out backwards; animation-delay: var(--d, 0ms); }
@keyframes wave { 40% { filter: brightness(1.8); transform: scale(1.08); } }
.board.lost .cell[class*=" k"] { animation: sink 0.5s ease-out forwards; animation-delay: var(--d, 0ms); }
@keyframes sink { to { filter: grayscale(1) brightness(0.65); } }
/* のこり10個から目立たせる */
.box.left.hurry { border-color: #e0672f; background: #fff3ea; }
.box.left.hurry .val { color: #d4541a; }
.box.left.last .val { animation: beat 0.9s ease-in-out infinite; }
@keyframes beat { 50% { transform: scale(1.18); } }
.combo.hot { border-color: #c2397c; background: #ffe0f0; }
@keyframes rise { 0% { opacity: 0; transform: translate(-50%, -30%) scale(0.6); } 20% { opacity: 1; transform: translate(-50%, -50%) scale(1.12); } 70% { opacity: 1; transform: translate(-50%, -70%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -95%) scale(1); } }

/* 下の3つ（トレー） */
.tray { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px auto 0; max-width: 420px; height: 104px; touch-action: none; }
.slot { position: relative; display: grid; place-items: center; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; cursor: grab; min-width: 0; }
.slot.empty { background: transparent; border-style: dashed; cursor: default; }
.slot.lift .piece { opacity: 0.18; }
.slot.nofit { cursor: not-allowed; }
.slot.nofit .piece { opacity: 0.3; filter: grayscale(1); }
.slot.nofit::after { content: "置けない"; position: absolute; bottom: 4px; left: 0; right: 0; font-size: 11px; font-weight: 900; color: var(--ink-soft); text-align: center; }
.slot.hint { animation: hint 1.6s ease-in-out infinite; }
@keyframes hint { 50% { box-shadow: 0 0 0 4px rgba(58, 91, 208, 0.35); transform: translateY(-3px); } }
.slot.new .piece { animation: deal 0.28s ease-out backwards; }
.slot[data-s="1"].new .piece { animation-delay: 0.05s; }
.slot[data-s="2"].new .piece { animation-delay: 0.1s; }
@keyframes deal { 0% { transform: translateY(18px) scale(0.6); opacity: 0; } }
.piece { display: grid; gap: 2px; }
.piece .pc, .piece .px { width: var(--pcs, 18px); height: var(--pcs, 18px); border-radius: 3px; }
.piece .pc { box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35), inset 0 -2px 0 rgba(0, 0, 0, 0.22); }

/* 引っぱっているブロック */
.carry { position: fixed; left: 0; top: 0; z-index: 50; display: grid; pointer-events: none; will-change: transform; filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.3)); }
.carry .pc, .carry .px { border-radius: 5px; }
.carry.back { transition: transform 0.18s ease-in, opacity 0.18s; opacity: 0; }

.under { margin: 6px auto 0; max-width: 420px; }
.kbd { margin: 0; font-size: 12px; color: var(--ink-soft); text-align: center; }
.tool { flex: none; display: inline-flex; align-items: center; gap: 4px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--ink); font: 900 13px/1 var(--font); cursor: pointer; white-space: nowrap; }

/* タイトル・結果（盤を隠して全体を見せる） */
.play.menu .bar, .play.menu .board-wrap, .play.menu .tray, .play.menu .under { display: none; }
.card-ui { width: 100%; max-width: 420px; margin: 0 auto; background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 20px 16px 16px; text-align: center; box-shadow: 0 10px 30px rgba(35, 40, 56, 0.1); }
.logo { margin: 0; font: 900 26px/1.3 var(--font); letter-spacing: 0.02em; white-space: nowrap; }
.day { margin: 2px 0 12px; font-size: 13px; color: var(--ink-soft); font-weight: 900; }
.daily-box { border: 2px solid var(--primary); border-radius: 16px; padding: 12px; margin-bottom: 10px; }
.daily-lbl { font-size: 11px; font-weight: 900; color: var(--ink-soft); letter-spacing: 0.1em; }
.daily-name { font: 900 24px/1.4 var(--font); color: var(--primary-dark); }
.mini { display: grid; grid-template-columns: repeat(8, 9px); gap: 2px; justify-content: center; margin: 6px auto 2px; padding: 4px; width: max-content; background: var(--board); border-radius: 6px; }
.mini i { width: 9px; height: 9px; border-radius: 2px; background: var(--well); }
.mini i.on { background: var(--k10); }
.daily-note { margin: 4px 0 8px; font-size: 12px; color: var(--ink-soft); }
.done { font-size: 14px; font-weight: 900; margin-top: 6px; }
.howto { list-style: none; margin: 12px 0 0; padding: 10px 12px; background: var(--bg); border-radius: 12px; text-align: left; font-size: 13px; font-weight: 700; }
.howto li { display: flex; align-items: baseline; gap: 6px; padding: 3px 0; }
.howto .num { flex: none; font-weight: 900; color: var(--primary); }
.stats { font-size: 12px; color: var(--ink-soft); font-weight: 700; margin: 10px 0 0; }

.btn { display: block; width: 100%; margin: 8px 0; padding: 13px 10px; border: 0; border-radius: 14px; font: 900 16px/1.2 var(--font); cursor: pointer; background: var(--bg); color: var(--ink); }
.btn small { display: block; font-size: 11px; font-weight: 700; color: var(--ink-soft); margin-top: 3px; }
.btn.primary { background: var(--primary); color: #fff; box-shadow: 0 4px 0 var(--primary-dark); }
.btn.primary:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--primary-dark); }
.btn.sub { font-size: 15px; }
.btn.ghost { background: transparent; border: 2px solid var(--line); color: var(--ink-soft); font-size: 14px; }
.btn.x { background: #000; color: #fff; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn:disabled { opacity: 0.5; cursor: default; }

.clear-lbl { font-size: 13px; font-weight: 900; color: var(--primary-dark); }
.clear-big { margin: 6px 0 2px; }
.clear-big b { font: 700 56px/1 var(--num); font-variant-numeric: tabular-nums; }
.clear-big span { font: 900 18px/1 var(--font); margin-left: 4px; }
.clear-sub { margin: 0; font-size: 14px; font-weight: 700; }
.best { display: block; width: max-content; max-width: 100%; margin: 8px auto 0; padding: 2px 12px; border-radius: 999px; background: var(--gold); font-weight: 900; font-size: 13px; }
.gap { margin: 8px 0 0; font-size: 13px; font-weight: 900; color: var(--primary-dark); }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 12px 0 0; }
.facts div { background: var(--bg); border-radius: 12px; padding: 6px 2px; min-width: 0; }
.facts span { display: block; font-size: 11px; font-weight: 900; color: var(--ink-soft); white-space: nowrap; }
.facts b { font: 700 20px/1.3 var(--num); }
.rank { margin: 12px 0; padding: 8px; background: var(--bg); border-radius: 14px; }
.rank-lbl { font-size: 11px; font-weight: 900; color: var(--ink-soft); }
.rank-name { font: 900 22px/1.4 var(--font); }
.c-note { margin: 8px 0; padding: 8px 10px; border-radius: 12px; background: #fff6dd; font-size: 13px; font-weight: 700; text-align: left; }
.share { margin: 8px 0; }

.toast { position: absolute; left: 50%; top: 32%; transform: translate(-50%, -50%); z-index: 40; width: max-content; max-width: calc(100% - 24px); padding: 10px 18px; border-radius: 16px; background: rgba(35, 40, 56, 0.92); color: #fff; font-weight: 900; font-size: 14px; text-align: center; pointer-events: none; }

/* 下の解説（ポータルと同じ決まり: 行間 1.85・段落の間は1行分・見出しは前を広く後ろを狭く） */
.guide { margin-top: 28px; background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 22px 20px 12px; font-size: 15px; line-height: 1.85; }
.guide p { margin: 0 0 1em; }
.guide h2 { font: 900 19px/1.4 var(--font); margin: 32px 0 12px; padding-left: 10px; border-left: 5px solid var(--primary); }
.guide h2:first-child { margin-top: 0; }
.guide h3 { font-size: 16px; margin: 22px 0 6px; line-height: 1.5; }
.guide ul { padding-left: 1.3em; margin: 0 0 1em; }
.guide li { margin: 6px 0; }
.guide .steps { list-style: none; padding: 0; }
.guide .steps li { display: flex; align-items: baseline; gap: 6px; }
.guide .steps .num { flex: none; font-weight: 900; color: var(--primary); }
.guide details { border-top: 1px solid var(--line); padding: 12px 0; }
.guide details p { margin: 8px 0 4px; }
.guide summary { font-weight: 900; cursor: pointer; }
.guide a { color: var(--primary-dark); }
.g-foot { max-width: 520px; margin: 0 auto; padding: 14px 16px 28px; font-size: 12px; text-align: center; }
.g-foot a { color: var(--ink-soft); }

.card-ui .mg-box { background: var(--bg); border-color: transparent; }

@media (max-width: 360px) {
  .logo { font-size: 22px; }
  .board { gap: 2px; padding: 5px; }
  .tray { height: 96px; gap: 6px; }
  .bar { grid-template-columns: 1.3fr 1fr 1fr 40px; gap: 5px; }
  .val { font-size: 18px; }
  .clear-big b { font-size: 48px; }
}
@media (prefers-reduced-motion: reduce) {
  .board.shake, .board.shake2, .cell.land, .val.bump, .slot.hint, .slot.new .piece, .box.left.last .val, .board.won .cell { animation: none; }
  .board.lost .cell[class*=" k"] { animation-duration: 0.01s; animation-delay: 0ms; }
  .float.end { animation: fade 2.5s ease-in forwards; }
  .pop { animation: fade 0.3s ease-out forwards; }
  .float { animation: fade 0.9s ease-out forwards; }
  .carry.back { transition: opacity 0.12s; }
}
@keyframes fade { 0% { opacity: 1; } 100% { opacity: 0; } }
