/* ワード・クラッシュ10 — スタイルシート */
/* すべての色・フォント・レイアウトはここで管理します */
@import url("https://fonts.googleapis.com/css2?family=BIZ+UDGothic:wght@400;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: "BIZ UDGothic", "Hiragino Sans", "Yu Gothic", 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(122,219,255,0.42), 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); }

/* ── ヘッダー（rulebar） ── */
.rulebar {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 12px 16px;
  width: 100%;
  padding: 8px 16px 8px;
  background: transparent;
  z-index: 10;
  font-family: var(--font-en), var(--font-base);
}

/* ── グレードバッジ（左上） ── */
.rulebar__badge {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  padding: 0;
  clip-path: none;
  background: transparent;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}
.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;
}
.badge-lv b { color: #fff; font-weight: 900; }
.grade-kyu { font-size: 32px; font-weight: 900; color: #fff; }

/* ── アクションピル（右上） ── */
.action-pill {
  grid-column: 1 / -1;
  grid-row: 2;
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 24px;
  background: transparent;
  border: none;
  box-shadow: none;
  margin-top: 50px;
}
.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 4px 8px rgba(0,0,0,0.4), inset 0 1px 1px rgba(255,255,255,0.3);
  border-radius: 8px;
  padding: 6px 16px;
  gap: 8px;
  cursor: pointer;
  min-width: 72px;
}
.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: 0 1px 2px rgba(0,0,0,0.4);
}
.rulebar__btn--shuffle b, .action-pill__free b {
  font-size: 32px;
  font-weight: 900;
  color: #fff;
  font-family: var(--font-en);
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
  line-height: 1;
}
.action-pill__free span {
  font-size: 32px;
  color: #fff;
  font-weight: 900;
  font-family: var(--font-en);
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

.rulebar__stat--combo b {
  font-size: 96px;
  font-weight: 900;
  color: #fff;
  line-height: 0.9;
  font-family: var(--font-en);
  text-shadow: 0 2px 4px rgba(0,0,0,0.4);
  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: 0 1px 2px rgba(0,0,0,0.4);
}

.rulebar__menu {
  grid-column: 4;
  grid-row: 1;
  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 {
  position: absolute;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: row;
  align-items: baseline;
  justify-content: center;
  background: transparent;
  border: none;
  box-shadow: none;
  margin-top: 0;
  gap: 16px;
  pointer-events: none;
  z-index: 20;
}
.combo-display { display: flex; align-items: baseline; gap: 2px; }
.combo-slash { font-size: 0.35em; opacity: 0.8; }

.rulebar__secondary {
  grid-column: 3;
  grid-row: 1;
  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(0 1px 2px rgba(0,0,0,0.4));
}
.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;
  overflow: hidden;
  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: .48em;
  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--ja .card__sub { font-size: .46em; }
.card--ja .card__main {
  word-break: keep-all;
  overflow-wrap: break-word;
  line-height: 0.92;
}

/* 文字数によるフォントサイズ調整 (6文字以上、10文字以上、16文字以上) */
.card--long   .card__main { font-size: .86em; letter-spacing: -0.035em; }
.card--xlong  .card__main { font-size: .72em; letter-spacing: -0.055em; }
.card--xxlong .card__main { font-size: .60em; letter-spacing: -0.07em; }
.card--xxlong .card__sub  { font-size: .36em; }

/* 密度が高い盤面（5列以上）: カード幅基準 */
.board--dense .card--en              { font-size: clamp(15px, 2.8vw, 23px); }
.board--dense .card--ja              { font-size: clamp(12px, 2.15vw, 19px); }
.board--dense .card--long.card--en   { font-size: clamp(13px, 2.3vw, 20px); }
.board--dense .card--long.card--ja   { font-size: clamp(10px, 1.9vw, 16px); }
.board--dense .card--xlong.card--en  { font-size: clamp(11px, 2vw, 17px); }
.board--dense .card--xlong.card--ja  { font-size: clamp(9px, 1.7vw, 14px); }

/* カード状態 */
.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 1px 1px rgba(255,255,255,0.6), 0 3px 0 rgba(140,0,50,0.8), 0 0 18px rgba(255,45,120,0.6) !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; }

.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);
  text-shadow: 0 0 18px rgba(247,201,72,0.4);
  margin-bottom: 14px;
}
.clear-box__stats {
  color: var(--color-muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.rewards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 14px 0 16px;
}
.reward {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-base);
  padding: 10px 6px;
}
.reward__value { display: block; font-size: 20px; font-weight: 700; }
.reward__label { color: var(--color-muted); font-size: 11px; }

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

