@import url('./tokens.css');
@import url('./buttons.css');
@import url('./sliders.css');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ════ iOS Safari ズーム・選択・ドラッグ抑止（共通基盤） ════
   touch-action: manipulation でダブルタップズームを CSS レベルで抑止。
   canvas は touch-action:none に上書きされる場合があるが、
   manipulation をベースラインとして置いておくことで Safari の
   300ms click delay も除去できる。
   JS レベルの gesture / touchend 抑止は MobileGuard.inline.js が担う。
*/
html,
body,
#app,
canvas {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}
img,
canvas {
  -webkit-user-drag: none;
  user-drag: none;
}
:root {
  --char-h: 120px;

  /* ゲームごとのテーマカラー。GameTheme.inline.js が manifest.themeColor で上書きする。
     未適用時はブランド色にフォールバックする。 */
  --game-theme: var(--ui-color-brand);
}
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Hiragino Maru Gothic ProN','Rounded Mplus 1c','Noto Sans JP',sans-serif;
  background: var(--ui-color-background);
  min-height: 100vh;
}

/* 福笑いは固定幅の子要素を持つため、幅未指定だと flex の intrinsic size に
   引っ張られてスマホ時に #js-game-root より広がることがある。
   ルートだけを親幅へ固定し、absolute配置の右上UIも可視領域内に保つ。 */
.fw-app {
  width: 100%;
  min-width: 0;
}

/* ════ デバッグパネル ════ */
#debug-panel {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 30vh;
  display: none;
  flex-direction: column;
  z-index: 9999;
  background: rgba(8,8,12,0.96);
  color: #f5f5f5;
  opacity: 1;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  border-top: 2px solid #444;
  pointer-events: auto;
}
#debug-panel.visible { display: flex; }

/* タブヘッダー：高さ固定、スクロールに巻き込まれない */
#dbg-tabs {
  flex: 0 0 auto;
  height: 34px;
  display: flex;
  align-items: center;
  background: #050508;
  color: #f5f5f5;
  z-index: 2;
  border-bottom: 1px solid #222;
}
.dbg-tab {
  padding: 0 12px;
  height: 100%;
  display: flex;
  align-items: center;
  font-size: 10px;
  cursor: pointer;
  color: #666;
  border: none;
  background: none;
  font-family: inherit;
  border-bottom: 2px solid transparent;
  transition: color .12s;
  white-space: nowrap;
  flex-shrink: 0;
}
.dbg-tab.active { color: #7fffb0; border-bottom-color: #7fffb0; }
.dbg-badge {
  display: inline-block;
  background: #e74c3c; color: #fff;
  border-radius: 8px; font-size: 8px;
  padding: 0 4px; margin-left: 3px;
  min-width: 14px; text-align: center;
  visibility: hidden;
}
.dbg-badge.on { visibility: visible; }
#dbg-export {
  padding: 0 8px; height: 100%;
  display: flex; align-items: center;
  font-size: 10px; cursor: pointer;
  color: #6af; border: none; background: none;
  font-family: inherit; flex-shrink: 0;
}
#dbg-export:hover { color: #9cf; }
#dbg-clear {
  margin-left: auto;
  padding: 0 10px; height: 100%;
  display: flex; align-items: center;
  font-size: 10px; cursor: pointer;
  color: #666; border: none; background: none;
  font-family: inherit; flex-shrink: 0;
}
#dbg-clear:hover { color: #aaa; }

/* ログ本文ペイン：残り高さを全部使ってスクロール */
.dbg-pane {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: none;
  flex-direction: column;
  overscroll-behavior: contain;
  opacity: 1;
  color: #f5f5f5;
}
.dbg-pane.active { display: flex; }

/* ログ行・文字色：!important で他CSSに負けない */
#debug-panel * { opacity: 1; }
.dbg-row,
.dbg-row * {
  color: #f5f5f5 !important;
  opacity: 1 !important;
}
.dbg-row {
  padding: 2px 8px;
  border-bottom: 1px solid rgba(255,255,255,.04);
  word-break: break-all;
  line-height: 1.5;
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.dbg-row .dt {
  flex-shrink: 0;
  font-size: 9px;
  padding-top: 2px;
  min-width: 90px;
  color: #999 !important;
}
.dbg-row .dm { flex: 1; }

/* 種別ごとの色分け（!important で確実に適用） */
.dbg-row.log   .dm { color: #d0d0d0 !important; }
.dbg-row.info  .dm { color: #7ecfff !important; }
.dbg-row.warn  .dm { color: #ffd080 !important; }
.dbg-row.error .dm { color: #ff8080 !important; }
.dbg-row.error      { background: rgba(255,0,0,.08); }
.dbg-row.gl-event   .dm { color: #7fffb0 !important; }
.dbg-row.gl-input   .dm { color: #87cefa !important; }
.dbg-row.gl-comment .dm { color: #ffdf80 !important; }
.dbg-row.gl-system  .dm { color: #aaa    !important; }
.dbg-row.sc         .dm { color: #c792ea !important; }
#debug-toggle {
  position: fixed;
  bottom: 8px;
  right: 8px;
  z-index: 10000;
  background: rgba(10,10,18,.9);
  color: #7fffb0;
  border: 1.5px solid #444;
  border-radius: 7px;
  padding: 4px 10px;
  font-size: 10px;
  cursor: pointer;
  font-family: 'Courier New',monospace;
}
.err-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #e74c3c;
  margin-right: 3px;
  visibility: hidden;
  animation: errBlink .8s ease-in-out infinite;
}
.err-dot.on { visibility: visible; }
@keyframes errBlink { 0%,100% { opacity:1; } 50% { opacity:.15; } }

/* ══════════════════════════════════════════
   アニメデバッグペイン（#pane-anim）
   CommentatorAnimatorDebug.inline.js が使う
══════════════════════════════════════════ */
#pane-anim {
  padding: 10px 12px;
  overflow-y: auto;
  gap: 10px;
  flex-direction: column;
}
.dbg-anim-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.dbg-anim-label {
  font-size: 10px;
  color: #aaa;
  min-width: 80px;
  flex-shrink: 0;
}
.dbg-anim-btn {
  padding: 4px 9px;
  font-size: 10px;
  border-radius: 5px;
  border: 1px solid #555;
  background: #1a1a28;
  color: #ccc;
  cursor: pointer;
  font-family: inherit;
  transition: background .1s, color .1s, border-color .1s;
  flex-shrink: 0;
}
.dbg-anim-btn:hover { background: #2a2a40; color: #fff; border-color: #888; }
.dbg-anim-btn.active {
  background: #1e3d2a;
  color: #7fffb0;
  border-color: #7fffb0;
}
#dbg-chobo-preview {
  position: relative;
  width: 64px;
  height: 72px;
  background: rgba(255,255,255,.04);
  border: 1px dashed #444;
  border-radius: 6px;
  overflow: visible;
  flex-shrink: 0;
}
#dbg-chobo-preview .char-img-wrap {
  width: 100%;
  height: 100%;
}
.dbg-anim-divider {
  border: none;
  border-top: 1px solid #222;
  margin: 4px 0;
}
