/* =========================================
   ベース＆リセット（スマホ縦画面 9:16 最適化）
   ========================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #181c24;
  font-family: "Noto Sans JP", -apple-system, BlinkMacSystemFont, sans-serif;
  color: #1e293b;
}

.viewport-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-container {
  --cw: min(100vw, 100dvh * 9 / 16);
  position: relative;
  height: 100dvh;
  max-height: 100%;
  aspect-ratio: 9 / 16;
  max-width: 100vw;
  background-color: #f1f5f9;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* =========================================
   上部 HUD ヘッダー（常に横長長方形＆本体との余白を確保）
   ========================================= */
.hud-header {
  position: absolute;
  top: calc(var(--cw) * 0.022);
  left: calc(var(--cw) * 0.022);
  right: calc(var(--cw) * 0.022);
  height: calc(var(--cw) * 0.126);
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: calc(var(--cw) * 0.014);
  z-index: 10;
}

.hud-badge {
  flex: 1.05 1 0;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--cw) * 0.004);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(6px);
  border: 2px solid #cbd5e1;
  border-radius: calc(var(--cw) * 0.026);
  padding: calc(var(--cw) * 0.004) calc(var(--cw) * 0.006);
  font-size: calc(var(--cw) * 0.0195);
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
  color: #334155;
  box-shadow: 0 calc(var(--cw) * 0.007) 0 #cbd5e1;
  overflow: hidden;
}

#state-label {
  display: block;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-dot {
  flex-shrink: 0;
  width: calc(var(--cw) * 0.013);
  height: calc(var(--cw) * 0.013);
  border-radius: 50%;
  background-color: #2563eb;
}

.hud-menu-group {
  flex: 3.45 1 0;
  display: flex;
  align-items: stretch;
  gap: calc(var(--cw) * 0.014);
  min-width: 0;
}

.menu-pill-btn {
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.97);
  border: 2px solid #cbd5e1;
  border-radius: calc(var(--cw) * 0.026);
  padding: calc(var(--cw) * 0.004) calc(var(--cw) * 0.006);
  font-family: inherit;
  font-size: calc(var(--cw) * 0.028);
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
  color: #1e293b;
  cursor: pointer;
  box-shadow: 0 calc(var(--cw) * 0.007) 0 #cbd5e1, 0 4px 10px rgba(15, 23, 42, 0.08);
  transition: background-color 0.12s ease, transform 0.08s ease, box-shadow 0.08s ease;
  touch-action: manipulation;
  overflow: hidden;
}

.menu-pill-btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #cbd5e1;
  background-color: #e2e8f0;
}

.menu-pill-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.menu-pill-btn span {
  max-width: 100%;
  white-space: nowrap;
}

.menu-pill-btn strong {
  max-width: 100%;
  white-space: nowrap;
  font-size: calc(var(--cw) * 0.021);
  color: #2563eb;
  font-variant-numeric: tabular-nums;
  margin-top: calc(var(--cw) * 0.002);
}

/* 図鑑ボタン（薄い青色） */
#btn-open-zukan {
  background: linear-gradient(180deg, #67e8f9 0%, #22d3ee 100%);
  border-color: #0891b2;
  color: #083344;
  box-shadow: 0 calc(var(--cw) * 0.007) 0 #0891b2, 0 4px 10px rgba(6, 182, 212, 0.22);
}

#btn-open-zukan:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #0891b2;
  background: linear-gradient(180deg, #22d3ee 0%, #06b6d4 100%);
}

#btn-open-zukan strong {
  color: #164e63;
}

/* オリジナル台メーカーボタン（黄色・「台」の直後のみ改行許可） */
#btn-open-editor {
  flex: 1.55 1 0;
  background: linear-gradient(180deg, #fef08a 0%, #f3d938 100%);
  border-color: #ca8a04;
  color: #422006;
  box-shadow: 0 calc(var(--cw) * 0.007) 0 #ca8a04, 0 4px 10px rgba(234, 179, 8, 0.22);
}

#btn-open-editor:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #ca8a04;
  background: linear-gradient(180deg, #f3d938 0%, #eab308 100%);
}

.editor-btn-label {
  display: block;
  width: 100%;
  font-size: calc(var(--cw) * 0.024);
  line-height: 1.12;
  word-break: keep-all;
  overflow-wrap: normal;
  white-space: normal !important;
}

