* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; background: #1b1d24; color: #eceef2;
  font-family: 'Noto Sans KR', 'Malgun Gothic', sans-serif; overscroll-behavior: none; }

.gate { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 24px; font-size: 18px; line-height: 1.6; }

/* 인증 화면 (코드 복사) */
.pair { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; }
.pair-card { background: #23262f; border: 1px solid #3a3d47; border-radius: 16px; padding: 32px 28px;
  text-align: center; max-width: 420px; width: 100%; box-shadow: 0 12px 44px rgba(0,0,0,.6); }
.pair-title { font-size: 26px; font-weight: 900; margin-bottom: 14px; }
.pair-desc { font-size: 16px; color: #c7ccd6; line-height: 1.6; margin-bottom: 22px; }
.pair-desc b { color: #ffd34d; }
.copy-btn { width: 100%; padding: 18px; border: none; border-radius: 12px; cursor: pointer;
  background: #3a86ff; color: #fff; font-size: 19px; font-weight: 800; transition: background .15s; }
.copy-btn:hover { background: #2f6fd6; }
.copy-btn.copied { background: #28a745; }
.pair-cmd-wrap { margin-top: 16px; font-size: 13px; color: #8b919c; }
.pair-cmd-wrap b { color: #eceef2; font-size: 15px; letter-spacing: 1px;
  background: #2a2d36; padding: 3px 8px; border-radius: 6px; }
.pair-wait { margin-top: 20px; font-size: 14px; color: #7ee787; }

.app { display: flex; flex-direction: column; height: 100%; }
.canvas-wrap { flex: 1; }   /* 캔버스 = 위쪽 크게 */

/* 아래쪽에 모든 도구 + 팔레트 (예전 스타일) */
.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; }
.palette-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 6px 12px 10px; }
.colors { display: grid; grid-template-columns: repeat(40, minmax(0, 30px)); gap: 3px; flex: 0 1 auto; }   /* 80색(14색상×5 + 무채색10) = 정확히 2줄 */
.palette-actions { display: flex; flex-direction: column; gap: 8px; margin-left: auto; }   /* 팔레트 오른쪽 빈 공간 */
.palette-actions .btn-help, .palette-actions .btn-done { width: 100%; white-space: nowrap; margin: 0; }
.cost-big { text-align: center; font-size: 13px; color: #c7ccd6; white-space: nowrap; }
.cost-big b { font-size: 22px; color: #ffd34d; font-variant-numeric: tabular-nums; margin: 0 3px; }
.cost-big span { font-size: 13px; }
.mobilebar { display: none; }   /* 데스크탑 숨김 — 모바일 전용 하단 바 */

/* ===== 모바일: 캔버스 꽉 + 항상 보이는 하단 바 + 색/도구는 반높이 시트 ===== */
@media (max-width: 979px) {
  .topbar { display: none; }                          /* 제목줄 숨김 (공간 절약) */
  .inkbar { padding: 5px 10px 6px; }
  .canvas-wrap { flex: 1; padding: 2px 4px 58px; }    /* 하단 바 자리 확보 */

  /* 도구바(.tools)·팔레트(.palette-bar) = 하단 바 "위에서" 올라오는 시트 (캔버스·하단바 보이면서 선택) */
  .tools, .palette-bar {
    position: fixed; left: 0; right: 0; bottom: 56px; z-index: 97;
    max-height: 60vh; overflow-y: auto;
    background: #20232b; border-top: 1px solid #3a3d47; border-radius: 16px 16px 0 0;
    box-shadow: 0 -10px 30px rgba(0,0,0,.55);
    display: flex; flex-wrap: wrap; align-items: center; gap: 9px;
    padding: 16px 12px 18px;
    transform: translateY(130%); transition: transform .22s ease; visibility: hidden;
  }
  .app.more-open .tools { transform: translateY(0); visibility: visible; }
  .app.color-open .palette-bar { transform: translateY(0); visibility: visible; }
  .tools .btn-tool, .tools .btn-help, .tools label.btn-tool { font-size: 15px; padding: 11px 14px; }

  /* 팔레트 큰 스와치 (8열, 32색) */
  .colors { grid-template-columns: repeat(8, 1fr); gap: 7px; width: 100%; flex: 1 1 100%; }
  .palette-actions { width: 100%; display: flex; flex-direction: row; gap: 8px; }
  .palette-actions .cost-big { order: -1; width: 100%; }
  .palette-actions .btn-help, .palette-actions .btn-done { flex: 1; }

  /* 항상 보이는 하단 바 */
  .mobilebar { display: flex; align-items: center; gap: 6px;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 99;   /* 항상 최상단 — 시트 열려도 보임 */
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
    background: #14161c; border-top: 1px solid #2a2d36; }
  .mb-btn { flex: 1; min-width: 0; padding: 12px 4px; border: 1px solid #2f333d; border-radius: 9px;
    background: #262a33; color: #eceef2; font-size: 17px; font-weight: 700; cursor: pointer; }
  .mb-btn.mb-active { background: #3a86ff; border-color: #3a86ff; }
  .mb-wide { flex: 1.4; display: inline-flex; align-items: center; justify-content: center; gap: 5px; font-size: 14px; }
  .mb-dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #fff; background: #000; }
  .mb-size { min-width: 24px; text-align: center; font-weight: 800; font-size: 15px; color: #ffd34d; }
}

.topbar { display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; font-weight: 700; }
.topbar .who { font-size: 16px; }
.topbar .timer { font-size: 16px; color: #ffd34d; font-variant-numeric: tabular-nums; }

.inkbar { padding: 4px 14px 10px; }
.ink-track { height: 12px; background: #2a2d36; border-radius: 8px; overflow: hidden; }
.ink-fill { height: 100%; width: 100%; background: linear-gradient(90deg,#4cc2ff,#7ee787);
  transition: width 0.08s linear; }
.ink-info { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-top: 6px; color: #c7ccd6; }
.ink-info b { color: #ffd34d; }
.btn-refill { margin-left: auto; padding: 5px 10px; border: none; border-radius: 6px;
  background: #3a86ff; color: #fff; font-weight: 700; font-size: 12px; cursor: pointer; }

.canvas-wrap { flex: 1; display: flex; align-items: safe center; justify-content: safe center;
  padding: 3px 6px; min-height: 0; overflow: auto; }   /* safe center: 줌인 오버플로우 시 양방향 스크롤(pan) 가능 */
.stage { position: relative; flex: 0 0 auto; }
#canvas { display: block; width: 100%; height: 100%; background: #fff; border-radius: 8px;
  position: relative; z-index: 1;   /* 게임배경(z-index 0)보다 위 — 그린 획이 또렷하게 보이도록 */
  box-shadow: 0 4px 20px rgba(0,0,0,.5); touch-action: none; cursor: crosshair; }
/* 투명 배경 표시용 체커보드 (그리기 화면 전용 — 실제 그림은 투명) */
#canvas.checker {
  background-color: #ffffff;
  background-image:
    linear-gradient(45deg, #dde0e4 25%, transparent 25%),
    linear-gradient(-45deg, #dde0e4 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #dde0e4 75%),
    linear-gradient(-45deg, transparent 75%, #dde0e4 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}
.grid { position: absolute; inset: 0; pointer-events: none; display: none; border-radius: 8px; z-index: 2;
  background-image: linear-gradient(rgba(0,0,0,.22) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(0,0,0,.22) 1px, transparent 1px);
  background-size: 40px 40px; }
.grid.on { display: block; }
/* 게임화면 배경(어니언스킨) — 캔버스 "뒤"에 반투명으로 깔아 따라 그리기.
   캔버스가 위(z-index 1)라 그린 획은 또렷하고, 안 그린 빈 곳에만 게임이 비쳐 보임. */
.bg-game { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill;
  pointer-events: none; display: none; z-index: 0; opacity: .35; border-radius: 8px; }
.bg-op { width: 90px; display: none; }
.bg-hint { font-size: 11px; color: #ffd479; background: rgba(255,180,40,.12); border: 1px solid rgba(255,180,40,.3);
  padding: 3px 8px; border-radius: 6px; line-height: 1.3; }
.bg-hint b { color: #ffe2a0; }
.bg-op-num { width: 48px; padding: 5px 6px; border: 1px solid #3a3d47; border-radius: 6px;
  background: #2a2d36; color: #eceef2; font-size: 13px; text-align: center; display: none; }
.zoomgrp { display: inline-flex; align-items: center; gap: 2px; }
.btn-icon { font-size: 16px; line-height: 1; min-width: 36px; text-align: center; }
.btn-tool:disabled { opacity: .4; cursor: default; }

.swatch { width: 100%; aspect-ratio: 1 / 1; border-radius: 50%; border: 2px solid rgba(255,255,255,.2);
  cursor: pointer; }
.swatch.active { border-color: #fff; box-shadow: 0 0 0 2px #3a86ff; }
.size { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #c7ccd6; }
.size input[type="range"] { width: 100px; }
.size-num { width: 50px; padding: 5px 6px; border: 1px solid #3a3d47; border-radius: 6px;
  background: #2a2d36; color: #eceef2; font-size: 13px; text-align: center; }
.btn-tool { padding: 8px 12px; border: 1px solid #3a3d47; border-radius: 6px;
  background: #2a2d36; color: #eceef2; font-size: 13px; cursor: pointer; }
.btn-done { margin-left: auto; padding: 10px 22px; border: none; border-radius: 8px;
  background: #28a745; color: #fff; font-weight: 800; font-size: 15px; cursor: pointer; }
.btn-done:disabled { background: #4a5a4f; cursor: not-allowed; }

/* 펜/지우개 활성 표시 */
.btn-tool.tool-active { background: #3a86ff; border-color: #3a86ff; color: #fff; font-weight: 700; }
/* 컬러 팔레트(직접 선택) */
.picker-wrap { display: inline-flex; align-items: center; gap: 4px; font-size: 16px; cursor: pointer; }
.picker-wrap input[type="color"] { width: 30px; height: 30px; padding: 0; border: 2px solid rgba(255,255,255,.25);
  border-radius: 6px; background: none; cursor: pointer; }
.btn-refill:disabled { background: #3a3d47; color: #8b919c; cursor: default; }
.hint { font-size: 11px; color: #8b919c; }

/* 붓/지우개 크기 원형 커서 */
#brush-ring { position: fixed; display: none; pointer-events: none; z-index: 50;
  border: 1.5px solid rgba(0,0,0,.75); border-radius: 50%;
  box-shadow: 0 0 0 1.5px rgba(255,255,255,.8); transform: translate(-50%, -50%); }

/* 단축키 도움말 */
.help-panel { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55); }
.help-card { background: #23262f; border: 1px solid #3a3d47; border-radius: 12px; padding: 18px 20px;
  width: 90%; max-width: 420px; max-height: 86vh; overflow: auto; box-shadow: 0 12px 44px rgba(0,0,0,.6); }
.help-head { display: flex; align-items: center; justify-content: space-between; font-weight: 800; font-size: 19px; margin-bottom: 14px; }
.help-head button { background: none; border: none; color: #c7ccd6; font-size: 18px; cursor: pointer; }
.help-sec { margin-bottom: 16px; }
.help-title { font-weight: 800; font-size: 14px; color: #ffd34d; margin-bottom: 6px; }
.help-text { font-size: 13px; color: #dfe3ea; line-height: 1.65; }
.help-text b { color: #ffe2a0; }
.help-card ul { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.help-card li { font-size: 13.5px; color: #dfe3ea; display: flex; align-items: baseline; }
.help-card li b { flex: 0 0 138px; color: #ffd34d; }

/* 📖 사용설명서 버튼 — 크고 눈에 띄게 */
.btn-help { padding: 9px 16px; border: none; border-radius: 9px; cursor: pointer;
  background: linear-gradient(180deg,#ffe07a,#ffcf3a); color: #2a2200; font-weight: 900; font-size: 14.5px;
  box-shadow: 0 3px 12px rgba(255,200,40,.45); }
.btn-help:hover { filter: brightness(1.05); }

/* 주/부 색상 위젯 (포토샵식) */
.dualcolor { position: relative; width: 38px; height: 34px; padding: 0; border: none; background: none; cursor: pointer; flex: 0 0 auto; }
.dualcolor .cc-pri, .dualcolor .cc-sec { position: absolute; width: 22px; height: 22px; border: 2px solid rgba(255,255,255,.5); border-radius: 4px; }
.dualcolor .cc-pri { top: 0; left: 0; z-index: 2; }
.dualcolor .cc-sec { bottom: 0; right: 0; z-index: 1; }

/* 토스트 알림 */
.toast { position: fixed; left: 50%; top: 64px; transform: translateX(-50%); display: none; z-index: 120;
  background: rgba(20,22,28,.95); color: #fff; padding: 9px 16px; border-radius: 8px; font-size: 14px;
  border: 1px solid #3a3d47; box-shadow: 0 6px 24px rgba(0,0,0,.5); }

.bucket-ico { vertical-align: -2px; margin-right: 3px; }
