/* ワード・クラッシュ10 — スタイルシート */
/* すべての色・フォント・レイアウトはここで管理します */
@import url("https://fonts.googleapis.com/css2?family=BIZ+UDGothic:wght@400;700&family=LINE+Seed+JP:wght@700&family=Roboto+Condensed:wght@700;800;900&family=Lexend:wght@700;800;900&display=swap");

/* ── CSS変数（テーマカラー） ──────────────────────── */
:root {
  --color-bg:        #0267dc;
  --color-panel:     #043590;
  --color-panel-2:   #0648b8;
  --color-line:      rgba(178,226,255,0.45);
  --color-text:      #ffffff;
  --color-muted:     rgba(255,255,255,0.72);
  --color-gold:      #ffd22e;
  --color-red:       #ff5d57;
  --color-blue:      #55b7ff;
  --color-green:     #54d38a;

  --skin-bg-1:       #0788ff;
  --skin-bg-2:       #004ebf;
  --skin-bg-3:       #003188;
  --skin-panel:      #01348f;
  --skin-panel-deep: #022168;
  --skin-board:      rgba(1,18,72,0.97);
  --btn-bg-1:   #006bdf;
  --btn-bg-2:   #0045b8;
  --btn-bg-3:   #002778;
  --btn-border: rgba(80,183,255,0.98);
  --btn-glow-1: rgba(80,183,255,0.65);
  --btn-glow-2: rgba(80,183,255,0.28);
  --btn-shadow: rgba(0,15,76,0.9);
  --skin-en-top:     #f0ffff;
  --skin-en-mid:     #91ecff;
  --skin-en-btm:     #16b8e7;
  --skin-en-text:    #07195d;
  --skin-ja-top:     #fff9cf;
  --skin-ja-mid:     #ffdc6e;
  --skin-ja-btm:     #ff9b1f;
  --skin-ja-text:    #4a1d02;

  --card-en-bg:      var(--skin-en-mid);
  --card-ja-bg:      var(--skin-ja-mid);

  --color-en-top:    var(--skin-en-top);
  --color-en-btm:    var(--skin-en-btm);
  --color-ja-top:    var(--skin-ja-top);
  --color-ja-btm:    var(--skin-ja-btm);

  --font-base: "BIZ UDGothic", system-ui, sans-serif;
  --font-en: "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  --font-ja: "LINE Seed JP", "BIZ UDGothic", "Hiragino Sans", system-ui, sans-serif;
  --radius-base: 8px;
}

body[data-skin="pink"] {
  --skin-bg-1: #ff7ac8; --skin-bg-2: #b72ed8; --skin-bg-3: #641a9c; --skin-panel: #7b1fb4;
  --skin-board: rgba(28,0,58,0.97);
  --btn-bg-1: #cc30e0; --btn-bg-2: #8a18b8; --btn-bg-3: #500880;
  --btn-border: rgba(255,130,230,0.98); --btn-glow-1: rgba(255,100,220,0.65); --btn-glow-2: rgba(255,100,220,0.28); --btn-shadow: rgba(60,0,80,0.9);
  --card-en-bg: #8bf3c9; /* ミントグリーン（ピンクと被らない） */
  --card-ja-bg: #ffd558; /* ゴールドイエロー */
}
body[data-skin="sunset"] {
  --skin-bg-1: #ffb142; --skin-bg-2: #ff5d7d; --skin-bg-3: #5524b8; --skin-panel: #7d2ea3;
  --skin-board: rgba(22,6,55,0.97);
  --btn-bg-1: #ff6828; --btn-bg-2: #cc2858; --btn-bg-3: #7a0090;
  --btn-border: rgba(255,160,80,0.98); --btn-glow-1: rgba(255,130,60,0.65); --btn-glow-2: rgba(255,130,60,0.28); --btn-shadow: rgba(80,0,60,0.9);
  --card-en-bg: #8debff; /* ライトシアン（赤と被らない） */
  --card-ja-bg: #b0ffb5; /* ライトグリーン */
}
body[data-skin="rainbow"] {
  --skin-bg-1: #36d1dc; --skin-bg-2: #5b86e5; --skin-bg-3: #8a45ff; --skin-panel: #255fd1;
  --skin-board: rgba(4,14,60,0.97);
  --btn-bg-1: #18c0d0; --btn-bg-2: #2858d8; --btn-bg-3: #5828c0;
  --btn-border: rgba(100,210,255,0.98); --btn-glow-1: rgba(80,200,255,0.65); --btn-glow-2: rgba(80,200,255,0.28); --btn-shadow: rgba(0,20,80,0.9);
  --card-en-bg: #90f0ff; /* 明るいシアン */
  --card-ja-bg: #ffd558; /* ゴールドイエロー */
}
body[data-skin="midnight"] {
  --skin-bg-1: #1672ff; --skin-bg-2: #093da7; --skin-bg-3: #07135f; --skin-panel: #071b74;
  --skin-board: rgba(1,3,32,0.98);
  --btn-bg-1: #1050e8; --btn-bg-2: #0838b0; --btn-bg-3: #041870;
  --btn-border: rgba(60,140,255,0.98); --btn-glow-1: rgba(60,140,255,0.65); --btn-glow-2: rgba(60,140,255,0.28); --btn-shadow: rgba(0,10,60,0.9);
}

/* ── リセット ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── ページ共通 ───────────────────────────────────── */
body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% 8%, rgba(255,255,255,0.30), transparent 24%),
    linear-gradient(180deg, var(--skin-bg-1), var(--skin-bg-2) 42%, var(--skin-bg-3));
  color: var(--color-text);
  font-family: var(--font-base);
  display: flex;
  justify-content: center;
  padding: 0;
  overflow-x: hidden;
}

[hidden] {
  display: none !important;
}

/* ═══════════════════════════════════════════════════
   グレード選択画面 (index.html)
═══════════════════════════════════════════════════ */