.nowrap {
  display: inline-block;
  white-space: nowrap;
}

/* ハンバーガーメニューボタン */
#btn-open-menu {
  background: linear-gradient(180deg, #8791a8 0%, #768098 100%);
  border-color: #5a6378;
  color: #ffffff;
  gap: calc(var(--cw) * 0.007);
  box-shadow: 0 calc(var(--cw) * 0.007) 0 #5a6378, 0 4px 10px rgba(90, 99, 120, 0.22);
}

#btn-open-menu:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #5a6378;
  background: linear-gradient(180deg, #768098 0%, #667087 100%);
}

.hamburger-icon {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: calc(var(--cw) * 0.046);
  height: calc(var(--cw) * 0.032);
}

.hamburger-icon span {
  display: block;
  width: 100%;
  height: max(2px, calc(var(--cw) * 0.0055));
  background-color: #ffffff;
  border-radius: 999px;
}

.menu-btn-caption {
  font-size: calc(var(--cw) * 0.02);
  font-weight: 900;
  line-height: 1;
}

/* =========================================
   チュートリアル専用 UI（右上スキップ・強調枠・操作ガード）
   ========================================= */
.tutorial-skip-btn {
  position: absolute;
  top: calc(var(--cw) * 0.162);
  right: calc(var(--cw) * 0.032);
  z-index: 95;
  height: calc(var(--cw) * 0.088);
  min-height: 32px;
  max-height: 38px;
  max-width: calc(100% - var(--cw) * 0.064);
  padding: 0 calc(var(--cw) * 0.034);
  border-radius: 999px;
  border: 2px solid #475569;
  background: rgba(15, 23, 42, 0.92);
  color: #ffffff;
  font-family: inherit;
  font-size: clamp(10.5px, calc(var(--cw) * 0.029), 13px);
  font-weight: 900;
  letter-spacing: 0.01em;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.28);
  transition: transform 0.08s ease, background-color 0.12s ease;
  touch-action: manipulation;
}

.tutorial-skip-btn:active {
  transform: scale(0.95);
  background: #0f172a;
}

.tutorial-spotlight-layer {
  position: absolute;
  inset: 0;
  z-index: 65;
  background: rgba(15, 23, 42, 0.16);
  pointer-events: auto;
}

.tutorial-spotlight-layer.is-pass-through {
  background: transparent;
  pointer-events: none;
}

.tutorial-highlight-ring {
  position: absolute;
  z-index: 90;
  border: 3.5px solid #f59e0b;
  border-radius: 16px;
  box-shadow:
    0 0 0 3px rgba(254, 240, 138, 0.85),
    0 0 18px rgba(245, 158, 11, 0.7);
  pointer-events: none;
  animation: tutorialPulse 1.2s ease-in-out infinite;
}

@keyframes tutorialPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow:
      0 0 0 3px rgba(254, 240, 138, 0.85),
      0 0 16px rgba(245, 158, 11, 0.65);
  }
  50% {
    transform: scale(1.018);
    box-shadow:
      0 0 0 5px rgba(254, 240, 138, 0.95),
      0 0 24px rgba(245, 158, 11, 0.9);
  }
}

/* チュートリアルでモーダル（台メーカー・メニュー）と吹き出しを同時表示する際の上寄せ調整 */
.game-container.has-tutorial-bottom-space .modal-backdrop:not(#get-modal) {
  align-items: flex-start;
  padding-top: calc(var(--cw) * 0.24);
  padding-bottom: 225px;
}

.game-container.has-tutorial-bottom-space #editor-grid-canvas {
  max-height: 22dvh;
}

/* =========================================
   猫店員＆吹き出しエリア（プレイフィールド下のスペース）
   ========================================= */
.cat-clerk-area {
  position: absolute;
  top: 56%;
  bottom: calc(104px + env(safe-area-inset-bottom));
  left: calc(var(--cw) * 0.036);
  right: calc(var(--cw) * 0.036);
  z-index: 12;
  display: flex;
  align-items: center;
  gap: calc(var(--cw) * 0.026);
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(6px);
  border: 2px solid #cbd5e1;
  border-radius: 18px;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
  transition: bottom 0.18s ease, box-shadow 0.18s ease;
  overflow: hidden;
}

