body {
  font-family: sans-serif;
  color: #333;
  padding: 12px;
  box-sizing: border-box;
  /* max-width: 100vw;           (변경) 화면 최대 너비 제한 */
  max-width: 100vw;           /* (변경) 화면 최대 너비 제한 */
  min-height: 480px;
  background: #fff;
}

.card {
  margin-bottom: 16px;
  padding: 12px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  max-width: 800px;           /* (추가) PC에서 폭 제한 */
  width: 70%;                /* (추가) 모바일에서 가로 100% */
  box-sizing: border-box;
  margin-left: auto;
  margin-right: auto;
}

label {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}

h2 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: bold;
}

/* 기간 버튼 영역 */
.period-buttons {
  display: flex;
  gap: 6px;
  margin: 12px 0;
  flex-wrap: wrap;          /* (추가) 모바일에서 여러줄 가능 */
}

/* 개별 기간 버튼 */
.period-btn {
  flex-grow: 1;
  padding: 8px 0;           /* (변경) 상하 여백 확대 */
  font-size: 13px;          /* (변경) 글씨 조금 키움 */
  background-color: #f0f0f0;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.period-btn:hover {
  background-color: #e0e0e0;
}
.period-btn.active {
  background-color: #ffe066;
  border-color: #f0c000;
  font-weight: bold;
}

/* 요일/시간 그리드 헤더 */
.grid-header {
  display: grid;
  margin-bottom: 4px;
  font-size: 12px;
  color: #666;
  user-select: none;
}
.day-header {
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
}

/* 요일/시간 그리드 */
.grid {
  display: grid;
  gap: 2px;
}
.day-grid {
  grid-template-columns: repeat(7, 1fr);
}

/* 셀 */
.grid .cell {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  background: #fafafa;
  border: 1px solid #e0e0e0;
  border-radius: 3px;
  font-size: 13px;
  color: #333;
}
.grid .cell.highlight {
  background: #ffe066;
  font-weight: bold;
}

/* 차트(캔버스) 반응형 - 핵심 */
.card canvas {
  display: block;
  margin: 0 auto;
  width: 100% !important;    /* (변경) 부모 크기에 맞춤 */
  max-width: 400px;          /* (변경) PC에서 최대 300px */
  height: auto !important;   (변경) 모바일/PC 모두 자동
  aspect-ratio: 1 / 2;       /* (추가) 비율 유지 (최신 브라우저 지원) */
}

/* 코인 선택 버튼 영역 */
.coin-selector {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  margin-bottom: 12px;
  overflow-x: auto;
  justify-content: space-between;
}

.coin-btn {
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 500;
  background-color: #f0f0f0;
  border: 1px solid #ccc;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.coin-btn:hover {
  background-color: #e0e0e0;
}
.coin-btn.active {
  background-color: #333;
  color: #fff;
  border-color: #333;
}

/* 로딩 오버레이/스피너 */
.loading-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255,255,255,0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
}
.loading-overlay.hidden {
  display: none;
}
.spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid #3498db;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ----------------- */
/* 모바일 반응형 추가 */
/* ----------------- */
@media (max-width: 600px) {
  body {
    padding: 4px;
    min-height: 320px;
  }
  .card {
    padding: 8px;
    max-width: 99vw;        /* (변경) 모바일에서는 화면 거의 꽉차게 */
  }
  .period-btn {
    font-size: 11px;
    padding: 6px 0;
  }
  .coin-btn {
    font-size: 11px;
    padding: 2px 6px;
  }
  .card canvas {
    max-width: 99vw;
    min-width: 180px;
    height: 160px !important; /* (변경) 모바일에서 차트 세로 길이 강제 */
  }
  h2 {
    font-size: 15px;
  }
  .grid .cell {
    font-size: 12px;
    height: 22px;
  }
}