.grade-app {
  width: min(740px, 100%);
  padding: 32px 0 24px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.grade-header { text-align: center; }
.grade-header h1 { font-size: clamp(26px, 5vw, 48px); line-height: 1; }
.grade-header p  { margin-top: 8px; color: var(--color-muted); font-size: 14px; }

.grade-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.grade-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 20px 12px;
  border: 1px solid var(--color-line);
  background: rgba(255,255,255,0.045);
  border-radius: var(--radius-base);
  color: var(--color-text);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 180ms, background 180ms, transform 180ms;
}
.grade-card:hover {
  border-color: rgba(255,255,255,0.38);
  background: rgba(255,255,255,0.10);
  transform: translateY(-2px);
}
.grade-card__label {
  font-size: clamp(20px, 3.5vw, 28px);
  font-weight: 900;
  line-height: 1;
}
.grade-card__en   { font-size: 11px; color: var(--color-muted); }
.grade-card__count{ font-size: 11px; color: var(--color-muted); }
.grade-card__classic {
  margin-top: 6px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-base);
  padding: 5px 9px;
  color: var(--color-gold);
  font-size: 11px;
  font-weight: 900;
}

/* 準N級は2列で中央寄せ */
.grade-grid--sub {
  grid-template-columns: repeat(2, 1fr);
  max-width: 400px;
  margin: 0 auto;
  width: 100%;
}

.grade-footer { text-align: center; color: var(--color-muted); font-size: 12px; }

/* ═══════════════════════════════════════════════════
   ゲーム画面 (game.html)
═══════════════════════════════════════════════════ */

.game-app {
  width: 100%;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}

/* ── 上部バー ────────────────────────────────────── */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}
.topbar__title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}
.topbar__title h1 {
  font-size: clamp(22px, 4vw, 38px);
  line-height: 1;
}
.topbar__sub {
  color: var(--color-muted);
  font-size: 13px;
  white-space: nowrap;
}

/* ── HUD ─────────────────────────────────────────── */
.hud {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.hud__pill {
  min-width: 86px;
  border: 1px solid var(--color-line);
  background: rgba(255,255,255,0.055);
  padding: 7px 10px;
  border-radius: var(--radius-base);
  text-align: center;
}
.hud__pill b {
  display: block;
  color: #fff;
  font-size: 18px;
  line-height: 1.05;
}
.hud__pill span {
  color: var(--color-muted);
  font-size: 11px;
  white-space: nowrap;
}

/* ── プログレスバー ──────────────────────────────── */
.progress-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: rgba(255,255,255,0.045);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-base);
}
.progress-bar__track {
  height: 12px;
  background: rgba(0,0,0,0.28);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar__fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--color-green), var(--color-gold), #ff7b54);
  transition: width 420ms cubic-bezier(.2,.8,.2,1);
}
.progress-bar__label {
  color: var(--color-muted);
  font-weight: 700;
  font-size: 13px;
}