/* チュートリアル解説中はモーダルよりも前面に浮き上がらせる */
.cat-clerk-area.is-tutorial-elevated {
  top: auto;
  bottom: calc(16px + env(safe-area-inset-bottom));
  min-height: 142px;
  max-height: 196px;
  z-index: 80;
  background: rgba(255, 255, 255, 0.98);
  border-color: #f59e0b;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.34);
}

.cat-avatar-box {
  flex: 0 0 auto;
  height: 100%;
  max-height: 112px;
  aspect-ratio: 119.57 / 162.83;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  padding: 5px;
  cursor: pointer;
  transition: transform 0.14s ease;
}

.cat-avatar-box:active {
  transform: scale(0.95);
}

.cat-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cat-avatar-box.is-talking .cat-img {
  animation: catBounce 0.35s ease;
}

@keyframes catBounce {
  0% { transform: translateY(0) scale(1); }
  40% { transform: translateY(-5px) scale(1.04); }
  100% { transform: translateY(0) scale(1); }
}

.cat-speech-bubble {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 100%;
  max-height: 170px;
  background-color: #ffffff;
  border: 2px solid #94a3b8;
  border-radius: 14px;
  padding: 7px 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

.cat-speech-bubble::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  border-style: solid;
  border-width: 7px 10px 7px 0;
  border-color: transparent #94a3b8 transparent transparent;
}

.cat-speech-bubble::after {
  content: "";
  position: absolute;
  left: -7px;
  top: 50%;
  transform: translateY(-50%);
  border-style: solid;
  border-width: 5px 8px 5px 0;
  border-color: transparent #ffffff transparent transparent;
}

.cat-speaker-tag {
  display: inline-block;
  align-self: flex-start;
  font-size: clamp(9px, calc(var(--cw) * 0.023), 10.5px);
  font-weight: 900;
  color: #2563eb;
  background-color: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  padding: 1px 7px;
  margin-bottom: 3px;
  white-space: nowrap;
}

.cat-speech-text {
  font-size: clamp(10.5px, calc(var(--cw) * 0.0285), 13px);
  font-weight: 700;
  line-height: 1.38;
  color: #1e293b;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.cat-speech-controls {
  margin-top: 5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tutorial-step-badge {
  font-size: clamp(10px, calc(var(--cw) * 0.025), 11.5px);
  font-weight: 900;
  color: #64748b;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tutorial-next-btn {
  height: 30px;
  padding: 0 12px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
  color: #ffffff;
  font-family: inherit;
  font-size: clamp(11px, calc(var(--cw) * 0.028), 12.5px);
  font-weight: 900;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 3px 0 #b45309;
  touch-action: manipulation;
}

.tutorial-next-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #b45309;
}

/* =========================================
   下部操作エリア（親指操作ボタン：高さ 74px 基準）
   ========================================= */
.controls-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 10px calc(var(--cw) * 0.036) calc(16px + env(safe-area-inset-bottom));
  display: flex;
  gap: calc(var(--cw) * 0.026);
  z-index: 10;
}

.btn {
  min-width: 0;
  padding: 4px 6px;
  border: none;
  border-radius: 16px;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform 0.08s ease, box-shadow 0.08s ease, opacity 0.15s ease;
  touch-action: manipulation;
  overflow: hidden;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

.btn-reset {
  flex: 0 0 32%;
  height: 74px;
  background-color: #ffffff;
  color: #334155;
  border: 2px solid #cbd5e1;
  box-shadow: 0 4px 0 #cbd5e1;
}

.btn-reset:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #cbd5e1;
}

.btn-reset .btn-main {
  max-width: 100%;
  font-size: clamp(13px, calc(var(--cw) * 0.036), 16px);
  font-weight: 900;
  white-space: nowrap;
}

.btn-reset .btn-sub {
  max-width: 100%;
  font-size: clamp(8.5px, calc(var(--cw) * 0.023), 10px);
  font-weight: 700;
  color: #64748b;
  margin-bottom: 2px;
  white-space: nowrap;
}

