/* ========= BBS 共通 ========= */
.bbs-wrap, .oekaki-wrap {
  max-width: 700px; margin: 0 auto; padding: 16px;
}

.rules-box {
  background: #fff8f0; border: 1px solid #f9c; border-radius: 10px;
  padding: 14px; margin-bottom: 20px; font-size: .9rem;
}
.rules-box ul { margin: 6px 0; padding-left: 20px; }
.rules-box li { margin: 4px 0; }

/* ========= 掲示板 ========= */
.post-form {
  background: #fff; border: 2px solid #f9c; border-radius: 12px;
  padding: 16px; margin-bottom: 24px;
}
.post-form h3 { margin: 0 0 12px; color: #c06; }
.post-form input,
.post-form textarea {
  width: 100%; box-sizing: border-box;
  border: 1px solid #ddd; border-radius: 8px;
  padding: 8px 10px; margin-bottom: 8px;
  font-family: inherit; font-size: .95rem;
}
.post-form textarea { min-height: 80px; resize: vertical; }
.bbs-field-row { display: flex; gap: 8px; }
.bbs-field-row input { flex: 1; }
.char-count { text-align: right; font-size: .78rem; color: #999; margin-top: -4px; margin-bottom: 8px; }

.bbs-submit-btn {
  background: #e07; color: #fff; border: none; border-radius: 8px;
  padding: 10px 24px; font-size: 1rem; cursor: pointer; font-family: inherit;
  transition: opacity .15s;
}
.bbs-submit-btn:hover { opacity: .85; }
.bbs-submit-btn:disabled { opacity: .5; cursor: default; }

.posts-section h3 { color: #c06; margin: 0 0 12px; }
.post-card {
  background: #fff; border: 1px solid #f9c; border-radius: 10px;
  padding: 12px 14px; margin-bottom: 12px; position: relative;
}
.post-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.post-name { font-weight: bold; color: #c06; }
.post-time { font-size: .78rem; color: #aaa; }
.post-no   { font-size: .78rem; color: #ccc; }
.post-body { white-space: pre-wrap; word-break: break-all; font-size: .95rem; line-height: 1.7; }
.post-delete-btn {
  position: absolute; top: 10px; right: 10px;
  background: none; border: 1px solid #ddd; border-radius: 6px;
  color: #bbb; font-size: .75rem; padding: 2px 8px; cursor: pointer;
}
.post-delete-btn:hover { border-color: #e07; color: #e07; }

/* ========= お絵かき掲示板 ========= */
.oekaki-wrap { max-width: 760px; }
.draw-panel {
  background: #fff; border: 2px solid #f9c; border-radius: 14px;
  padding: 16px; margin-bottom: 20px;
}
.draw-panel h3 { margin: 0 0 12px; color: #c06; }
.oekaki-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.oekaki-tools label { font-size: .85rem; color: #666; }
.color-picker { width: 36px; height: 36px; border: none; border-radius: 50%; cursor: pointer; padding: 0; }
.size-slider { width: 100px; }
.tool-btn {
  border: 2px solid #ddd; border-radius: 8px; padding: 5px 12px;
  background: #fff; cursor: pointer; font-family: inherit; font-size: .88rem;
}
.tool-btn.active { border-color: #e07; background: #fff0f5; color: #e07; font-weight: bold; }
#canvas-wrap {
  position: relative; border: 2px solid #eee; border-radius: 10px;
  overflow: hidden; background: #fff; touch-action: none; cursor: crosshair;
}
#main-canvas { display: block; width: 100%; }
.oekaki-submit-form { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.oekaki-submit-form input[type=text],
.oekaki-submit-form input[type=password] {
  flex: 1; min-width: 130px; border: 1px solid #ddd; border-radius: 8px;
  padding: 8px 10px; font-family: inherit; font-size: .9rem;
}
.clear-btn {
  border: none; border-radius: 8px; padding: 9px 14px;
  font-size: .9rem; cursor: pointer; font-family: inherit;
  background: #eee; color: #666;
}
.clear-btn:hover { background: #ddd; }

.gallery-section h3 { color: #c06; margin: 0 0 12px; }
.gallery-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px;
}
.gallery-card {
  background: #fff; border: 1px solid #f9c; border-radius: 10px;
  overflow: hidden; position: relative;
}
.gallery-card .thumb-wrap { overflow: hidden; cursor: zoom-in; background: #f8f8f8; }
.gallery-card img {
  width: 100%; display: block; aspect-ratio: 5/3; object-fit: contain;
  transition: transform .2s;
}
.gallery-card .thumb-wrap:hover img { transform: scale(1.03); }
.gallery-card .card-info { padding: 8px 10px; }
.card-name    { font-weight: bold; color: #c06; font-size: .9rem; }
.card-time    { font-size: .75rem; color: #aaa; margin-top: 2px; }
.card-comment { font-size: .85rem; margin-top: 4px; color: #555; word-break: break-all; }
.card-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px 8px;
}
.like-btn {
  background: none; border: 1.5px solid #f9c; border-radius: 20px;
  padding: 4px 12px; font-size: .88rem; cursor: pointer; font-family: inherit;
  color: #c06; transition: background .15s, transform .1s;
  display: flex; align-items: center; gap: 4px;
}
.like-btn:hover:not(.liked) { background: #fff0f5; transform: scale(1.08); }
.like-btn.liked {
  background: #ffe0ee; border-color: #e07; color: #e07;
  cursor: default;
}
.like-btn .like-count { font-weight: bold; min-width: 1ch; }

.card-del-btn {
  background: none; border: 1px solid #ddd; border-radius: 6px;
  color: #bbb; font-size: .72rem; padding: 2px 7px; cursor: pointer;
}
.card-del-btn:hover { border-color: #e07; color: #e07; }

/* ========= 全画面描きモード（スマホ用） ========= */
.btn-fullscreen-canvas {
  display: none; /* デスクトップでは非表示 */
  width: 100%; margin-top: 10px;
  background: #fff0f5; border: 1.5px solid #f9c; border-radius: 10px;
  padding: 11px; color: #c06; font-size: .95rem; cursor: pointer;
  font-family: inherit; align-items: center; justify-content: center;
  gap: 6px; transition: background .15s;
}
.btn-fullscreen-canvas:hover { background: #ffe0ee; }

@media (max-width: 767px) {
  .btn-fullscreen-canvas { display: flex; }
}

.canvas-fs {
  display: none;
  position: fixed; inset: 0; z-index: 900;
  background: #fff;
  flex-direction: column;
}
.canvas-fs.show { display: flex; }

.canvas-fs-tools {
  /* .oekaki-tools がそのまま移動してくるのでラッパーは薄く */
  background: #fff8f0; border-bottom: 1px solid #f9c;
  padding: 6px 10px; flex-shrink: 0;
}
.canvas-fs-tools .oekaki-tools { margin: 0; }

.canvas-fs-area {
  flex: 1;
  min-height: 0;             /* ← flex 子要素の縮小に必須 */
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e8e8e8;
  overflow: hidden;
  padding: 4px;
}
/* aspect-ratio を使わず min() で確実にアスペクト比を維持 */
.canvas-fs-area #canvas-wrap {
  /* 幅 = min(使える幅, 高さ × (700/420)) で letterbox 的に収める */
  width:  min(100%, calc((100vh - 130px) * (700 / 420)));
  height: min(100%, calc((100vw)         * (420 / 700)));
  border-radius: 8px; border: 2px solid #ddd; overflow: hidden;
  background: #fff; touch-action: none; cursor: crosshair;
  /* position:relative は既存ルールから継承 */
}
.canvas-fs-area #main-canvas {
  display: block; width: 100%; height: 100%;
}

.canvas-fs-bottom {
  background: #fff8f0; border-top: 1px solid #f9c;
  padding: 10px 16px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
}

/* ========= ライトボックス ========= */
.bbs-lightbox {
  display: none; position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.85);
  align-items: center; justify-content: center; flex-direction: column;
  cursor: zoom-out;
}
.bbs-lightbox.show { display: flex; }
.bbs-lightbox img {
  max-width: 92vw; max-height: 80vh;
  border-radius: 8px; box-shadow: 0 4px 32px rgba(0,0,0,.5);
}
.lb-info { color: #fff; margin-top: 12px; text-align: center; font-size: .9rem; }
.lb-info .lb-name    { font-weight: bold; font-size: 1rem; }
.lb-info .lb-comment { margin-top: 4px; color: #ddd; }
.lb-close {
  position: absolute; top: 16px; right: 20px;
  background: none; border: none; color: #fff; font-size: 2rem; cursor: pointer; line-height: 1;
}

/* ========= 削除ダイアログ（共通） ========= */
.bbs-del-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 999;
  align-items: center; justify-content: center;
}
.bbs-del-overlay.show { display: flex; }
.bbs-del-box {
  background: #fff; border-radius: 14px; padding: 24px;
  width: min(340px, 90vw); box-shadow: 0 4px 24px rgba(0,0,0,.2);
}
.bbs-del-box h4 { margin: 0 0 8px; }
.bbs-del-box p  { font-size: .84rem; color: #888; margin: 0 0 12px; }
.bbs-del-box input {
  width: 100%; box-sizing: border-box; border: 1px solid #ddd;
  border-radius: 8px; padding: 8px; font-size: 1rem; margin-bottom: 12px; font-family: inherit;
}
.bbs-del-box .btn-row { display: flex; gap: 8px; justify-content: flex-end; }
.bbs-del-box button   { border: none; border-radius: 8px; padding: 8px 18px; cursor: pointer; font-size: .9rem; font-family: inherit; }
.bbs-btn-cancel  { background: #eee; }
.bbs-btn-confirm { background: #e07; color: #fff; }

.bbs-loading { color: #aaa; text-align: center; padding: 24px; }