/* ── ハンバーガーメニュー ───────────────────────── */
.menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
}
.menu-popup {
  position: fixed;
  top: 78px;
  right: 8px;
  z-index: 50;
  background: rgba(0,20,80,0.97);
  border: 2px solid rgba(80,183,255,0.5);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  overflow: hidden;
  min-width: 160px;
}
.menu-popup__item {
  display: block;
  width: 100%;
  padding: 14px 20px;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font-base);
  text-align: left;
  text-decoration: none;
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 1px solid rgba(80,183,255,0.18);
}
.menu-popup__item:last-child { border-bottom: none; }
.menu-popup__item:active { background: rgba(80,183,255,0.15); }
.menu-popup__item--danger { color: #ff7070; }

/* ── ミッション ──────────────────────────────────── */
.mission {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 13px 18px;
  border: 3px solid rgba(255,238,176,0.86);
  background: linear-gradient(180deg, rgba(4,67,174,0.96), rgba(1,41,128,0.98));
  border-radius: 18px;
  box-shadow: inset 0 2px rgba(255,255,255,0.18), 0 5px 0 rgba(0,24,91,0.9);
}
.mission__title {
  display: block;
  color: #fff;
  font-size: 18px;
  font-weight: 950;
  text-shadow: 0 2px 0 rgba(0,0,0,0.32);
}
.mission__sub   { color: rgba(224,238,255,0.82); font-size: 13px; font-weight: 850; }
.mission__reward{ color: var(--color-gold); font-size: 26px; font-weight: 950; text-shadow: 0 2px 0 rgba(0,0,0,0.35); }

/* ── ヘッダー ── */
.header-bar {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  width: 100%;
  padding: 8px 16px;
  background: transparent;
  z-index: 10;
  font-family: var(--font-en), var(--font-base);
  gap: 16px;
}
.nav-left {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.nav-right {
  flex: 1;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
}

/* ── グレードバッジ ── */
.rulebar__badge {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  padding: 0;
  clip-path: none;
  background: transparent;
  filter: drop-shadow(1px 1px 0 rgba(0,0,0,0.5));
}
.badge-crown {
  font-size: 32px;
  color: var(--color-gold);
  line-height: 1;
}
.badge-grade {
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.badge-grade b {
  font-size: 32px;
  font-weight: 900;
  color: #fff;
  line-height: 1;
}
.badge-lv {
  font-size: 32px;
  font-weight: 900;
  color: #fff;
  background: rgba(255,255,255,0.18);
  border: 1.5px solid rgba(255,255,255,0.55);
  border-radius: 8px;
  padding: 2px 8px;
  line-height: 1.2;
}
.badge-lv b { color: #fff; font-weight: 900; }
.grade-kyu { font-size: 32px; font-weight: 900; color: #fff; }

/* ── アクションピル ── */
.action-pill {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 24px;
  background: transparent;
  border: none;
  box-shadow: none;
}
.action-pill--danger::after {
  content: "GAME OVER";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 8px;
  color: #ff6060;
  font-size: 24px;
  font-weight: 900;
  animation: text-danger-pulse 1s ease-in-out infinite;
}
.action-pill--danger b, .action-pill--danger span {
  color: #ff6060 !important;
  animation: text-danger-pulse 1s ease-in-out infinite;
}
@keyframes text-danger-pulse {
  0%,100% { text-shadow: 0 1px 0 rgba(0,0,0,0.8); }
  50%     { text-shadow: 0 0 10px #ff6060, 0 1px 0 rgba(0,0,0,0.8); }
}

.rulebar__btn--shuffle {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, var(--btn-bg-1), var(--btn-bg-2));
  border: 1px solid var(--btn-border);
  box-shadow: 0 2px 4px rgba(0,0,0,0.3), inset 0 1px 1px rgba(255,255,255,0.3);
  border-radius: 8px;
  padding: 4px 14px;
  gap: 8px;
  cursor: pointer;
  min-width: 72px;
  transition: transform 0.15s, filter 0.15s;
}
.rulebar__btn--shuffle:hover {
  filter: brightness(1.15);
  transform: scale(1.05);
}
.rulebar__btn--shuffle:active {
  filter: brightness(0.88);
  transform: scale(0.93) translateY(2px);
  transition: transform 0.07s, filter 0.07s;
}
.action-pill__free {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  justify-content: center;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 6px 8px;
  gap: 6px;
  cursor: default;
}
.rulebar__btn--shuffle .rulebar__icon {
  font-size: 32px;
  color: #fff;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
}
.rulebar__btn--shuffle b, .action-pill__free b {
  font-size: 32px;
  font-weight: 900;
  color: #fff;
  font-family: var(--font-en);
  text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
  line-height: 1;
}
.action-pill__free span {
  font-size: 32px;
  color: #fff;
  font-weight: 900;
  font-family: var(--font-en);
  text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
}
.action-pill__left {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: 6px;
  padding: 6px 8px;
}
.action-pill__left b {
  font-size: 32px;
  font-weight: 900;
  color: #fff;
  font-family: var(--font-en);
  text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
  line-height: 1;
}
.action-pill__left span {
  font-size: 32px;
  color: #fff;
  font-weight: 900;
  font-family: var(--font-en);
  text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
}

.rulebar__stat--combo b {
  font-size: 96px;
  font-weight: 900;
  background: linear-gradient(to bottom, #FFFFFF 0%, #FFE566 25%, #FF8C00 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(1px 1px 0 rgba(0,0,0,0.5));
  line-height: 0.9;
  font-family: "Lexend", var(--font-en);
  letter-spacing: -0.02em;
}
.rulebar__stat--combo span {
  font-size: 32px;
  color: var(--color-gold);
  font-weight: 900;
  font-family: var(--font-en);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
}

.rulebar__menu {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: transparent;
  border: none;
  padding: 4px;
  cursor: pointer;
}
.rulebar__menu span {
  display: block;
  width: 24px;
  height: 3px;
  background: #fff;
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

.rulebar__stat--combo {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  justify-content: center;
  background: transparent;
  border: none;
  box-shadow: none;
  gap: 6px;
  pointer-events: none;
}
.combo-display { display: flex; align-items: baseline; gap: 2px; }
.combo-slash { font-size: 0.35em; opacity: 0.8; }

.rulebar__secondary {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 20px;
  padding-top: 0;
}
.rulebar__sec-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  filter: drop-shadow(1px 1px 0 rgba(0,0,0,0.5));
}
.rulebar__sec-item b {
  font-size: 32px;
  font-weight: 900;
  color: #fff;
  font-family: var(--font-en);
}
.rulebar__sec-item span {
  font-size: 32px;
  font-weight: 900;
  color: #fff;
  font-family: var(--font-en);
}

.rulebar__btn:disabled { opacity: 0.45; cursor: default; }
@keyframes combo-bump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.3); filter: drop-shadow(0 0 12px rgba(255,220,0,0.9)); }
  70%  { transform: scale(0.95); }
  100% { transform: scale(1); filter: none; }
}
#comboStat.combo--bump b { animation: combo-bump 220ms cubic-bezier(0.34,1.56,0.64,1); }
@keyframes rainbow-text {
  0%   { color: #ff5757; } 14%  { color: #ff9f00; } 28%  { color: #ffe600; }
  42%  { color: #22e820; } 57%  { color: #00b4ff; } 71%  { color: #b400ff; }
  85%  { color: #ff57c8; } 100% { color: #ff5757; }
}
@keyframes combo-glow-pulse {
  animation: combo-glow-pulse 1.2s ease-in-out infinite;
  border-color: rgba(255,220,0,0.6);
}

.mission-bonus-float {
  font-size: clamp(18px, 3.5vw, 28px);
  font-weight: 900;
  font-style: italic;
  font-family: "Lexend", var(--font-en);
  color: #ffe600;
  pointer-events: none;
  z-index: 30;
  animation: floatUp 1.4s ease-out forwards;
  white-space: nowrap;
  text-shadow: 0 2px 6px rgba(0,0,0,0.8);
}

.inline-hint {
  min-height: 22px;
  padding: 3px 12px;
  font-size: 13px;
  font-weight: 700;
  color: rgba(255,255,255,0.85);
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  text-align: center;
}
.rulebar__btn:disabled {
  opacity: 0.45;
  cursor: default;
}
.rulebar__menu {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  text-decoration: none;
}
.rulebar__menu span {
  display: block;
  width: 22px;
  height: 3px;
  background: #fff;
  border-radius: 2px;
  flex-shrink: 0;
}

.nextbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.nextbar[hidden] {
  display: none !important;
}
.nextbar div {
  border: 1px solid rgba(85,183,255,0.22);
  background: rgba(85,183,255,0.07);
  border-radius: var(--radius-base);
  min-height: 38px;
  padding: 6px 10px;
}
.nextbar span {
  display: block;
  color: var(--color-muted);
  font-size: 10px;
  font-weight: 900;
}
.nextbar b {
  color: #fff;
  font-size: 14px;
  line-height: 1.1;
}

.abilitybar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.abilitybar__item {
  border: 1px solid var(--color-line);
  background: rgba(255,255,255,0.055);
  border-radius: var(--radius-base);
  min-height: 38px;
  padding: 6px 10px;
  text-align: center;
}
.abilitybar__item b {
  display: block;
  color: #fff;
  font-size: 18px;
  line-height: 1;
}
.abilitybar__item span {
  color: var(--color-muted);
  font-size: 11px;
}

/* ── 盤面シェル ──────────────────────────────────── */
.board-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 0;
  padding: 0 14px;
  width: 100%;
}

/* ── 盤面 ────────────────────────────────────────── */
.board {
  position: relative;
  --cell-size: 62px;
  width: calc(6 * var(--cell-size));
  height: calc(8 * var(--cell-size));
  aspect-ratio: auto;
  border: 2px solid rgba(255,255,255,0.18);
  background: var(--skin-board);
  border-radius: 8px;
  isolation: isolate;
  transform: translateZ(0);
  box-shadow: inset 0 4px 20px rgba(0,0,0,0.55), inset 0 0 0 1px rgba(0,0,0,0.3);
}
.board::before {
  display: none;
}

.board--side {
  background: var(--skin-board);
}

.board__zone-label {
  position: absolute;
  left: 10px;
  z-index: 2;
  font-size: 11px;
  font-weight: 900;
  color: rgba(255,255,255,0.38);
  letter-spacing: 0.08em;
}
.board__zone-label--en { top: 8px; }
.board__zone-label--ja { top: calc(50% + 8px); }
.board--side .board__zone-label--en {
  top: 8px;
  left: 10px;
}
.board--side .board__zone-label--ja {
  top: 8px;
  left: calc(50% + 10px);
}

/* ── コネクターライン ────────────────────────────── */
.board__connector {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  z-index: 18;
  pointer-events: none;
}
.board__connector line {
  opacity: 0;
  stroke: #fff;
  stroke-width: 5;
  stroke-linecap: round;
  filter: drop-shadow(0 0 8px rgba(247,201,72,0.8));
}
.board__connector line.is-active { opacity: 0.9; }

/* ── カード ──────────────────────────────────────── */
.card {
  position: absolute;
  width: calc(100% / var(--cols, 5));
  height: calc(100% / var(--rows, 4));
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2px;
  border: none;
  border-radius: 6px;
  color: #07195d;
  font-weight: 850;
  text-align: center;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255,255,255,0.6);
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
  cursor: pointer;
  user-select: none;
  touch-action: none;
  --tx: 0px;
  --ty: 0px;
  --card-scale: 1;
  transform-origin: center center;
  transform: translate3d(var(--tx), var(--ty), 0) scale(var(--card-scale));
  transition:
    transform 330ms cubic-bezier(.18,.9,.28,1.18),
    opacity 220ms ease,
    filter 180ms ease,
    border-color 180ms ease;
  z-index: 3;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 5px;
  border: none;
  box-shadow: none;
  pointer-events: none;
}
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 4px;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,0.65) 50%, transparent 70%);
  background-size: 220% 100%;
  background-position: 200% 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.card--study::after,
.card--combo::after {
  opacity: 1;
  animation: cardShimmer 1.1s ease-in-out infinite;
}
@keyframes cardShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -60% 0; }
}
.card--en {
  font-family: var(--font-en);
  color: var(--skin-en-text);
  background: var(--card-en-bg);
  box-shadow:
    inset 0 2.5px 0 rgba(255,255,255,0.55),
    inset 2.5px 0 0 rgba(255,255,255,0.3),
    inset 0 -3px 0 rgba(0,0,0,0.35),
    inset -3px 0 0 rgba(0,0,0,0.2),
    0 2.5px 0 rgba(0,0,0,0.55);
  text-shadow: 0 1px 0 rgba(255,255,255,0.5);
  font-size: clamp(18px, 3.4vw, 30px);
}
.card--ja {
  font-family: var(--font-ja);
  color: var(--skin-ja-text);
  background: var(--card-ja-bg);
  box-shadow:
    inset 0 2.5px 0 rgba(255,255,255,0.55),
    inset 2.5px 0 0 rgba(255,255,255,0.3),
    inset 0 -3px 0 rgba(0,0,0,0.35),
    inset -3px 0 0 rgba(0,0,0,0.2),
    0 2.5px 0 rgba(0,0,0,0.55);
  text-shadow: 0 1px 0 rgba(255,255,255,0.45);
  font-size: clamp(16px, 3vw, 26px);
}