.btn-move {
  flex: 1;
  min-width: 0;
  height: 74px;
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  color: #ffffff;
  box-shadow: 0 5px 0 #1d4ed8, 0 8px 16px rgba(37, 99, 235, 0.28);
}

.btn-move.is-pressing,
.btn-move:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #1d4ed8, 0 3px 8px rgba(37, 99, 235, 0.25);
  background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
}

.btn-move .btn-main {
  max-width: 100%;
  font-size: clamp(16px, calc(var(--cw) * 0.045), 20px);
  font-weight: 900;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.btn-move .btn-sub {
  max-width: 100%;
  font-size: clamp(9.5px, calc(var(--cw) * 0.025), 11px);
  font-weight: 500;
  opacity: 0.92;
  margin-top: 2px;
  white-space: nowrap;
}

/* =========================================
   モーダル共通＆ゲット詳細カード（図鑑より手前に表示）
   ========================================= */
.modal-backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  z-index: 50;
  animation: fadeIn 0.16s ease-out;
}

#get-modal {
  z-index: 70;
}

.modal-backdrop.hidden,
.hidden {
  display: none !important;
}

.modal-card {
  width: 100%;
  max-width: 390px;
  background-color: #ffffff;
  border-radius: 22px;
  padding: 18px 16px 14px;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.3);
  border: 2px solid #e2e8f0;
  text-align: center;
  animation: popUp 0.22s cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 10px;
}

.get-tag {
  flex-shrink: 0;
  background-color: #f59e0b;
  color: #ffffff;
  font-size: clamp(10.5px, calc(var(--cw) * 0.027), 12px);
  font-weight: 900;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.get-tag.is-new {
  background-color: #ef4444;
}

.get-tag.is-zukan {
  background-color: #2563eb;
}

.grade-tag {
  min-width: 0;
  font-size: clamp(10px, calc(var(--cw) * 0.025), 11.5px);
  font-weight: 700;
  color: #475569;
  background-color: #f1f5f9;
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kanji-hero {
  width: 112px;
  height: 112px;
  margin: 4px auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 80px;
  font-weight: 900;
  line-height: 1;
  color: #0f172a;
  background-color: #f8fafc;
  border: 2px solid #cbd5e1;
  border-radius: 18px;
}

.spec-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.spec-item {
  flex: 1;
  min-width: 0;
  background-color: #f8fafc;
  border-radius: 10px;
  padding: 6px 8px;
  border: 1px solid #e2e8f0;
}

.spec-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: #64748b;
}

.spec-value {
  display: block;
  font-size: clamp(11.5px, calc(var(--cw) * 0.029), 13.5px);
  font-weight: 900;
  color: #1e293b;
  margin-top: 1px;
  word-break: keep-all;
}

.reading-section {
  text-align: left;
  background-color: #f8fafc;
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.reading-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: clamp(12px, calc(var(--cw) * 0.031), 13.5px);
  font-weight: 700;
}

.reading-badge {
  flex-shrink: 0;
  font-size: 10.5px;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 5px;
  color: #ffffff;
}

.reading-badge.on {
  background-color: #2563eb;
}

.reading-badge.kun {
  background-color: #059669;
}

.reading-text {
  color: #1e293b;
  word-break: break-word;
}

.reading-text .okurigana {
  color: #64748b;
  font-weight: 500;
}

.example-section {
  text-align: left;
  padding: 0 4px;
  margin-bottom: 12px;
}

.example-title {
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  margin-bottom: 4px;
}

.example-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.example-list li {
  font-size: clamp(11px, calc(var(--cw) * 0.028), 12.5px);
  font-weight: 700;
  color: #334155;
  background-color: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 4px 9px;
  border-radius: 8px;
  max-width: 100%;
  word-break: break-word;
}

.modal-hint {
  font-size: 12px;
  font-weight: 700;
  color: #94a3b8;
}

/* =========================================
   シートモーダル共通（図鑑・メニュー・設定・オリジナル台メーカー・共有）
   ========================================= */
.sheet-card {
  width: 100%;
  max-height: 96%;
  background-color: #ffffff;
  border-radius: 20px;
  padding: 12px;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.32);
  border: 2px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  overflow-x: hidden;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

.sheet-title-wrap {
  flex: 1;
  min-width: 0;
}

.sheet-title {
  font-size: clamp(15px, calc(var(--cw) * 0.041), 18px);
  font-weight: 900;
  color: #0f172a;
  line-height: 1.25;
}

.sheet-subtitle {
  font-size: clamp(10.5px, calc(var(--cw) * 0.028), 12.5px);
  font-weight: 700;
  color: #64748b;
  line-height: 1.3;
  word-break: break-word;
}

.close-x-btn {
  flex-shrink: 0;
  width: clamp(50px, calc(var(--cw) * 0.145), 64px);
  height: clamp(50px, calc(var(--cw) * 0.145), 64px);
  border-radius: 15px;
  border: 2px solid #cbd5e1;
  background-color: #f8fafc;
  color: #334155;
  font-size: clamp(18px, calc(var(--cw) * 0.048), 22px);
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 0 #cbd5e1;
  touch-action: manipulation;
}

.close-x-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #cbd5e1;
  background-color: #e2e8f0;
}