/* ── ボタン ──────────────────────────────────────── */
.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); }

/* ── フッター ────────────────────────────────────── */
.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; }
  /* ── ルールバー（モバイル）: 3行グリッド構造に組み直し ── */
  /* row1: バッジ | サブ情報 | メニュー                     */
  /* row2: コンボ（全幅・中央・absolute解除）               */
  /* row3: アクションピル（shuffle+FREE）                   */
  .rulebar {
    grid-template-columns: 1fr auto auto;
    grid-template-rows: auto auto auto;
    gap: 4px 8px;
    padding: 8px 12px 4px;
  }
  /* row1 再配置 */
  .rulebar__badge    { grid-column: 1; grid-row: 1; padding: 4px 0; align-self: center; }
  .rulebar__secondary { grid-column: 2; grid-row: 1; padding: 2px 4px; gap: 12px; flex-direction: row; }
  .rulebar__menu     { grid-column: 3; grid-row: 1; }
  /* コンボ: absolute解除→row2で全幅中央配置 */
  .rulebar__stat--combo {
    grid-column: 1 / -1;
    grid-row: 2;
    position: static !important;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    justify-content: center;
    margin: 0;
  }
  /* アクションピル: row3、margin-topゼロ */
  .action-pill {
    grid-column: 1 / -1;
    grid-row: 3;
    margin-top: 0;
    justify-content: center;
  }
  /* 文字サイズ 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: 15px; }
  .rulebar__sec-item span { font-size: 15px; }
  .rulebar__stat--combo b { font-size: 58px; }
  .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: 4px 12px; }
  .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(18px, 5.2vw, 28px);
    letter-spacing: 0;
    word-break: normal;
    overflow-wrap: break-word;
  }
  .board--dense .card--en {
    font-size: clamp(16px, 4.6vw, 24px);
  }
  .card--en .card__main {
    line-height: 1.1;
    word-break: normal;
  }
  .card--ja  { font-size: clamp(13px, 3.7vw, 21px); line-height: 1.02; word-break: keep-all; }
  .card--ja .card__main,
  .card--ja .card__sub {
    overflow-wrap: break-word;
    word-break: keep-all;
  }
  .card--xlong .card__main,
  .card--xxlong .card__main {
    overflow-wrap: break-word;
    word-break: break-all;
  }
  /* 長単語クラス: 段階的に小さくする */
  .card--long.card--en   { font-size: clamp(16px, 4.5vw, 24px); }
  .card--xlong.card--en  { font-size: clamp(13px, 3.8vw, 20px); }
  .card--xxlong.card--en { font-size: clamp(11px, 3.2vw, 17px); }
  .board--dense .card--long.card--en   { font-size: clamp(14px, 4vw, 21px); }
  .board--dense .card--xlong.card--en  { font-size: clamp(12px, 3.4vw, 18px); }
  .board--dense .card--xxlong.card--en { font-size: clamp(10px, 2.9vw, 15px); }
  .card--long.card--ja  { font-size: clamp(11px, 3.1vw, 18px); }
  .card--xlong          { font-size: clamp(14px, 4vw, 22px); }
  .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%; }
}

@media (orientation: landscape) and (min-width: 701px) {
  .board {
    --cell-size: 76px;
    width: calc(8 * var(--cell-size));
    height: calc(6 * var(--cell-size));
    aspect-ratio: auto;
  }
}