.card__main {
  max-width: 100%;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.02em;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
  text-align: center;
}
.card--en .card__main {
  overflow-wrap: normal;
  word-break: normal;
  white-space: normal;
}
.card__sub {
  max-width: 100%;
  margin-top: 3px;
  font-size: .58em;
  font-weight: 700;
  color: currentColor;
  opacity: .78;
  line-height: 1.05;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
  text-align: center;
}
.card__sub:empty {
  display: none;
}
.card__count {
  position: absolute;
  bottom: 5px;
  right: 7px;
  font-size: 9px;
  line-height: 1;
  color: currentColor;
  opacity: 0.35;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.card--ja .card__sub { font-size: 1em; opacity: 1; }           /* ≤4文字カード: base */
.card--ja-med   .card__sub { font-size: 0.85em; }              /* 4文字カード sub */
.card--ja-break .card__sub { font-size: 0.75em; }              /* 5+文字カード sub: mainと同サイズ */
.card--ja-break .card__sub--lg { font-size: 0.65em; }          /* sub 5文字以上: overflow防止 */
.card--ja .card__main {
  word-break: keep-all;
  overflow-wrap: break-word;
  white-space: nowrap;
  line-height: 0.92;
}

/* 文字数によるフォントサイズ調整 (6文字以上、10文字以上、16文字以上) */
.card--long   .card__main { font-size: .86em; letter-spacing: -0.035em; }
.card--xlong  .card__main { font-size: .75em; letter-spacing: -0.03em; }
.card--xxlong .card__main { font-size: .72em; letter-spacing: -0.02em; line-height: 1.2; word-break: break-word; }
.card--xxlong             { padding: 1px; }
.card--xxlong .card__sub  { font-size: .40em; }

/* 4語以上の英語熟語：折り返し許可・フォント優先 */
.card--phrase .card__main {
  font-size: .82em;
  letter-spacing: -0.02em;
  line-height: 1.2;
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
}

/* 4文字の日本語：1行・フォント縮小 */
.card--ja-med .card__main {
  font-size: 0.85em;
}

/* 5文字以上の日本語：2行折り返し */
.card--ja-break .card__main {
  font-size: 0.75em;
  white-space: normal;
  word-break: break-all;
  line-height: 1.2;
}

/* 密度が高い盤面（5列以上）: カード幅基準 */
.board--dense .card--en              { font-size: clamp(15px, 2.8vw, 27px); }
.board--dense .card--ja              { font-size: clamp(12px, 2.15vw, 19px); }
.board--dense .card--long.card--en   { font-size: clamp(13px, 2.3vw, 22px); }
.board--dense .card--long.card--ja   { font-size: clamp(10px, 1.9vw, 16px); }
.board--dense .card--xlong.card--en  { font-size: clamp(11px, 2vw, 19px); }
.board--dense .card--xlong.card--ja  { font-size: clamp(9px, 1.7vw, 14px); }
/* 長い1単語（passenger等）: カード幅内で折り返し許可 */
.board--dense .card--long.card--en .card__main { overflow-wrap: normal; word-break: normal; }

/* カード状態 */
.card--selected {
  --card-scale: 1.32;
  border-color: #fff;
  filter: brightness(1.22);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.22), 0 0 24px rgba(255,255,255,0.28);
  z-index: 20;
}
.card--matching {
  animation: cardPop 420ms ease forwards;
  pointer-events: none;
}
.card--combo {
  box-shadow: 0 0 0 4px rgba(255,45,120,0.5), 0 0 28px rgba(255,45,120,0.55);
}
.card--study,
.card--combo {
  border-color: rgba(255,45,120,0.95) !important;
  box-shadow:
    inset 0 2.5px 0 rgba(255,255,255,0.6),
    inset 2.5px 0 0 rgba(255,255,255,0.35),
    inset 0 -3px 0 rgba(140,0,50,0.4),
    inset -3px 0 0 rgba(140,0,50,0.25),
    0 2.5px 0 rgba(140,0,50,0.8) !important;
}
.card--study.card--en,
.card--combo.card--en {
  background: linear-gradient(145deg, #fff8fb 0 8%, #ffd6e8 12%, #ff85b3 68%, #ff2d78 100%);
}
.card--study.card--ja,
.card--combo.card--ja {
  background: linear-gradient(145deg, #fff8fb 0 8%, #ffd6e8 12%, #ff85b3 68%, #ff2d78 100%);
}
.card--wrong {
  animation: cardShake 380ms ease;
  background: rgb(210, 110, 110) !important;
}

@keyframes cardShake {
  0%,100% { translate: 0 0; }
  15% { translate: -9px 0; }
  35% { translate:  8px 0; }
  55% { translate: -6px 0; }
  75% { translate:  4px 0; }
  40% { translate:  8px 0; }
  60% { translate: -6px 0; }
  80% { translate:  5px 0; }
}
@keyframes cardPop {
  0%   { opacity: 1; filter: brightness(1); }
  100% { opacity: 0; filter: brightness(1); }
}

/* ── フロートテキスト ────────────────────────────── */
.float-text.float-text--penalty {
  color: #ff2020;
  -webkit-text-fill-color: #ff2020;
  font-size: clamp(22px, 4vw, 36px);
  filter:
    drop-shadow(0 2px 0 rgba(0,0,0,0.95))
    drop-shadow(0 5px 0 rgba(160,0,0,0.75));
}
.float-text {
  position: absolute;
  z-index: 20;
  pointer-events: none;
  font-size: clamp(14px, 2.5vw, 22px);
  font-weight: 950;
  font-style: italic;
  font-family: "Lexend", var(--font-en);
  color: #fff;
  -webkit-text-fill-color: #fff;
  background: none;
  filter:
    drop-shadow(0 2px 0 rgba(0,0,0,0.95))
    drop-shadow(0 4px 0 rgba(0,0,0,0.6));
  animation: floatUp 900ms cubic-bezier(.18,.9,.28,1.1) forwards;
}
@keyframes floatUp {
  0%   { opacity: 0; transform: translate(-50%, -10%) scale(0.6); }
  16%  { opacity: 1; transform: translate(-50%, -22%) scale(1.12); }
  30%  { transform: translate(-50%, -28%) scale(0.94); }
  48%  { opacity: 1; transform: translate(-50%, -32%) scale(1.02); }
  100% { opacity: 0; transform: translate(-50%, -130%) scale(1.08); }
}

/* ── コンボバースト ──────────────────────────────── */
.combo-burst {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 22;
  font-size: clamp(22px, 4vw, 38px);
  font-weight: 950;
  font-style: italic;
  font-family: "Lexend", var(--font-en);
  background: linear-gradient(180deg, #ffe566 10%, #ff9000 55%, #cc5500 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
  filter:
    drop-shadow(0 3px 0 rgba(150,55,0,0.95))
    drop-shadow(0 5px 0 rgba(0,0,0,0.8));
  animation: comboBurst 1100ms cubic-bezier(.18,.9,.28,1.1) forwards;
  pointer-events: none;
  white-space: nowrap;
}
@keyframes comboBurst {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.18) rotate(-14deg); }
  14%  { opacity: 1; transform: translate(-50%, -50%) scale(1.28) rotate(6deg); }
  24%  { transform: translate(-50%, -50%) scale(0.87) rotate(-3deg); }
  34%  { transform: translate(-50%, -50%) scale(1.1) rotate(1deg); }
  46%  { transform: translate(-50%, -50%) scale(0.97) rotate(0deg); }
  70%  { opacity: 1; transform: translate(-50%, -50%) scale(1.0); }
  100% { opacity: 0; transform: translate(-50%, -86%) scale(1.28); }
}

/* ── クリアオーバーレイ ──────────────────────────── */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: none;
  place-items: center;
  background: rgba(16,17,20,0.72);
  backdrop-filter: blur(4px);
}
.overlay--show { display: grid; }