/* =========================================
   ハンバーガーメニューモーダル UI
   ========================================= */
.menu-sheet-card,
.transfer-sheet-card {
  max-width: 440px;
}

.menu-nav-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 4px;
}

.menu-nav-item {
  width: 100%;
  min-width: 0;
  min-height: 60px;
  padding: 10px 16px;
  border-radius: 16px;
  border: 2px solid #cbd5e1;
  background-color: #f8fafc;
  color: #0f172a;
  font-family: inherit;
  font-size: clamp(13.5px, calc(var(--cw) * 0.037), 16.5px);
  font-weight: 900;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 0 #cbd5e1;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background-color 0.12s ease;
  touch-action: manipulation;
}

.menu-nav-title {
  flex: 1;
  min-width: 0;
  text-align: left;
  line-height: 1.3;
  word-break: keep-all;
  overflow-wrap: break-word;
}

.menu-nav-item:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #cbd5e1;
  background-color: #e2e8f0;
}

.menu-nav-arrow {
  flex-shrink: 0;
  font-size: 22px;
  font-weight: 900;
  color: #64748b;
  line-height: 1;
}

/* =========================================
   図鑑 UI（改行3列グリッド配置・縦幅を文字幅＋少しの余白に設定）
   ========================================= */
.zukan-progress-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
}

.zukan-grade-progress {
  color: #0284c7;
  font-weight: 900;
}

.zukan-filter-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  flex-shrink: 0;
}

.zukan-tab {
  min-width: 0;
  height: auto;
  padding: 8px 4px;
  border-radius: 11px;
  border: 2px solid #cbd5e1;
  background-color: #f8fafc;
  color: #334155;
  font-family: inherit;
  font-size: clamp(10px, calc(var(--cw) * 0.0265), 12.5px);
  font-weight: 900;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  text-align: center;
  box-shadow: 0 3px 0 #cbd5e1;
  touch-action: manipulation;
}

.zukan-tab.is-all {
  grid-column: span 2;
  font-size: clamp(11.5px, calc(var(--cw) * 0.03), 13.5px);
}

.zukan-tab:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #cbd5e1;
}

.zukan-tab.is-active {
  background-color: #2563eb;
  border-color: #1d4ed8;
  color: #ffffff;
  box-shadow: 0 3px 0 #1e40af;
}

.zukan-grid-wrapper {
  flex: 1;
  min-height: 160px;
  overflow-y: auto;
  background-color: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  padding: 8px;
}

.zukan-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}

.zukan-cell {
  aspect-ratio: 1 / 1;
  min-width: 0;
  border-radius: 10px;
  font-family: inherit;
  font-size: clamp(16px, calc(var(--cw) * 0.045), 20px);
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.zukan-cell.is-unlocked {
  background-color: #ffffff;
  border: 2px solid #93c5fd;
  color: #0f172a;
  cursor: pointer;
}

.zukan-cell.is-unlocked:active {
  transform: scale(0.92);
  background-color: #eff6ff;
}

.zukan-cell.is-empty {
  background-color: #e2e8f0;
  border: 1px dashed #cbd5e1;
  cursor: default;
}

/* 引き継ぎコード */
.transfer-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 2px;
}

.transfer-label {
  font-size: clamp(11.5px, calc(var(--cw) * 0.029), 13px);
  font-weight: 800;
  color: #334155;
}

.transfer-row {
  display: flex;
  gap: 8px;
}

.text-input {
  flex: 1;
  min-width: 0;
  height: 64px;
  padding: 10px 12px;
  border: 2px solid #cbd5e1;
  border-radius: 15px;
  font-size: clamp(13px, calc(var(--cw) * 0.034), 16px);
  font-family: monospace;
  background-color: #ffffff;
  color: #1e293b;
  user-select: text;
  -webkit-user-select: text;
}

.small-action-btn {
  flex-shrink: 0;
  height: 64px;
  padding: 0 14px;
  border-radius: 15px;
  border: 2px solid #cbd5e1;
  background-color: #ffffff;
  font-family: inherit;
  font-size: clamp(12.5px, calc(var(--cw) * 0.032), 14.5px);
  font-weight: 900;
  white-space: nowrap;
  color: #334155;
  cursor: pointer;
  box-shadow: 0 4px 0 #cbd5e1;
  touch-action: manipulation;
}

.small-action-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #cbd5e1;
}

.small-action-btn.is-primary {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  border-color: #1d4ed8;
  color: #ffffff;
  box-shadow: 0 4px 0 #1d4ed8;
}

.transfer-feedback {
  font-size: clamp(11.5px, calc(var(--cw) * 0.029), 13px);
  font-weight: 700;
  color: #2563eb;
  min-height: 20px;
  word-break: break-word;
}

/* =========================================
   設定 UI（大型ボタン・タップ領域統一）
   ========================================= */
.settings-scroll {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.setting-block {
  background-color: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 16px;
  padding: 12px;
}

.setting-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.setting-block h3 {
  font-size: clamp(13px, calc(var(--cw) * 0.034), 15px);
  font-weight: 900;
  color: #1e293b;
}

.mini-link-btn {
  flex-shrink: 0;
  height: 48px;
  padding: 0 12px;
  border: 2px solid #bfdbfe;
  border-radius: 12px;
  background-color: #eff6ff;
  font-family: inherit;
  font-size: clamp(11.5px, calc(var(--cw) * 0.029), 13.5px);
  font-weight: 900;
  white-space: nowrap;
  color: #2563eb;
  cursor: pointer;
  box-shadow: 0 3px 0 #bfdbfe;
  touch-action: manipulation;
}

.mini-link-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #bfdbfe;
  background-color: #dbeafe;
}

.setting-note {
  font-size: clamp(10.5px, calc(var(--cw) * 0.026), 12px);
  color: #64748b;
  margin-bottom: 10px;
  line-height: 1.35;
}

.grade-check-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.grade-check-item {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 60px;
  padding: 8px 10px;
  background-color: #ffffff;
  border: 2px solid #cbd5e1;
  border-radius: 14px;
  font-size: clamp(10.5px, calc(var(--cw) * 0.0265), 12.5px);
  font-weight: 900;
  line-height: 1.25;
  color: #334155;
  cursor: pointer;
  box-shadow: 0 3px 0 #cbd5e1;
  touch-action: manipulation;
  overflow: hidden;
}

.grade-check-item span {
  min-width: 0;
  word-break: keep-all;
  overflow-wrap: break-word;
}

.grade-check-item.is-checked {
  border-color: #60a5fa;
  background-color: #eff6ff;
  color: #1e3a8a;
  box-shadow: 0 3px 0 #93c5fd;
}

.grade-check-item input[type="checkbox"] {
  accent-color: #2563eb;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.toggle-row {
  margin-top: 8px;
  min-height: 62px;
  padding: 10px 12px;
  background-color: #ffffff;
  border: 2px solid #cbd5e1;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: clamp(11.5px, calc(var(--cw) * 0.029), 13.5px);
  font-weight: 800;
  line-height: 1.4;
  color: #334155;
  cursor: pointer;
  touch-action: manipulation;
}