/* ゲームオーバーポップアップ: </main>外・IDで直接制御 */
#gameOverOverlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  place-items: center;
  background: rgba(16,17,20,0.82);
  backdrop-filter: blur(4px);
}

.clear-box {
  width: min(560px, calc(100% - 28px));
  border: 1px solid rgba(247,201,72,0.42);
  background: rgba(25,27,32,0.94);
  border-radius: var(--radius-base);
  padding: 26px 22px 20px;
  text-align: center;
  box-shadow: 0 25px 75px rgba(0,0,0,0.55);
}
.clear-box__title {
  font-size: clamp(38px, 9vw, 78px);
  line-height: .95;
  color: var(--color-gold);
  font-family: "Lexend", var(--font-en);
  font-weight: 900;
  letter-spacing: -0.02em;
  text-shadow: 0 0 24px rgba(247,201,72,0.5), 0 2px 0 rgba(0,0,0,0.3);
  margin-bottom: 12px;
}

/* ミッション結果 */
.clear-mission {
  font-size: 15px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 8px;
  margin-bottom: 14px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.15);
  line-height: 1.5;
}

/* 統計3ボックス */
.clear-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.clear-stat {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: var(--radius-base);
  padding: 12px 8px;
  text-align: center;
}
.clear-stat__value {
  display: block;
  font-size: clamp(24px, 5vw, 40px);
  font-weight: 900;
  color: var(--color-gold);
  font-family: var(--font-en);
  line-height: 1;
  text-shadow: 0 1px 0 rgba(0,0,0,0.6);
}
.clear-stat__label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--color-muted);
  margin-top: 4px;
  letter-spacing: 0.04em;
}