.toggle-row span {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.toggle-row input[type="checkbox"] {
  accent-color: #2563eb;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

/* =========================================
   オリジナル台メーカー＆共有 UI
   ========================================= */
.editor-toolbar,
.editor-sub-toolbar {
  display: flex;
  align-items: stretch;
  gap: 6px;
  flex-shrink: 0;
}

.tool-btn {
  flex: 1 1 0;
  min-width: 0;
  height: 60px;
  padding: 4px 3px;
  border-radius: 14px;
  border: 2px solid #cbd5e1;
  background-color: #f8fafc;
  font-family: inherit;
  font-size: clamp(10.5px, calc(var(--cw) * 0.0265), 13px);
  font-weight: 900;
  line-height: 1.18;
  color: #334155;
  cursor: pointer;
  box-shadow: 0 4px 0 #cbd5e1;
  touch-action: manipulation;
  word-break: keep-all;
  overflow: hidden;
}

.tool-btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #cbd5e1;
}

.tool-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tool-btn.is-active {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  border-color: #1d4ed8;
  color: #ffffff;
  box-shadow: 0 4px 0 #1d4ed8;
}

.tool-btn.is-history {
  flex: 0.9 1 0;
  background-color: #ffffff;
  color: #1e293b;
  white-space: nowrap;
}

.tool-btn.is-danger {
  flex: 0.78 1 0;
  color: #dc2626;
  border-color: #fecaca;
  background-color: #fef2f2;
  box-shadow: 0 4px 0 #fecaca;
  white-space: nowrap;
}

.fixed-char-box {
  flex: 1.32 1 0;
  min-width: 0;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  padding: 5px 7px;
  background-color: #eff6ff;
  border: 2px solid #93c5fd;
  border-radius: 14px;
  box-shadow: 0 4px 0 #bfdbfe;
  overflow: hidden;
}

.fixed-char-label {
  flex-shrink: 0;
  font-size: clamp(9.5px, calc(var(--cw) * 0.0235), 11px);
  font-weight: 900;
  color: #1e3a8a;
  line-height: 1.15;
  text-align: center;
  white-space: nowrap;
}

.char-box-input {
  flex: 1;
  min-width: 48px;
  width: auto;
  height: 46px;
  padding: 2px 4px;
  border-radius: 10px;
  border: 2px solid #2563eb;
  background-color: #ffffff;
  color: #0f172a;
  font-family: inherit;
  font-size: clamp(20px, calc(var(--cw) * 0.05), 24px);
  font-weight: 900;
  text-align: center;
  user-select: text;
  -webkit-user-select: text;
}

.editor-canvas-frame {
  width: 100%;
  border: 2px solid #94a3b8;
  border-radius: 12px;
  overflow: hidden;
  background-color: #f8fafc;
  display: flex;
  justify-content: center;
  flex-shrink: 1;
}

#editor-grid-canvas {
  display: block;
  width: 100%;
  max-height: 31dvh;
  object-fit: contain;
  touch-action: none;
  cursor: crosshair;
}

.editor-hint {
  font-size: clamp(10px, calc(var(--cw) * 0.025), 11.5px);
  color: #64748b;
  line-height: 1.35;
  flex-shrink: 0;
  word-break: break-word;
}

.editor-footer-actions,
.share-btn-row {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.action-btn {
  flex: 1 1 0;
  min-width: 0;
  height: 66px;
  padding: 8px 6px;
  border-radius: 15px;
  border: none;
  font-family: inherit;
  font-size: clamp(12.5px, calc(var(--cw) * 0.033), 15.5px);
  font-weight: 900;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  touch-action: manipulation;
}

.action-btn:active {
  transform: translateY(3px);
}

.action-btn.is-secondary {
  background-color: #ffffff;
  border: 2px solid #cbd5e1;
  color: #1e293b;
  box-shadow: 0 4px 0 #cbd5e1;
}

.action-btn.is-secondary:active {
  box-shadow: 0 1px 0 #cbd5e1;
}

.action-btn.is-primary {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  color: #ffffff;
  box-shadow: 0 5px 0 #1d4ed8, 0 8px 16px rgba(37, 99, 235, 0.28);
}

.action-btn.is-primary:active {
  box-shadow: 0 1px 0 #1d4ed8;
}

.share-preview-box {
  width: 100%;
  border: 1.5px solid #cbd5e1;
  border-radius: 12px;
  overflow: hidden;
  background-color: #e2e8f0;
  display: flex;
  justify-content: center;
}

#share-preview-canvas {
  display: block;
  width: 100%;
  max-height: 30dvh;
  object-fit: contain;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes popUp {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}