/* Lvアップ */
.clear-lvup {
  font-size: 15px;
  font-weight: 900;
  color: var(--color-gold);
  text-shadow: 0 0 10px rgba(247,201,72,0.6);
  margin-bottom: 10px;
  min-height: 1.4em;
}

.actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

/* ── チャンクマップ ───────────────────────────────── */
.chunk-map {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  margin-top: 18px;
  max-height: 160px;
  overflow-y: auto;
  padding: 2px 4px;
}
.chunk-map__cell {
  width: 28px;
  height: 28px;
  border-radius: 5px;
  font-size: 9px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.3);
  border: 1px solid rgba(255,255,255,0.1);
}
.chunk-map__cell--done {
  background: rgba(85,183,255,0.25);
  color: rgba(255,255,255,0.7);
  border-color: rgba(85,183,255,0.35);
}
.chunk-map__cell--current {
  background: var(--color-gold);
  color: #1a1200;
  border-color: var(--color-gold);
  box-shadow: 0 0 8px rgba(247,201,72,0.6);
}

/* ── ボタン ──────────────────────────────────────── */
.btn {
  border: 1px solid var(--color-line);
  background: var(--color-panel-2);
  color: var(--color-text);
  border-radius: var(--radius-base);
  min-height: 42px;
  padding: 0 14px;
  font-weight: 850;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-base);
  font-size: 14px;
  transition: background 160ms, border-color 160ms;
}
.btn--primary {
  border-color: rgba(247,201,72,0.45);
  background: linear-gradient(180deg, #f8ce55, #b96e1d);
  color: #18110a;
}
.btn--primary:hover { filter: brightness(1.08); }
.btn--ad {
  border-color: rgba(100,220,120,0.45);
  background: linear-gradient(180deg, #72dd8a, #1a8f3c);
  color: #0a1f0f;
}
.btn--ad:hover { filter: brightness(1.08); }

/* ── フッター ────────────────────────────────────── */
.footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  color: var(--color-muted);
  font-size: 12px;
}
.footer__hint {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.footer__hint--hidden { display: none; }
.footer__detail {
  margin-top: 6px;
  border: 1px solid var(--color-line);
  background: rgba(255,255,255,0.055);
  border-radius: var(--radius-base);
  padding: 8px 10px;
  color: var(--color-muted);
  font-size: 12px;
  line-height: 1.4;
}
.footer__detail--hidden { display: none; }
.ad-slot {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 60px;
  background: rgba(255, 255, 255, 0.05);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 12px;
  color: var(--color-muted);
}
.ad-slot::after {
  content: "広告スペース";
}
/* ── コンフェッティ ──────────────────────────────── */
.confetti {
  position: absolute;
  width: 8px;
  height: 14px;
  top: -20px;
  animation: confettiFall 1200ms linear forwards;
  z-index: 35;
}
@keyframes confettiFall {
  to { transform: translateY(120vh) rotate(680deg); opacity: 0.2; }
}

/* ── レスポンシブ ────────────────────────────────── */
@media (max-width: 700px) {
  body { padding: 0; }
  .game-app {
    min-height: 100vh;
    grid-template-rows: auto 1fr auto;
    gap: 8px;
  }
  .topbar {
    display: none;
    grid-template-columns: 1fr;
  }
  .topbar__title { display: none; }
  .hud {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  .hud__pill {
    min-width: 0;
    padding: 5px 4px;
  }
  .hud__pill:nth-child(1),
  .hud__pill:nth-child(2) {
    display: none;
  }
  .hud__pill b { font-size: 18px; }
  .hud__pill span { font-size: 10px; }
  .progress-bar { display: none; }
  .mission {
    padding: 8px 12px;
    min-height: 58px;
  }
  .mission__title { font-size: 16px; }
  .mission__sub { font-size: 12px; }
  .mission__reward { font-size: 22px; }
  /* ── ヘッダー（モバイル縦型）: 上部ナビ ── */
  /* 行1: nav-left（≡ + グレード + スコア）              */
  /* 行2: nav-right（コンボ大 ＋ アクションピル）        */
  .header-bar {
    flex-direction: column;
    padding: 6px 12px 4px;
    gap: 2px;
  }
  .nav-left {
    width: 100%;
    justify-content: space-between;
    padding: 2px 0;
  }
  .nav-right {
    width: 100%;
    flex: none;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
  }
  .rulebar__secondary { gap: 12px; flex-direction: row; }
  .rulebar__stat--combo { justify-content: center; }
  .action-pill { justify-content: center; margin: 0; }
  /* 文字サイズ 32px×60%=19px、96px×60%=58px */
  .badge-crown { font-size: 19px; }
  .badge-grade b { font-size: 19px; }
  .badge-lv { font-size: 19px; }
  .grade-kyu { font-size: 19px; }
  .action-pill__free { padding: 2px 6px; flex-direction: row; }
  .action-pill__free b { font-size: 19px; }
  .action-pill__free span { font-size: 19px; }
  .rulebar__sec-item b { font-size: 19px; }
  .rulebar__sec-item span { font-size: 19px; }
  .action-pill__left b { font-size: 19px; }
  .action-pill__left span { font-size: 19px; }
  .rulebar__stat--combo b { font-size: 40px; }
  .rulebar__stat--combo span { font-size: 19px; }
  .grade-kyu, .grade-lv-bot { font-size: 19px; }
  .rulebar__btn b { font-size: 19px; }
  .rulebar__icon { font-size: 19px; }
  .rulebar__btn--shuffle { padding: 2px 10px; }
  .rulebar__menu { gap: 4px; padding: 4px 8px; }
  .rulebar__menu span { width: 22px; height: 3px; }
  .nextbar {
    gap: 6px;
  }
  .nextbar div {
    min-height: 30px;
    padding: 4px 8px;
  }
  .nextbar b { font-size: 12px; }
  .board-shell {
    overflow-x: hidden;
    overflow-y: hidden;
    justify-items: stretch;
  }
  .board {
    width: calc(6 * var(--cell-size));
    height: calc(8 * var(--cell-size));
    min-height: 0;
    aspect-ratio: auto;
    max-height: none;
  }
  .card {
    width: calc(100% / var(--cols, 5) - 3px);
    height: calc(100% / var(--rows, 4) - 3px);
    padding: 1px;
  }
  /* モバイルカードフォント: 6列☥6px幅に収まる値に統一。短単語が折り返さないようword-break:normal */
  .card--en  {
    font-size: clamp(19px, 5.6vw, 30px);
    letter-spacing: 0;
    word-break: normal;
    overflow-wrap: break-word;
  }
  .board--dense .card--en {
    font-size: clamp(17px, 5vw, 26px);
  }
  .card--en .card__main {
    line-height: 1.1;
    word-break: normal;
  }
  .card--ja  { font-size: clamp(20px, 6.2vw, 26px); line-height: 1.02; word-break: break-all; overflow-wrap: break-word; -webkit-text-stroke: 0.35px; }
  .card--ja .card__main,
  .card--ja .card__sub {
    overflow-wrap: break-word;
    word-break: break-all;
  }
  /* EN単語は途中折り返し禁止・フォント縮小で対応 */
  .card--en .card__main,
  .card--long.card--en .card__main,
  .card--xlong.card--en .card__main,
  .card--xxlong.card--en .card__main {
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
    white-space: nowrap;
  }
  /* JA xlong/xxlong は引き続き文字折り返し許可 */
  .card--xlong.card--ja .card__main,
  .card--xxlong.card--ja .card__main {
    overflow-wrap: break-word;
    word-break: break-all;
    white-space: normal;
  }
  /* 長単語クラス: 縦型sideMirror=6列、カード幅≒vw/6
     Roboto Condensed文字幅比≈0.5。N文字: font≤vw/(6*N*0.5)=vw/(3N) */
  /* EN長単語: 赤ライン(カード内側影)まで拡大。card--longは~17px、xlong以上は小さめ */
  .card--long.card--en   { font-size: clamp(12px, 4.5vw, 18px); }
  /* xlong(10文字以上): letter-spacingを詰めて13pxまで許容 */
  .card--xlong.card--en  { font-size: clamp(9px, 3.2vw, 13px); letter-spacing: -0.06em; }
  .card--xxlong.card--en { font-size: clamp(6px, 1.5vw, 10px); }
  .card--phrase .card__main { font-size: 1em; white-space: normal; }
  .board--dense .card--long.card--en   { font-size: clamp(12px, 4.5vw, 18px); }
  .board--dense .card--xlong.card--en  { font-size: clamp(9px, 3.2vw, 13px); letter-spacing: -0.06em; }
  .board--dense .card--xxlong.card--en { font-size: clamp(6px,  1.5vw, 10px); }
  /* JA: 全長さ統一サイズ（card--ja 基本クラスで設定済み、長単語は改行で対応） */
  .card--long.card--ja,
  .board--dense .card--long.card--ja,
  .card--xlong.card--ja,
  .board--dense .card--xlong.card--ja { word-break: break-all; overflow-wrap: break-word; white-space: normal; }
  .card--long.card--ja .card__main, .card--long.card--ja .card__sub,
  .card--xlong.card--ja .card__main, .card--xlong.card--ja .card__sub { word-break: break-all; overflow-wrap: break-word; white-space: normal; }
  .board__zone-label {
    display: none;
  }
  .footer__hint {
    white-space: normal;
    line-height: 1.3;
  }
  .rewards { grid-template-columns: repeat(2, 1fr); }
  .footer  {
    position: static;
    z-index: 45;
    padding: 0;
    background: transparent;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .abilitybar { display: none; }
  .abilitybar__item {
    min-height: 32px;
    padding: 4px 8px;
  }
  .abilitybar__item b { font-size: 16px; }
  .abilitybar__item span { font-size: 10px; }
  .footer > div[style] { display: none !important; }
  .ad-slot {
    display: block !important;
    min-height: 56px;
  }
  .grade-grid { grid-template-columns: repeat(2, 1fr); }
  .grade-grid--sub { max-width: 100%; }
}

/* 横型（Mac・iPad）: 16:9ボード → 8×6でカードが4:3になる */
@media (orientation: landscape) and (min-width: 701px) {
  .board-shell {
    justify-content: center;
  }
  .board {
    aspect-ratio: 16 / 9;
    height: min(100%, calc((100vw - 28px) * 9 / 16));
    width: auto;
  }

  /* 行間の端数px隙間に外側ドロップシャドウが見えるのを防ぐ */
  .card--en,
  .card--ja {
    box-shadow:
      inset 0 2.5px 0 rgba(255,255,255,0.55),
      inset 2.5px 0 0 rgba(255,255,255,0.3),
      inset 0 -3px 0 rgba(0,0,0,0.35),
      inset -3px 0 0 rgba(0,0,0,0.2);
  }

  /* EN: ≤9文字(base+long)=22px、10文字以上(xlong+xxlong)=20px
     .card__main の 0.86em 縮小を 1em に上書き              */
  .card--en,
  .board--dense .card--en,
  .card--long.card--en,
  .board--dense .card--long.card--en   { font-size: clamp(10px, 2.8dvh, 22px); }

  .card--xlong.card--en,
  .board--dense .card--xlong.card--en,
  .card--xxlong.card--en,
  .board--dense .card--xxlong.card--en { font-size: clamp(10px, 2.5dvh, 20px); }

  .card--en .card__main,
  .card--long.card--en .card__main,
  .card--xlong.card--en .card__main,
  .card--xxlong.card--en .card__main   { font-size: 1em; letter-spacing: -0.01em; }

  /* JA: 全長さ統一 22px（原因サイズ基準） */
  .card--ja,
  .board--dense .card--ja,
  .card--long.card--ja,
  .board--dense .card--long.card--ja,
  .card--xlong.card--ja,
  .board--dense .card--xlong.card--ja,
  .card--xxlong.card--ja,
  .board--dense .card--xxlong.card--ja { font-size: clamp(11px, 2.8dvh, 22px); }
}

/* スマホ横型: 左ナビ(絶対配置) ＋ ボード(中央) ＋ 右ナビ(絶対配置) */
@media (orientation: landscape) and (max-height: 550px) {
  /* game-app を位置の基準に */
  .game-app {
    position: relative;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    display: block;
    padding: 0;
  }

  /* header-bar は絶対配置の親として機能（クリック透過） */
  .header-bar {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: block;
    z-index: 10;
    padding: 0;
    pointer-events: none;  /* 盤面のクリックをブロックしない */
  }

  /* ── 左サイドバー（絶対配置） ── */
  .nav-left {
    position: absolute;
    top: 0; left: 0;
    pointer-events: auto;
    flex-direction: column;
    align-items: center;
    /* safe-area分をpadding-leftで吸収し、内容幅80pxを確保 */
    width: calc(80px + env(safe-area-inset-left, 0px));
    padding-left: max(env(safe-area-inset-left, 8px), 8px);
    padding-right: 4px;
    padding-top: 10px;
    padding-bottom: 8px;
    height: 100dvh;
    gap: 8px;
    overflow: hidden;
    border-right: 1px solid var(--color-line);
    background: var(--color-panel);
    z-index: 11;
  }
  .nav-left .rulebar__menu { margin-bottom: 2px; flex-shrink: 0; }
  .nav-left .rulebar__badge {
    flex-direction: column; align-items: center; gap: 4px;
    width: 100%; flex-shrink: 0;
  }
  .nav-left .rulebar__secondary {
    flex-direction: column; align-items: center; gap: 2px;
    width: 100%; margin-top: auto; flex-shrink: 0;
  }
  .nav-left .badge-grade b  { font-size: 13px; }
  .nav-left .badge-lv       { font-size: 11px; padding: 1px 4px; }
  .nav-left .grade-kyu      { font-size: 13px; }
  .nav-left .rulebar__sec-item b,
  .nav-left .rulebar__sec-item span { font-size: 13px; }

  /* ── 右サイドバー（絶対配置） ── */
  .nav-right {
    position: absolute;
    top: 0; right: 0;
    pointer-events: auto;
    flex-direction: column;
    align-items: center;
    width: calc(86px + env(safe-area-inset-right, 0px));
    padding-right: max(env(safe-area-inset-right, 6px), 6px);
    padding-left: 4px;
    padding-top: 10px;
    padding-bottom: 8px;
    height: 100dvh;
    gap: 6px;
    overflow: hidden;
    border-left: 1px solid var(--color-line);
    background: var(--color-panel);
    z-index: 11;
  }
  .nav-right .rulebar__stat--combo {
    flex-direction: column; align-items: center; gap: 2px; width: 100%; flex-shrink: 0;
  }
  .nav-right .rulebar__stat--combo b    { font-size: 36px; }
  .nav-right .rulebar__stat--combo span { font-size: 11px; }
  .nav-right .action-pill {
    flex-direction: column; align-items: center;
    gap: 5px; width: 100%; margin: 0; flex-shrink: 0;
  }
  /* シャッフルボタン: 固定サイズ・幅auto */
  .nav-right .rulebar__btn--shuffle {
    padding: 5px 12px; min-width: unset; width: auto;
  }
  .nav-right .rulebar__btn--shuffle .rulebar__icon { font-size: 16px; }
  .nav-right .rulebar__btn--shuffle b              { font-size: 16px; }
  .nav-right .action-pill__free {
    padding: 2px 6px; flex-direction: column; align-items: center; gap: 1px;
  }
  .nav-right .action-pill__left {
    padding: 2px 6px; flex-direction: column; align-items: center; gap: 1px;
  }
  .nav-right .action-pill__free b,
  .nav-right .action-pill__left b    { font-size: 20px; }
  .nav-right .action-pill__free span,
  .nav-right .action-pill__left span { font-size: 11px; }

  /* ── 中央: ボード ── */
  .board-shell {
    position: absolute;
    top: 0; bottom: 0;
    left:  calc(80px + env(safe-area-inset-left,  0px));
    right: calc(86px + env(safe-area-inset-right, 0px));
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
  }
  .board {
    height: 100dvh !important;
    width:  calc(100dvh * 16 / 9) !important;
    max-width:  100% !important;
    max-height: 100% !important;
    aspect-ratio: unset !important;
  }

  /* EN: カード横幅基準で拡大（vw比率） */
  /* cell幅 ≈ (100vw - 166px) / 8 ≈ 85px → 目標90%埋め */
  .card--en,
  .board--dense .card--en                          { font-size: clamp(16px, 3.3vw, 28px); }
  .card--long.card--en,
  .board--dense .card--long.card--en               { font-size: clamp(13px, 2.5vw, 22px); }
  .card--xlong.card--en,
  .board--dense .card--xlong.card--en,
  .card--xxlong.card--en,
  .board--dense .card--xxlong.card--en             { font-size: clamp(9px,  1.8vw, 16px); }
  .card--en .card__main,
  .card--long.card--en .card__main,
  .card--xlong.card--en .card__main,
  .card--xxlong.card--en .card__main               { font-size: 1em; }

  /* JA: 全長さ統一・break-all */
  .card--ja,
  .board--dense .card--ja,
  .card--long.card--ja,
  .board--dense .card--long.card--ja,
  .card--xlong.card--ja,
  .board--dense .card--xlong.card--ja,
  .card--xxlong.card--ja,
  .board--dense .card--xxlong.card--ja             { font-size: clamp(18px, 2.8vw, 26px); }

  /* 広告スロット非表示 */
  .ad-slot { display: none !important; }
}

/* ── チャンクマップページ ─────────────────────────── */
.map-app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  color: var(--color-text);
}
.map-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--color-panel);
  border-bottom: 1px solid var(--color-line);
  flex-shrink: 0;
}
.map-back {
  font-size: 22px;
  color: var(--color-text);
  text-decoration: none;
  padding: 4px 8px;
  line-height: 1;
}
.map-header h1 {
  font-size: 20px;
  font-weight: 900;
  color: var(--color-gold);
}
.map-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 16px;
  flex: 1;
  align-content: flex-start;
}
.map-footer {
  padding: 14px 16px;
  background: var(--color-panel);
  border-top: 1px solid var(--color-line);
  display: flex;
  justify-content: center;
  flex-shrink: 0;
}
.map-footer .btn {
  width: 100%;
  max-width: 320px;
  min-height: 50px;
  font-size: 18px;
}
